public function testPrevCurrentNext() { $request = new RequestAggregate(); $controller = new UsersController($request); $controller->initialize(); $request->setRequest(new Param('/Users/page')); $request->setRequest(new Query([])); $controller->Paginator->paginate(); $view = new ViewAdapter('../../app/View', '../../app/Layout', $controller); //current = 1 $this->assertEquals(null, $view->Paginator->prev('prev')); $this->assertEquals(1, $view->Paginator->current()); $this->assertEquals("<a href='/Users/page/?page=2'>next</a>", $view->Paginator->next('next')); $request->setRequest(new Query(['page' => 1])); $controller->Paginator->paginate(); //current = 1 $this->assertEquals(null, $view->Paginator->prev('prev')); $this->assertEquals(1, $view->Paginator->current()); $this->assertEquals("<a href='/Users/page/?page=2'>next</a>", $view->Paginator->next('next')); $request->setRequest(new Query(['page' => 2])); $controller->Paginator->paginate(); //current = 1 $this->assertEquals("<a href='/Users/page/?page=1'>prev</a>", $view->Paginator->prev('prev')); $this->assertEquals(2, $view->Paginator->current()); $this->assertEquals(null, $view->Paginator->next('next')); }
function main() { $login = ""; $answer = 0; if (count($this->args) != 1) { die("Not enough parameters"); } else { $login = $this->args[0]; } App::import('Core', 'Controller'); App::import('Component', 'Acl'); App::import('Controller', 'Users'); $UsersController = new UsersController(); $UsersController->constructClasses(); $this->Acl =& new AclComponent(); $controller = null; $this->Acl->startup($controller); $this->Aco =& $this->Acl->Aco; $conditions = array('login ' => $login); $users = $this->User->find('all', array('conditions' => $conditions, 'fields' => array('User.active'))); $num_users = count($users); if ($num_users > 0) { if ($num_users == 1) { $active = $users[0]['User']['active']; if ($active == 0) { $answer = 1; } } } echo $answer; }
public function testMainCallsFind() { $userClass = \idfly\Moka::stubClass(null, ['::find' => 'USER']); $controller = new UsersController($userClass); $controller->find(1000); // check that `find` was called with 100 $this->assertEquals([1000], $userClass::$moka->report('find')[0]); }
public function testLoadComponent() { $request = new RequestAggregate(); $request->setRequest(new Param('/Mocks/index/1')); $controller = new UsersController($request); $controller->initialize(); $this->assertInstanceOf('MockComponent', $controller->Mock); $this->assertEquals('success', $controller->Mock->startup()); }
function onAfterDispatch() { JFactory::getLanguage()->load('com_tz_pinboard'); $mainframe = JFactory::getApplication(); if ($mainframe->isAdmin()) { return; } $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $task = JRequest::getCmd('task'); $layout = JRequest::getCmd('layout'); $user = JFactory::getUser(); if ($option == 'com_users' && $view == 'registration' && !$layout) { require_once JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_users' . DIRECTORY_SEPARATOR . 'controller.php'; $controller = new UsersController(); $views = $controller->getView($view, 'html'); $tplName = JFactory::getApplication()->getTemplate(); $tplPath = JPATH_THEMES . DIRECTORY_SEPARATOR . $tplName . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'com_tz_pinboard' . DIRECTORY_SEPARATOR . 'manageruser'; if (!JFile::exists($tplPath . DIRECTORY_SEPARATOR . 'register.php')) { $tplPath = JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_tz_pinboard' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'manageruser' . DIRECTORY_SEPARATOR . 'tmpl'; } $views->addTemplatePath($tplPath); $views->setLayout('register'); ob_start(); $views->display(); $contents = ob_get_clean(); $document = JFactory::getDocument(); $document->setBuffer($contents, 'component'); } if ($user->username && $option == 'com_users' && $view == 'profile' && ($layout == 'edit' || $task == 'profile.edit')) { require_once JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_users' . DIRECTORY_SEPARATOR . 'controller.php'; $controller = new UsersController(); $views = $controller->getView($view, 'html'); $tplName = JFactory::getApplication()->getTemplate(); $tplPath = JPATH_THEMES . DIRECTORY_SEPARATOR . $tplName . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'com_tz_pinboard' . DIRECTORY_SEPARATOR . 'manageruser'; if (!JFile::exists($tplPath . DIRECTORY_SEPARATOR . 'profile.php')) { $tplPath = JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_tz_pinboard' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'manageruser' . DIRECTORY_SEPARATOR . 'tmpl'; } $views->addTemplatePath($tplPath); $views->setLayout('profile'); require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_tz_pinboard' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'user.php'; $model = new TZ_PinboardModelUser(); $userData = $model->getUsers($user->id); $views->assign('TZUser', $userData); ob_start(); $active = JFactory::getApplication()->getMenu()->getActive(); if (isset($active->query['layout']) && $active->query['layout'] != 'profile') { $active->query['layout'] = 'profile'; } $views->assign('user', $user); $views->display(); $contents = ob_get_clean(); $document = JFactory::getDocument(); $document->setBuffer($contents, 'component'); } }
public function run($page) { switch ($page) { case 'index': $users = new UsersController(); $users->runIndex(); break; default: $home_view = new HomeView(); $home_view->runIndex(); break; } }
/** * Constructor * * @params array Controller configuration array */ function __construct($config = array()) { parent::__construct($config); $pathViews = JPATH_ADMINISTRATOR . DS . "components" . DS . "com_noixacl" . DS . "views"; $this->addViewPath($pathViews); JRequest::setVar('view', 'users'); }
public function logSearch($searchTerm, $searchType) { $userId = UsersController::getUserIdByHash(); $userId = $userId != null ? $userId : 0; //if no user is returned, the request will be logged as if the user_id = 0 was making the request. DB::insert('INSERT INTO ns_searches (user_id, search_term, type) VALUES (?, ?, ?)', [$userId, $searchTerm, $searchType]); }
public function render($action = null, $layout = null, $file = null) { if (!$this->testView) { $this->renderedAction = $action; } else { return parent::render($action, $layout, $file); } }
public function render($action = null, $layout = null, $file = null) { if (is_null($action)) { $action = $this->action; } if (!file_exists(VIEWS . $this->viewPath . DS . $action . '.ctp')) { $file = App::pluginPath('users') . 'views' . DS . 'users' . DS . $action . '.ctp'; } return parent::render($action, $layout, $file); }
public function render($action = null, $layout = null) { if (is_null($action)) { $action = $this->action; } $view = ROOT . DS . APP_DIR . DS . 'View' . DS . $this->viewPath . DS . $action . '.ctp'; if (!file_exists(ROOT . DS . APP_DIR . DS . 'View' . DS . $this->viewPath . DS . $action . '.ctp')) { $view = App::pluginPath('Users') . 'View' . DS . 'Users' . DS . $action . '.ctp'; } return parent::render($view, $layout); }
public function render($view = null, $layout = null) { if (is_null($view)) { $view = $this->action; } $viewPath = substr(get_class($this), 0, strlen(get_class($this)) - 10); if (!file_exists(APP . 'View' . DS . $viewPath . DS . $view . '.ctp')) { $this->plugin = 'Users'; } else { $this->viewPath = $viewPath; } return parent::render($view, $layout); }
/** * Constructor * * @param Request $request * @return UsersCalendarController */ function __construct($request) { parent::__construct($request); if (!can_access_profile_calendar($this->logged_user, $this->active_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->active_user->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $this->wireframe->addBreadCrumb(lang('Calendar'), Calendar::getProfileCalendarUrl($this->active_user)); }
function beforeFilter() { $this->Auth->allow('index'); $this->Auth->allow('add'); $this->Auth->allow('edit'); $this->Auth->allow('list'); $this->Auth->allow('delete'); $this->Auth->allow('view'); //表示権限がない場合はリダイレクト $ret=UsersController::_page_check(); if ( $ret == 0 ){ $this->redirect('/'); } }
public function inventoryAction($requestData) { // Используем модель Items; include_once '/models/Items.php'; $item = new Items(); // Вызываем контроллер пользователя для получения данных; include "/controllers/UsersController.php"; $myUser = new UsersController(); $myUser->readUser(); $this->data = $myUser->data; // В бою нельзя лазить в инвентарь; if ($this->data['user']->questId != 0) { $this->data['returnPage'] = 'main'; $this->data['errorMessage'] = 'В бою нельзя пользоваться инвентарем!<br>Вернитесь в бой!'; } else { // Любые действия над предметом проходят проверку на наличие предмета; if ($requestData['parseValue2'] != '') { $this->data['item'] = $item->readById($requestData['parseValue2']); } // Продаем предмет; if ($requestData['parseValue1'] == 'sell') { } // Одеваем предмет; if ($requestData['parseValue1'] == 'use') { } // Все предметы; $this->data['items'] = $item->readAllItemsByUserId($_SESSION['userId']); // Количество предметов; $this->data['itemsCount'] = $item->itemsCount($_SESSION['userId']); // Уровень скила отвечающий за количество одетых предметов; include_once '/models/Skills.php'; $mySkill = new Skills(); $this->data['skillWear'] = $mySkill->readSkillValue($_SESSION['userId'], 18); $this->data['returnPage'] = 'inventory'; } return $this->data; }
/** * Ensures that if the deleteUser method is called and user_id is an * admin, but the delete fails, then an exception is thrown * * @return void */ public function testDeleteUserWithAdminAccessDeletesSuccesfully() { define('UNIT_TEST', 1); $request = new \Request([], ['REQUEST_URI' => "http://api.dev.joind.in/v2.1/users/3", 'REQUEST_METHOD' => 'DELETE']); $request->user_id = 1; $usersController = new \UsersController(); // Please see below for explanation of why we're mocking a "mock" PDO // class $db = $this->getMockBuilder('\\JoindinTest\\Inc\\mockPDO')->getMock(); $userMapper = $this->getMockBuilder('\\UserMapper')->setConstructorArgs(array($db, $request))->getMock(); $userMapper->expects($this->once())->method('thisUserHasAdminOn')->will($this->returnValue(true)); $userMapper->expects($this->once())->method('delete')->will($this->returnValue(true)); $usersController->setUserMapper($userMapper); $this->assertTrue($usersController->deleteUser($request, $db)); }
// Controlpanel $routes->get('/controlpanel', 'admin', function () { AuthController::controlpanel(); }); // Users $routes->get('/users', 'admin', function () { UsersController::index(); }); $routes->get('/users/create', 'admin', function () { UsersController::create(); }); $routes->post('/users/store', 'admin', function () { UsersController::store(); }); $routes->get('/users/:id/destroy', 'admin', function ($id) { UsersController::destroy($id); }); // Roles $routes->get('/roles', 'admin', function () { RolesController::index(); }); $routes->get('/roles/create', 'admin', function () { RolesController::create(); }); $routes->post('/roles/store', 'admin', function () { RolesController::store(); }); $routes->get('/roles/:id/edit', 'admin', function ($id) { RolesController::edit($id); }); $routes->post('/roles/:id/update', 'admin', function ($id) {
if (isset($request) && !empty($request) && $request[0] !== '') { if ($request[0] == 'auth') { UsersController::currentUser(); } else { if ($request[0] == 'privilege') { if (isset($request[1]) && !empty($request[1]) && $request[1] !== '') { $id = $request[1]; UsersController::getAccessDetails($id); } else { UsersController::getAccessList(); } } else { $id = $request[0]; UsersController::detail($id); } } } else { UsersController::read(); } break; case 'DELETE': if (isset($request) && !empty($request) && $request[0] !== '') { $id = $request[0]; UsersController::delete($id); } break; default: return print json_encode('DECISION SUPPORT SYSTEM API v.0.1 developed by: Philip Cesar B. Garay'); break; } exit;
<?php /** * Created by Yogesh on 12/2/2015. * */ session_start(); require_once "../config/Route.php"; require_once "../model/UsersController.php"; require_once "../model/ContributionController.php"; if (array_key_exists('userId', $_SESSION)) { $contributionController = new ContributionController(); $userController = new UsersController(); $userId = $_SESSION['userId']; $user = $userController->find($userId); if ($user) { if (array_key_exists('post', $_GET) && array_key_exists('s', $_GET)) { $id = test_input($_GET['post']); $poi = $contributionController->find($id); if ($poi) { $action = test_input($_GET['s']); switch ($action) { case "a": $poi->setStatus("A"); $contributionController->update($poi); Route::redirect($_SERVER['HTTP_REFERER']); break; case "r": $poi->setStatus("R"); $contributionController->update($poi); Route::redirect($_SERVER['HTTP_REFERER']);
$_REQUEST['order_by'] = 'id'; } // Список зарег. пользователей $control = new UsersController(); $response = $control->plist_action($_REQUEST["event"], $_REQUEST['order_by']); } elseif ($uri == 'login') { // Форма входа $control = new UsersController(); $response = $control->login_action(); } elseif ($uri == 'logout') { // Выход $control = new UsersController(); $response = $control->logout_action(); } elseif ($uri == 'admin' and $access_granted) { // Административная часть $control = new UsersController(); $response = $control->admin_action(); } elseif ($uri == 'add' and $access_granted) { // Новое мероприятие $control = new EventsController(); $response = $control->add_action(); } elseif ($uri == 'event' and $access_granted and isset($_REQUEST["remove"])) { // Удаление мероприятия $control = new EventsController(); $response = $control->remove_action($_REQUEST['remove']); } elseif ($uri == 'event' and $access_granted and isset($_REQUEST["lock"])) { // Открытие/закрытие мероприятия $control = new EventsController(); $response = $control->lock_action($_REQUEST['lock'], $_REQUEST['flag']); } elseif ($uri == 'event' and $access_granted and isset($_REQUEST["edit"])) { // Изменить мероприятие
public function ajaxComIntAdd() { //ajaxAdd($userModel, $currentModel, $userData, $currentData) //debug($this->request->data); exit; $this->layout = null; $this->autoRender = false; // $this->Session->write("data", $this->request->data); App::uses('UsersController', 'Controller'); $user = new UsersController(); $user->ajaxAdd("CompradorInternacional", $this->request->data["User"], $this->request->data["CompradorInternacional"], "comint"); }
<?php session_start(); require_once __DIR__ . '/autoload.php'; $controller = new UsersController(); if (empty($_POST['login']) || empty($_POST['password'])) { $_SESSION['errors'] = 'Login or password is empty!'; header('Location: /views/reg.php'); exit; } $login = $_POST['login']; $password = $_POST['password']; $repassword = $_POST['re_password']; $name = $_POST['name']; $phone = $_POST['phone']; if ($controller->checkExistUser($login)) { $_SESSION['errors'] = 'This user is exist!'; header('Location: /views/reg.php'); exit; } if (!preg_match('|^[-A-Za-z0-9-_]*$|', $login) || !preg_match('|^[-A-Za-z0-9-_]*$|', $password)) { $_SESSION['errors'] = 'Incorrect symbols!'; header('Location: /views/reg.php'); exit; } if (strlen($password) < 8) { $_SESSION['errors'] = 'Password should be 8 and more symbols!'; header('Location: /views/reg.php'); exit; } if ($password !== $repassword) {
$class->inheritable_array_unshift("filters__{$chain}", $options); } elseif ($where == 'end') { $class->inheritable_array_push("filters__{$chain}", $options); } } public function before_filter($class, $method, $options = array()) { $this->add_filter($class, 'before', 'end', $method, $options); } public function after_filter($class, $method, $options = array()) { $this->add_filter($class, 'after', 'end', $method, $options); } } class RescueMacro { public function rescue_from($class, $exception_class, $rescue_method) { $class->merge_inheritable_array('rescue_macro__rescues', array($exception_class => $rescue_method)); } } class RecordNotFoundException extends Exception { } phpx\PHPX::init(); phpx\Macro::register('\\FilterMacro'); phpx\Macro::register('\\RescueMacro'); $action = isset($_GET['action']) ? $_GET['action'] : 'index'; $params = $_GET; $controller = new UsersController(); $controller->invoke_action($action, $params);
/** * Public interface to _setCookie */ public function setCookie($options = array()) { parent::_setCookie($options); }
function main() { $sender = ""; $company = ""; $subject = ""; $url_taolin = ""; $domain = ""; $limit = 0; $activate = 0; $sendmessage = 0; switch (count($this->args)) { case 0: break; case 1: $limit = $this->args[0]; break; case 2: $limit = $this->args[0]; $activate = $this->args[1]; break; case 5: $activate = 1; $sendmessage = 1; $sender = $this->args[0]; $domain = $this->args[1]; $company = $this->args[2]; $subject = $this->args[3]; $url_taolin = $this->args[4]; break; case 6: $limit = $this->args[0]; $activate = 1; $sendmessage = 1; $sender = $this->args[1]; $domain = $this->args[2]; $company = $this->args[3]; $subject = $this->args[4]; $url_taolin = $this->args[5]; break; default: die("Not enough parameters"); break; } /* if (count($this->args) < 4) { die("Not enough parameters"); } else { $sender = $this->args[0]; $domain = $this->args[1]; $company = $this->args[2]; $subject = $this->args[3]; $url_taolin = $this->args[4]; } */ App::import('Core', 'Controller'); App::import('Component', 'Acl'); App::import('Component', 'Email'); App::import('Controller', 'Users'); App::import('Controller', 'Mailer'); $UsersController = new UsersController(); $UsersController->constructClasses(); $this->Acl =& new AclComponent(); $controller = null; $this->Acl->startup($controller); $this->Aco =& $this->Acl->Aco; $conditions = array('active' => 0, 'deleted' => 0, array('NOT' => array('login ' => null))); if ($limit > 0) { $users = $this->User->find('all', array('limit' => $limit, 'conditions' => $conditions, 'fields' => array('User.active', 'User.created', 'User.id', 'User.name', 'User.surname', 'User.gender', 'User.login'), 'order' => array('created DESC'))); } else { $users = $this->User->find('all', array('conditions' => $conditions, 'fields' => array('User.active', 'User.created', 'User.id', 'User.name', 'User.surname', 'User.gender', 'User.login'), 'order' => array('created DESC'))); } foreach ($users as $user) { $id = $user['User']['id']; $name = $user['User']['name']; $gender = $user['User']['gender']; $login = $user['User']['login']; $email = $user['User']['login']; $email = $login . "@" . $domain; if ($activate == 1) { $UsersController->admin_activate($id, 1); } if ($sendmessage == 1) { $MailController = new MailerController(); $MailController->constructClasses(); $MailController->sendWelcome($name, $email, $sender, $subject, $company, $url_taolin, $gender); } echo "{$login}\n"; } }
<?php $user = new UsersController(); $user->logout(); ?> <h1> U bent succesvol uitgelogd.</h1>
} public function changeAccess($uid, $access) { return $this->model->changeAccess($uid, $access); } public function deleteUser($uid) { $result = $this->model->deleteUser($uid); if ($result['success'] === true) { header("location:" . Route::getUrl('?mode=admin&route=users')); } else { Bufer::add(array('errors' => $result['error'])); } } } $controller = new UsersController(); Bufer::set(array('usersList' => array('data' => $controller->model->getUsersList(), 'paginate' => $controller->paginate()), 'accessList' => $controller->getAccessList())); if (isset($_GET['updateAccess'])) { $temp = explode(',', $_GET['updateAccess']); $uid = (int) $temp[0]; $access = (int) $temp[1]; $result = $controller->changeAccess($uid, $access); if ($result === false) { Bufer::set(array('errors' => array('Произошла ошибка при смене прав пользователя'), 'usersList' => array('data' => $controller->model->getUsersList(), 'paginate' => $controller->paginate()), 'accessList' => $controller->getAccessList())); } else { header("location: " . Route::getUrl('?mode=admin&route=users')); } } $controller->view(ADMIN_TPLS_DIR . '/header.tpl'); $controller->view(ADMIN_TPLS_DIR . '/users.tpl'); $controller->view(ADMIN_TPLS_DIR . '/footer.tpl');
<?php printf('<h2>GESTIÓN DE USUARIOS</h2>'); $users = new UsersController(); $all_users = $users->get_users(); if (is_array($all_users)) { $template_all_users = ' <div class="item"> <table> <tr> <th>Usuario</th> <th>Correo</th> <th>Nombre</th> <th>Cumpleaños</th> <th>Contraseña</th> <th>Rol</th> <th colspan="2"> <form method="POST"> <input type="hidden" name="r" value="user-add"> <input class="button add" type="submit" value="Agregar"> </form> </th> </tr> '; foreach ($all_users as $row) { $template_all_users .= ' <tr> <td>' . $row['user'] . '</td> <td>' . $row['email'] . '</td> <td>' . $row['name'] . '</td> <td>' . $row['birthday'] . '</td>
/** * Public intefface to _getMailInstance */ public function getMailInstance() { return parent::_getMailInstance(); }
<?php /** * @version $Id: users.php 9764 2007-12-30 07:48:11Z ircmaxell $ * @package Joomla * @subpackage Users * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined('_JEXEC') or die('Restricted access'); /* * Make sure the user is authorized to view this page */ $user =& JFactory::getUser(); if (!$user->authorize('com_users', 'manage')) { $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); } // Require the base controller require_once _COMMUNITY_ACL_ADMIN_HOME . '/controller.php'; // Create the controller $controller = new UsersController(); // Perform the Request task $controller->execute(JRequest::getCmd('task')); $controller->redirect();