Advertisement
Guest User

UserSpice 4.3 Dev - us_helpers.php snippet

a guest
Sep 25th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1.                 function checkMenu($permission, $id = 0) {
  2.                     $db = DB::getInstance();
  3.                     global $user;
  4.                     if ($id == 0 && $user->isLoggedIn()) $id = $user->data()->id;
  5.                     //Grant access if master user
  6.                     $access = 0;
  7.  
  8.                     if ($access == 0){
  9.                         $query = $db->query("SELECT id FROM user_permission_matches  WHERE user_id = ? AND permission_id = ?",array($id,$permission));
  10.                         $results = $query->count();
  11.                         if ($results > 0){
  12.                             $access = 1;
  13.                         }
  14.                     }
  15.                     if ($access == 1){
  16.                         return true;
  17.                     }
  18.                     if ($user->isLoggedIn() && $user->data()->id == 1){
  19.                         return true;
  20.                     }else{
  21.                         return false;
  22.                     }
  23.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement