Exemplo 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];
 }
Exemplo n.º 2
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;
 }