Beispiel #1
0
 /**
  * Pobranie wszystkich ról z dziedziczeniem oraz z przypisanymi groupmi
  * uprawnień,  przyczym jeśli profil jest obecny, zwraca tylko role dla
  * profilu. Wykożystywane przy inicjowaniu rów w resource ACL (co poprawia
  * działanie $acl->hasRole('role').
  *
  * @param $profiel mixed null | Row_Profile
  * @return array
  *
  */
 public function getRoles($profile = null)
 {
     $roleModel = new Role();
     $roleParentsModel = new RoleRole();
     $roleGroupsModel = new RoleGroup();
     if ($profile && $profile->id) {
         $db = Zend_Db_Table::getDefaultAdapter();
         $sql = $db->quoteInto('select r.* from profile_role pr left join "role" r on r.id = pr.id_role where  pr.id_profile = ?', $profile->id);
         $roles = $db->fetchAll($sql);
     } else {
         $roles = $roleModel->fetchAll("ghost = false ", 'priority asc')->toArray();
     }
     $roleGroups = $roleGroupsModel->fetchAll()->toArray();
     $roleParents = $roleParentsModel->fetchAll()->toArray();
     $rolesArray = array();
     foreach ($roles as $role) {
         $role['parents']['group'] = array();
         $role['parents']['role'] = array();
         $rolesArray[$role['id']] = $role;
     }
     foreach ($roleParents as $parent) {
         if (isset($rolesArray[$parent['id_role']])) {
             $rolesArray[$parent['id_role']]['parents']['role'][] = $parent['id_parent'];
         }
     }
     foreach ($roleGroups as $group) {
         if (isset($rolesArray[$group['id_role']])) {
             $rolesArray[$group['id_role']]['parents']['group'][] = $group['id_group'];
         }
     }
     return $rolesArray;
 }
Beispiel #2
0
 public function __construct($options = null)
 {
     $rolaModel = new Role();
     $grupaModel = new Group();
     $this->roles = $rolaModel->fetchAll(array('ghost = false', 'is_system = false'))->toArray();
     $this->groups = $grupaModel->fetchAll(array('ghost = false', 'is_system = false'), 'group_name asc')->toArray();
     parent::__construct($options);
 }
Beispiel #3
0
 public function __construct($options = null)
 {
     $rola = new Role();
     $this->role = $rola->fetchAll(array('ghost = false ', 'is_system = false '))->toArray();
     parent::__construct($options);
 }
Beispiel #4
0
 public function getDataToUserReport()
 {
     $profileModel = new Profile();
     $select = $profileModel->select()->order('id_user');
     $profileDataArray = $profileModel->fetchAll($select)->toArray();
     $groupModel = new Group();
     $select = $groupModel->select();
     $groupDataArray = $groupModel->fetchAll($select)->toArray();
     foreach ($groupDataArray as $key => $value) {
         $tmp[$value['id']] = $value;
     }
     $groupDataArray = $tmp;
     unset($tmp);
     $branchModel = new Branch();
     $select = $branchModel->select();
     $branchDataArray = $branchModel->fetchAll($select)->toArray();
     foreach ($branchDataArray as $key => $value) {
         $tmp[$value['id']] = $value;
     }
     $branchDataArray = $tmp;
     unset($tmp);
     $userModel = new User();
     $select = $userModel->select();
     $userDataArray = $userModel->fetchAll($select)->toArray();
     foreach ($userDataArray as $key => $value) {
         $tmp[$value['id']] = $value;
     }
     $userDataArray = $tmp;
     unset($tmp);
     $roleModel = new Role();
     $select = $roleModel->select();
     $roleDataArray = $roleModel->fetchAll($select)->toArray();
     foreach ($roleDataArray as $key => $value) {
         $tmp[$value['id']] = $value;
     }
     $roleDataArray = $tmp;
     unset($tmp);
     $groupArray = array();
     foreach ($profileDataArray as $key => $value) {
         $data = $this->getAuthorizationsForProfile($value['id']);
         foreach ($data as $key2 => $values) {
             foreach ($values as $key3 => $privs) {
                 /* if ($privs['ghost'] === true) {
                     unset($data[$key2][$key3]);
                     continue;
                     }
                    */
                 $tmp = array('login' => '', 'surname' => '', 'first_name' => '', 'group' => '', 'role' => '', 'branch' => '', 'ghost' => '');
                 if ($key2 === 'group') {
                     $tmp['group'] = $groupDataArray[$privs['id_group']]['group_name'];
                 }
                 if ($key2 === 'role') {
                     $tmp['role'] = $roleDataArray[$privs['id_role']]['description'];
                 }
                 $tmp['login'] = $userDataArray[$value['id_user']]['login'];
                 $tmp['surname'] = $userDataArray[$value['id_user']]['surname'];
                 $tmp['first_name'] = $userDataArray[$value['id_user']]['first_name'];
                 $tmp['branch'] = $branchDataArray[$value['id_branch']]['branch_name'];
                 $tmp['ghost'] = $userDataArray['ghost'] ? 'NIEAKTYWNY' : 'AKTYWNY';
                 $groupArray[] = $tmp;
             }
         }
     }
     return $groupArray;
 }