Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #168 from mybb/feature-modcp
Browse files Browse the repository at this point in the history
Moderator CP: Logs and approval queue
  • Loading branch information
euantorano committed Oct 18, 2015
2 parents a8e7a0f + cc64893 commit 9f6837f
Show file tree
Hide file tree
Showing 81 changed files with 1,680 additions and 231 deletions.
32 changes: 32 additions & 0 deletions app/Content/ContentInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* @author MyBB Group
* @version 2.0.0
* @package mybb/core
* @license http://www.mybb.com/licenses/bsd3 BSD-3
*/

namespace MyBB\Core\Content;

interface ContentInterface
{
/**
* @return int
*/
public function getId();

/**
* @return string
*/
public function getType();

/**
* @return string
*/
public function getUrl();

/**
* @return string
*/
public function getTitle();
}
35 changes: 34 additions & 1 deletion app/Database/Models/Forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace MyBB\Core\Database\Models;

use MyBB\Core\Content\ContentInterface;
use MyBB\Core\Moderation\Moderations\CloseableInterface;
use MyBB\Core\Permissions\Interfaces\InheritPermissionInterface;
use MyBB\Core\Permissions\Traits\InheritPermissionableTrait;
Expand All @@ -19,7 +20,7 @@
/**
* @property int id
*/
class Forum extends Node implements HasPresenter, InheritPermissionInterface, CloseableInterface
class Forum extends Node implements HasPresenter, InheritPermissionInterface, CloseableInterface, ContentInterface
{
use InheritPermissionableTrait;

Expand Down Expand Up @@ -144,4 +145,36 @@ public function open()
{
return $this->update(['closed' => 0]);
}

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @return string
*/
public function getType()
{
return 'forum';
}

/**
* @return string
*/
public function getUrl()
{
return route('forums.show', ['id' => $this->id, 'slug' => $this->slug]);
}

/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
}
73 changes: 73 additions & 0 deletions app/Database/Models/ModerationLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* @author MyBB Group
* @version 2.0.0
* @package mybb/core
* @license http://www.mybb.com/licenses/bsd3 BSD-3
*/

namespace MyBB\Core\Database\Models;

use Illuminate\Database\Eloquent\Model;
use McCool\LaravelAutoPresenter\HasPresenter;

/**
* @property int id
* @property string moderation
* @property string destination_content_type
* @property int destination_content_id
* @property string source_content_type
* @property int source_content_id
*/
class ModerationLog extends Model implements HasPresenter
{
/**
* @var string
*/
protected $table = 'moderation_logs';

/**
* @var array
*/
protected $guarded = ['id'];

/**
* @var array
*/
protected $casts = [
'id' => 'int',
'destination_content_id' => 'int',
'source_content_id' => 'int'
];

/**
* @var array
*/
protected $dates = ['created_at'];

/**
* Get the presenter class.
*
* @return string
*/
public function getPresenterClass()
{
return 'MyBB\Core\Presenters\ModerationLogPresenter';
}

/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function subjects()
{
return $this->hasMany('MyBB\Core\Database\Models\ModerationLogSubject');
}

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('MyBB\Core\Database\Models\User');
}
}
24 changes: 24 additions & 0 deletions app/Database/Models/ModerationLogSubject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* @author MyBB Group
* @version 2.0.0
* @package mybb/core
* @license http://www.mybb.com/licenses/bsd3 BSD-3
*/

namespace MyBB\Core\Database\Models;

use Illuminate\Database\Eloquent\Model;

class ModerationLogSubject extends Model
{
/**
* @var string
*/
protected $table = 'moderation_log_subjects';

/**
* @var array
*/
protected $guarded = ['id'];
}
35 changes: 34 additions & 1 deletion app/Database/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use McCool\LaravelAutoPresenter\HasPresenter;
use MyBB\Core\Content\ContentInterface;
use MyBB\Core\Likes\Traits\LikeableTrait;
use MyBB\Core\Moderation\Moderations\ApprovableInterface;

Expand All @@ -22,7 +23,7 @@
* @property int id
* @property User author
*/
class Post extends Model implements HasPresenter, ApprovableInterface
class Post extends Model implements HasPresenter, ApprovableInterface, ContentInterface
{
use SoftDeletes;
use LikeableTrait;
Expand Down Expand Up @@ -128,4 +129,36 @@ public function unapprove()

return $result;
}

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @return string
*/
public function getType()
{
return 'post';
}

/**
* @return string
*/
public function getUrl()
{
return route('posts.show', ['id' => $this->id]);
}

/**
* @return string
*/
public function getTitle()
{
return null;
}
}
35 changes: 34 additions & 1 deletion app/Database/Models/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use McCool\LaravelAutoPresenter\HasPresenter;
use MyBB\Core\Content\ContentInterface;
use MyBB\Core\Moderation\Moderations\ApprovableInterface;
use MyBB\Core\Moderation\Moderations\CloseableInterface;

Expand All @@ -21,7 +22,7 @@
* @property Forum forum
* @property int forum_id
*/
class Topic extends Model implements HasPresenter, ApprovableInterface, CloseableInterface
class Topic extends Model implements HasPresenter, ApprovableInterface, CloseableInterface, ContentInterface
{
use SoftDeletes;

Expand Down Expand Up @@ -196,4 +197,36 @@ public function open()
{
return $this->update(['closed' => 0]);
}

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @return string
*/
public function getType()
{
return 'topic';
}

/**
* @return string
*/
public function getUrl()
{
return route('topics.show', ['id' => $this->id, 'slug' => $this->slug]);
}

/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
}
48 changes: 48 additions & 0 deletions app/Database/Repositories/Eloquent/ModerationLogRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* @author MyBB Group
* @version 2.0.0
* @package mybb/core
* @license http://www.mybb.com/licenses/bsd3 BSD-3
*/

namespace MyBB\Core\Database\Repositories\Eloquent;

use MyBB\Core\Database\Models\ModerationLog;
use MyBB\Core\Database\Repositories\ModerationLogRepositoryInterface;

class ModerationLogRepository implements ModerationLogRepositoryInterface
{
/**
* @var ModerationLog
*/
protected $moderationLog;

/**
* @param ModerationLog $moderationLog
*/
public function __construct(ModerationLog $moderationLog)
{
$this->moderationLog = $moderationLog;
}

/**
* @param int $id
*
* @return ModerationLog
*/
public function find($id)
{
return $this->moderationLog->find($id);
}

/**
* @param array $attributes
*
* @return ModerationLog
*/
public function create(array $attributes)
{
return $this->moderationLog->create($attributes);
}
}
Loading

0 comments on commit 9f6837f

Please sign in to comment.