本文整理汇总了PHP中AuthService::authCountUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::authCountUsers方法的具体用法?PHP AuthService::authCountUsers怎么用?PHP AuthService::authCountUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::authCountUsers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: countUsersForRepository
/**
* @param string $repositoryId
* @param boolean $details
* @return Integer|Array
*/
public function countUsersForRepository($repositoryId, $details = false)
{
$object = ConfService::getRepositoryById($repositoryId);
if ($object->securityScope() == "USER") {
if ($details) {
return array('internal' => 1);
} else {
return 1;
}
} else {
if ($object->securityScope() == "GROUP") {
// Count users from current group
$groupUsers = AuthService::authCountUsers(AuthService::getLoggedUser()->getGroupPath());
if ($details) {
return array('internal' => $groupUsers);
} else {
return $groupUsers;
}
}
}
// Users from roles
$internal = 0;
$roles = $this->getRolesForRepository($repositoryId);
foreach ($roles as $rId) {
if (strpos($rId, "AJXP_USR_/") === 0) {
continue;
}
$internal += $this->getUsersForRole($rId, true);
}
// NEW METHOD : SEARCH PERSONAL ROLE
if (is_numeric($repositoryId)) {
$likeValue = "i:{$repositoryId};s:";
} else {
$likeValue = '"' . $repositoryId . '";s:';
}
switch ($this->sqlDriver["driver"]) {
case "sqlite":
case "sqlite3":
case "postgre":
$q = 'SELECT count([role_id]) FROM [ajxp_roles] WHERE [role_id] LIKE \'AJXP_USR_/%\' AND [searchable_repositories] LIKE %~like~';
break;
case "mysql":
$q = 'SELECT count([role_id]) as c FROM [ajxp_roles] WHERE [role_id] LIKE \'AJXP_USR_/%\' AND [serial_role] LIKE %~like~';
break;
default:
return "ERROR!, DB driver " . $this->sqlDriver["driver"] . " not supported yet in __FUNCTION__";
}
if ($details) {
if ($this->sqlDriver["driver"] == "sqlite" || $this->sqlDriver["driver"] == "sqlite3") {
$internalClause = " AND NOT EXISTS (SELECT * FROM [ajxp_user_rights] WHERE [ajxp_roles].[role_id]='AJXP_USR_/'||[ajxp_user_rights].[login] AND [ajxp_user_rights].[repo_uuid] = 'ajxp.parent_user')";
$externalClause = " AND EXISTS (SELECT * FROM [ajxp_user_rights] WHERE [ajxp_roles].[role_id]='AJXP_USR_/'||[ajxp_user_rights].[login] AND [ajxp_user_rights].[repo_uuid] = 'ajxp.parent_user')";
} else {
$internalClause = " AND NOT EXISTS (SELECT * FROM [ajxp_user_rights] WHERE [ajxp_roles].[role_id]=CONCAT('AJXP_USR_/',[ajxp_user_rights].[login]) AND [ajxp_user_rights].[repo_uuid] = 'ajxp.parent_user')";
$externalClause = " AND EXISTS (SELECT * FROM [ajxp_user_rights] WHERE [ajxp_roles].[role_id]=CONCAT('AJXP_USR_/',[ajxp_user_rights].[login]) AND [ajxp_user_rights].[repo_uuid] = 'ajxp.parent_user')";
}
$intRes = dibi::query($q . $internalClause, $likeValue);
$extRes = dibi::query($q . $externalClause, $likeValue);
return array('internal' => $internal + $intRes->fetchSingle(), 'external' => $extRes->fetchSingle());
} else {
$res = dibi::query($q, $likeValue);
return $internal + $res->fetchSingle();
}
//$all = $res->fetchAll();
}
示例2: listUsers
function listUsers($root, $child, $hashValue = null)
{
$columns = '<columns switchGridMode="filelist" template_name="ajxp_conf.users">
<column messageId="ajxp_conf.6" attributeName="ajxp_label" sortType="String" defaultWidth="40%"/>
<column messageId="ajxp_conf.7" attributeName="isAdmin" sortType="String" defaultWidth="10%"/>
<column messageId="ajxp_conf.70" attributeName="ajxp_roles" sortType="String" defaultWidth="15%"/>
<column messageId="ajxp_conf.62" attributeName="rights_summary" sortType="String" defaultWidth="15%"/>
</columns>';
if (AuthService::driverSupportsAuthSchemes()) {
$columns = '<columns switchGridMode="filelist" template_name="ajxp_conf.users">
<column messageId="ajxp_conf.6" attributeName="ajxp_label" sortType="String" defaultWidth="40%"/>
<column messageId="ajxp_conf.115" attributeName="auth_scheme" sortType="String" defaultWidth="5%"/>
<column messageId="ajxp_conf.7" attributeName="isAdmin" sortType="String" defaultWidth="5%"/>
<column messageId="ajxp_conf.70" attributeName="ajxp_roles" sortType="String" defaultWidth="15%"/>
<column messageId="ajxp_conf.62" attributeName="rights_summary" sortType="String" defaultWidth="15%"/>
</columns>';
}
AJXP_XMLWriter::sendFilesListComponentConfig($columns);
if (!AuthService::usersEnabled()) {
return;
}
$count = AuthService::authCountUsers();
$USER_PER_PAGE = 50;
if (empty($hashValue)) {
$hashValue = 1;
}
if (AuthService::authSupportsPagination() && $count > $USER_PER_PAGE) {
$offset = ($hashValue - 1) * $USER_PER_PAGE;
AJXP_XMLWriter::renderPaginationData($count, $hashValue, ceil($count / $USER_PER_PAGE));
$users = AuthService::listUsers("", $offset, $USER_PER_PAGE);
} else {
$users = AuthService::listUsers();
}
$mess = ConfService::getMessages();
$repos = ConfService::getRepositoriesList();
$loggedUser = AuthService::getLoggedUser();
$userArray = array();
foreach ($users as $userIndex => $userObject) {
$label = $userObject->getId();
if ($userObject->hasParent()) {
$label = $userObject->getParent() . "000" . $label;
}
$userArray[$label] = $userObject;
}
ksort($userArray);
foreach ($userArray as $userObject) {
$isAdmin = $userObject->isAdmin();
$userId = $userObject->getId();
$icon = "user" . ($userId == "guest" ? "_guest" : ($isAdmin ? "_admin" : ""));
if ($userObject->hasParent()) {
$icon = "user_child";
}
$rightsString = "";
if ($isAdmin) {
$rightsString = $mess["ajxp_conf.63"];
} else {
$r = array();
foreach ($repos as $repoId => $repository) {
if ($repository->getAccessType() == "ajxp_shared") {
continue;
}
if (!$userObject->canRead($repoId) && !$userObject->canWrite($repoId)) {
continue;
}
$rs = $userObject->canRead($repoId) ? "r" : "";
$rs .= $userObject->canWrite($repoId) ? "w" : "";
$r[] = $repository->getDisplay() . " (" . $rs . ")";
}
$rightsString = implode(", ", $r);
}
$nodeLabel = $userId;
$scheme = AuthService::getAuthScheme($userId);
AJXP_XMLWriter::renderNode("/users/" . $userId, $nodeLabel, true, array("isAdmin" => $mess[$isAdmin ? "ajxp_conf.14" : "ajxp_conf.15"], "icon" => $icon . ".png", "auth_scheme" => $scheme != null ? $scheme : "", "rights_summary" => $rightsString, "ajxp_roles" => implode(", ", array_keys($userObject->getRoles())), "ajxp_mime" => "user" . ($userId != "guest" && $userId != $loggedUser->getId() ? "_editable" : "")));
}
}
示例3: listUsers
public function listUsers($root, $child, $hashValue = null, $returnNodes = false, $findNodePosition = null)
{
$USER_PER_PAGE = 50;
if ($root == "users") {
$baseGroup = "/";
} else {
$baseGroup = substr($root, strlen("users"));
}
if ($findNodePosition != null && $hashValue == null) {
// Add groups offset
$groups = AuthService::listChildrenGroups($baseGroup);
$offset = 0;
if (count($groups)) {
$offset = count($groups);
}
$position = AuthService::findUserPage($baseGroup, $findNodePosition, $USER_PER_PAGE);
if ($position != -1) {
$key = "/data/" . $root . "/" . $findNodePosition;
$data = array($key => AJXP_XMLWriter::renderNode($key, $findNodePosition, true, array("page_position" => $position), true, false));
return $data;
} else {
// Loop on each page to find the correct page.
$count = AuthService::authCountUsers($baseGroup);
$pages = ceil($count / $USER_PER_PAGE);
for ($i = 0; $i < $pages; $i++) {
$tests = $this->listUsers($root, $child, $i + 1, true, $findNodePosition);
if (is_array($tests) && isset($tests["/data/" . $root . "/" . $findNodePosition])) {
return array("/data/" . $root . "/" . $findNodePosition => str_replace("ajxp_mime", "page_position='" . ($i + 1) . "' ajxp_mime", $tests["/data/" . $root . "/" . $findNodePosition]));
}
}
}
return array();
}
$allNodes = array();
$columns = '<columns switchDisplayMode="list" switchGridMode="filelist" template_name="ajxp_conf.users">
<column messageId="ajxp_conf.6" attributeName="ajxp_label" sortType="String" defaultWidth="40%"/>
<column messageId="ajxp_conf.102" attributeName="object_id" sortType="String" defaultWidth="10%"/>
<column messageId="ajxp_conf.7" attributeName="isAdmin" sortType="String" defaultWidth="10%"/>
<column messageId="ajxp_conf.70" attributeName="ajxp_roles" sortType="String" defaultWidth="15%"/>
<column messageId="ajxp_conf.62" attributeName="rights_summary" sortType="String" defaultWidth="15%"/>
</columns>';
if (AuthService::driverSupportsAuthSchemes()) {
$columns = '<columns switchDisplayMode="list" switchGridMode="filelist" template_name="ajxp_conf.users_authscheme">
<column messageId="ajxp_conf.6" attributeName="ajxp_label" sortType="String" defaultWidth="40%"/>
<column messageId="ajxp_conf.102" attributeName="object_id" sortType="String" defaultWidth="10%"/>
<column messageId="ajxp_conf.115" attributeName="auth_scheme" sortType="String" defaultWidth="5%"/>
<column messageId="ajxp_conf.7" attributeName="isAdmin" sortType="String" defaultWidth="5%"/>
<column messageId="ajxp_conf.70" attributeName="ajxp_roles" sortType="String" defaultWidth="15%"/>
<column messageId="ajxp_conf.62" attributeName="rights_summary" sortType="String" defaultWidth="15%"/>
</columns>';
}
if (!$returnNodes) {
AJXP_XMLWriter::sendFilesListComponentConfig($columns);
}
if (!AuthService::usersEnabled()) {
return array();
}
if (empty($hashValue)) {
$hashValue = 1;
}
$count = AuthService::authCountUsers($baseGroup, "", null, null, false);
if (AuthService::authSupportsPagination() && $count >= $USER_PER_PAGE) {
$offset = ($hashValue - 1) * $USER_PER_PAGE;
if (!$returnNodes) {
AJXP_XMLWriter::renderPaginationData($count, $hashValue, ceil($count / $USER_PER_PAGE));
}
$users = AuthService::listUsers($baseGroup, "", $offset, $USER_PER_PAGE, true, false);
if ($hashValue == 1) {
$groups = AuthService::listChildrenGroups($baseGroup);
} else {
$groups = array();
}
} else {
$users = AuthService::listUsers($baseGroup, "", -1, -1, true, false);
$groups = AuthService::listChildrenGroups($baseGroup);
}
foreach ($groups as $groupId => $groupLabel) {
$nodeKey = "/data/" . $root . "/" . ltrim($groupId, "/");
$meta = array("icon" => "users-folder.png", "ajxp_mime" => "group", "object_id" => $groupId);
if (in_array($nodeKey, $this->currentBookmarks)) {
$meta = array_merge($meta, array("ajxp_bookmarked" => "true", "overlay_icon" => "bookmark.png"));
}
$xml = AJXP_XMLWriter::renderNode($nodeKey, $groupLabel, false, $meta, true, false);
if (!$returnNodes) {
print $xml;
} else {
$allNodes[$nodeKey] = $xml;
}
}
$mess = ConfService::getMessages();
$loggedUser = AuthService::getLoggedUser();
$userArray = array();
foreach ($users as $userObject) {
$label = $userObject->getId();
if ($userObject->hasParent()) {
$label = $userObject->getParent() . "000" . $label;
} else {
$children = ConfService::getConfStorageImpl()->getUserChildren($label);
foreach ($children as $addChild) {
$userArray[$label . "000" . $addChild->getId()] = $addChild;
//.........这里部分代码省略.........
示例4: countUsersForRepository
/**
* @param string $repositoryId
* @param boolean $details
* @param bool $admin
* @return array|int
*/
public function countUsersForRepository($repositoryId, $details = false, $admin = false)
{
$object = ConfService::getRepositoryById($repositoryId);
if (!$admin) {
if ($object->securityScope() == "USER") {
if ($details) {
return array('users' => 1);
} else {
return 1;
}
} else {
if ($object->securityScope() == "GROUP") {
// Count users from current group
$groupUsers = AuthService::authCountUsers(AuthService::getLoggedUser()->getGroupPath());
if ($details) {
return array('users' => $groupUsers);
} else {
return $groupUsers;
}
}
}
}
// Users from roles
$roles = $this->getRolesForRepository($repositoryId, '', $details);
if ($details) {
return array('users' => count($roles['role_user']), 'groups' => count($roles['role_group']) + count($roles['role_role']));
} else {
return count($roles);
}
}