本文整理匯總了PHP中Role::fetchAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::fetchAll方法的具體用法?PHP Role::fetchAll怎麽用?PHP Role::fetchAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Role
的用法示例。
在下文中一共展示了Role::fetchAll方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getRoles
/**
* 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;
}
示例2: __construct
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);
}
示例3: __construct
public function __construct($options = null)
{
$rola = new Role();
$this->role = $rola->fetchAll(array('ghost = false ', 'is_system = false '))->toArray();
parent::__construct($options);
}
示例4: getDataToUserReport
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;
}