本文整理汇总了PHP中UserManager::returnUserInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::returnUserInfo方法的具体用法?PHP UserManager::returnUserInfo怎么用?PHP UserManager::returnUserInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::returnUserInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process($parameters)
{
//iba prihlaseny uzivatelia
$this->checkUser();
$userManager = new UserManager();
$messageManager = new MessageManager();
$loggedUser = $userManager->returnUser();
//ak je zadane URL pre vytvorenie novej spravy
if (!empty($parameters[0]) && $parameters[0] == 'vytvorit') {
$users = $userManager->returnUsers();
//vytvorenie zdroja pre automaticke doplnovanie uzivatelov v poli 'prijemca'
$autocompleteSource = '';
foreach ($users as $user) {
$autocompleteSource = $autocompleteSource . "'" . $user['name'] . "'" . ', ';
}
$autocompleteSource = rtrim($autocompleteSource, ", ");
$this->data['autocompleteSource'] = $autocompleteSource;
//ak bol zadany prijemca v URL
if (!empty($parameters[1])) {
$this->data['recipient_url'] = strip_tags($parameters[1]);
} else {
$this->data['recipient_url'] = '';
}
$this->head['title'] = 'Nová správa';
$this->view = 'messageForm';
}
//ak je zadane URL na odstranenie spravy
if (!empty($parameters[1]) && $parameters[1] == 'odstranit') {
$message = $messageManager->returnMessage($parameters[0]);
if ($message) {
$messageManager->deleteMessage($parameters[0], $loggedUser);
$this->createMessage('Správa bola odstránená', 'success');
$this->redirect('panel');
} else {
$this->redirect('chyba');
}
}
//ak je zadane URL na zobrazenie spravy
if (!empty($parameters[1]) && $parameters[1] == 'zobrazit') {
$message = $messageManager->returnMessage($parameters[0]);
//ak sprava existuje a otvara ju prijimatel, alebo odosielatel
if ($message && ($message['sender'] == $loggedUser['name'] || $message['recipient'] == $loggedUser['name'])) {
//pri prvom otvoreni, oznac spravu ako precitanu
if ($message['unread'] == 1 && $message['recipient'] == $loggedUser['name']) {
$messageManager->readMessage($message['message_id']);
}
$this->head['title'] = 'Správa - ' . $message['subject'];
$this->data['message'] = $message;
$this->view = 'message';
} else {
$this->redirect('chyba');
}
}
//ak bol odoslany formular pre odoslanie spravy
if ($_POST) {
$sender = $userManager->returnUser();
$recipient = strip_tags($_POST['recipient']);
$subject = htmlspecialchars($_POST['subject']);
$message = htmlspecialchars($_POST['message']);
try {
$recipient = $userManager->returnUserInfo($recipient);
if (!$recipient) {
throw new UserError('Užívateľ neexistuje');
}
if ($sender['name'] == $recipient['name']) {
throw new UserError('Nemôžete poslať správu sám sebe');
}
//odoslanie spravy do databazy
$messageManager->sendMessage($sender['name'], $recipient['name'], $subject, $message);
$this->createMessage('Vaša správa bola úspešne odoslaná', 'success');
$this->redirect('panel');
} catch (UserError $error) {
$this->createMessage($error->getMessage(), 'warning');
}
}
//zadane URL bez parametrov
if (empty($parameters)) {
$this->redirect('chyba');
}
}
示例2: process
//.........这里部分代码省略.........
//ak je zadane URL pre zobrazenie konkretnej strany
if (!empty($parameters[0]) && $parameters[0] == 'page') {
//ak je zadane cislo strany
if (!empty($parameters[1]) && is_numeric($parameters[1])) {
if ($parameters[1] == 1) {
$offset = 0;
} else {
$offset = $parameters[1] * 5 - 5;
}
//zisti pocet clankov, a pripravi pocet stran
$articles = $articleManager->returnPublicArticles(0);
//vsetky clanky
$countArticles = sizeof($articles);
$modulo = $countArticles % 5;
if ($modulo == 0) {
$this->data['pages'] = $countArticles / 5;
} else {
$this->data['pages'] = intval($countArticles / 5 + 1);
}
$this->data['currentPage'] = $parameters[1];
//aktualna strana
//vratenie clankov s pozadovanym offsetom
$articles = $articleManager->returnPublicArticles($offset);
$this->data['articles'] = $validation->statusOfArticles($articles);
$this->view = 'articles';
} else {
$this->redirect('clanky');
}
}
//ak je zadane URL pre zmazanie clanku
if (!empty($parameters[1]) && $parameters[1] == 'odstranit' && $parameters[0] != 'page') {
//overi ci clanok z URL existuje
if (!$article) {
$this->redirect('chyba');
}
//overi ci je prihlaseny admin
$this->checkUser(true);
$articleManager->deleteArticle($parameters[0]);
$this->createMessage('Článok bol odstránený', 'success');
$this->redirect('clanky');
}
//ak je zadane URL pre zmazanie komentara
if (!empty($parameters[0]) && !empty($parameters[1]) && $parameters[1] == 'odstranit-komentar' && !empty($parameters[2])) {
//overi ci clanok z URL existuje
if (!$article) {
$this->redirect('chyba');
}
$this->checkUser(true);
//overi ci je prihlaseny admin
$commentManager->deleteComment($parameters[2]);
$this->createMessage('Komentár bol odstránený', 'success');
}
//ak je zadane URL clanku
if (!empty($parameters[0]) && $parameters[0] != 'page' && $parameters[0] != 'unpublished') {
//ak nebol clanok na zadanej URL najdeny
//alebo ak uzivatel nie je admin a clanok nie je publikovany
//presmeruj na chybove hlasenie
if (!$article || $user['admin'] != '1' && $article['public'] == '0') {
$this->redirect('chyba');
}
//ak bol odoslany komentar
if ($_POST) {
//ak bol spravne vyplneny antispam
if ($_POST['year'] == date('Y')) {
//vyber udajov z $_POST a ich ulozenie do premennej $comment
$keys = array('article_id', 'comment', 'author');
$comment = array_intersect_key($_POST, array_flip($keys));
//ulozenie komentara do DB
$commentManager->saveComment($comment, $user['name']);
$this->createMessage('Váš komentár bol úspešne pridaný', 'success');
$this->redirect('clanky/' . $article['url']);
} else {
$this->createMessage('Chybne vyplnený antispam', 'warning');
$this->redirect('clanky/' . $article['url']);
}
}
//hlavicka stranky
$this->head = array('title' => $article['title'], 'key_words' => $article['key_words'], 'description' => $article['description']);
//naplnenie premennych pre sablonu
$this->data['article'] = $article;
$this->data['user'] = $user['name'];
//status clanku (publikovany/nepublikovany)
$status = $validation->statusOfArticles(array($article));
$this->data['article']['status'] = $status[0]['status'];
//komentare k clanku
$this->data['comments'] = $commentManager->returnCommentsById($article['article_id']);
//priradenie avataru uzivatela do komentarov
$i = 0;
foreach ($this->data['comments'] as $commentData) {
$userData = $userManager->returnUserInfo($commentData['author']);
$this->data['comments'][$i]['avatar'] = $userData['avatar'];
$this->data['comments'][$i]['userRank'] = $validation->returnUserRank($userData['admin']);
$i += 1;
}
//zaznamena navstevu clanku
$articleManager->newVisit($article['article_id'], $article['visits']);
//nastavenie sablony
$this->view = 'article';
}
}
示例3: process
//.........这里部分代码省略.........
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') {
$this->checkUser(true);
$requiredUser = $userManager->returnUserInfo($parameters[0]);
//ak ma uzivatel hodnost 'Clen', zmen ho na 'Redaktor'
if ($requiredUser['admin'] == 0) {
$value = array('admin' => 2);
$userManager->updateUserData($parameters[0], $value);
$this->createMessage('Užívateľovi ' . $parameters[0] . ' bola priradená hodnosť Redaktor', 'success');
$this->redirect('uzivatelia');
}
//ak ma uzivatel hodnost 'Redaktor', zmen ho na 'Clen'
if ($requiredUser['admin'] == 2) {
$value = array('admin' => 0);
$userManager->updateUserData($parameters[0], $value);
$this->createMessage('Užívateľovi ' . $parameters[0] . ' bola priradená hodnosť Člen', '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'];
$this->data['userRank'] = $validation->returnUserRank($user['admin']);
$this->data['user'] = $user['name'];
$this->data['avatar'] = $user['avatar'];
$this->data['registrationDate'] = $user['registration_date'];
$this->data['lastVisit'] = $user['last_visit'];
$this->data['comments'] = $user['comments'];
$this->data['articles'] = $user['articles'];
$this->data['sex'] = $user['sex'];
$this->data['email'] = $user['email'];
$this->data['loggedUser'] = $userManager->returnUser();
//sablona
$this->view = 'profile';
} else {
$this->checkUser(true);
//premenne pre sablonu
$this->head['title'] = 'Správa užívateľov';
$this->data['admin'] = $user && $user['admin'];
$this->data['users'] = $userManager->returnUsers();
$this->data['loggedUser'] = $userManager->returnUser();
$index = 0;
foreach ($this->data['users'] as $userData) {
$this->data['users'][$index]['rank'] = $validation->returnUserRank($userData['admin']);
$index += 1;
}
//sablona
$this->view = 'users';
}
}
示例4: process
//.........这里部分代码省略.........
//ak je zadane URL pre zmazanie clanku
if (!empty($parameters[1]) && $parameters[1] == 'odstranit' && $parameters[0] != 'page') {
//overi ci clanok z URL existuje
if (!$article) {
$this->redirect('chyba');
}
//ak je clanok nepublikovany a je prihlaseny autor tohoto clanku
if ($article['public'] == 0 && $article['author'] == $user['name']) {
$articleManager->deleteArticle($parameters[0]);
} else {
//overi ci je prihlaseny admin
$this->checkUser(true);
$articleManager->deleteArticle($parameters[0]);
}
$this->createMessage('Článok bol odstránený', 'success');
$this->redirect('clanky');
}
//ak je zadane URL pre publikovanie clanku
if (!empty($parameters[1]) && $parameters[1] == 'publikovat' && $parameters[0] != 'page') {
//overi ci clanok z URL existuje
if (!$article) {
$this->redirect('chyba');
}
//overi ci je prihlaseny admin
$this->checkUser(true);
$articleManager->publishArticle($article['url']);
$this->createMessage('Článok bol publikovaný', 'success');
$this->redirect('clanky');
}
//ak je zadane URL pre zmazanie komentara
if (!empty($parameters[0]) && !empty($parameters[1]) && $parameters[1] == 'odstranit-komentar' && !empty($parameters[2])) {
//overi ci clanok z URL existuje
if (!$article) {
$this->redirect('chyba');
}
$this->checkUser(true);
//overi ci je prihlaseny admin
$commentManager->deleteComment($parameters[2]);
$this->createMessage('Komentár bol odstránený', 'success');
}
//ak je zadane URL clanku
if (!empty($parameters[0]) && $parameters[0] != 'page' && $parameters[0] != 'unpublished') {
//ak nebol clanok na zadanej URL najdeny
if (!$article) {
$this->redirect('chyba');
}
//ak uzivatel nie je admin ALEBO redaktor A clanok nie je publikovany
if ($article['public'] == 0 && $user['admin'] == 0) {
$this->redirect('chyba');
}
//ak je uzivatel redaktor A nie je autorom daneho clanku
if ($user['admin'] == 2 && $user['name'] != $article['author'] && $article['public'] == 0) {
$this->redirect('chyba');
}
//ak bol odoslany komentar
if ($_POST) {
//odstranenie skodliveho kodu z antispam pola
$captchaAnswer = strip_tags($_POST['captchaAnswer']);
//ak bol spravne vyplneny antispam
if ($validation->checkCaptcha($_POST['captchaNumber1'], $_POST['captchaNumber2'], $captchaAnswer)) {
$comment['article_id'] = $_POST['article_id'];
$comment['author'] = $_POST['author'];
$comment['comment'] = htmlspecialchars($_POST['comment']);
//pridanie emoticonov
$comment['comment'] = $commentManager->addEmoticons($comment['comment']);
//ulozenie komentara do DB
$commentManager->saveComment($comment, $user['name']);
$this->createMessage('Váš komentár bol úspešne pridaný', 'success');
$this->redirect('clanky/' . $article['url']);
} else {
$this->createMessage('Chybne vyplnený antispam', 'warning');
$this->redirect('clanky/' . $article['url']);
}
}
//naplnenie premennych pre sablonu
$this->data['article'] = $article;
$this->data['category'] = $validation->returnCategoryName($article['category']);
$this->data['user'] = $user['name'];
//status clanku (publikovany/nepublikovany)
$status = $validation->statusOfArticles(array($article));
$this->data['article']['status'] = $status[0]['status'];
//komentare k clanku
$this->data['comments'] = $commentManager->returnCommentsById($article['article_id']);
//antispam otazka
$this->data['captcha'] = $validation->returnCaptcha();
//priradenie avataru uzivatela do komentarov
$i = 0;
foreach ($this->data['comments'] as $commentData) {
$userData = $userManager->returnUserInfo($commentData['author']);
$this->data['comments'][$i]['avatar'] = $userData['avatar'];
$this->data['comments'][$i]['userRank'] = $validation->returnUserRank($userData['admin']);
$i += 1;
}
//zaznamena navstevu clanku
$articleManager->newVisit($article['article_id'], $article['visits']);
//hlavicka stranky
$this->head = array('title' => $article['title'], 'key_words' => $article['key_words'], 'description' => $article['description']);
$this->view = 'article';
}
}
示例5: 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'];
//.........这里部分代码省略.........