Пример #1
0
 public function startup()
 {
     //check permission
     if (!$this->user->isLoggedIn()) {
         $backlink = $this->application->storeRequest();
         $this->redirect(':Front:Login:'******'backlink' => $backlink));
     }
     //allow this request?
     $allowed = $this->triggerStaticEvent('allow_admin_request', $this);
     if (!$allowed) {
         if ($this->isAjax()) {
             $this->sendResponse(new JsonResponse(array("snippets" => array("snippet--flashes" => "<div class=\"flash alert\">Nedostatečné oprávnění.</div>"))));
             //<script>window.setTimeout(function(){ $('#flashes div div').fadeOut(8000); }, 5000);</script>
             $this->terminate();
         }
         throw new ForbiddenRequestException("Nedostatečné oprávnění.");
     }
     //initialize admin
     parent::startup();
     //admin things
     PagesModel::$showUnpublished = true;
     $this->template->wysiwygConfig = $this->context->params['npress']['wysiwyg'];
     //adminMenu
     $classes = $this->context->plugins->getEventTriggers('adminMenu');
     $this->template->adminMenu = array();
     foreach ($classes as $class) {
         $link = $this->link($class::$adminMenuLink);
         $this->template->adminMenu[$link] = $class::$adminMenu;
     }
 }