本文整理汇总了PHP中Role::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getList方法的具体用法?PHP Role::getList怎么用?PHP Role::getList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role::getList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_main
function do_main()
{
$this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Role Management'));
$this->oPage->setTitle(_kt('Role Management'));
$edit_fields = array();
$role_id = KTUtil::arrayGet($_REQUEST, 'role_id', null);
if (is_null($role_id)) {
$oRole = null;
// handle broken case of role == -1
} else {
$oRole = Role::get($role_id);
}
if (PEAR::isError($oRole) || $oRole == false) {
$for_edit = false;
} else {
$for_edit = true;
$edit_fields[] = new KTStringWidget(_kt('Name'), _kt('A short, human-readable name for the role.'), 'name', $oRole->getName(), $this->oPage, true);
}
$aRoles =& Role::getList('id > 0');
$add_fields = array();
$add_fields[] = new KTStringWidget(_kt('Name'), _kt('A short, human-readable name for the role.'), 'name', null, $this->oPage, true);
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate('ktcore/principals/roleadmin');
$oTemplate->setData(array("context" => $this, "add_fields" => $add_fields, "for_edit" => $for_edit, 'edit_role' => $oRole, 'edit_fields' => $edit_fields, 'roles' => $aRoles));
return $oTemplate;
}
示例2: displayConfiguration
function displayConfiguration($args)
{
// permissions
$aKeyedRoles = array();
$aRoles = Role::getList();
foreach ($aRoles as $oRole) {
$aKeyedRoles[$oRole->getId()] = $oRole->getName();
}
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate('ktcore/workflowtriggers/roles');
$aTemplateData = array('context' => $this, 'roles' => $aKeyedRoles, 'current_role' => KTUtil::arrayGet($this->aConfig, 'role_id'), 'args' => $args);
return $oTemplate->render($aTemplateData);
}
示例3: getList
/**
* Returns a list of roles matching the filter criteria.
*
* @author KnowledgeTree Team
* @access public
* @static
* @param string $filter
* @param array $options
* @return array of KTAPI_Role
*/
public static function getList($filter = null, $options = array())
{
$roles = Role::getList($filter, $options);
if (PEAR::isError($roles)) {
return $roles;
}
$list = array();
foreach ($roles as $role) {
$list[] = new KTAPI_Role($role);
}
return $list;
}
示例4: json_notificationusers
function json_notificationusers()
{
$sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false);
if ($sFilter == false) {
$values = array('off' => _kt('-- Please filter --'));
// default
}
$sFilter = trim($sFilter);
$values = array('off' => _kt('-- Please filter --'));
// default
if (!empty($sFilter)) {
$allowed = array();
// Modified Jarrett Jordaan Only notify enabled users
$q = sprintf('name like "%%%s%%" AND disabled = 0', DBUtil::escapeSimple($sFilter));
$aUsers = User::getList($q);
$q = sprintf('name like "%%%s%%"', DBUtil::escapeSimple($sFilter));
$aGroups = Group::getList($q);
$aRoles = Role::getList($q);
$empty = true;
if (!PEAR::isError($aUsers)) {
$allowed['user'] = $aUsers;
if (!empty($aUsers)) {
$empty = false;
}
}
if (!PEAR::isError($aGroups)) {
$allowed['group'] = $aGroups;
if (!empty($aGroups)) {
$empty = false;
}
}
if (!PEAR::isError($aRole)) {
$allowed['role'] = $aRoles;
if (!empty($aRoles)) {
$empty = false;
}
}
if ($empty) {
$values = array('off' => '-- No results --');
// default
} else {
$values = $this->descriptorToJSON($allowed);
}
}
return $values;
}
示例5: json_getEntities
function json_getEntities($optFilter = null)
{
$sFilter = KTUtil::arrayGet($_REQUEST, 'filter', false);
if ($sFilter == false && $optFilter != null) {
$sFilter = $optFilter;
}
$bSelected = KTUtil::arrayGet($_REQUEST, 'selected', false);
$aEntityList = array('off' => _kt('-- Please filter --'));
// check permissions
$oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
$aOptions = array('redirect_to' => array('json', 'json_action=permission_error&fFolderId=' . $this->oFolder->getId()));
if (!KTBrowseUtil::inAdminMode($this->oUser, $this->oFolder)) {
$this->oValidator->userHasPermissionOnItem($this->oUser, $this->_sEditShowPermission, $this->oFolder, $aOptions);
}
// get permissions map
$aPermissionsMap =& $this->_getPermissionsMap();
if ($bSelected || $sFilter && trim($sFilter)) {
if (!$bSelected) {
$aEntityList = array();
}
$aGroups = Group::getList(sprintf('name like \'%%%s%%\'', $sFilter));
foreach ($aGroups as $oGroup) {
$aPerm = @array_keys($aPermissionsMap['group'][$oGroup->getId()]);
if (!is_array($aPerm)) {
$aPerm = array();
}
if ($bSelected) {
if (count($aPerm)) {
$aEntityList['g' . $oGroup->getId()] = array('type' => 'group', 'display' => _kt('Group') . ': ' . $oGroup->getName(), 'name' => $oGroup->getName(), 'permissions' => $aPerm, 'id' => $oGroup->getId(), 'selected' => true);
}
} else {
$aEntityList['g' . $oGroup->getId()] = array('type' => 'group', 'display' => _kt('Group') . ': ' . $oGroup->getName(), 'name' => $oGroup->getName(), 'permissions' => $aPerm, 'id' => $oGroup->getId());
}
}
$aRoles = Role::getList(sprintf('name like \'%%%s%%\'', $sFilter));
foreach ($aRoles as $oRole) {
$aPerm = @array_keys($aPermissionsMap['role'][$oRole->getId()]);
if (!is_array($aPerm)) {
$aPerm = array();
}
if ($bSelected) {
if (count($aPerm)) {
$aEntityList['r' . $oRole->getId()] = array('type' => 'role', 'display' => _kt('Role') . ': ' . $oRole->getName(), 'name' => $oRole->getName(), 'permissions' => $aPerm, 'id' => $oRole->getId(), 'selected' => true);
}
} else {
$aEntityList['r' . $oRole->getId()] = array('type' => 'role', 'display' => _kt('Role') . ': ' . $oRole->getName(), 'name' => $oRole->getName(), 'permissions' => $aPerm, 'id' => $oRole->getId());
}
}
}
return $aEntityList;
}
示例6: do_main
function do_main()
{
$this->oPage->setTitle(_kt("View Roles"));
$this->oPage->setBreadcrumbDetails(_kt("View Roles"));
$oTemplating = new KTTemplating();
$oTemplate = $oTemplating->loadTemplate("ktcore/action/view_roles");
// we need to have:
// - a list of roles
// - with their users / groups
// - and that allocation id
$aRoles = array();
// stores data for display.
$aRoleList = Role::getList();
foreach ($aRoleList as $oRole) {
$iRoleId = $oRole->getId();
$aRoles[$iRoleId] = array("name" => $oRole->getName());
$oRoleAllocation = DocumentRoleAllocation::getAllocationsForDocumentAndRole($this->oDocument->getId(), $iRoleId);
if (is_null($oRoleAllocation)) {
$oRoleAllocation = RoleAllocation::getAllocationsForFolderAndRole($this->oDocument->getFolderID(), $iRoleId);
}
$u = array();
$g = array();
$aid = null;
$raid = null;
if (is_null($oRoleAllocation)) {
// nothing.
} else {
//var_dump($oRoleAllocation);
$raid = $oRoleAllocation->getId();
// real_alloc_id
$aAllowed = $oRoleAllocation->getAllowed();
if (!empty($aAllowed['user'])) {
$u = $aAllowed['user'];
}
if (!empty($aAllowed['group'])) {
$g = $aAllowed['group'];
}
}
$aRoles[$iRoleId]['users'] = $u;
$aRoles[$iRoleId]['groups'] = $g;
$aRoles[$iRoleId]['real_allocation_id'] = $raid;
}
// final step.
// map to users, groups.
foreach ($aRoles as $key => $role) {
$_users = array();
foreach ($aRoles[$key]['users'] as $iUserId) {
$oUser = User::get($iUserId);
if (!(PEAR::isError($oUser) || $oUser == false)) {
$_users[] = $oUser->getName();
}
}
if (empty($_users)) {
$aRoles[$key]['users'] = '<span class="descriptiveText"> ' . _kt('no users') . '</span>';
} else {
$aRoles[$key]['users'] = implode(', ', $_users);
}
$_groups = array();
foreach ($aRoles[$key]['groups'] as $iGroupId) {
$oGroup = Group::get($iGroupId);
if (!(PEAR::isError($oGroup) || $oGroup == false)) {
$_groups[] = $oGroup->getName();
}
}
if (empty($_groups)) {
$aRoles[$key]['groups'] = '<span class="descriptiveText"> ' . _kt('no groups') . '</span>';
} else {
$aRoles[$key]['groups'] = implode(', ', $_groups);
}
}
$aTemplateData = array('context' => &$this, 'roles' => $aRoles);
return $oTemplate->render($aTemplateData);
}