Club System
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Models\Entry;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
@@ -12,20 +13,49 @@ class SubmitEntryStatus extends Component
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public string $section
|
||||
public string $section,
|
||||
public bool $isEdit,
|
||||
public ?string $currentState,
|
||||
public null|string|Entry $entry = 'App\Models\Entry',
|
||||
)
|
||||
{
|
||||
//
|
||||
if( $this->entry === null )
|
||||
$this->entry = 'App\Models\Entry';
|
||||
}
|
||||
|
||||
public function availableStates(): array
|
||||
{
|
||||
// TODO: Change for permissions.
|
||||
return [
|
||||
'draft' => "Save into my drafts",
|
||||
'pending' => "Add to submissions queue",
|
||||
'published' => "Publish it now"
|
||||
|
||||
$labelPublished = $this->isEdit && $this->currentState === 'published' ? "Keep it published" : "Publish it now";
|
||||
$labelPending = $this->isEdit && $this->currentState === 'pending' ? "Keep it to submissions queue" : "Add to submissions queue";
|
||||
$labelDraft = $this->isEdit && $this->currentState === 'draft' ? "Keep it into my drafts" : "Save into my drafts";
|
||||
$labelHidden = $this->isEdit && $this->currentState === 'hidden' ? "Keep it hidden" : "Hide this entry";
|
||||
$labelLocked = $this->isEdit && $this->currentState === 'locked' ? "Keep it locked" : "Lock this entry";
|
||||
|
||||
$states = [
|
||||
'draft' => $labelDraft,
|
||||
'pending' => $labelPending,
|
||||
];
|
||||
|
||||
if( $this->isEdit ) {
|
||||
|
||||
$isAuthor = $this->entry->user_id === \Auth::user()->user_id;
|
||||
if( $isAuthor && ( \Auth::user()->can('skip-queue', $this->entry) || $this->currentState === 'published' ) )
|
||||
$states['published'] = $labelPublished;
|
||||
else if( \Auth::user()->can('moderate', $this->entry) )
|
||||
$states['published'] = $labelPublished;
|
||||
if( \Auth::user()->can('moderate', $this->entry) && \Auth::user()->can('view-hidden', $this->entry) )
|
||||
$states['hidden'] = $labelHidden;
|
||||
if(\Auth::user()->can('moderate', $this->entry) && \Auth::user()->can('view-locked', $this->entry) )
|
||||
$states['locked'] = $labelLocked;
|
||||
|
||||
} else {
|
||||
if( \Auth::user()->can('skip-queue', $this->entry ) ){
|
||||
$states['published'] = $labelPublished;
|
||||
}
|
||||
}
|
||||
|
||||
return $states;
|
||||
}
|
||||
|
||||
public function defaultState(): string
|
||||
|
||||
@@ -21,6 +21,9 @@ class XfUsernameLink extends Component
|
||||
|
||||
if( $this->user === null && $this->userId !== null ){
|
||||
$this->user = app(XenforoService::class)->getXfUser($this->userId);
|
||||
if( $this->user === null ){
|
||||
$this->user = app(XenforoService::class)->getXfUser(config('xenforo.bot_user_id'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user