当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthService::createGroup方法代码示例

本文整理汇总了PHP中AuthService::createGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::createGroup方法的具体用法?PHP AuthService::createGroup怎么用?PHP AuthService::createGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AuthService的用法示例。


在下文中一共展示了AuthService::createGroup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: switchAction


//.........这里部分代码省略.........
                         }
                         print '</tree>';
                     }
                 }
                 AJXP_XMLWriter::close();
             }
             break;
         case "stat":
             header("Content-type:application/json");
             print '{"mode":true}';
             return;
             break;
         case "clear_plugins_cache":
             AJXP_XMLWriter::header();
             // Clear plugins cache if they exist
             AJXP_PluginsService::clearPluginsCache();
             ConfService::clearMessagesCache();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf." . (AJXP_SKIP_CACHE ? "132" : "131")], null);
             AJXP_XMLWriter::reloadDataNode();
             AJXP_XMLWriter::close();
             break;
         case "create_group":
             if (isset($httpVars["group_path"])) {
                 $basePath = AJXP_Utils::forwardSlashDirname($httpVars["group_path"]);
                 if (empty($basePath)) {
                     $basePath = "/";
                 }
                 $gName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic(basename($httpVars["group_path"])), AJXP_SANITIZE_ALPHANUM);
             } else {
                 $basePath = substr($httpVars["dir"], strlen("/data/users"));
                 $gName = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["group_name"]), AJXP_SANITIZE_ALPHANUM);
             }
             $gLabel = AJXP_Utils::decodeSecureMagic($httpVars["group_label"]);
             AuthService::createGroup($basePath, $gName, $gLabel);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.124"], null);
             AJXP_XMLWriter::reloadDataNode();
             AJXP_XMLWriter::close();
             break;
         case "create_role":
             $roleId = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["role_id"]), AJXP_SANITIZE_HTML_STRICT);
             if (!strlen($roleId)) {
                 throw new Exception($mess[349]);
             }
             if (AuthService::getRole($roleId) !== false) {
                 throw new Exception($mess["ajxp_conf.65"]);
             }
             $r = new AJXP_Role($roleId);
             if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
                 $r->setGroupPath(AuthService::getLoggedUser()->getGroupPath());
             }
             AuthService::updateRole($r);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.66"], null);
             AJXP_XMLWriter::reloadDataNode("", $httpVars["role_id"]);
             AJXP_XMLWriter::close();
             break;
         case "edit_role":
             $roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
             $roleGroup = false;
             $userObject = null;
             $groupLabel = null;
             if (strpos($roleId, "AJXP_GRP_") === 0) {
                 $groupPath = substr($roleId, strlen("AJXP_GRP_"));
                 $filteredGroupPath = AuthService::filterBaseGroup($groupPath);
                 $groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:67,代码来源:class.ajxp_confAccessDriver.php

示例2: updateUserObject


//.........这里部分代码省略.........
                                     if (isset($matchFilter) && !preg_match($matchFilter, $uniqValueWithPrefix)) {
                                         continue;
                                     }
                                     if (isset($valueFilters) && !in_array($uniqValueWithPrefix, $valueFilters)) {
                                         continue;
                                     }
                                     $roleToAdd = AuthService::getRole($uniqValueWithPrefix, true);
                                     $roleToAdd->setLabel($uniqValue);
                                     AuthService::updateRole($roleToAdd);
                                     $userObject->addRole($roleToAdd);
                                     $changes = true;
                                 }
                             } else {
                                 foreach ($entry[$key] as $uniqValue) {
                                     if (isset($matchFilter) && !preg_match($matchFilter, $uniqValue)) {
                                         continue;
                                     }
                                     if (isset($valueFilters) && !in_array($uniqValue, $valueFilters)) {
                                         continue;
                                     }
                                     if (!in_array($uniqValue, array_keys($userObject->getRoles())) && !empty($uniqValue)) {
                                         $userObject->addRole(AuthService::getRole($uniqValue, true));
                                         $changes = true;
                                     }
                                 }
                             }
                             break;
                         case "group_path":
                             if ($key == "memberof") {
                                 $filter = $params["MAPPING_LOCAL_PARAM"];
                                 if (strpos($filter, "preg:") !== false) {
                                     $matchFilter = "/" . str_replace("preg:", "", $filter) . "/i";
                                 } else {
                                     if (!empty($filter)) {
                                         $valueFilters = array_map("trim", explode(",", $filter));
                                     }
                                 }
                                 foreach ($memberValues as $uniqValue => $fullDN) {
                                     if (isset($matchFilter) && !preg_match($matchFilter, $uniqValue)) {
                                         continue;
                                     }
                                     if (isset($valueFilters) && !in_array($uniqValue, $valueFilters)) {
                                         continue;
                                     }
                                     if ($userObject->personalRole->filterParameterValue("auth.ldap", "MEMBER_OF", AJXP_REPO_SCOPE_ALL, "") == $fullDN) {
                                         //break;
                                     }
                                     $humanName = $uniqValue;
                                     $branch = array();
                                     $this->buildGroupBranch($uniqValue, $branch);
                                     $parent = "/";
                                     if (count($branch)) {
                                         $parent = "/" . implode("/", array_reverse($branch));
                                     }
                                     if (!ConfService::getConfStorageImpl()->groupExists(rtrim(AuthService::filterBaseGroup($parent), "/") . "/" . $fullDN)) {
                                         AuthService::createGroup($parent, $fullDN, $humanName);
                                     }
                                     $userObject->setGroupPath(rtrim($parent, "/") . "/" . $fullDN, true);
                                     // Update Roles from groupPath
                                     $b = array_reverse($branch);
                                     $b[] = $fullDN;
                                     for ($i = 1; $i <= count($b); $i++) {
                                         $userObject->addRole(AuthService::getRole("AJXP_GRP_/" . implode("/", array_slice($b, 0, $i)), true));
                                     }
                                     $userObject->personalRole->setParameterValue("auth.ldap", "MEMBER_OF", $fullDN);
                                     $userObject->recomputeMergedRole();
                                     $changes = true;
                                 }
                             }
                             break;
                         case "profile":
                             if ($userObject->getProfile() != $value) {
                                 $changes = true;
                                 $userObject->setProfile($value);
                                 AuthService::updateAutoApplyRole($userObject);
                             }
                             break;
                         case "plugin_param":
                         default:
                             if (strpos($params["MAPPING_LOCAL_PARAM"], "/") !== false) {
                                 list($pId, $param) = explode("/", $params["MAPPING_LOCAL_PARAM"]);
                             } else {
                                 $pId = $this->getId();
                                 $param = $params["MAPPING_LOCAL_PARAM"];
                             }
                             if ($userObject->personalRole->filterParameterValue($pId, $param, AJXP_REPO_SCOPE_ALL, "") != $value) {
                                 $userObject->personalRole->setParameterValue($pId, $param, $value);
                                 $userObject->recomputeMergedRole();
                                 $changes = true;
                             }
                             break;
                     }
                 }
             }
         }
         if ($changes) {
             $userObject->save("superuser");
         }
     }
 }
