Exemple #1
0
 public function testIsAdmin()
 {
     $this->http = new Http($this->mockResponse('admin-anyName'), $this->mockRequest());
     $this->assertTrue($this->http->isAdmin());
     $this->http = new Http($this->mockResponse('anyName'), $this->mockRequest());
     $this->assertFalse($this->http->isAdmin());
 }
Exemple #2
0
 public function loadView()
 {
     if (!empty($this->viewFileName)) {
         if ($this->http->isAdmin()) {
             $this->loadAdminExtensionThemeFile($this->viewFileName);
         } else {
             $this->loadFile($this->viewFileName);
         }
     }
 }
Exemple #3
0
 public function configureThemePath()
 {
     if ($this->http->isAdmin()) {
         $this->themeFolder = "view/admin";
         $this->themePath = __VIEWDIR__ . "/admin";
     } else {
         $themeName = $this->conf->getTheme();
         $this->themeFolder = "view/public/{$themeName}";
         $this->themePath = __VIEWDIR__ . "/public/{$themeName}";
     }
 }
Exemple #4
0
 /**
  * Method checks if admin panel route is open and then valid permission to
  * stay there. If user is admin (or moderator) method loads necessary extensions
  */
 public function loadAdmin()
 {
     if ($this->http->isAdmin()) {
         // If not logged open login panel
         if (!$this->user->isUserLoggedIn()) {
             $this->view->loadFile('../../admin/extensions/Index/login.html');
             exit;
         }
         // Check permissions
         if ($this->user->getUserSession()->getRole() != 'admin') {
             Server::headerLocation();
             // Go to main page
         }
         // Admin view helper classes
         $this->viewHelper->add($this->conf['adminViewHelper'] ?? []);
         $this->registry->set('App\\Admin\\Admin', new Admin($this->adminExtension, $this->yaml));
     }
 }
Exemple #5
0
 /**
  * In admin panel it is possible to select 'all', 'public' or 'edit' post
  * by calling QueryController::status(string $value) method
  * In other cases handler select only 'public' posts
  */
 private function statusHandler()
 {
     // For entities which have getPublic method
     if (method_exists($this->entityName, 'getPublic')) {
         $value = 1;
         if ($this->http->isAdmin()) {
             // Check if admin panel is avilable
             if ($this->status === 'public') {
                 $value = 1;
             } elseif ($this->status === 'edit') {
                 $value = 0;
             } else {
                 $value = null;
             }
         }
         // Create query based on $value
         if (is_int($value)) {
             $query = $this->query->andwhere('c.public = ' . $value);
             $this->query = $query;
         }
     }
 }