本文整理汇总了PHP中UserManager::returnUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::returnUsers方法的具体用法?PHP UserManager::returnUsers怎么用?PHP UserManager::returnUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::returnUsers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process($parameters)
{
//editor je pristupny iba pre admina
$this->checkUser(true);
$this->head['title'] = 'Editor článkov';
//vytvorenie instancie spravcu clankov
$articleManager = new ArticleManager();
$userManager = new UserManager();
$validation = new Validation();
$article = array('article_id' => '', 'thumbnail_img' => '', 'title' => '', 'content' => '', 'url' => '', 'description' => '', 'key_words' => '', 'author' => '');
//ak je odoslany formular
if ($_POST) {
//ziskanie clanku z $_POST
$keys = array('title', 'thumbnail_img', 'content', 'url', 'description', 'key_words', 'author', 'public');
$article = array_intersect_key($_POST, array_flip($keys));
//ak bol oznaceny checkbox public, tak nastav clanok ako publikovany
if (isset($_POST['public'])) {
$article['public'] = '1';
} else {
$article['public'] = '0';
}
//ak nebol nastaveny nahladovy obrazok, nastav defaultny
if (empty($_POST['thumbnail_img'])) {
$article['thumbnail_img'] = 'img/articles/no_thumb.jpg';
}
try {
//vytvorenie URL adresy z pola title
$article['url'] = $validation->checkUrl($article['title']);
//ulozenie clanku do databazy
$articleManager->saveArticle($_POST['article_id'], $article);
$this->createMessage('Článok bol úspešne uložený', 'success');
$this->redirect('clanky/' . $article['url']);
} catch (UserError $error) {
$this->createMessage($error->getMessage(), 'warning');
$this->redirect('editor');
}
} elseif (!empty($parameters[0])) {
$loadedArticle = $articleManager->returnArticle($parameters[0]);
if ($loadedArticle) {
$article = $loadedArticle;
} else {
$this->createMessage('Článok sa nenašiel', 'warning');
$this->redirect('chyba');
}
}
$this->data['authors'] = $userManager->returnUsers();
$this->data['article'] = $article;
//sablona
$this->view = 'editor';
}
示例2: 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');
}
}
示例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
//.........这里部分代码省略.........
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'];
$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();
$index = 0;
foreach ($this->data['users'] as $userData) {
$this->data['users'][$index]['rank'] = $validation->returnUserRank($userData['admin']);
$index += 1;
}
//sablona
$this->view = 'users';
}
}