Source of file CommentAdmin.php
Size: 4,164 Bytes - Last Modified: 2021-12-23T10:28:57+00:00
/var/www/docs.ssmods.com/process/src/src/Admin/CommentAdmin.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | <?php namespace SilverStripe\Comments\Admin; use SilverStripe\Admin\LeftAndMain; use SilverStripe\Comments\Model\Comment; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\Tab; use SilverStripe\Forms\TabSet; use SilverStripe\Security\PermissionProvider; use SilverStripe\Security\Security; /** * Comment administration system within the CMS * * @package comments */ class CommentAdmin extends LeftAndMain implements PermissionProvider { private static $url_segment = 'comments'; private static $url_rule = '/$Action'; private static $menu_title = 'Comments'; private static $menu_icon_class = 'font-icon-comment'; private static $allowed_actions = [ 'approvedmarked', 'deleteall', 'deletemarked', 'hammarked', 'showtable', 'spammarked', 'EditForm', 'unmoderated' ]; private static $required_permission_codes = 'CMS_ACCESS_CommentAdmin'; public function providePermissions() { return [ 'CMS_ACCESS_CommentAdmin' => [ 'name' => _t(__CLASS__ . '.ADMIN_PERMISSION', "Access to 'Comments' section"), 'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access') ], ]; } /** * @return Form */ public function getEditForm($id = null, $fields = null) { if (!$id) { $id = $this->currentPageID(); } $form = parent::getEditForm($id); $record = $this->getRecord($id); if ($record && !$record->canView()) { return Security::permissionFailure($this); } $newComments = Comment::get()->filter('Moderated', 0); $newGrid = CommentsGridField::create( 'NewComments', '', $newComments, CommentsGridFieldConfig::create() ); $approvedComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 0); $approvedGrid = CommentsGridField::create( 'ApprovedComments', '', $approvedComments, CommentsGridFieldConfig::create() ); $spamComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 1); $spamGrid = CommentsGridField::create( 'SpamComments', '', $spamComments, CommentsGridFieldConfig::create() ); $fields = FieldList::create( $root = TabSet::create( 'Root', Tab::create( 'NewComments', _t( __CLASS__.'.NewComments', 'New ({count})', ['count' => count($newComments)] ), $newGrid ), Tab::create( 'ApprovedComments', _t( __CLASS__.'.ApprovedComments', 'Approved ({count})', ['count' => count($approvedComments)] ), $approvedGrid ), Tab::create( 'SpamComments', _t( __CLASS__.'.SpamComments', 'Spam ({count})', ['count' => count($spamComments)] ), $spamGrid ) ) ); $actions = FieldList::create(); $form = Form::create( $this, 'EditForm', $fields, $actions ); $form->addExtraClass('cms-edit-form fill-height'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); if ($form->Fields()->hasTabset()) { $form->Fields()->findOrMakeTab('Root')->setTemplate('SilverStripe\\Forms\\CMSTabSet'); $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses()); } $this->extend('updateEditForm', $form); return $form; } } |