本文整理汇总了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;
}