mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
291 checks if ->value is iterable
This commit is contained in:
parent
33be3a0c34
commit
4d85da179f
@ -9,6 +9,7 @@ use SilverStripe\ORM\ArrayList;
|
|||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DataObjectInterface;
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use Traversable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a categorized list of available permissions (through {@link Permission::get_codes()}).
|
* Shows a categorized list of available permissions (through {@link Permission::get_codes()}).
|
||||||
@ -248,7 +249,7 @@ class PermissionCheckboxSetField extends FormField
|
|||||||
Permission::checkMember($record, 'ADMIN') && $code != 'ADMIN') {
|
Permission::checkMember($record, 'ADMIN') && $code != 'ADMIN') {
|
||||||
$icon = 'plus-circled';
|
$icon = 'plus-circled';
|
||||||
}
|
}
|
||||||
|
|
||||||
$options .= "<li class=\"$extraClass\">"
|
$options .= "<li class=\"$extraClass\">"
|
||||||
. "<input id=\"$itemID\"$disabled name=\"$this->name[$code]\" type=\"checkbox\""
|
. "<input id=\"$itemID\"$disabled name=\"$this->name[$code]\" type=\"checkbox\""
|
||||||
. " value=\"$code\"$checked class=\"checkbox\" />"
|
. " value=\"$code\"$checked class=\"checkbox\" />"
|
||||||
@ -298,7 +299,9 @@ class PermissionCheckboxSetField extends FormField
|
|||||||
|
|
||||||
// Remove all "privileged" permissions if the currently logged-in user is not an admin
|
// Remove all "privileged" permissions if the currently logged-in user is not an admin
|
||||||
$privilegedPermissions = Permission::config()->privileged_permissions;
|
$privilegedPermissions = Permission::config()->privileged_permissions;
|
||||||
if (!Permission::check('ADMIN')) {
|
if ((is_array($this->value) || $this->value instanceof Traversable)
|
||||||
|
&& !Permission::check('ADMIN')
|
||||||
|
) {
|
||||||
foreach ($this->value as $id => $bool) {
|
foreach ($this->value as $id => $bool) {
|
||||||
if (in_array($id, $privilegedPermissions)) {
|
if (in_array($id, $privilegedPermissions)) {
|
||||||
unset($this->value[$id]);
|
unset($this->value[$id]);
|
||||||
@ -321,7 +324,7 @@ class PermissionCheckboxSetField extends FormField
|
|||||||
$record->write(); // We need a record ID to write permissions
|
$record->write(); // We need a record ID to write permissions
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->value) {
|
if (is_array($this->value) || $this->value instanceof Traversable) {
|
||||||
foreach ($this->value as $id => $bool) {
|
foreach ($this->value as $id => $bool) {
|
||||||
if ($bool) {
|
if ($bool) {
|
||||||
$perm = new $managedClass();
|
$perm = new $managedClass();
|
||||||
|
Loading…
Reference in New Issue
Block a user