本文整理汇总了PHP中AuthService::canAssign方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::canAssign方法的具体用法?PHP AuthService::canAssign怎么用?PHP AuthService::canAssign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::canAssign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: repositoryIsAccessible
/**
* @param String $repositoryId
* @param Repository $repositoryObject
* @param AbstractAjxpUser $userObject
* @param bool $details
* @param bool $includeShared
*
* @return bool
*/
public static function repositoryIsAccessible($repositoryId, $repositoryObject, $userObject = null, $details = false, $includeShared = true)
{
if ($userObject == null) {
$userObject = AuthService::getLoggedUser();
}
if ($userObject == null && AuthService::usersEnabled()) {
return false;
}
if (!AuthService::canAssign($repositoryObject, $userObject)) {
return false;
}
if ($repositoryObject->isTemplate) {
return false;
}
if ($repositoryObject->getAccessType() == "ajxp_conf" && $userObject != null) {
if (AuthService::usersEnabled() && !$userObject->isAdmin()) {
return false;
}
}
if ($repositoryObject->getAccessType() == "ajxp_user" && $userObject != null) {
return $userObject->canRead($repositoryId) || $userObject->canWrite($repositoryId);
}
if ($repositoryObject->getAccessType() == "ajxp_shared" && !AuthService::usersEnabled()) {
return false;
}
if ($repositoryObject->getUniqueUser() && (!AuthService::usersEnabled() || $userObject == null || $userObject->getId() == "shared" || $userObject->getId() != $repositoryObject->getUniqueUser())) {
return false;
}
if ($userObject != null && !($userObject->canRead($repositoryId) || $userObject->canWrite($repositoryId)) && !$details) {
return false;
}
if ($userObject == null || $userObject->canRead($repositoryId) || $userObject->canWrite($repositoryId) || $details) {
// Do not display standard repositories even in details mode for "sub"users
if ($userObject != null && $userObject->hasParent() && !($userObject->canRead($repositoryId) || $userObject->canWrite($repositoryId))) {
return false;
}
// Do not display shared repositories otherwise.
if ($repositoryObject->hasOwner() && !$includeShared && ($userObject == null || $userObject->getParent() != $repositoryObject->getOwner())) {
return false;
}
if ($userObject != null && $repositoryObject->hasOwner() && !$userObject->hasParent()) {
// Display the repositories if allow_crossusers is ok
if (ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf") === false || ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf") === 0) {
return false;
}
// But still do not display its own shared repositories!
if ($repositoryObject->getOwner() == $userObject->getId()) {
return false;
}
}
if ($repositoryObject->hasOwner() && $userObject != null && $details && !($userObject->canRead($repositoryId) || $userObject->canWrite($repositoryId))) {
return false;
}
}
return true;
}
示例2: switchAction
//.........这里部分代码省略.........
if (strpos($roleId, "AJXP_GRP_") === 0) {
$groupPath = substr($roleId, strlen("AJXP_GRP_"));
$filteredGroupPath = AuthService::filterBaseGroup($groupPath);
$groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
$key = "/" . basename($groupPath);
if (!array_key_exists($key, $groups)) {
throw new Exception("Cannot find group with this id!");
}
$roleId = "AJXP_GRP_" . $filteredGroupPath;
$groupLabel = $groups[$key];
$roleGroup = true;
}
if (strpos($roleId, "AJXP_USR_") === 0) {
$usrId = str_replace("AJXP_USR_/", "", $roleId);
$userObject = ConfService::getConfStorageImpl()->createUserObject($usrId);
if (!AuthService::canAdministrate($userObject)) {
throw new Exception("Cant find user!");
}
$role = $userObject->personalRole;
} else {
$role = AuthService::getRole($roleId, $roleGroup);
}
if ($role === false) {
throw new Exception("Cant find role! ");
}
if (isset($httpVars["format"]) && $httpVars["format"] == "json") {
HTMLWriter::charsetHeader("application/json");
$roleData = $role->getDataArray(true);
$allReps = ConfService::getRepositoriesList("all", false);
$repos = array();
if (!empty($userObject)) {
// USER
foreach ($allReps as $repositoryId => $repositoryObject) {
if (!AuthService::canAssign($repositoryObject, $userObject) || $repositoryObject->isTemplate || $repositoryObject->getAccessType() == "ajxp_conf" && !$userObject->isAdmin() || $repositoryObject->getUniqueUser() != null && $repositoryObject->getUniqueUser() != $userObject->getId()) {
continue;
}
$repos[$repositoryId] = SystemTextEncoding::toUTF8($repositoryObject->getDisplay());
}
} else {
foreach ($allReps as $repositoryId => $repositoryObject) {
if (!AuthService::canAdministrate($repositoryObject)) {
continue;
}
$repos[$repositoryId] = SystemTextEncoding::toUTF8($repositoryObject->getDisplay());
}
}
// Make sure it's utf8
$data = array("ROLE" => $roleData, "ALL" => array("REPOSITORIES" => $repos));
if (isset($userObject)) {
$data["USER"] = array();
$data["USER"]["LOCK"] = $userObject->getLock();
$data["USER"]["PROFILE"] = $userObject->getProfile();
$data["ALL"]["PROFILES"] = array("standard|Standard", "admin|Administrator", "shared|Shared", "guest|Guest");
$data["USER"]["ROLES"] = array_keys($userObject->getRoles());
$data["ALL"]["ROLES"] = array_keys(AuthService::getRolesList(array(), true));
if (isset($userObject->parentRole)) {
$data["PARENT_ROLE"] = $userObject->parentRole->getDataArray();
}
} else {
if (isset($groupPath)) {
$data["GROUP"] = array("PATH" => $groupPath, "LABEL" => $groupLabel);
}
}
$scope = "role";
if ($roleGroup) {
$scope = "group";