Loading src/Plugin/EntityLimit/RoleLimit.php +13 −0 Original line number Diff line number Diff line Loading @@ -80,12 +80,25 @@ class RoleLimit extends EntityLimitPluginBase implements ContainerFactoryPluginI $allowed_roles[$role->id()] = $role->label(); } // Administrator role can not be limited. unset($allowed_roles['administrator']); $form['limits'] = [ '#type' => 'table', '#caption' => $this->t('Add limits'), '#header' => [$this->t('Role'), $this->t('Limit'), $this->t('Operations')], '#prefix' => '<div id="limits-table">', '#suffix' => '</div>', '#footer' => [ 'data' => [ [ 'data' => $this->t( 'You can not select the Administrator role because administrators always has full access.' ), 'colspan' => 3, ], ], ], ]; for ($i = 0; $i < $count; $i++) { Loading src/Plugin/EntityLimit/UserLimit.php +25 −0 Original line number Diff line number Diff line Loading @@ -74,12 +74,31 @@ class UserLimit extends EntityLimitPluginBase implements ContainerFactoryPluginI $count = $form_state->get('num_rows'); } $roles = user_roles(TRUE); $allowed_roles = []; foreach ($roles as $role) { // Users with Administrator role can not be limited. if ($role->id() != 'administrator') { $allowed_roles[] = $role->id(); } } $form['limits'] = [ '#type' => 'table', '#caption' => $this->t('Add limits'), '#header' => [$this->t('User'), $this->t('Limit'), $this->t('Operations')], '#prefix' => '<div id="limits-table">', '#suffix' => '</div>', '#footer' => [ 'data' => [ [ 'data' => $this->t( 'You can not select users with Administrator role because administrators always has full access.' ), 'colspan' => 3, ], ], ], ]; for ($i = 0; $i < $count; $i++) { Loading @@ -90,6 +109,12 @@ class UserLimit extends EntityLimitPluginBase implements ContainerFactoryPluginI '#description' => $this->t('Limit will be applied to these users. Seperate multiple users by comma'), '#required' => TRUE, '#default_value' => isset($limits[$i]['id']) ? User::load($limits[$i]['id']) : '', '#selection_settings' => [ 'include_anonymous' => FALSE, 'filter' => [ 'role' => $allowed_roles, ], ], ]; $form['limits'][$i]['limit'] = [ Loading Loading
src/Plugin/EntityLimit/RoleLimit.php +13 −0 Original line number Diff line number Diff line Loading @@ -80,12 +80,25 @@ class RoleLimit extends EntityLimitPluginBase implements ContainerFactoryPluginI $allowed_roles[$role->id()] = $role->label(); } // Administrator role can not be limited. unset($allowed_roles['administrator']); $form['limits'] = [ '#type' => 'table', '#caption' => $this->t('Add limits'), '#header' => [$this->t('Role'), $this->t('Limit'), $this->t('Operations')], '#prefix' => '<div id="limits-table">', '#suffix' => '</div>', '#footer' => [ 'data' => [ [ 'data' => $this->t( 'You can not select the Administrator role because administrators always has full access.' ), 'colspan' => 3, ], ], ], ]; for ($i = 0; $i < $count; $i++) { Loading
src/Plugin/EntityLimit/UserLimit.php +25 −0 Original line number Diff line number Diff line Loading @@ -74,12 +74,31 @@ class UserLimit extends EntityLimitPluginBase implements ContainerFactoryPluginI $count = $form_state->get('num_rows'); } $roles = user_roles(TRUE); $allowed_roles = []; foreach ($roles as $role) { // Users with Administrator role can not be limited. if ($role->id() != 'administrator') { $allowed_roles[] = $role->id(); } } $form['limits'] = [ '#type' => 'table', '#caption' => $this->t('Add limits'), '#header' => [$this->t('User'), $this->t('Limit'), $this->t('Operations')], '#prefix' => '<div id="limits-table">', '#suffix' => '</div>', '#footer' => [ 'data' => [ [ 'data' => $this->t( 'You can not select users with Administrator role because administrators always has full access.' ), 'colspan' => 3, ], ], ], ]; for ($i = 0; $i < $count; $i++) { Loading @@ -90,6 +109,12 @@ class UserLimit extends EntityLimitPluginBase implements ContainerFactoryPluginI '#description' => $this->t('Limit will be applied to these users. Seperate multiple users by comma'), '#required' => TRUE, '#default_value' => isset($limits[$i]['id']) ? User::load($limits[$i]['id']) : '', '#selection_settings' => [ 'include_anonymous' => FALSE, 'filter' => [ 'role' => $allowed_roles, ], ], ]; $form['limits'][$i]['limit'] = [ Loading