Esempio n. 1
0
 /**
  * Get user details for authorisation testing
  *
  * @param int $id Joomla user id
  * @return array TableUser
  */
 public static function getAuthorisedUser($id = null)
 {
     static $userarray;
     if (!isset($userarray)) {
         $userarray = array();
     }
     if (is_null($id)) {
         $juser = JFactory::getUser();
         $id = $juser->id;
     }
     if (!array_key_exists($id, $userarray)) {
         JLoader::import("jevuser", JPATH_ADMINISTRATOR . "/components/" . JEV_COM_COMPONENT . "/tables/");
         $user = new TableUser();
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
         $authorisedonly = $params->get("authorisedonly", 0);
         // if authorised only then load from database
         if ($authorisedonly) {
             $users = $user->getUsersByUserid($id);
             if (count($users) > 0) {
                 $userarray[$id] = current($users);
                 // user must also be enabled!
                 if (!$userarray[$id]->published) {
                     $userarray[$id] = null;
                 }
             } else {
                 $userarray[$id] = null;
             }
         } else {
             $userarray[$id] = null;
         }
     }
     return $userarray[$id];
 }
Esempio n. 2
0
 function removeUser()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     if (!JEVHelper::isAdminUser()) {
         $msg = "Not Authorised";
         $link = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=user.list', false);
         $this->setRedirect($link, $msg);
         return;
     }
     $model = $this->getModel('user');
     $users = TableUser::getUsers($this->cid);
     $countdeleted = 0;
     foreach ($users as $user) {
         $countdeleted += $user->delete() ? 1 : 0;
     }
     if ($countdeleted = count($users)) {
         $msg = JText::_('USERS_DELETED');
     } else {
         $msg = JText::_('NOT_ALL_USERS_DELETED');
     }
     $link = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=user.list', false);
     $this->setRedirect($link, $msg);
 }
Esempio n. 3
0
 /**
  * Method to load the users in the system
  * 
  * @return void
  */
 function _loadUsers()
 {
     $this->_users = TableUser::getUsers();
 }
Esempio n. 4
0
 function authorisedUser($lang = 0)
 {
     $user = JFactory::getUser();
     $users = TableUser::getUsersByUserid($user->id, "langid");
     if (count($users) > 0 && $lang <= 0) {
         return true;
     }
     if (array_key_exists($lang, $users)) {
         return $users[$lang];
     }
     if (count($users) > 0) {
         foreach ($users as $user) {
             if ($user->langid == $lang && $user->published) {
                 return true;
             }
         }
     }
     return false;
 }