Пример #1
0
 /**
  * Checks whether a user has privileges to access a given module
  * @param string $username The username
  * @param string $module The module name
  * @return boolean
  */
 private static function checkUserPrivileges($username, $module)
 {
     global $dbo;
     $pro = new \Ventus\Profile\MyProfile($dbo);
     // Function to filter modules based on path returned from database
     $filterByModule = function ($mod) use($module) {
         return $mod['path'] === $module;
     };
     // Function to filter modules based on global availability and path returned from database
     $filterByGlobal = function ($mod) use($module) {
         return $mod['globally_available'] === '1' && $mod['path'] === $module;
     };
     /**
      * The user has priviliges if
      * (1) the module is "profile"
      * (2) the user modules contains the module, or
      * (3) the module is globally available
      */
     return $module === 'profile' || sizeof(array_filter($pro->getEmpModules($username), $filterByModule)) || sizeof(array_filter($pro->getAllModules(), $filterByGlobal));
 }