예제 #1
1
 /**
  * Rebuilds cache files for dropdown filters extension
  */
 protected function rebuild_dropdown_filters()
 {
     $roles = ACLRole::getAllRoles();
     foreach ($roles as $role) {
         $this->rebuild_role_dropdown_filters($role->id);
     }
 }
예제 #2
0
 public function testgetAllRoles()
 {
     $aclRole = new ACLRole();
     //test with returnAsArray default/flase
     $result = $aclRole->getAllRoles();
     $this->assertTrue(is_array($result));
     //test with returnAsArray true
     $result = $aclRole->getAllRoles(true);
     $this->assertTrue(is_array($result));
 }
예제 #3
0
 /**
  * Returns object storage containing available roles as keys
  * and flags indicating if there is role specific metadata as value
  *
  * @param callable $callback Callback that checks if there is role specific metadata
  * @return SplObjectStorage
  */
 public static function getRoles($callback = null)
 {
     global $current_user;
     $roles = new SplObjectStorage();
     //Only super user should have access to all roles
     $allRoles = $current_user->isAdmin() ? ACLRole::getAllRoles() : ACLRole::getUserRoles($current_user->id, false);
     foreach ($allRoles as $role) {
         if (in_array($role->name, static::$hiddenRoles)) {
             continue;
         }
         $roles[$role] = $callback ? $callback(array('role' => $role->id)) : null;
     }
     return $roles;
 }
예제 #4
0
 /**
  *  Create a user in the seed data.
  */
 function _create_seed_user($id, $last_name, $first_name, $user_name, $title, $is_admin, $reports_to, $reports_to_name, $email)
 {
     $u = new User();
     $u->id = $id;
     $u->new_with_id = true;
     $u->last_name = $last_name;
     $u->first_name = $first_name;
     $u->user_name = $user_name;
     $u->title = $title;
     $u->status = 'Active';
     $u->employee_status = 'Active';
     $u->is_admin = $is_admin;
     $u->is_group = 0;
     //$u->user_password = $u->encrypt_password($user_name);
     $u->user_hash = User::getPasswordHash($user_name);
     $u->reports_to_id = $reports_to;
     $u->reports_to_name = $reports_to_name;
     //$u->email1 = $email;
     $u->emailAddress->addAddress($email, true);
     $u->emailAddress->addAddress("reply." . $email, false, true);
     $u->emailAddress->addAddress("alias." . $email);
     // bug 15371 tyoung set a user preference so that Users/DetailView.php can find something without repeatedly querying the db in vain
     $u->setPreference('max_tabs', '7');
     $u->savePreferencesToDB();
     $u->picture = $this->_copy_user_image($id);
     $u->save();
     if ($id == "seed_jim_id") {
         // add to Sales Administrator Role
         $acl_roles = new ACLRole();
         $arrRoles = $acl_roles->getAllRoles(true);
         foreach ($arrRoles as $role) {
             if ($role['name'] == "Sales Administrator") {
                 $u->load_relationship('aclroles');
                 $u->aclroles->add($role['id']);
                 // re-save user manually. otherwise the relation to role set will not be saved
                 // because One2MBeanRelationship::add() doesn't call SugarRelationship::addToResaveList()
                 // in workflow and during installation
                 $u->save();
                 break;
             }
         }
     }
 }