示例#1
0
 /**
  * Check employee permission for module (static method)
  * @param int $id_module
  * @param array $variable (action)
  * @param object $employee
  * @return bool if module can be transplanted on hook
  */
 public static function getPermissionStatic($id_module, $variable, $employee = null)
 {
     if (!in_array($variable, array('view', 'configure', 'uninstall'))) {
         return false;
     }
     if (!$employee) {
         $employee = Context::getContext()->employee;
     }
     if ($employee->id_profile == _PS_ADMIN_PROFILE_) {
         return true;
     }
     $slug = Access::findSlugByIdModule($id_module) . Access::getAuthorizationFromLegacy($variable);
     return Access::isGranted($slug, $employee->id_profile);
 }
示例#2
0
 /**
  *
  * @param string $action
  * @param bool $disable
  */
 public function access($action, $disable = false)
 {
     if (empty($this->tabAccess[$action])) {
         $slugs = array();
         foreach ((array) Access::getAuthorizationFromLegacy($action) as $roleSuffix) {
             $slugs[] = $this->getTabSlug() . $roleSuffix;
         }
         $this->tabAccess[$action] = Access::isGranted($slugs, $this->context->employee->id_profile);
     }
     return $this->tabAccess[$action];
 }