예제 #1
0
 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;
 }
예제 #2
0
 /**
  *
  * @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();
 }
예제 #3
0
 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']));
     }
 }
예제 #4
0
 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();
 }
예제 #5
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]));
 }
예제 #6
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();
     }
 }
예제 #7
0
 /**
  *
  * @param Command $command
  */
 private function saveData(Command $command)
 {
     $command->setEmail($this->http->request->get('userEmail'))->update(['email' => ['unique' => [$command->entity()->getEmail()]]]);
 }
예제 #8
0
 public function insert(array $array = []) : Command
 {
     parent::insert($array);
     RegistryFactory::start('file')->remove('Conf\\Conf');
     return $this;
 }
예제 #9
0
 private function removeMenuWithMenuItems()
 {
     $controller = new Command(new Menus());
     $controller->find($this->id)->remove();
 }
예제 #10
0
파일: Validator.php 프로젝트: ignaszak/cms
 public function __construct(Command $command)
 {
     $this->command = $command;
     $this->registry = RegistryFactory::start();
     $this->entityName = get_class($this->command->entity());
 }