本文整理汇总了PHP中AuthService::deleteRole方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::deleteRole方法的具体用法?PHP AuthService::deleteRole怎么用?PHP AuthService::deleteRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::deleteRole方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRolesStorage
public function testRolesStorage()
{
$r = new \AJXP_Role("phpunit_temporary_role");
$r->setAcl(0, "rw");
\AuthService::updateRole($r);
$r1 = \AuthService::getRole("phpunit_temporary_role");
$this->assertTrue(is_a($r1, "AJXP_Role"));
$this->assertEquals("rw", $r1->getAcl(0));
\AuthService::deleteRole("phpunit_temporary_role");
$r2 = \AuthService::getRole("phpunit_temporary_role");
$this->assertFalse($r2);
}
示例2: deleteShare
/**
* @param String $type
* @param String $element
* @throws Exception
* @return bool
*/
public function deleteShare($type, $element)
{
$mess = ConfService::getMessages();
AJXP_Logger::debug(__CLASS__, __FILE__, "Deleting shared element " . $type . "-" . $element);
if ($type == "repository") {
if (strpos($element, "repo-") === 0) {
$element = str_replace("repo-", "", $element);
}
$repo = ConfService::getRepositoryById($element);
if ($repo == null) {
// Maybe a share has
$share = $this->loadShare($element);
if (is_array($share) && isset($share["REPOSITORY"])) {
$repo = ConfService::getRepositoryById($share["REPOSITORY"]);
}
if ($repo == null) {
throw new Exception("Cannot find associated share");
}
$element = $share["REPOSITORY"];
}
$this->testUserCanEditShare($repo->getOwner());
$res = ConfService::deleteRepository($element);
if ($res == -1) {
throw new Exception($mess[427]);
}
if ($this->sqlSupported) {
if (isset($share)) {
$this->confStorage->simpleStoreClear("share", $element);
} else {
$shares = self::findSharesForRepo($element);
if (count($shares)) {
$keys = array_keys($shares);
$this->confStorage->simpleStoreClear("share", $keys[0]);
}
}
}
} else {
if ($type == "minisite") {
$minisiteData = $this->loadShare($element);
$repoId = $minisiteData["REPOSITORY"];
$repo = ConfService::getRepositoryById($repoId);
if ($repo == null) {
return false;
}
$this->testUserCanEditShare($repo->getOwner());
$res = ConfService::deleteRepository($repoId);
if ($res == -1) {
throw new Exception($mess[427]);
}
// Silently delete corresponding role if it exists
AuthService::deleteRole("AJXP_SHARED-" . $repoId);
// If guest user created, remove it now.
if (isset($minisiteData["PRELOG_USER"]) && AuthService::userExists($minisiteData["PRELOG_USER"])) {
AuthService::deleteUser($minisiteData["PRELOG_USER"]);
}
// If guest user created, remove it now.
if (isset($minisiteData["PRESET_LOGIN"]) && AuthService::userExists($minisiteData["PRESET_LOGIN"])) {
AuthService::deleteUser($minisiteData["PRESET_LOGIN"]);
}
if (isset($minisiteData["PUBLICLET_PATH"]) && is_file($minisiteData["PUBLICLET_PATH"])) {
unlink($minisiteData["PUBLICLET_PATH"]);
} else {
if ($this->sqlSupported) {
$this->confStorage->simpleStoreClear("share", $element);
}
}
} else {
if ($type == "user") {
$this->testUserCanEditShare($element);
AuthService::deleteUser($element);
} else {
if ($type == "file") {
$publicletData = $this->loadShare($element);
if (isset($publicletData["OWNER_ID"]) && $this->testUserCanEditShare($publicletData["OWNER_ID"])) {
PublicletCounter::delete($element);
if (isset($publicletData["PUBLICLET_PATH"]) && is_file($publicletData["PUBLICLET_PATH"])) {
unlink($publicletData["PUBLICLET_PATH"]);
} else {
if ($this->sqlSupported) {
$this->confStorage->simpleStoreClear("share", $element);
}
}
} else {
throw new Exception($mess["share_center.160"]);
}
}
}
}
}
}
示例3: switchAction
//.........这里部分代码省略.........
case "group":
$httpVars["group"] = "/data/users" . $httpVars["data_id"];
break;
default:
break;
}
unset($httpVars["data_type"]);
unset($httpVars["data_id"]);
}
if (isset($httpVars["repository_id"])) {
$repId = $httpVars["repository_id"];
$repo = ConfService::getRepositoryById($repId);
if (!is_object($repo)) {
$res = -1;
} else {
$res = ConfService::deleteRepository($repId);
}
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess[427]);
} else {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.59"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
return;
} else {
if (isset($httpVars["role_id"])) {
$roleId = $httpVars["role_id"];
if (AuthService::getRole($roleId) === false) {
throw new Exception($mess["ajxp_conf.67"]);
}
AuthService::deleteRole($roleId);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.68"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
} else {
if (isset($httpVars["group"])) {
$groupPath = $httpVars["group"];
$basePath = substr(AJXP_Utils::forwardSlashDirname($groupPath), strlen("/data/users"));
$gName = basename($groupPath);
AuthService::deleteGroup($basePath, $gName);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.128"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
} else {
if (!isset($httpVars["user_id"]) || $httpVars["user_id"] == "" || AuthService::isReservedUserId($httpVars["user_id"]) || $loggedUser->getId() == $httpVars["user_id"]) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
}
AuthService::deleteUser($httpVars["user_id"]);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.60"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
}
}
}
break;
case "get_plugin_manifest":
$ajxpPlugin = AJXP_PluginsService::getInstance()->getPluginById($httpVars["plugin_id"]);
AJXP_XMLWriter::header("admin_data");
示例4: deleteSharedElement
/**
* @static
* @param String $type
* @param String $element
* @param AbstractAjxpUser $loggedUser
* @throws Exception
*/
public static function deleteSharedElement($type, $element, $loggedUser)
{
$mess = ConfService::getMessages();
AJXP_Logger::debug($type . "-" . $element);
if ($type == "repository") {
$repo = ConfService::getRepositoryById($element);
if ($repo == null) {
return;
}
if (!$repo->hasOwner() || $repo->getOwner() != $loggedUser->getId()) {
throw new Exception($mess["ajxp_shared.12"]);
} else {
$res = ConfService::deleteRepository($element);
if ($res == -1) {
throw new Exception($mess["ajxp_conf.51"]);
}
}
} else {
if ($type == "minisite") {
$minisiteData = self::loadPublicletData($element);
$repoId = $minisiteData["REPOSITORY"];
$repo = ConfService::getRepositoryById($repoId);
if ($repo == null) {
return false;
}
if (!$repo->hasOwner() || $repo->getOwner() != $loggedUser->getId()) {
throw new Exception($mess["ajxp_shared.12"]);
} else {
$res = ConfService::deleteRepository($repoId);
if ($res == -1) {
throw new Exception($mess["ajxp_conf.51"]);
}
// Silently delete corresponding role if it exists
AuthService::deleteRole("AJXP_SHARED-" . $repoId);
// If guest user created, remove it now.
if (isset($minisiteData["PRELOG_USER"])) {
AuthService::deleteUser($minisiteData["PRELOG_USER"]);
}
unlink($minisiteData["PUBLICLET_PATH"]);
}
} else {
if ($type == "user") {
$confDriver = ConfService::getConfStorageImpl();
$object = $confDriver->createUserObject($element);
if (!$object->hasParent() || $object->getParent() != $loggedUser->getId()) {
throw new Exception($mess["ajxp_shared.12"]);
} else {
AuthService::deleteUser($element);
}
} else {
if ($type == "file") {
$publicletData = self::loadPublicletData($element);
if (isset($publicletData["OWNER_ID"]) && $publicletData["OWNER_ID"] == $loggedUser->getId()) {
PublicletCounter::delete($element);
unlink($publicletData["PUBLICLET_PATH"]);
} else {
throw new Exception($mess["ajxp_shared.12"]);
}
}
}
}
}
}
示例5: switchAction
//.........这里部分代码省略.........
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.58"], null);
AJXP_XMLWriter::close();
break;
case "delete":
if (isset($httpVars["repository_id"])) {
$repId = $httpVars["repository_id"];
$res = ConfService::deleteRepository($repId);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
} else {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.59"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
return;
} else {
if (isset($httpVars["shared_file"])) {
AJXP_XMLWriter::header();
$element = basename($httpVars["shared_file"]);
$dlFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER");
$publicletData = $this->loadPublicletData($dlFolder . "/" . $element . ".php");
unlink($dlFolder . "/" . $element . ".php");
AJXP_XMLWriter::sendMessage($mess["ajxp_shared.13"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
} else {
if (isset($httpVars["role_id"])) {
$roleId = $httpVars["role_id"];
if (AuthService::getRole($roleId) === false) {
throw new Exception($mess["ajxp_conf.67"]);
}
AuthService::deleteRole($roleId);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.66"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
} else {
if (!isset($httpVars["user_id"]) || $httpVars["user_id"] == "" || AuthService::isReservedUserId($httpVars["user_id"]) || $loggedUser->getId() == $httpVars["user_id"]) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
}
$res = AuthService::deleteUser($httpVars["user_id"]);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.60"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
}
}
}
break;
case "clear_expired":
$deleted = $this->clearExpiredFiles();
AJXP_XMLWriter::header();
if (count($deleted)) {
AJXP_XMLWriter::sendMessage(sprintf($mess["ajxp_shared.23"], count($deleted) . ""), null);
AJXP_XMLWriter::reloadDataNode();
} else {
AJXP_XMLWriter::sendMessage($mess["ajxp_shared.24"], null);
}
AJXP_XMLWriter::close();
break;
case "get_plugin_manifest":
$ajxpPlugin = AJXP_PluginsService::getInstance()->getPluginById($httpVars["plugin_id"]);
示例6: createSharedRepository
//.........这里部分代码省略.........
}
}
foreach ($users as $userName) {
if (AuthService::userExists($userName, "r")) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
} else {
if (ConfService::getAuthDriverImpl()->getOptionAsBool("TRANSMIT_CLEAR_PASS")) {
$pass = $uPasses[$userName];
} else {
$pass = md5($uPasses[$userName]);
}
if (!isset($httpVars["minisite"])) {
// This is an explicit user creation - check possible limits
AJXP_Controller::applyHook("user.before_create", array($userName));
$limit = $loggedUser->personalRole->filterParameterValue("core.conf", "USER_SHARED_USERS_LIMIT", AJXP_REPO_SCOPE_ALL, "");
if (!empty($limit) && intval($limit) > 0) {
$count = count(ConfService::getConfStorageImpl()->getUserChildren($loggedUser->getId()));
if ($count >= $limit) {
$mess = ConfService::getMessages();
throw new Exception($mess['483']);
}
}
}
AuthService::createUser($userName, $pass);
$userObject = $confDriver->createUserObject($userName);
$userObject->personalRole->clearAcls();
$userObject->setParent($loggedUser->id);
$userObject->setGroupPath($loggedUser->getGroupPath());
$userObject->setProfile("shared");
if (isset($httpVars["minisite"])) {
$mess = ConfService::getMessages();
$userObject->setHidden(true);
$userObject->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", "[" . $mess["share_center.109"] . "] " . AJXP_Utils::sanitize($newRepo->getDisplay(), AJXP_SANITIZE_EMAILCHARS));
}
AJXP_Controller::applyHook("user.after_create", array($userObject));
}
// CREATE USER WITH NEW REPO RIGHTS
$userObject->personalRole->setAcl($newRepo->getUniqueId(), $uRights[$userName]);
if (isset($httpVars["minisite"])) {
if (isset($editingRepo)) {
try {
AuthService::deleteRole("AJXP_SHARED-" . $newRepo->getUniqueId());
} catch (Exception $e) {
}
}
$newRole = new AJXP_Role("AJXP_SHARED-" . $newRepo->getUniqueId());
$r = AuthService::getRole("MINISITE");
if (is_a($r, "AJXP_Role")) {
if ($httpVars["disable_download"]) {
$f = AuthService::getRole("MINISITE_NODOWNLOAD");
if (is_a($f, "AJXP_Role")) {
$r = $f->override($r);
}
}
$allData = $r->getDataArray();
$newData = $newRole->getDataArray();
if (isset($allData["ACTIONS"][AJXP_REPO_SCOPE_SHARED])) {
$newData["ACTIONS"][$newRepo->getUniqueId()] = $allData["ACTIONS"][AJXP_REPO_SCOPE_SHARED];
}
if (isset($allData["PARAMETERS"][AJXP_REPO_SCOPE_SHARED])) {
$newData["PARAMETERS"][$newRepo->getUniqueId()] = $allData["PARAMETERS"][AJXP_REPO_SCOPE_SHARED];
}
$newRole->bunchUpdate($newData);
AuthService::updateRole($newRole);
$userObject->addRole($newRole);
}
}
$userObject->save("superuser");
if ($this->watcher !== false) {
// Register a watch on the current folder for shared user
if ($uWatches[$userName] == "true") {
$this->watcher->setWatchOnFolder(new AJXP_Node($this->urlBase . $file), $userName, MetaWatchRegister::$META_WATCH_USERS_CHANGE, array(AuthService::getLoggedUser()->getId()));
} else {
$this->watcher->removeWatchFromFolder(new AJXP_Node($this->urlBase . $file), $userName, true);
}
}
}
if ($this->watcher !== false) {
// Register a watch on the new repository root for current user
if ($httpVars["self_watch_folder"] == "true") {
$this->watcher->setWatchOnFolder(new AJXP_Node($this->baseProtocol . "://" . $newRepo->getUniqueId() . "/"), AuthService::getLoggedUser()->getId(), MetaWatchRegister::$META_WATCH_BOTH);
} else {
$this->watcher->removeWatchFromFolder(new AJXP_Node($this->baseProtocol . "://" . $newRepo->getUniqueId() . "/"), AuthService::getLoggedUser()->getId());
}
}
foreach ($groups as $group) {
$r = $uRights[$group];
if ($group == "AJXP_GRP_/") {
$group = "ROOT_ROLE";
}
$grRole = AuthService::getRole($group, true);
$grRole->setAcl($newRepo->getUniqueId(), $r);
AuthService::updateRole($grRole);
}
if (array_key_exists("minisite", $httpVars) && $httpVars["minisite"] != true) {
AJXP_Controller::applyHook(isset($editingRepo) ? "node.share.update" : "node.share.create", array('type' => 'repository', 'repository' => &$repository, 'accessDriver' => &$accessDriver, 'new_repository' => &$newRepo));
}
return $newRepo;
}
示例7: switchAction
//.........这里部分代码省略.........
case "delete_meta_source":
$repId = $httpVars["repository_id"];
$repo = ConfService::getRepositoryById($repId);
$metaSourceId = $httpVars["plugId"];
$repoOptions = $repo->getOption("META_SOURCES");
if (is_array($repoOptions) && array_key_exists($metaSourceId, $repoOptions)) {
unset($repoOptions[$metaSourceId]);
$repo->addOption("META_SOURCES", $repoOptions);
ConfService::replaceRepository($repId, $repo);
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.57"], null);
AJXP_XMLWriter::close();
break;
case "edit_meta_source":
$repId = $httpVars["repository_id"];
$repo = ConfService::getRepositoryById($repId);
$metaSourceId = $httpVars["plugId"];
$options = array();
$this->parseParameters($httpVars, $options);
$repoOptions = $repo->getOption("META_SOURCES");
if (!is_array($repoOptions)) {
$repoOptions = array();
}
$repoOptions[$metaSourceId] = $options;
$repo->addOption("META_SOURCES", $repoOptions);
ConfService::replaceRepository($repId, $repo);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.58"], null);
AJXP_XMLWriter::close();
break;
case "delete":
if (isset($httpVars["repository_id"])) {
$repId = $httpVars["repository_id"];
//if(get_magic_quotes_gpc()) $repLabel = stripslashes($repLabel);
$res = ConfService::deleteRepository($repId);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
} else {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.59"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
exit(1);
} else {
if (isset($httpVars["shared_file"])) {
AJXP_XMLWriter::header();
$element = basename($httpVars["shared_file"]);
$publicletData = $this->loadPublicletData(PUBLIC_DOWNLOAD_FOLDER . "/" . $element . ".php");
unlink(PUBLIC_DOWNLOAD_FOLDER . "/" . $element . ".php");
AJXP_XMLWriter::sendMessage($mess["ajxp_shared.13"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
} else {
if (isset($httpVars["role_id"])) {
$roleId = $httpVars["role_id"];
if (AuthService::getRole($roleId) === false) {
throw new Exception($mess["ajxp_conf.67"]);
}
AuthService::deleteRole($roleId);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.66"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
} else {
$forbidden = array("guest", "share");
if (!isset($httpVars["user_id"]) || $httpVars["user_id"] == "" || in_array($httpVars["user_id"], $forbidden) || $loggedUser->getId() == $httpVars["user_id"]) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
exit(1);
}
$res = AuthService::deleteUser($httpVars["user_id"]);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.60"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
exit(1);
}
}
}
break;
case "clear_expired":
$deleted = $this->clearExpiredFiles();
AJXP_XMLWriter::header();
if (count($deleted)) {
AJXP_XMLWriter::sendMessage(sprintf($mess["ajxp_shared.23"], count($deleted) . ""), null);
AJXP_XMLWriter::reloadDataNode();
} else {
AJXP_XMLWriter::sendMessage($mess["ajxp_shared.24"], null);
}
AJXP_XMLWriter::close();
break;
default:
break;
}
return;
}
示例8: createRoleForMinisite
/**
* @param string $repositoryId
* @param bool $disableDownload
* @param bool $replace
* @return AJXP_Role|null
*/
public function createRoleForMinisite($repositoryId, $disableDownload, $replace)
{
if ($replace) {
try {
AuthService::deleteRole("AJXP_SHARED-" . $repositoryId);
} catch (Exception $e) {
}
}
$newRole = new AJXP_Role("AJXP_SHARED-" . $repositoryId);
$r = AuthService::getRole("MINISITE");
if (is_a($r, "AJXP_Role")) {
if ($disableDownload) {
$f = AuthService::getRole("MINISITE_NODOWNLOAD");
if (is_a($f, "AJXP_Role")) {
$r = $f->override($r);
}
}
$allData = $r->getDataArray();
$newData = $newRole->getDataArray();
if (isset($allData["ACTIONS"][AJXP_REPO_SCOPE_SHARED])) {
$newData["ACTIONS"][$repositoryId] = $allData["ACTIONS"][AJXP_REPO_SCOPE_SHARED];
}
if (isset($allData["PARAMETERS"][AJXP_REPO_SCOPE_SHARED])) {
$newData["PARAMETERS"][$repositoryId] = $allData["PARAMETERS"][AJXP_REPO_SCOPE_SHARED];
}
$newRole->bunchUpdate($newData);
AuthService::updateRole($newRole);
return $newRole;
}
return null;
}