2010-11-29 23:24:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Comment administration system within the CMS
|
|
|
|
*
|
|
|
|
* @package comments
|
|
|
|
*/
|
2014-11-11 22:35:35 +01:00
|
|
|
class CommentAdmin extends LeftAndMain implements PermissionProvider {
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $url_segment = 'comments';
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $url_rule = '/$Action';
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $menu_title = 'Comments';
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $allowed_actions = array(
|
2010-11-29 23:24:17 +01:00
|
|
|
'approvedmarked',
|
|
|
|
'deleteall',
|
|
|
|
'deletemarked',
|
|
|
|
'hammarked',
|
|
|
|
'showtable',
|
|
|
|
'spammarked',
|
|
|
|
'EditForm',
|
|
|
|
'unmoderated'
|
|
|
|
);
|
2012-07-22 02:47:59 +02:00
|
|
|
|
2014-11-11 22:35:35 +01:00
|
|
|
public function providePermissions() {
|
|
|
|
return array(
|
|
|
|
"CMS_ACCESS_CommentAdmin" => array(
|
|
|
|
'name' => _t('CommentAdmin.ADMIN_PERMISSION', "Access to 'Comments' section"),
|
|
|
|
'category' => _t('Permission.CMS_ACCESS_CATEGORY', 'CMS Access')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-11-29 23:24:17 +01:00
|
|
|
/**
|
2012-07-22 02:47:59 +02:00
|
|
|
* @return Form
|
2010-11-29 23:24:17 +01:00
|
|
|
*/
|
2012-06-01 08:34:31 +02:00
|
|
|
public function getEditForm($id = null, $fields = null) {
|
|
|
|
if(!$id) $id = $this->currentPageID();
|
2012-07-22 02:47:59 +02:00
|
|
|
|
2012-06-01 08:34:31 +02:00
|
|
|
$form = parent::getEditForm($id);
|
|
|
|
$record = $this->getRecord($id);
|
2012-07-22 02:47:59 +02:00
|
|
|
|
|
|
|
if($record && !$record->canView()) {
|
|
|
|
return Security::permissionFailure($this);
|
|
|
|
}
|
2013-12-21 00:19:11 +01:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
$commentsConfig = CommentsGridFieldConfig::create();
|
2013-12-21 05:05:37 +01:00
|
|
|
|
2012-07-22 02:47:59 +02:00
|
|
|
$needs = new GridField(
|
|
|
|
'Comments',
|
|
|
|
_t('CommentsAdmin.NeedsModeration', 'Needs Moderation'),
|
2012-12-17 20:53:16 +01:00
|
|
|
Comment::get()->filter('Moderated',0),
|
2012-07-22 02:47:59 +02:00
|
|
|
$commentsConfig
|
|
|
|
);
|
|
|
|
|
|
|
|
$moderated = new GridField(
|
|
|
|
'CommentsModerated',
|
2015-04-07 05:56:00 +02:00
|
|
|
_t('CommentsAdmin.Moderated', 'Moderated'),
|
2012-12-17 20:53:16 +01:00
|
|
|
Comment::get()->filter('Moderated',1),
|
2012-07-22 02:47:59 +02:00
|
|
|
$commentsConfig
|
|
|
|
);
|
|
|
|
|
2012-06-01 08:34:31 +02:00
|
|
|
$fields = new FieldList(
|
|
|
|
$root = new TabSet(
|
|
|
|
'Root',
|
2012-07-22 02:47:59 +02:00
|
|
|
new Tab('NeedsModeration', _t('CommentAdmin.NeedsModeration', 'Needs Moderation'),
|
|
|
|
$needs
|
|
|
|
),
|
|
|
|
new Tab('Comments', _t('CommentAdmin.Moderated', 'Moderated'),
|
|
|
|
$moderated
|
2012-06-01 08:34:31 +02:00
|
|
|
)
|
2012-07-22 02:47:59 +02:00
|
|
|
)
|
2012-06-01 08:34:31 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$root->setTemplate('CMSTabSet');
|
|
|
|
|
|
|
|
$actions = new FieldList();
|
|
|
|
|
|
|
|
$form = new Form(
|
|
|
|
$this,
|
|
|
|
'EditForm',
|
|
|
|
$fields,
|
|
|
|
$actions
|
|
|
|
);
|
2012-07-22 02:47:59 +02:00
|
|
|
|
2012-06-01 08:34:31 +02:00
|
|
|
$form->addExtraClass('cms-edit-form');
|
|
|
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2012-07-22 02:47:59 +02:00
|
|
|
if($form->Fields()->hasTabset()) {
|
|
|
|
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
|
|
|
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
|
2010-12-11 06:33:21 +01:00
|
|
|
}
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2012-07-22 02:47:59 +02:00
|
|
|
$this->extend('updateEditForm', $form);
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2012-07-22 02:47:59 +02:00
|
|
|
return $form;
|
2010-11-29 23:24:17 +01:00
|
|
|
}
|
|
|
|
}
|