Exemplo n.º 1
0
 public function saveformAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxString $uri, \Difra\Param\AjaxString $notify, \Difra\Param\AjaxString $button, \Difra\Param\AjaxHTML $description = null, \Difra\Param\AjaxData $fieldType = null, \Difra\Param\AjaxData $fieldName = null, \Difra\Param\AjaxData $fieldDescription = null, \Difra\Param\AjaxData $fieldMandatory = null, \Difra\Param\AjaxData $selectVariants = null, \Difra\Param\AjaxInt $formId = null, \Difra\Param\AjaxString $originalUri = null)
 {
     if (is_null($fieldType) || is_null($fieldName)) {
         return $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('formProcessor/adm/create/noFieldsNotify'));
     }
     $FP = \Difra\Plugins\FormProcessor::getInstance();
     $uri = $uri->val();
     $originalUri = !is_null($originalUri) ? $originalUri->val() : null;
     if (is_null($formId) && $uri != $originalUri) {
         if ($FP->checkDupUri($uri)) {
             return $this->ajax->invalid('uri', \Difra\Locales::getInstance()->getXPath('formProcessor/adm/create/duplicateUri'));
         }
     }
     $errorField = $FP->checkEmptyNameFields($fieldType, $fieldName);
     if ($errorField !== true) {
         return $this->ajax->notify($errorField);
     }
     $mainFieldsArray = ['title' => $name->val(), 'uri' => $uri, 'answer' => $notify->val(), 'submit' => $button->val(), 'description' => $description];
     $fieldMandatory = !is_null($fieldMandatory) ? $fieldMandatory->val() : null;
     $selectVariants = !is_null($selectVariants) ? $selectVariants->val() : null;
     $formFieldsArray = ['names' => $fieldName->val(), 'mandatory' => $fieldMandatory, 'types' => $fieldType->val(), 'descriptions' => $fieldDescription->val(), 'variants' => $selectVariants];
     if (!is_null($formId)) {
         if (!$FP->updateForm($formId->val(), $mainFieldsArray, $formFieldsArray)) {
             return $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('formProcessor/adm/edit/idError'));
         }
         \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('formProcessor/adm/edit/formUpdated'));
     } else {
         $FP->createForm($mainFieldsArray, $formFieldsArray);
         \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('formProcessor/adm/create/formAdded'));
     }
     $this->ajax->redirect('/adm/formprocessor/manage');
 }
Exemplo n.º 2
0
 public static function remove()
 {
     if (!empty($_COOKIE['resume'])) {
         DB::getInstance(Users::getDB())->query("DELETE FROM `user_session` WHERE `session`=?", [$_COOKIE['resume']]);
         Cookies::getInstance()->remove('resume');
     }
 }
Exemplo n.º 3
0
 public function createaliaseAjaxAction(\Difra\Param\AjaxInt $tagId, \Difra\Param\AjaxString $module, \Difra\Param\AjaxString $aliase)
 {
     if (\Difra\Plugins\Tags::getInstance()->createAliase($module->val(), $tagId->val(), $aliase->val())) {
         \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('tags/adm/aliasCreated'));
         $this->ajax->reload();
     } else {
         $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('tags/adm/aliasCreateError'));
     }
 }
Exemplo n.º 4
0
 public function addimageAjaxAction(\Difra\Param\AjaxInt $id, \Difra\Param\AjaxFiles $images = null)
 {
     if ($images) {
         try {
             \Difra\Plugins\Catalog::getInstance()->addImages($id, $images);
         } catch (\Difra\Exception $ex) {
             $ex->notify();
             \Difra\Libs\Cookies::getInstance()->notify($this->locale->getXPath('catalog/adm/ext/bad-image'));
         }
         $this->ajax->refresh();
     } else {
         $this->ajax->notify($this->locale->getXPath('catalog/adm/images/no-file'));
     }
 }
Exemplo n.º 5
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());
 }
Exemplo n.º 6
0
 /**
  * Change password using recovery link
  * @param AnyString $code
  * @param AjaxString $password1
  * @param AjaxString $password2
  * @throws Exception
  */
 public function submitAjaxAction(AnyString $code, AjaxString $password1, AjaxString $password2)
 {
     try {
         Recover::verify($code->val());
     } catch (\Difra\Plugins\Users\UsersException $ex) {
         Ajaxer::notify(Locales::get('auth/recover/' . $ex->getMessage()));
         return;
     }
     // verify passwords
     $register = new \Difra\Plugins\Users\Register();
     $register->setPassword1($password1->val());
     $register->setPassword2($password2->val());
     if (!$register->validatePasswords()) {
         $register->callAjaxerEvents();
         return;
     }
     Recover::recoverSetPassword($code->val(), $password1->val());
     Cookies::getInstance()->notify(Locales::get('auth/recover/done'));
     Ajaxer::redirect('/');
 }
Exemplo n.º 7
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/');
 }
Exemplo n.º 8
0
 public function savepriorityAjaxAction(\Difra\Param\AnyInt $id, \Difra\Param\AnyInt $priority)
 {
     \Difra\Plugins\Announcements::setPriority($id->val(), $priority->val());
     \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/prioritySet'));
     $this->ajax->refresh();
 }
Exemplo n.º 9
0
 /**
  * Redefine this method if you want custom actions after activation
  */
 protected function afterActivate()
 {
     Cookies::getInstance()->notify(Locales::get('auth/activate/done'));
     \Difra\View::redirect('/');
 }