/**
  * @param FormValidationEvent $event
  */
 public function validateManageMenuItem(FormValidationEvent $event)
 {
     $formData = $event->getFormData();
     if ($this->acl->hasPermission('admin/menus/items/create') === true && isset($formData['create']) === true) {
         $event->getValidator()->addConstraint(NotEmptyValidationRule::class, ['data' => $formData, 'field' => 'menu_item_title', 'message' => $this->translator->t('menus', 'title_to_short')])->addConstraint(IntegerValidationRule::class, ['data' => $formData, 'field' => 'block_id', 'message' => $this->translator->t('menus', 'select_menu_bar')])->addConstraint(ParentIdValidationRule::class, ['data' => $formData, 'field' => 'parent_id', 'message' => $this->translator->t('menus', 'select_superior_page')])->addConstraint(InArrayValidationRule::class, ['data' => $formData, 'field' => 'display', 'message' => $this->translator->t('menus', 'select_item_visibility'), 'extra' => ['haystack' => [0, 1]]])->addConstraint(AllowedMenuValidationRule::class, ['data' => $formData, 'field' => ['parent_id', 'block_id'], 'message' => $this->translator->t('menus', 'superior_page_not_allowed')]);
     }
 }
 /**
  * @param \ACP3\Core\View\Event\TemplateEvent $templateEvent
  */
 public function onDisplayCaptcha(TemplateEvent $templateEvent)
 {
     if ($this->acl->hasPermission('frontend/captcha/index/image') === true) {
         $arguments = $templateEvent->getParameters();
         echo $this->captchaHelper->captcha(isset($arguments['length']) ? $arguments['length'] : Helpers::CAPTCHA_DEFAULT_LENGTH, isset($arguments['input_id']) ? $arguments['input_id'] : Helpers::CAPTCHA_DEFAULT_INPUT_ID, isset($arguments['input_only']) ? $arguments['input_only'] : false, isset($arguments['path']) ? $arguments['path'] : '');
     }
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function process(array $params, \Smarty_Internal_Template $smarty)
 {
     if (isset($params['path']) === true) {
         return $this->acl->hasPermission($params['path']);
     }
     return false;
 }
 public function renderInvalidPageCacheAlert()
 {
     $systemSettings = $this->settings->getSettings(Schema::MODULE_NAME);
     if ($this->acl->hasPermission('admin/system/maintenance/cache') && $systemSettings['page_cache_is_valid'] == 0) {
         $this->view->displayTemplate('System/Partials/alert_invalid_page_cache.tpl');
     }
 }
Example #5
0
 /**
  * @param array $params
  *
  * @return string
  */
 public function outputLinkOrButton(array $params)
 {
     if (isset($params['mode']) && isset($params['path'])) {
         $action = [];
         $query = explode('/', strtolower($params['path']));
         if (isset($query[0]) && $query[0] === 'acp') {
             $action[0] = isset($query[1]) ? $query[1] : 'acp';
             $action[1] = isset($query[2]) ? $query[2] : 'index';
             $action[2] = isset($query[3]) ? $query[3] : 'index';
             $area = Core\Controller\AreaEnum::AREA_ADMIN;
         } else {
             $action[0] = $query[0];
             $action[1] = isset($query[1]) ? $query[1] : 'index';
             $action[2] = isset($query[2]) ? $query[2] : 'index';
             $area = Core\Controller\AreaEnum::AREA_FRONTEND;
         }
         $permissionPath = $area . '/' . $action[0] . '/' . $action[1] . '/' . $action[2];
         if ($this->acl->hasPermission($permissionPath) === true) {
             return $this->collectData($params, $action, $area);
         } elseif ($params['mode'] === 'link' && isset($params['title'])) {
             // If the user has no permission and the type is "link",
             // just return the given title without the surrounding hyperlink
             return $params['title'];
         }
     }
     return '';
 }
 /**
  * @param TemplateEvent $event
  */
 public function renderManageMenuItem(TemplateEvent $event)
 {
     $parameters = $event->getParameters();
     if ($this->acl->hasPermission('admin/menus/items/create') === true) {
         $menuItem = $this->fetchMenuItems(!empty($parameters['path']) ? $parameters['path'] : '');
         $this->view->assign('options', $this->fetchCreateMenuItemOption(!empty($menuItem) ? 1 : 0))->assign('form', $this->modifyFormValues($menuItem))->assign($this->addFormFields($menuItem));
         $this->view->displayTemplate('Menus/Partials/manage_menu_item.tpl');
     }
 }
 /**
  * @param \ACP3\Core\Helpers\DataGrid\ColumnRenderer\Event\CustomOptionEvent $customOptionEvent
  */
 public function onDataGridCustomOptionBefore(CustomOptionEvent $customOptionEvent)
 {
     if ($customOptionEvent->getIdentifier() === '#newsletter-data-grid' && $this->acl->hasPermission('admin/newsletter/index/send') === true) {
         $dbResultRow = $customOptionEvent->getDbResultRow();
         if (array_key_exists('status', $dbResultRow) && $dbResultRow['status'] != 1) {
             $customOptionEvent->getOptionRenderer()->addOption('acp/newsletter/index/send/id_' . $dbResultRow['id'], $this->translator->t('newsletter', 'send'), 'glyphicon-envelope', 'btn-primary', true);
         }
     }
 }
 /**
  * @inheritdoc
  */
 public function isValid($data, $field = '', array $extra = [])
 {
     if (is_array($data) && array_key_exists($field, $data)) {
         return $this->isValid($data[$field], $field, $extra);
     }
     if ($this->acl->hasPermission('frontend/captcha/index/image') === true && $this->user->isAuthenticated() === false) {
         return $this->checkCaptcha($data, isset($extra['path']) ? $extra['path'] : '');
     }
     return true;
 }
Example #9
0
File: Helpers.php Project: acp3/cms
 /**
  * Gibt die für die Suche verfügbaren Module zurück
  *
  * @return array
  */
 public function getModules()
 {
     $searchModules = [];
     foreach ($this->availableModulesRegistrar->getAvailableModuleNames() as $module) {
         if ($this->acl->hasPermission('frontend/' . $module) === true) {
             $info = $this->modules->getModuleInfo($module);
             $name = $info['name'];
             $searchModules[$name] = ['dir' => $module, 'checked' => $this->formsHelper->selectEntry('mods', $module, $module, 'checked'), 'name' => $name];
         }
     }
     ksort($searchModules);
     return $searchModules;
 }
 /**
  * @param array $roles
  *
  * @return boolean
  */
 protected function aclRolesExist(array $roles)
 {
     $allRoles = $this->acl->getAllRoles();
     $good = [];
     foreach ($allRoles as $row) {
         $good[] = $row['id'];
     }
     foreach ($roles as $row) {
         if (in_array($row, $good) === false) {
             return false;
         }
     }
     return true;
 }
Example #11
0
 /**
  * @inheritdoc
  */
 public function process(array $params, \Smarty_Internal_Template $smarty)
 {
     $pathArray = $this->convertPathToArray($params['module']);
     $path = $pathArray[0] . '/' . $pathArray[1] . '/' . $pathArray[2] . '/' . $pathArray[3];
     $arguments = [];
     if (isset($params['args']) && is_array($params['args'])) {
         $arguments = array_map(function ($item) {
             return urlencode($item);
         }, $params['args']);
     }
     $response = '';
     if ($this->acl->hasPermission($path) === true) {
         $response = $this->esiInclude($path, $arguments);
     }
     return $response;
 }
Example #12
0
 /**
  * @return array
  */
 public function render()
 {
     $canDelete = $this->acl->hasPermission($this->resourcePathDelete);
     $canEdit = $this->acl->hasPermission($this->resourcePathEdit);
     $this->addDefaultColumns($canDelete, $canEdit);
     $this->findPrimaryKey();
     return ['can_edit' => $canEdit, 'can_delete' => $canDelete, 'identifier' => substr($this->identifier, 1), 'header' => $this->renderTableHeader(), 'config' => $this->generateDataTableConfig(), 'results' => $this->mapTableColumnsToDbFields()];
 }
Example #13
0
 /**
  * @return $this
  * @throws Core\ACL\Exception\AccessForbiddenException
  */
 public function preDispatch()
 {
     $path = $this->request->getArea() . '/' . $this->request->getFullPathWithoutArea();
     if ($this->acl->hasPermission($path) === false) {
         throw new Core\ACL\Exception\AccessForbiddenException();
     }
     $this->view->assign(['PHP_SELF' => $this->appPath->getPhpSelf(), 'ROOT_DIR' => $this->appPath->getWebRoot(), 'HOST_NAME' => $this->request->getHttpHost(), 'ROOT_DIR_ABSOLUTE' => $this->request->getScheme() . '://' . $this->request->getHttpHost() . $this->appPath->getWebRoot(), 'DESIGN_PATH' => $this->appPath->getDesignPathWeb(), 'DESIGN_PATH_ABSOLUTE' => $this->appPath->getDesignPathAbsolute(), 'LANG_DIRECTION' => $this->translator->getDirection(), 'LANG' => $this->translator->getShortIsoCode()]);
     return $this;
 }
Example #14
0
 /**
  * Listet alle Kategorien eines Moduls auf
  *
  * @param string $module
  * @param string $categoryId
  * @param boolean $categoryCreate
  * @param string $formFieldName
  * @param string $customText
  *
  * @return array
  */
 public function categoriesList($module, $categoryId = '', $categoryCreate = false, $formFieldName = 'cat', $customText = '')
 {
     $categories = [];
     $categories['custom_text'] = !empty($customText) ? $customText : $this->translator->t('system', 'pls_select');
     $categories['name'] = $formFieldName;
     $categories['categories'] = $this->categoriesCache->getCache($module);
     $cData = count($categories['categories']);
     for ($i = 0; $i < $cData; ++$i) {
         $categories['categories'][$i]['selected'] = $this->formsHelper->selectEntry($formFieldName, $categories['categories'][$i]['id'], $categoryId);
     }
     if ($categoryCreate === true && $this->acl->hasPermission('admin/categories/index/create') === true) {
         $categories['create']['name'] = $formFieldName . '_create';
         $categories['create']['value'] = $this->request->getPost()->get('create', ['name' => ''])['name'];
     }
     return $categories;
 }
 /**
  * @inheritdoc
  */
 protected function getDbValueIfExists(array $dbResultRow, $field)
 {
     return isset($dbResultRow[$field]) ? implode(', ', $this->acl->getUserRoleNames($dbResultRow[$field])) : null;
 }