예제 #1
0
 public function getUserRole()
 {
     $user = new I2CE_User();
     if ($user->role) {
         return I2CE_User_Form::getRoleNameFromShortName($user->role);
     } else {
         return null;
     }
 }
예제 #2
0
 /**
  * Populate a drop down of users that can be edited by the current user given his/her access level.
  * @param string $selectId
  * @global array
  */
 public function listUsersToEdit($selectId, $username = null)
 {
     $add_last = array();
     if ($username == null) {
         $usernames = I2CE_User::findUsersByInfo(false, array(), false);
         //we all users except the interal admin user regardless or role or details.
     } else {
         $userAccess = I2CE::getUserAccess();
         if (!$userAccess instanceof I2CE_UserAccess_Mechansim) {
             return false;
         }
         if (!in_array('creator', $userAccess->getAllowedDetails())) {
             return false;
         }
         $usernames = I2CE_User::findUsersByInfo(false, array('creator' => $username));
     }
     if (!is_array($usernames)) {
         return false;
     }
     foreach ($usernames as $username) {
         $user = new I2CE_User($username, true, false, false);
         if (!$user instanceof I2CE_User) {
             continue;
         }
         $role = $user->getRole();
         if ($role) {
             $role = I2CE_User_Form::getRoleNameFromShortName($role);
         }
         $disp = trim($user->displayName());
         if (!$disp) {
             $disp = "({$username})";
         }
         if ($role == "") {
             $add_last[$username] = 'No Access - ' . $disp;
         } else {
             $this->template->addOption($selectId, $username, $role . ' - ' . $disp);
         }
     }
     foreach ($add_last as $username => $dispname) {
         $this->template->addOption($selectId, $username, $dispname);
     }
 }