开发者ID:ad-m,项目名称:pydio-core,代码行数:101,代码来源:class.ldapAuthDriver.php

示例3: updateUserObject

 public function updateUserObject(&$userObject)
 {
     if (!empty($this->separateGroup)) {
         $userObject->setGroupPath("/" . $this->separateGroup);
     }
     // SHOULD BE DEPRECATED
     if (!empty($this->customParamsMapping)) {
         $checkValues = array_values($this->customParamsMapping);
         $prefs = $userObject->getPref("CUSTOM_PARAMS");
         if (!is_array($prefs)) {
             $prefs = array();
         }
         // If one value exist, we consider the mapping has already been done.
         foreach ($checkValues as $val) {
             if (array_key_exists($val, $prefs)) {
                 return;
             }
         }
         $changes = false;
         $entries = $this->getUserEntries($userObject->getId());
         if ($entries["count"]) {
             $entry = $entries[0];
             foreach ($this->customParamsMapping as $key => $value) {
                 if (isset($entry[$key])) {
                     $prefs[$value] = $entry[$key][0];
                     $changes = true;
                 }
             }
         }
         if ($changes) {
             $userObject->setPref("CUSTOM_PARAMS", $prefs);
             $userObject->save();
         }
     }
     if (!empty($this->paramsMapping)) {
         $changes = false;
         $entries = $this->getUserEntries($userObject->getId());
         if ($entries["count"]) {
             $entry = $entries[0];
             foreach ($this->paramsMapping as $params) {
                 $key = strtolower($params['MAPPING_LDAP_PARAM']);
                 if (isset($entry[$key])) {
                     $value = $entry[$key][0];
                     $memberValues = array();
                     if ($key == "memberof") {
                         // get CN from value
                         foreach ($entry[$key] as $possibleValue) {
                             $hnParts = array();
                             $parts = explode(",", ltrim($possibleValue, '/'));
                             foreach ($parts as $part) {
                                 list($att, $attVal) = explode("=", $part);
                                 if (strtolower($att) == "cn") {
                                     $hnParts[] = $attVal;
                                 }
                             }
                             if (count($hnParts)) {
                                 $memberValues[implode(",", $hnParts)] = $possibleValue;
                             }
                         }
                     }
                     switch ($params['MAPPING_LOCAL_TYPE']) {
                         case "role_id":
                             if ($key == "memberof") {
                                 foreach ($memberValues as $uniqValue => $fullDN) {
                                     if (!in_array($uniqValue, array_keys($userObject->getRoles()))) {
                                         $userObject->addRole(AuthService::getRole($uniqValue, true));
                                         $userObject->recomputeMergedRole();
                                         $changes = true;
                                     }
                                 }
                             }
                             break;
                         case "group_path":
                             if ($key == "memberof") {
                                 $filter = $params["MAPPING_LOCAL_PARAM"];
                                 if (strpos($filter, "preg:") !== false) {
                                     $matchFilter = "/" . str_replace("preg:", "", $filter) . "/i";
                                 } else {
                                     if (!empty($filter)) {
                                         $valueFilters = array_map("trim", explode(",", $filter));
                                     }
                                 }
                                 foreach ($memberValues as $uniqValue => $fullDN) {
                                     if (isset($matchFilter) && !preg_match($matchFilter, $uniqValue)) {
                                         continue;
                                     }
                                     if (isset($valueFilters) && !in_array($uniqValue, $valueFilters)) {
                                         continue;
                                     }
                                     if ($userObject->personalRole->filterParameterValue("auth.ldap", "MEMBER_OF", AJXP_REPO_SCOPE_ALL, "") == $fullDN) {
                                         //break;
                                     }
                                     $humanName = $uniqValue;
                                     $branch = array();
                                     $this->buildGroupBranch($uniqValue, $branch);
                                     $parent = "/";
                                     if (count($branch)) {
                                         $parent = "/" . implode("/", array_reverse($branch));
                                     }
                                     AuthService::createGroup($parent, $fullDN, $humanName);
//.........这里部分代码省略.........
开发者ID:biggtfish,项目名称:cms,代码行数:101,代码来源:class.ldapAuthDriver.php


注:本文中的AuthService::createGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。