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; }
/** * * @param Command $command */ private function sendMail(Command $command) { $login = $command->entity()->getLogin(); $transport = new MailTransport('mail'); $mail = new Mail($transport->conf()); $mail->setSubject('Remind password')->setFrom($mail->getAdminEmail())->setTo($this->http->request->get('userEmail'))->setBody("Dear {$login}\n" . "Your new password is: {$this->randomPassword}\n" . "You can change it later in your user account."); $mail->send(); }
public function run() { $this->action = $this->http->router->get('action'); $this->alias = $this->http->router->get('alias'); $this->view->addView('theme/post-edit.html'); if ($this->action === 'delete' && $this->alias) { $controller = new Command(new Posts()); $controller->findOneBy(['alias' => $this->alias])->remove(); Server::headerLocation($this->url('admin-post-list', ['action' => 'view'])); } }
public function run() { Server::setReferData(['form' => 'registration']); if ($this->registry->get('user')->isUserLoggedIn()) { Server::setReferData(['error' => ['userMustBeLogout' => 1]]); Server::headerLocationReferer(); } $this->login = $this->http->request->get('userLogin'); $this->email = $this->http->request->get('userEmail'); $this->password = $this->http->request->get('userPassword'); $controller = new Command(new Users()); $controller->setLogin($this->login)->setEmail($this->email)->setPassword($this->password)->setRegDate(new \DateTime('now'))->setLogDate(new \DateTime('now'))->setRole('user')->insert(['login' => ['unique'], 'email' => ['unique'], 'password' => []]); $this->sendMail(); Server::setReferData(['registrationSuccess' => 1]); Server::headerLocationReferer(); }
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])); }
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(); } }
/** * * @param Command $command */ private function saveData(Command $command) { $command->setEmail($this->http->request->get('userEmail'))->update(['email' => ['unique' => [$command->entity()->getEmail()]]]); }
public function insert(array $array = []) : Command { parent::insert($array); RegistryFactory::start('file')->remove('Conf\\Conf'); return $this; }
private function removeMenuWithMenuItems() { $controller = new Command(new Menus()); $controller->find($this->id)->remove(); }
public function __construct(Command $command) { $this->command = $command; $this->registry = RegistryFactory::start(); $this->entityName = get_class($this->command->entity()); }