[ '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; } }