public function run()
 {
     if ($this->request['id'] === 1) {
         return;
     }
     // Initialize
     $controller = new Command(new Categories());
     // Find entity by id to update
     $refresh = 'refresh';
     if (is_numeric($this->request['id'])) {
         $refresh = '';
         $controller->find($this->request['id']);
     }
     if ($this->request['action'] === 'edit') {
         $alias = $controller->getAlias($this->request['title']);
         $parentId = is_numeric($this->request['parentId']) ? $this->request['parentId'] : 0;
         $controller->setParentId($parentId)->setTitle($this->request['title'])->setAlias($alias)->insert(['title' => [], 'alias' => []]);
         echo $refresh;
     } elseif ($this->request['action'] === 'delete') {
         $controller = new Command(new Categories());
         $idArray = array_filter($this->getChildCategories($this->request['id']));
         $controller->findBy(['id' => $idArray])->remove();
     }
     exit;
 }
Example #2
0
 public function run()
 {
     $this->request = $this->http->request->all();
     // Initialize
     $controller = new Command(new Posts());
     $date = new \DateTime();
     // Find entity by id to update
     if ($this->request['id']) {
         $controller->find($this->request['id']);
         $date = $controller->entity()->getDate('DateTime');
     }
     $alias = $controller->getAlias($this->request['title']);
     $public = (int) $this->request['public'] ?? 0;
     $controller->setReference('category', $this->getCategoryId())->setReference('author', $this->view->getUserId())->setDate($date)->setTitle($this->request['title'])->setAlias($alias)->setContent($this->request['content'])->setPublic($public)->insert(['date' => [], 'title' => [], 'alias' => [], 'content' => []]);
     Server::headerLocation($this->url('admin-post-edit', ['action' => 'edit', 'alias' => $alias]));
 }
Example #3
0
 public function run()
 {
     $user = $this->registry->get('user');
     $this->checkIfUserIsLogged($user);
     $userId = $user->getUserSession()->getId();
     $controller = new Command(new Users());
     $controller->find($userId);
     if (!empty($this->http->request->get('userPassword'))) {
         Server::setReferData(['form' => 'accountPassword']);
         $this->savePassword($controller);
     } else {
         Server::setReferData(['form' => 'accountData']);
         $this->saveData($controller);
     }
     $this->reloadUserSession($controller->entity());
     Server::setReferData(['accountSuccess' => 1]);
     Server::headerLocationReferer();
 }
Example #4
0
 public function run()
 {
     if ($this->registry->get('user')->isUserLoggedIn()) {
         Server::headerLocationReferer();
     }
     $this->login = $this->http->request->get('userLogin');
     $this->column = $this->isEmail($this->login) ? 'email' : 'login';
     $this->password = $this->http->request->get('userPassword');
     $this->remember = $this->http->request->get('userRemember', null);
     $userId = $this->getUserId();
     if ($userId === 0) {
         Server::setReferData(['form' => 'login', 'error' => ['valid' . ucfirst($this->column) . '_or_password' => 1]]);
         Server::headerLocationReferer();
     } else {
         $controller = new Command(new Users());
         $controller->find($userId)->setLogDate(new \DateTime('now'))->update();
         $this->setSession();
         Server::headerLocationReferer();
     }
 }
Example #5
0
 private function removeMenuWithMenuItems()
 {
     $controller = new Command(new Menus());
     $controller->find($this->id)->remove();
 }