/**
  * Users index method
  *
  * @return void
  */
 public function index()
 {
     $this->prepareView('index.phtml', array('assets' => $this->project->getAssets(), 'acl' => $this->project->getService('acl'), 'phireNav' => $this->project->getService('phireNav')));
     $this->view->set('title', $this->view->i18n->__('Users'));
     $user = new Model\User(array('acl' => $this->project->getService('acl')));
     // If type id is set, get users by type
     if (null !== $this->request->getPath(1) && is_numeric($this->request->getPath(1))) {
         $user->getAll($this->request->getPath(1), $this->project->module('Phire'), $this->request->getQuery('sort'), $this->request->getQuery('page'));
         $this->view->set('typeId', $this->request->getPath(1))->set('table', $user->table)->set('searchBy', $user->searchBy)->set('searchFor', $user->searchFor)->set('title', $this->view->title . ' ' . $this->view->separator . ' ' . $user->title);
         // Else, list user types to choose from
     } else {
         $this->view->set('typeId', null)->set('types', $user->getUserTypes());
     }
     $this->send();
 }
Exemplo n.º 2
0
 /**
  * Index action method
  *
  * @param  int $id
  * @return void
  */
 public function index($id = null)
 {
     if (null === $id || $this->services['acl']->isAllowed($this->sess->user->role, 'users-of-role-' . $id, 'index')) {
         $deniedRoles = [];
         $resources = $this->services['acl']->getResources();
         foreach ($resources as $name => $resource) {
             if (!$this->services['acl']->isAllowed($this->sess->user->role, $name, 'index')) {
                 $deniedRoles[] = (int) substr($name, strrpos($name, '-') + 1);
             }
         }
         $user = new Model\User();
         $searchAry = null;
         if (null !== $this->request->getQuery('search_for') && null !== $this->request->getQuery('search_by') && $this->request->getQuery('search_for') != '' && $this->request->getQuery('search_by') != '----') {
             $searchAry = ['for' => $this->request->getQuery('search_for'), 'by' => $this->request->getQuery('search_by')];
         }
         if ($user->hasPages($this->config->pagination, $id, $searchAry, $deniedRoles)) {
             $limit = $this->config->pagination;
             $pages = new Paginator($user->getCount($id, $searchAry, $deniedRoles), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->prepareView('phire/users/index.phtml');
         $this->view->title = 'Users';
         $this->view->pages = $pages;
         $this->view->roleId = $id;
         $this->view->queryString = $this->getQueryString('sort');
         $this->view->searchFor = $this->request->getQuery('search_for');
         $this->view->searchBy = $this->request->getQuery('search_by');
         $this->view->users = $user->getAll($id, $searchAry, $deniedRoles, $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
         $this->view->roles = $user->getRoles();
         $this->send();
     } else {
         $this->redirect(BASE_PATH . APP_URI . '/users');
     }
 }
Exemplo n.º 3
0
 /**
  * Remove action method
  *
  * @return void
  */
 public function remove()
 {
     $roleId = $this->getRoleId();
     $user = new Model\User();
     $users = $user->getAll($roleId);
     $userIds = [];
     $this->console->append();
     $this->console->append("ID  \tUsername\tEmail");
     $this->console->append("----\t--------\t-----");
     foreach ($users as $user) {
         $userIds[] = $user->id;
         $this->console->append($user->id . "\t" . $user->username . "\t\t" . $user->email);
     }
     $this->console->append();
     $this->console->send();
     $userId = null;
     while (!is_numeric($userId) || !in_array($userId, $userIds)) {
         $userId = $this->console->prompt($this->console->getIndent() . 'Select User ID: ');
     }
     $user = new Model\User();
     $user->process(['process_users' => [$userId], 'user_process_action' => -1]);
     $this->console->write();
     $this->console->write($this->console->colorize('User Removed!', Console::BOLD_RED));
 }