本文整理汇总了PHP中AuthService::deleteUser方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::deleteUser方法的具体用法?PHP AuthService::deleteUser怎么用?PHP AuthService::deleteUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::deleteUser方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAction
//.........这里部分代码省略.........
if (is_array($option)) {
$nested[] = $option;
}
}
}
if (count($nested)) {
print ">";
foreach ($nested as $option) {
foreach ($option as $key => $optValue) {
if (is_bool($optValue)) {
$optValue = $optValue ? "true" : "false";
}
print "<param name=\"{$key}\" value=\"{$optValue}\"/>";
}
}
print "</repository>";
} else {
print "/>";
}
print ConfService::availableDriversToXML("param", $repository->accessType);
AJXP_XMLWriter::close("admin_data");
exit(1);
break;
case "edit_repository_label":
case "edit_repository_data":
$repId = $_GET["repository_id"];
$repo = ConfService::getRepositoryById($repId);
$res = 0;
if (isset($_GET["newLabel"])) {
$repo->setDisplay(SystemTextEncoding::fromPostedFileName($_GET["newLabel"]));
$res = ConfService::replaceRepository($repId, $repo);
} else {
$options = array();
$this->parseParameters($_GET, $options);
if (count($options)) {
foreach ($options as $key => $value) {
$repo->addOption($key, $value);
}
}
if (is_file(INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $repo->getAccessType() . ".php")) {
chdir(INSTALL_PATH . "/server/tests/plugins");
include INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $repo->getAccessType() . ".php";
$className = "ajxp_" . $repo->getAccessType();
$class = new $className();
$result = $class->doRepositoryTest($repo);
if (!$result) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $class->failedInfo);
AJXP_XMLWriter::close();
exit(1);
}
}
ConfService::replaceRepository($repId, $repo);
}
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, "Error while trying to edit repository");
} else {
AJXP_XMLWriter::sendMessage("Successfully edited repository", null);
AJXP_XMLWriter::reloadFileList(isset($_GET["newLabel"]) ? SystemTextEncoding::fromPostedFileName($_GET["newLabel"]) : false);
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
exit(1);
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, "The conf directory is not writeable");
} else {
AJXP_XMLWriter::sendMessage("Successfully deleted repository", null);
AJXP_XMLWriter::reloadFileList(false);
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
exit(1);
} else {
$forbidden = array("guest", "share");
if (!isset($httpVars["user_id"]) || $httpVars["user_id"] == "" || in_array($_GET["user_id"], $forbidden) || $loggedUser->getId() == $httpVars["user_id"]) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, "Wrong Arguments!");
AJXP_XMLWriter::close();
exit(1);
}
$res = AuthService::deleteUser($httpVars["user_id"]);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage("User successfully erased", null);
AJXP_XMLWriter::reloadFileList($httpVars["user_id"]);
AJXP_XMLWriter::close();
exit(1);
}
break;
default:
break;
}
return;
}
示例2: array
$_SESSION = array();
$result = TRUE;
break;
case 'addUser':
global $user;
if (is_array($user)) {
$newSession = new SessionSwitcher("AjaXplorer");
AuthService::createUser($user["name"], $user["password"], false);
$result = TRUE;
}
break;
case 'delUser':
global $userName;
if (strlen($userName)) {
$newSession = new SessionSwitcher("AjaXplorer");
AuthService::deleteUser($userName);
$result = TRUE;
}
break;
case 'updateUser':
global $user;
if (is_array($user)) {
$newSession = new SessionSwitcher("AjaXplorer");
if (AuthService::updatePassword($user["name"], $user["password"])) {
//@TODO Change this to match your CMS code
if ($user["right"] == "admin") {
$userObj = getLoggedUser();
if ($user["name"] == $userObj->getId()) {
AuthService::updateAdminRights($userObj);
}
}
示例3: switchAction
//.........这里部分代码省略.........
AJXP_XMLWriter::reloadDataNode("", $newRep->getUniqueId());
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
break;
case "user_delete_repository":
$repoId = $httpVars["repository_id"];
$repository = ConfService::getRepositoryById($repoId);
if (!$repository->getUniqueUser() || $repository->getUniqueUser() != AuthService::getLoggedUser()->getId()) {
throw new Exception("You are not allowed to perform this operation!");
}
$res = ConfService::deleteRepository($repoId);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess[427]);
} else {
$loggedUser = AuthService::getLoggedUser();
// Make sure we do not override remotely set rights
$loggedUser->load();
$loggedUser->personalRole->setAcl($repoId, "");
$loggedUser->save("superuser");
AuthService::updateUser($loggedUser);
AJXP_XMLWriter::sendMessage($mess[428], null);
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
break;
case "user_delete_user":
$userId = $httpVars["user_id"];
$userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
if ($userObject == null || !$userObject->hasParent() || $userObject->getParent() != AuthService::getLoggedUser()->getId()) {
throw new Exception("You are not allowed to edit this user");
}
AuthService::deleteUser($userId);
echo "SUCCESS";
break;
case "user_list_authorized_users":
$defaultFormat = "html";
HTMLWriter::charsetHeader();
if (!ConfService::getAuthDriverImpl()->usersEditable()) {
break;
}
$loggedUser = AuthService::getLoggedUser();
$crtValue = $httpVars["value"];
$usersOnly = isset($httpVars["users_only"]) && $httpVars["users_only"] == "true";
$existingOnly = isset($httpVars["existing_only"]) && $httpVars["existing_only"] == "true";
if (!empty($crtValue)) {
$regexp = '^' . $crtValue;
} else {
$regexp = null;
}
$skipDisplayWithoutRegexp = ConfService::getCoreConf("USERS_LIST_REGEXP_MANDATORY", "conf");
if ($skipDisplayWithoutRegexp && $regexp == null) {
print "<ul></ul>";
break;
}
$limit = intval(ConfService::getCoreConf("USERS_LIST_COMPLETE_LIMIT", "conf"));
$searchAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf");
$displayAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS_DISPLAY", "conf");
$baseGroup = "/";
if ($regexp == null && !$displayAll || $regexp != null && !$searchAll) {
$baseGroup = AuthService::filterBaseGroup("/");
}
AuthService::setGroupFiltering(false);
$allUsers = AuthService::listUsers($baseGroup, $regexp, 0, $limit, false);
if (!$usersOnly) {
示例4: switchAction
function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
parent::accessPreprocess($action, $httpVars, $fileVars);
$loggedUser = AuthService::getLoggedUser();
if (!ENABLE_USERS) {
return;
}
if ($action == "edit") {
if (isset($httpVars["sub_action"])) {
$action = $httpVars["sub_action"];
}
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// BASIC LISTING
//------------------------------------
case "ls":
$rootNodes = array("files" => array("LABEL" => $mess["ajxp_shared.3"], "ICON" => "html.png", "DESCRIPTION" => $mess["ajxp_shared.28"]), "repositories" => array("LABEL" => $mess["ajxp_shared.2"], "ICON" => "document_open_remote.png", "DESCRIPTION" => $mess["ajxp_shared.29"]), "users" => array("LABEL" => $mess["ajxp_shared.1"], "ICON" => "user_shared.png", "DESCRIPTION" => $mess["ajxp_shared.30"]));
$dir = isset($httpVars["dir"]) ? $httpVars["dir"] : "";
$splits = explode("/", $dir);
if (count($splits)) {
if ($splits[0] == "") {
array_shift($splits);
}
if (count($splits)) {
$strippedDir = strtolower(urldecode($splits[0]));
} else {
$strippedDir = "";
}
}
if (array_key_exists($strippedDir, $rootNodes)) {
AJXP_XMLWriter::header();
if ($strippedDir == "users") {
$this->listUsers();
} else {
if ($strippedDir == "repositories") {
$this->listRepositories();
} else {
if ($strippedDir == "files") {
$this->listSharedFiles();
}
}
}
AJXP_XMLWriter::close();
exit(1);
} else {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist"><column messageId="ajxp_shared.8" attributeName="ajxp_label" sortType="String"/><column messageId="ajxp_shared.31" attributeName="description" sortType="String"/></columns>');
foreach ($rootNodes as $key => $data) {
print '<tree text="' . $data["LABEL"] . '" icon="' . $data["ICON"] . '" filename="/' . $key . '" parentname="/" description="' . $data["DESCRIPTION"] . '" />';
}
AJXP_XMLWriter::close();
}
break;
case "stat":
header("Content-type:application/json");
print '{"mode":true}';
break;
case "delete":
$mime = $httpVars["ajxp_mime"];
$selection = new UserSelection();
$selection->initFromHttpVars();
$files = $selection->getFiles();
AJXP_XMLWriter::header();
foreach ($files as $index => $element) {
$element = basename($element);
if ($mime == "shared_repository") {
$repo = ConfService::getRepositoryById($element);
if (!$repo->hasOwner() || $repo->getOwner() != $loggedUser->getId()) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_shared.12"]);
break;
} else {
$res = ConfService::deleteRepository($element);
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
break;
} else {
if ($index == count($files) - 1) {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.59"], null);
AJXP_XMLWriter::reloadDataNode();
}
}
}
} else {
if ($mime == "shared_user") {
$confDriver = ConfService::getConfStorageImpl();
$object = $confDriver->createUserObject($element);
if (!$object->hasParent() || $object->getParent() != $loggedUser->getId()) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_shared.12"]);
break;
} else {
$res = AuthService::deleteUser($element);
if ($index == count($files) - 1) {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.60"], null);
AJXP_XMLWriter::reloadDataNode();
}
//.........这里部分代码省略.........
示例5: switchAction
//.........这里部分代码省略.........
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");
$fullManifest = $ajxpPlugin->getManifestRawContent("", "xml");
$xPath = new DOMXPath($fullManifest->ownerDocument);
$addParams = "";
$instancesDefinitions = array();
$pInstNodes = $xPath->query("server_settings/global_param[contains(@type, 'plugin_instance:')]");
foreach ($pInstNodes as $pInstNode) {
$type = $pInstNode->getAttribute("type");
$instType = str_replace("plugin_instance:", "", $type);
$fieldName = $pInstNode->getAttribute("name");
$pInstNode->setAttribute("type", "group_switch:" . $fieldName);
$typePlugs = AJXP_PluginsService::getInstance()->getPluginsByType($instType);
foreach ($typePlugs as $typePlug) {
if ($typePlug->getId() == "auth.multi") {
continue;
}
$checkErrorMessage = "";
try {
$typePlug->performChecks();
} catch (Exception $e) {
$checkErrorMessage = " (Warning : " . $e->getMessage() . ")";
}
示例6: 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"]);
}
}
}
}
}
}
示例7: 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"]);
}
}
}
}
}
}
示例8: switchAction
//.........这里部分代码省略.........
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"]);
AJXP_XMLWriter::header("admin_data");
echo AJXP_XMLWriter::replaceAjxpXmlKeywords($ajxpPlugin->getManifestRawContent());
$definitions = $ajxpPlugin->getConfigsDefinitions();
$values = $ajxpPlugin->getConfigs();
if (!is_array($values)) {
$values = array();
}
echo "<plugin_settings_values>";
foreach ($values as $key => $value) {
if ($definitions[$key]["type"] == "array" && is_array($value)) {
$value = implode(",", $value);
示例9: AuthService
$flash_messages = $this->flash->getMessages();
$userService = new AuthService();
$user = $userService->getUserById($id);
if ($request->isPost()) {
$user['full_name'] = filter_var($_POST['full_name'], FILTER_SANITIZE_STRING);
$user['email'] = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
$user_form = validateUserEditForm($user);
if ($user_form['is_valid']) {
$userService->updateUser($user);
$this->flash->addMessage('success', 'Details has been updated');
return $response->withRedirect($this->router->pathFor('admin-users-all'));
} else {
$field_errors = $user_form['has_errors'];
}
}
return $this->view->render($response, 'admin/admin_users_edit.twig', ['user' => $user, 'flash_messages' => $flash_messages, 'userLogged' => isset($_SESSION['user_id'])]);
})->setName('admin-users-edit');
$app->map(['GET', 'POST'], '/admin/users/delete/{id:[\\d]*}', function ($request, $response, $args) {
$user = [];
$id = (int) $args['id'];
$flash_messages = $this->flash->getMessages();
$userService = new AuthService();
$user = $userService->getUserById($id);
$OK_link = $this->router->pathFor('admin-users-delete', ['id' => $id]);
if ($request->isPost()) {
$userService->deleteUser($id);
$this->flash->addMessage('success', 'User has been successfully deleted');
return $response->withRedirect($this->router->pathFor('admin-users-all'));
}
return $this->view->render($response, 'admin/admin_users_delete.twig', ['user' => $user, 'OK_link' => $OK_link, 'flash_messages' => $flash_messages, 'userLogged' => isset($_SESSION['user_id'])]);
})->setName('admin-users-delete');
示例10: 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;
}
示例11: deleteSharedElement
/**
* @static
* @param String $type
* @param String $element
* @param AbstractAjxpUser $loggedUser
* @return void
*/
public static function deleteSharedElement($type, $element, $loggedUser)
{
$mess = ConfService::getMessages();
if ($type == "repository") {
$repo = ConfService::getRepositoryById($element);
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 == "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"]);
}
}
}
}
}