コード例 #1
0
ファイル: Drupal6.php プロジェクト: acbramley/DrupalDriver
 /**
  * {@inheritdoc}
  */
 public function userAddRole(\stdClass $user, $role_name)
 {
     $roles = array_flip(user_roles());
     $role = $roles[$role_name];
     if (!$role) {
         throw new \RuntimeException(sprintf('No role "%s" exists.', $role_name));
     }
     user_multiple_role_edit(array($user->uid), 'add_role', $role);
 }
コード例 #2
0
ファイル: Drupal7.php プロジェクト: ian-yin/drupalextension
 /**
  * {@inheritDoc}
  */
 public function userAddRole(\stdClass $user, $role_name)
 {
     $role = user_role_load_by_name($role_name);
     if (!$role) {
         throw new \RuntimeException(sprintf('No role "%s" exists.', $role_name));
     }
     user_multiple_role_edit(array($user->uid), 'add_role', $role->rid);
 }
コード例 #3
0
ファイル: UserSingle7.php プロジェクト: bjargud/drush
 public function removeRole($rid)
 {
     user_multiple_role_edit(array($this->account->uid), 'remove_role', $rid);
 }