Club System
This commit is contained in:
@@ -8,8 +8,7 @@ use Illuminate\Auth\Access\Response;
|
||||
|
||||
class EntryPolicy
|
||||
{
|
||||
|
||||
public function view(User $user): bool
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
if( $user->_can( 'romhackplaza', 'view' ) )
|
||||
return true;
|
||||
@@ -17,6 +16,47 @@ class EntryPolicy
|
||||
return false;
|
||||
}
|
||||
|
||||
public function viewPending(User $user, Entry $entry): bool
|
||||
{
|
||||
// Author.
|
||||
if( $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
|
||||
return $user->_can( 'romhackplaza', 'canModerateEntries' );
|
||||
}
|
||||
|
||||
public function viewDraft(User $user, Entry $entry): bool
|
||||
{
|
||||
// Author.
|
||||
if( $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
|
||||
return $user->_can( 'romhackplaza', 'canSeeOthersDrafts' );
|
||||
}
|
||||
|
||||
public function viewRejected(User $user, Entry $entry): bool
|
||||
{
|
||||
// Author.
|
||||
if( $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
|
||||
return $user->_can( 'romhackplaza', 'canSeeRejectedEntries' );
|
||||
}
|
||||
|
||||
public function viewHidden(User $user, Entry $entry): bool
|
||||
{
|
||||
return $user->_can('romhackplaza', 'canSeeHiddenEntries' );
|
||||
}
|
||||
|
||||
public function viewLocked(User $user, Entry $entry): bool
|
||||
{
|
||||
// Author.
|
||||
if( $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
|
||||
return $user->_can('romhackplaza', 'canSeeLockedEntries' );
|
||||
}
|
||||
|
||||
public function create(User $user, ?Entry $entry = null ): bool
|
||||
{
|
||||
return $user->_can( 'romhackplaza', 'canSubmitEntry' );
|
||||
@@ -27,13 +67,101 @@ class EntryPolicy
|
||||
*/
|
||||
public function update(User $user, Entry $entry): bool
|
||||
{
|
||||
if( $user->_can('romhackplaza', 'canEditOthersEntries') )
|
||||
return true;
|
||||
if( $entry->state === 'published' ){
|
||||
|
||||
if( $user->_can( 'romhackplaza', 'canEditMyEntries' ) && $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
// Staff editors
|
||||
if( $user->_can('romhackplaza', 'canEditOthersEntries') )
|
||||
return true;
|
||||
|
||||
// Author.
|
||||
if( $user->_can( 'romhackplaza', 'canEditMyEntries' ) && $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
} else if( $entry->state === 'pending' ){
|
||||
|
||||
// Staff moderation.
|
||||
if( $user->_can('romhackplaza', 'canEditOthersEntries') && $user->_can('romhackplaza', 'canModerateEntries') )
|
||||
return true;
|
||||
|
||||
// Author.
|
||||
if( $user->_can( 'romhackplaza', 'canEditMyEntries' ) && $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
|
||||
} else if( $entry->state === 'draft' ){
|
||||
|
||||
// Staff.
|
||||
if( $user->_can('romhackplaza', 'canEditOthersEntries') && $user->_can( 'romhackplaza', 'canSeeOthersDrafts' ) )
|
||||
return true;
|
||||
|
||||
// Author.
|
||||
if( $user->_can( 'romhackplaza', 'canEditMyEntries' ) && $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
|
||||
} else if( $entry->state === 'rejected' ){
|
||||
|
||||
// Staff.
|
||||
if( $user->_can('romhackplaza', 'canEditOthersEntries') && $user->_can( 'romhackplaza', 'canSeeRejectedEntries' ) )
|
||||
return true;
|
||||
|
||||
// Author.
|
||||
if( $user->_can( 'romhackplaza', 'canEditMyEntries' ) && $entry->user_id === $user->user_id )
|
||||
return true;
|
||||
|
||||
} else if( $entry->state === 'locked' ){
|
||||
|
||||
// Staff.
|
||||
if( $user->_can('romhackplaza', 'canEditOthersEntries') && $user->_can( 'romhackplaza', 'canSeeLockedEntries' ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
} else if( $entry->state === 'hidden' ){
|
||||
|
||||
// Staff.
|
||||
if( $user->_can('romhackplaza', 'canEditOthersEntries') && $user->_can( 'romhackplaza', 'canSeeHiddenEntries' ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function skipQueue(User $user, Entry $entry): bool
|
||||
{
|
||||
return $user->_can( 'romhackplaza', 'canSubmitEntryInPublished' );
|
||||
}
|
||||
|
||||
public function updateComment(User $user, Entry $entry): bool
|
||||
{
|
||||
return $user->_can('romhackplaza', 'canModerateEntries' );
|
||||
}
|
||||
|
||||
public function manageButtonsInQueue(User $user, Entry $entry): bool
|
||||
{
|
||||
if( $entry->state === 'rejected' ){
|
||||
return $this->viewRejected( $user, $entry );
|
||||
}
|
||||
|
||||
return $user->_can('romhackplaza', 'canModerateEntries' );
|
||||
}
|
||||
|
||||
public function approve(User $user, Entry $entry): bool
|
||||
{
|
||||
return $user->_can('romhackplaza', 'canModerateEntries' );
|
||||
}
|
||||
|
||||
public function reject(User $user, Entry $entry): bool
|
||||
{
|
||||
return $user->_can('romhackplaza', 'canModerateEntries' );
|
||||
}
|
||||
|
||||
public function moderate(User $user, Entry $entry): bool
|
||||
{
|
||||
return $user->_can('romhackplaza', 'canModerateEntries' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user