mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
parent
01c77790f7
commit
5245cda255
@ -51,6 +51,15 @@ class ContentReviewDefaultSettings extends DataExtension
|
||||
*/
|
||||
private static $content_review_template = 'ContentReviewEmail';
|
||||
|
||||
/**
|
||||
* The number of members in which the dropdown will morph into a gridfield
|
||||
*
|
||||
* @config
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $content_review_gridfield_threshold = 500;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -120,11 +129,19 @@ class ContentReviewDefaultSettings extends DataExtension
|
||||
$usersMap = $users->map('ID', 'Title')->toArray();
|
||||
asort($usersMap);
|
||||
|
||||
$userField = ListboxField::create('OwnerUsers', _t('ContentReview.PAGEOWNERUSERS', 'Users'), $usersMap)
|
||||
->setMultiple(true)
|
||||
->setAttribute('data-placeholder', _t('ContentReview.ADDUSERS', 'Add users'))
|
||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||
|
||||
if(Member::get()->count() > Config::inst()->get('SiteConfig', 'content_review_gridfield_threshold')) {
|
||||
$gridfieldconfig = GridFieldConfig_RelationEditor::create();
|
||||
$gridfieldconfig->removeComponentsByType(new GridFieldAddNewButton());
|
||||
$userField = GridField::create('OwnerUsers', _t("ContentReview.PAGEOWNERUSERS", "Users"),
|
||||
$this->OwnerUsers(), $gridfieldconfig)
|
||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||
} else {
|
||||
$userField = ListboxField::create('OwnerUsers', _t('ContentReview.PAGEOWNERUSERS', 'Users'), $usersMap)
|
||||
->setMultiple(true)
|
||||
->setAttribute('data-placeholder', _t('ContentReview.ADDUSERS', 'Add users'))
|
||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||
}
|
||||
|
||||
$fields->addFieldToTab('Root.ContentReview', $userField);
|
||||
|
||||
$groupsMap = array();
|
||||
|
@ -344,18 +344,26 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
||||
|
||||
$viewersOptionsField = OptionsetField::create("ContentReviewType", _t("ContentReview.OPTIONS", "Options"), $options);
|
||||
|
||||
$users = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
|
||||
|
||||
$users = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
|
||||
$usersMap = $users->map("ID", "Title")->toArray();
|
||||
|
||||
asort($usersMap);
|
||||
|
||||
$userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)
|
||||
->setMultiple(true)
|
||||
->addExtraClass('custom-setting')
|
||||
->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))
|
||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||
|
||||
if(Member::get()->count() > Config::inst()->get('SiteConfig', 'content_review_gridfield_threshold')) {
|
||||
// grid field for large numbers of users
|
||||
$gridfieldconfig = GridFieldConfig_RelationEditor::create();
|
||||
$gridfieldconfig->removeComponentsByType(new GridFieldAddNewButton());
|
||||
$userField = GridField::create('OwnerUsers', _t("ContentReview.PAGEOWNERUSERS", "Users"),
|
||||
$this->OwnerUsers(), $gridfieldconfig)
|
||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||
} else {
|
||||
$userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)
|
||||
->setMultiple(true)
|
||||
->addExtraClass('custom-setting')
|
||||
->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))
|
||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||
}
|
||||
|
||||
|
||||
$groupsMap = array();
|
||||
|
||||
foreach (Group::get() as $group) {
|
||||
|
@ -22,4 +22,15 @@ To set a content review schedule for a page go to `Settings > Content Review`.
|
||||
CMS users without the permission to change the content review schedule can still see the settings
|
||||
and previous reviews in the same view, but cannot change anything.
|
||||
|
||||
![](_images/content-review-settings-ro.png)
|
||||
![](_images/content-review-settings-ro.png)
|
||||
|
||||
## If your database contains a large number of members
|
||||
|
||||
The page owners selector will change from a ListboxField to a Gridfield in order
|
||||
to prevent your browser from crashing. By default this numbers is 500. You can
|
||||
customise this threshold by editing your .yml with the following settings:
|
||||
|
||||
```
|
||||
SiteTree:
|
||||
content_review_gridfield_threshold: 500
|
||||
```
|
@ -334,4 +334,34 @@ class SiteTreeContentReviewTest extends ContentReviewBaseTest
|
||||
|
||||
SS_Datetime::clear_mock_now();
|
||||
}
|
||||
public function testSiteSettingsFieldsListBox()
|
||||
{
|
||||
$author = $this->objFromFixture("Member", "editor");
|
||||
|
||||
$this->logInAs($author);
|
||||
|
||||
/** @var Page|SiteTreeContentReview $page */
|
||||
$page = $this->objFromFixture("Page", "contact");
|
||||
|
||||
$fields = $page->getSettingsFields();
|
||||
|
||||
$this->assertInstanceOf('ListboxField', $fields->dataFieldByName('OwnerUsers'));
|
||||
}
|
||||
|
||||
public function testSiteSettingsFieldsGridfield()
|
||||
{
|
||||
$author = $this->objFromFixture("Member", "editor");
|
||||
|
||||
$this->logInAs($author);
|
||||
|
||||
/** @var Page|SiteTreeContentReview $page */
|
||||
$page = $this->objFromFixture("Page", "contact");
|
||||
|
||||
// update the minimum threshhold to change to gridfield
|
||||
Config::inst()->update('SiteConfig', 'content_review_gridfield_threshold', 1);
|
||||
|
||||
$fields = $page->getSettingsFields();
|
||||
|
||||
$this->assertInstanceOf('GridField', $fields->dataFieldByName('OwnerUsers'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user