本文整理汇总了PHP中Roles::findSystemRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP Roles::findSystemRoles方法的具体用法?PHP Roles::findSystemRoles怎么用?PHP Roles::findSystemRoles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Roles
的用法示例。
在下文中一共展示了Roles::findSystemRoles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: system_roles
/**
* List all available system roles
*
* @param void
* @return null
*/
function system_roles()
{
$default_role_id = ConfigOptions::getValue('default_role');
if ($this->logged_user->isAdministrator() || $this->logged_user->isProjectManager()) {
$roles_data = array();
$system_permissions = Permissions::findSystem();
$roles = Roles::findSystemRoles();
if (is_foreachable($roles)) {
foreach ($roles as $role) {
$role_details = array('id' => $role->getId(), 'name' => $role->getName(), 'is_default' => $role->getId() == $default_role_id, 'permissions' => array());
foreach ($system_permissions as $permission) {
$role_details['permissions'][$permission] = (bool) $role->getPermissionValue($permission, false);
}
// foreach
$roles_data[] = $role_details;
}
// foreach
}
// if
$this->serveData($roles_data, 'system_roles');
} else {
$this->serveData($default_role_id, 'default_role_id');
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
}
示例2: smarty_function_select_role
/**
* Render select role helper
*
* Params:
*
* - value - ID of selected role
* - optional - Wether value is optional or not
* - active_user - Set if we are changing role of existing user so we can
* handle situations when administrator role is displayed or changed
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_role($params, &$smarty)
{
$value = array_var($params, 'value', null, true);
$optional = array_var($params, 'optional', false, true);
$active_user = array_var($params, 'active_user', false, true);
$logged_user = get_logged_user();
if (!instance_of($logged_user, 'User')) {
return new InvalidParamError('logged_user', $logged_user, '$logged_user is expected to be an instance of user class');
}
// if
if ($optional) {
$options = array(option_tag(lang('-- None --'), ''), option_tag('', ''));
} else {
$options = array();
}
// if
$roles = Roles::findSystemRoles();
if (is_foreachable($roles)) {
foreach ($roles as $role) {
$show_role = true;
$disabled = false;
if ($role->getPermissionValue('admin_access') && !$logged_user->isAdministrator() && !$active_user->isAdministrator()) {
$show_role = false;
// don't show administration role to non-admins and for non-admins
}
// if
if ($show_role) {
$option_attributes = $value == $role->getId() ? array('selected' => true, 'disabled' => $disabled) : null;
$options[] = option_tag($role->getName(), $role->getId(), $option_attributes);
}
// if
}
// foreach
}
// if
return select_box($options, $params);
}
示例3: module
/**
* Show module details page
*
* @param void
* @return null
*/
function module()
{
$this->smarty->assign('roles', Roles::findSystemRoles());
}
示例4: module
/**
* Show module details page
*
* @param void
* @return null
*/
function module()
{
js_assign('invoicing_precision', INVOICE_PRECISION);
$this->smarty->assign('roles', Roles::findSystemRoles());
}
示例5: who_can_see_private_objects
/**
* Returns list of system roles which have can_see_private_objects set to Yes
*
* If $as_string is set to yes function returns list of names separated with
* comma (like Adminstrator, Project Manager, People Manager or Member)
*
* @param boolean $as_string
* @return array
*/
function who_can_see_private_objects($as_string = false, $separator = null)
{
$roles = Roles::findSystemRoles();
$result = array();
if (is_foreachable($roles)) {
foreach ($roles as $role) {
if ($role->getPermissionValue('admin_access') || $role->getPermissionValue('project_management') || $role->getPermissionValue('can_see_private_objects')) {
$result[] = $as_string ? $role->getName() : $role;
}
// if
}
// foreach
}
// if
if ($as_string) {
if ($separator === null) {
$separator = lang(' and ');
}
// if
require_once SMARTY_PATH . '/plugins/function.join.php';
return smarty_function_join(array('items' => $result, 'final_separator' => $separator), $smarty);
} else {
return $result;
}
// if
}
示例6: countAdministrators
/**
* Return number of administrators
*
* @param void
* @return integer
*/
function countAdministrators()
{
$admin_role_ids = array();
$system_roles = Roles::findSystemRoles();
foreach ($system_roles as $system_role) {
if ($system_role->isAdministrator()) {
$admin_role_ids[] = $system_role->getId();
}
// if
}
// foreach
return count($admin_role_ids) > 0 ? Users::count(array("role_id IN (?)", $admin_role_ids)) : 0;
}