本文整理汇总了PHP中UserManager::deleteUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::deleteUser方法的具体用法?PHP UserManager::deleteUser怎么用?PHP UserManager::deleteUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::deleteUser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUser
/**
* Tests creating, saving, editing User objects.
*/
function testUser()
{
// elimino l'utente già creato in precedenza con questo nome.
$u = UserManager::loadUserByNickname($this->user_data[NICKNAME]);
//echo "<p>" . $u . "</p>"; //DEBUG
if ($u !== false) {
$u = UserManager::deleteUser($u);
//echo "<p>" . $u . "</p>"; //DEBUG
}
$u = UserManager::loadUserByNickname($this->user_data2[NICKNAME]);
if ($u !== false) {
$u = UserManager::deleteUser($u);
}
$u = UserManager::createUser($this->user_data);
//echo "<p>" . $u . "</p>"; //DEBUG
$data = Filter::filterArray($this->user_data);
if (isset($data[AVATAR])) {
if ($u->getAvatar() != $data[AVATAR]) {
return "User test NOT PASSED: avatar";
}
}
if (isset($data[BIRTHDAY])) {
if ($u->getBirthday() != $data[BIRTHDAY]) {
return "User test NOT PASSED: birthday";
}
}
if (isset($data[BIRTHPLACE])) {
if ($u->getBirthplace() != $data[BIRTHPLACE]) {
return "User test NOT PASSED: birthplace";
}
}
if (isset($data[EMAIL])) {
if ($u->getEMail() != $data[EMAIL]) {
return "User test NOT PASSED: email";
}
}
if (isset($data[GENDER])) {
if ($u->getGender() != $data[GENDER]) {
return "User test NOT PASSED: gender";
}
}
if (isset($data[HOBBIES])) {
if ($u->getHobbies() != $data[HOBBIES]) {
return "User test NOT PASSED: hobbies";
}
}
if (isset($data[JOB])) {
if ($u->getJob() != $data[JOB]) {
return "User test NOT PASSED: job";
}
}
if (isset($data[LIVING_PLACE])) {
if ($u->getLivingPlace() != $data[LIVING_PLACE]) {
return "User test NOT PASSED: living place";
}
}
if (isset($data[NAME])) {
if ($u->getName() != $data[NAME]) {
return "User test NOT PASSED: name";
}
}
if (isset($data[NICKNAME])) {
if ($u->getNickname() != $data[NICKNAME]) {
return "User test NOT PASSED: nickname";
}
}
if (isset($data[PASSWORD])) {
if ($u->getPassword() != $data[PASSWORD]) {
return "User test NOT PASSED: password";
}
}
if (isset($data[ROLE])) {
if ($u->getRole() != $data[ROLE]) {
return "User test NOT PASSED: role";
}
}
if (isset($data[SURNAME])) {
if ($u->getSurname() != $data[SURNAME]) {
return "User test NOT PASSED: surname";
}
}
if (isset($data[VISIBLE])) {
if ($u->getVisible() != $data[VISIBLE]) {
return "User test NOT PASSED: visible";
}
}
// TEST LOAD
$u2 = UserManager::loadUser($u->getID());
//echo "<p>" . $u . "<br />" . $u2 . "</p>"; //DEBUG
if ($u->getAvatar() != $u2->getAvatar()) {
return "User test NOT PASSED: avatar not loaded";
}
//echo "<p>" . $u->getBirthday() . "<br />" . $u2->getBirthday() . " - " . time() . "</p>"; //DEBUG
if ($u->getBirthday() != $u2->getBirthday()) {
return "User test NOT PASSED: birthday not loaded";
}
if ($u->getBirthplace() != $u2->getBirthplace()) {
//.........这里部分代码省略.........
示例2: array
<?php
require_once 'init2.php';
loadScripts();
$data = array("status" => "not set!");
if (Utils::isPOST()) {
// post means either to delete or add a user
$parameters = new Parameters("POST");
$action = $parameters->getValue('action');
$user_name = $parameters->getValue('username');
//$data = array("action" => $action, "user_name" => $user_name);
if ($action == 'delete' && !empty($user_name)) {
$um = new UserManager();
$um->deleteUser($user_name);
$data = array("status" => "success", "msg" => "User '{$user_name}' deleted.");
echo json_encode($data, JSON_FORCE_OBJECT);
return;
} else {
if ($action == 'update' && !empty($user_name)) {
$newFirstName = $parameters->getValue('newFirstName');
$newLastName = $parameters->getValue('newLastName');
$newUserName = $parameters->getValue('newUserName');
$newQuantity = $parameters->getValue('newQuantity');
if (!empty($newFirstName)) {
$um = new UserManager();
$count = $um->updateUserFirstName($user_name, $newFirstName);
if ($count > 0) {
$data = array("status" => "success", "msg" => "User '{$user_name}' updated with new first name ('{$newFirstName}').");
} else {
$data = array("status" => "fail", "msg" => "User '{$user_name}' was NOT updated with new first name ('{$newFirstName}').");
}
示例3: deleteUser
public function deleteUser(User $user)
{
$result = parent::deleteUser($user);
$this->invalidateUserCacheByUserId($user->id);
return $result;
}
示例4: html_liste_actions
/**
* Suppression d'un utilisateur
* @package Backend
* @subpackage Presentation
* @author Laurent Jouanneau
* @author Florian Hatat
* @copyright Copyright © 2003 OpenWeb.eu.org
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
*/
define('OW_BACKEND_ACTION', 'ACT_ADMIN_DELETE');
require_once '../../include/backend/init.inc.php';
echo html_liste_actions();
require_once PATH_INC_BACKEND_SERVICE . 'UserManager.class.php';
$um = new UserManager($db);
if (!(empty($_POST['uti_login']) || $_POST['uti_login'] == "none")) {
if ($um->deleteUser($_POST['uti_login'])) {
echo "<p>Utilisateur ", $_POST['uti_login'], " fusillé</p>";
} else {
echo "<p>Utilisateur ", $_POST['uti_login'], " gracié</p>";
}
exit;
}
$users = $um->getUserList(true);
?>
<form action="<?php
echo $_SERVER['PHP_SELF'];
?>
" method="post">
<fieldset>
<legend>Supprimer un utilisateur</legend>
<select name="uti_login" id="uti_login" size="">
示例5: UserManager
<html>
<head>
<link rel="stylesheet" type="text/css" href="style/css/style.css"/>
<link rel="shortcut icon" href="images/watermelon8.png"/>
</head>
<body>
<?php
require_once 'config.php';
require_once BUSINESS_DIR_USER . 'User.php';
require_once BUSINESS_DIR_USER . 'UserManager.php';
$userManager = new UserManager();
$userId = intval($_GET["id"]);
if ($_POST) {
$decativate = $userManager->deleteUser($userId);
if (!$decativate) {
echo "<script>alert('Error: Cannot Delete');</script>";
} else {
header("Location: user_test/logout.php");
}
}
?>
<div align="center" style="padding-top: 200px">
<h1><img src="images/sad.png" alt="unhappy" /> We are sorry. You are leaving.</h1>
<h2>Are sure you want to cancle your account?</h2>
<form action="deactivate_prof.php?id=<?php
echo $userId;
?>
" method="POST">
示例6: doUserAction
private static function doUserAction($request)
{
//echo "<p>" . serialize($request) . "</p>"; //DEBUG
$user = null;
$loadDependencies = self::$requestedAction == "Follow" || self::$requestedAction == "Feedback" || self::$requestedAction == "AddContact" || self::$requestedAction == "StopFollow" || self::$requestedAction == "Read";
if ($loadDependencies && self::$requestedAction != "Read") {
self::$user->loadFollows();
}
if (is_numeric(self::$currentID)) {
$user = UserManager::loadUser(self::$currentID, $loadDependencies);
} else {
if (isset(self::$currentID)) {
$user = UserManager::loadUserByNickname(self::$currentID, $loadDependencies);
}
}
switch (self::$requestedAction) {
case "Edit":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error.php?e=Oops la pagina non è stata trovata."));
}
require_once 'user/UserPage.php';
UserPage::showEditProfileForm($user);
break;
case "Follow":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error.php?e=Oops la pagina non è stata trovata."));
}
UserManager::followUser(self::$user, $user);
header("location:" . FileManager::appendToRootPath("User/" . $user->getID()));
break;
case "Feedback":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error.php?e=Oops la pagina non è stata trovata."));
}
require_once 'user/UserPage.php';
UserPage::showFeedbackForm($user);
break;
case "AddContact":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error.php?e=Oops la pagina non è stata trovata."));
}
require_once 'user/UserPage.php';
UserPage::showNewContactForm($user);
break;
case "StopFollow":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error.php?e=Oops la pagina non è stata trovata."));
}
UserManager::stopFollowingUser(self::$user, $user);
header("location:" . FileManager::appendToRootPath("User/" . $user->getID()));
break;
case "Verify":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error.php?e=Oops la pagina non è stata trovata."));
}
UserManager::verifyUser($user, $_GET["code"]);
header("location:" . FileManager::appendToRootPath("User/" . $user->getID()));
break;
case "Posts":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error?e=Oops la pagina non è stata trovata."));
}
require_once 'search/SearchManager.php';
$posts = SearchManager::searchBy("Post", array("ps_author" => $user->getID()), array("order" => -1, "by" => "ps_creationDate"));
require_once 'post/PostPage.php';
foreach ($posts as $p) {
PostPage::showPost($p, self::$post_options);
}
break;
case "Mails":
require_once 'mail/MailManager.php';
$mails = MailManager::loadDirectoryFromName(MAILBOX, self::$user);
require_once 'mail/MailPage.php';
foreach ($mails as $mail) {
MailPage::showShortMail($mail);
}
break;
case "Delete":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error.php?e=Oops la pagina non è stata trovata."));
}
UserManager::deleteUser($user);
header("location: " . FileManager::appendToRootPath(""));
break;
case "New":
require_once 'user/UserPage.php';
UserPage::showSignInForm();
break;
case "Read":
if (is_null($user) || $user === false) {
header("location: " . FileManager::appendToRootPath("error.php?e=Oops la pagina non è stata trovata."));
}
require_once 'user/UserPage.php';
UserPage::showProfile($user);
break;
case "Search":
default:
require_once "search/SearchPage.php";
SearchPage::showUserSearchForm($p);
break;
//.........这里部分代码省略.........
示例7: process
public function process($parameters)
{
//do control panela maju pristup len prihlaseny uzivatelia
$this->checkUser();
$noticeManager = new NoticeManager();
$userManager = new UserManager();
$loggedUser = $userManager->returnUser();
//zadane URL pre odhlasenie
if (!empty($parameters[0]) && $parameters[0] == 'odhlasit') {
$userManager->logOut();
$this->redirect('prihlasenie');
}
//zadane URL pre zobrazenie rozpisanych clankov redaktora alebo admina
if (!empty($parameters[0]) && $parameters[0] == 'moje-clanky') {
//ak je prihlaseny redaktor alebo admin
if ($loggedUser['admin'] == 1 || $loggedUser['admin'] == 2) {
$articleManager = new ArticleManager();
$unpublishedArticles = $articleManager->returnUnpublishedArticles();
//vybratie iba tych nepublikovanych clankov, ktorych autor je momentalne prihlaseny uzivatel
$userArticles = array();
foreach ($unpublishedArticles as $article) {
if ($article['author'] == $loggedUser['name']) {
$userArticles[] = $article;
}
}
//ak nie su ziadne clanky na zobrazenie
if (sizeof($userArticles) == 0) {
$this->createMessage('Žiadne články na zobrazenie', 'info');
}
$this->data['userArticles'] = $userArticles;
$this->head['title'] = 'Moje články';
$this->view = 'myArticles';
}
}
//ak bol odoslany formular s novym oznamom
if (isset($_POST['newNoticeSubmit'])) {
//overenie ci je prihlaseny admin
$this->checkUser(true);
if (isset($_POST['noticeField'])) {
$noticeManager->addNotice($_POST['noticeField']);
$this->createMessage('Oznam bol úspešne uložený', 'success');
$this->redirect('panel');
}
}
//zadane URL pre odstranenie oznamu
if (!empty($parameters[1]) && $parameters[1] == 'odstranit') {
//overenie ci je prihlaseny admin
$this->checkUser(true);
//odstran oznam s danym ID
$noticeManager->removeNotice($parameters[0]);
$this->redirect('panel');
}
//ak je zadane URL pre odstranenie uzivatelskeho uctu
if (!empty($parameters[1]) && $parameters[1] == 'odstranit-ucet') {
if ($parameters[0] == $loggedUser['name']) {
$userManager->deleteUser($parameters[0]);
} else {
$this->redirect('chyba');
}
$this->createMessage('Váš účet bol odstránený zo systému. Ďakujeme', 'warning');
$userManager->logOut();
$this->redirect('');
}
//zadane URL pre zobrazenie control panelu
if (empty($parameters[0])) {
$user = $userManager->returnUser();
//oznamy
$this->data['notices'] = $noticeManager->returnNotices();
//data pre sablonu
$this->data['admin'] = $user['admin'];
$this->data['user'] = $user['name'];
$messageManager = new MessageManager();
$this->data['receivedMessages'] = $messageManager->returnReceivedMessages($user['name']);
$this->data['sentMessages'] = $messageManager->returnSentMessages($user['name']);
//nastavenie sablony a title
$this->view = 'controlPanel';
$this->head['title'] = 'Ovládací panel';
}
}
示例8: process
public function process($parameters)
{
$userManager = new UserManager();
$validation = new Validation();
$user = $userManager->returnUser();
//ak bol odoslany formular pre ulozenie udajov uzivatela
//udaje z formularu sa ukladaju do premennej $data, z ktorej sa nakoniec vyberu a zapisu do DB vsetky udaje
//v celom bloku try sa odchytavaju vsetky vynimky
if (isset($_POST['submit'])) {
try {
$this->checkUser();
//polia pre zmenu hesla
//ak bolo vyplnene aspon jedno z poli
if (!empty($_POST['old']) || !empty($_POST['password'] != '') || !empty($_POST['password2'] != '')) {
$userManager->checkPassword($user['name'], $_POST['old']);
//over stare heslo
if (!empty($_POST['password']) && !empty($_POST['password2'])) {
if ($_POST['password'] == $_POST['password2']) {
$validation->checkPasswordLength($_POST['password']);
//overi minimalnu dlzku hesla
$data['password'] = $userManager->returnHash($_POST['password']);
//pripravi pole a zasifruje heslo
$this->createMessage('Heslo bolo úspešne zmenené.', 'success');
} else {
throw new UserError('Heslá sa nezhodujú.');
}
} else {
throw new UserError('Nevyplnené pole.');
}
}
//radio button pohlavie
if ($_POST['sex'] == 'male') {
$data['sex'] = 'muž';
} else {
$data['sex'] = 'žena';
}
$userManager->updateUserData($user['name'], $data);
//zapis udajov uzivatela do DB
$this->createMessage('Nastavenia boli úspešne uložené.', 'success');
} catch (UserError $error) {
$this->createMessage($error->getMessage(), 'warning');
}
}
//ak bol odoslany formular pre upload profiloveho obrazka
if (isset($_POST['uploadImage'])) {
$imageUpload = new upload($_FILES['image_field']);
$targetDirectory = 'img/users/' . $user['name'] . '/';
$filePath = $targetDirectory . 'user_avatar.gif';
try {
//ak neexistuje uzivatelov adresar, vytvor ho
if (!file_exists($targetDirectory)) {
mkdir($targetDirectory, '0777', true);
}
//ak bol obrazok nahraty
if ($imageUpload->uploaded) {
$imageUpload->allowed = array('image/*');
//povolene formaty
$imageUpload->mime_check = true;
//kontrola formatu zapnuta
$imageUpload->file_new_name_body = 'user_avatar';
//novy nazov suboru
$imageUpload->image_resize = true;
//zmensenie
$imageUpload->image_convert = 'gif';
//konvertovanie na gif
$imageUpload->image_x = 100;
//vysledna sirka 100px
$imageUpload->image_ratio_y = true;
//vyska: auto
//zmazanie existujuceho avataru
if (file_exists($filePath)) {
unlink($filePath);
}
$imageUpload->process($targetDirectory);
//uloz vysledny obrazok
//ak bol obrazok ulozeny
if ($imageUpload->processed) {
//uloz avatar do databazy
$userManager->updateUserData($user['name'], array('avatar' => $filePath));
$imageUpload->clean();
} else {
throw new UserError($imageUpload->error);
}
$this->createMessage('Váš obrázok bol úspešne uložený.', 'success');
} else {
throw new UserError('Obrázok sa nenahral');
}
} catch (UserError $error) {
$this->createMessage($error->getMessage(), 'warning');
}
}
//ak je zadana URL pre odstranenie uzivatela
if (!empty($parameters[1]) && $parameters[1] == 'odstranit') {
$this->checkUser(true);
$userManager->deleteUser($parameters[0]);
$this->createMessage('Užívateľ<strong> ' . $parameters[0] . ' </strong>bol odstránený', 'success');
$this->redirect('uzivatelia');
}
//ak je zadana URL pre zmenu opravnenia uzivatela
if (!empty($parameters[1]) && $parameters[1] == 'zmenit-opravnenie') {
//.........这里部分代码省略.........
示例9: process
public function process($parameters)
{
$userManager = new UserManager();
$validation = new Validation();
$user = $userManager->returnUser();
//ak bol odoslany formular pre ulozenie udajov uzivatela
//udaje z formularu sa ukladaju do premennej $data, z ktorej sa nakoniec vyberu a zapisu do DB vsetky udaje
//v celom bloku try sa odchytavaju vsetky vynimky
if (isset($_POST['submit'])) {
try {
$this->checkUser();
//polia pre zmenu hesla
//ak bolo vyplnene aspon jedno z poli
if (!empty($_POST['old']) || !empty($_POST['password'] != '') || !empty($_POST['password2'] != '')) {
$userManager->checkPassword($user['name'], $_POST['old']);
//over stare heslo
if (!empty($_POST['password']) && !empty($_POST['password2'])) {
if ($_POST['password'] == $_POST['password2']) {
$validation->checkPasswordLength($_POST['password']);
//overi minimalnu dlzku hesla
$data['password'] = $userManager->returnHash($_POST['password']);
//pripravi pole a zasifruje heslo
$this->createMessage('Heslo bolo úspešne zmenené.', 'success');
} else {
throw new UserError('Heslá sa nezhodujú.');
}
} else {
throw new UserError('Nevyplnené pole.');
}
}
//radio button pohlavie
if ($_POST['sex'] == 'male') {
$data['sex'] = 'muž';
} else {
$data['sex'] = 'žena';
}
//pole pre email
$data['email'] = $_POST['email'];
$userManager->updateUserData($user['name'], $data);
//zapis udajov uzivatela do DB
$this->createMessage('Nastavenia boli úspešne uložené.', 'success');
} catch (UserError $error) {
$this->createMessage($error->getMessage(), 'warning');
}
}
//ak bol odoslany formular pre upload profiloveho obrazka
if (isset($_POST['uploadImage'])) {
try {
//adresar pre ulozenie obrazkov
$targetDirectory = 'img/users/' . $user['name'] . '/';
$targetFile = $targetDirectory . basename($_FILES['fileToUpload']['name']);
$imageFileType = pathinfo($targetFile, PATHINFO_EXTENSION);
$targetFile = $targetDirectory . $user['user_id'] . '.' . $imageFileType;
//ak neexistuje uzivatelov adresar, vytvor ho
if (!file_exists($targetDirectory)) {
mkdir($targetDirectory, '0777', true);
}
//ak bol nahraty obrazok
if (!empty($_FILES['fileToUpload']['tmp_name'])) {
//skontroluje ci subor je naozaj obrazok
$check = getimagesize($_FILES['fileToUpload']['tmp_name']);
if ($check == false) {
throw new UserError('Súbor nie je obrázok');
}
} else {
throw new UserError('Nenahrali ste žiadny obrázok');
}
if ($_FILES['fileToUpload']['size'] > 512000) {
throw new UserError('Maximálna veľkosť obrázka je 0,5 MB.');
}
if ($imageFileType != 'jpg' && $imageFileType != 'png' && $imageFileType != 'jpeg' && $imageFileType != 'gif') {
throw new UserError('Nepovolený formát obrázku1');
}
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $targetFile)) {
$this->createMessage('Váš obrázok bol úspešne uložený.', 'success');
} else {
throw new UserError('Pri nahrávaní obrázka sa vyskytla chyba.');
}
//zapisanie avataru do databazy
$userManager->updateUserData($user['name'], array('avatar' => $user['name'] . '/' . $user['user_id'] . '.' . $imageFileType));
} catch (UserError $error) {
$this->createMessage($error->getMessage(), 'warning');
}
}
//ak je zadana URL pre odstranenie uzivatela
if (!empty($parameters[1]) && $parameters[1] == 'odstranit') {
$this->checkUser(true);
$userManager->deleteUser($parameters[0]);
$this->createMessage('Užívateľ<strong> ' . $parameters[0] . ' </strong>bol odstránený', 'success');
$this->redirect('uzivatelia');
}
//ak je zadane URL profilu uzivatela
if (!empty($parameters[0])) {
$user = $userManager->returnUserInfo($parameters[0]);
//ak pouzivatel nebol najdeny, presmeruj na chybove hlasenie
if (!$user) {
$this->redirect('chyba');
}
//premenne pre sablonu
$this->head['title'] = 'Užívateľský profil - ' . $user['name'];
//.........这里部分代码省略.........