Exemple #1
0
 /**
  * Check user access to a certain section
  * @author Howard <*****@*****.**>
  * @static
  * @param string $access
  * @param int $user_id
  * @return int
  */
 public static function check_access($access, $user_id = '')
 {
     if ($access == '') {
         return 1000;
     }
     /** get current user id **/
     if (!trim($user_id)) {
         $user_id = wpl_users::get_cur_user_id();
     }
     /** return admin access **/
     if (wpl_users::is_administrator($user_id)) {
         return 1000;
     }
     if (!trim($user_id) or !wpl_users::is_wpl_user($user_id)) {
         $query = "SELECT `access_" . $access . "` FROM `#__wpl_users` WHERE `id`='-2'";
     } else {
         $query = "SELECT `access_" . $access . "` FROM `#__wpl_users` WHERE `id`='{$user_id}'";
     }
     $result = wpl_db::select($query, 'loadResult');
     if ($result == '') {
         return 0;
     }
     return $result;
 }