Example #1
0
 public function updateAjaxAction(\Difra\Param\AjaxString $title, \Difra\Param\AjaxString $eventDate, \Difra\Param\AjaxString $beginDate, \Difra\Param\AjaxInt $priorityValue, \Difra\Param\AjaxCheckbox $visible, \Difra\Param\AjaxSafeHTML $shortDescription, \Difra\Param\AjaxInt $id, \Difra\Param\AjaxSafeHTML $description = null, \Difra\Param\AjaxInt $group = null, \Difra\Param\AjaxString $endDate = null, \Difra\Param\AjaxFile $eventImage = null)
 {
     $data = ['title' => $title->val(), 'eventDate' => $eventDate->val(), 'beginDate' => $beginDate->val(), 'id' => $id->val(), 'priority' => $priorityValue->val(), 'visible' => $visible->val(), 'shortDescription' => $shortDescription->val()];
     $data['description'] = is_null($description) ? null : $description->val();
     $data['group'] = is_null($group) ? null : $group->val();
     $data['endDate'] = is_null($endDate) ? null : $endDate->val();
     // из админки пока ставим так, потом добавим выбор юзера.
     $data['user'] = 1;
     $Announcements = \Difra\Plugins\Announcements::getInstance();
     // апдейтим анонс
     $eventId = $Announcements->create($data);
     if (is_null($eventId)) {
         $this->ajax->error(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/updateError'));
         return;
     }
     if (!is_null($eventImage)) {
         $Announcements->saveImage($eventId, $eventImage->val());
     }
     \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/goodUpdate'));
     $this->ajax->redirect('/adm/announcements/');
 }
Example #2
0
 public function updateAjaxActionAuth(Param\AjaxInt $id, Param\AjaxString $title, Param\AjaxSafeHTML $text, Param\AjaxString $tags = null)
 {
     if (!($post = Blogs\Post::getById($id))) {
         \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('blogs/notifies/post_not_found'), true);
         $this->view->redirect('/');
     }
     $Auth = \Difra\Auth::getInstance();
     if ($post->getUser() != $Auth->getEmail() && !$Auth->isModerator()) {
         $group = $post->getBlog()->getGroup();
         if (!$group or $group->getOwner() != \Difra\Auth::getInstance()->getEmail()) {
             \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('blogs/notifies/edit_post_denied'), true);
             $this->view->redirect('/');
         }
     }
     $post->setTitle($title->val());
     $post->setText($text->val());
     $post->setVisible(1);
     $post->save();
     $post = $post->getBlog()->getPost($post->getId());
     if (class_exists('Difra\\Plugins\\Tags')) {
         $tagsArray = Difra\Plugins\Tags::getInstance()->tagsFromString($tags);
         Difra\Plugins\Tags::getInstance()->update('posts', $id->val(), $tagsArray);
     }
     // убираем метку о редактировании поста
     unset($_SESSION['editPost']);
     $this->ajax->redirect($post->getUrl());
 }
Example #3
0
 /**
  * Set page body
  * @param \Difra\Param\AjaxHTML|\Difra\Param\AjaxSafeHTML|string $body
  * @throws \Difra\Exception
  */
 public function setBody($body)
 {
     $this->load();
     if ($body instanceof Param\AjaxHTML or $body instanceof Param\AjaxSafeHTML) {
         if (!$this->id) {
             $this->save();
         }
         if ($body->val(true) == $this->body) {
             return;
         }
         $body->saveImages(DIR_DATA . 'cms/img/' . $this->id, '/i/' . $this->id);
         $this->body = $body->val();
     } else {
         if ($body == $this->body) {
             return;
         }
         $this->body = $body;
     }
     $this->modified = true;
 }