Beispiel #1
0
 public function restore()
 {
     if (system::issetUrl(2) && is_numeric(system::url(2))) {
         // Одиночное востановление
         $obj = new ormObject(system::url(2));
         if ($obj->isInheritor('section')) {
             $obj = new ormPage(system::url(2));
         }
         $obj->restore();
         echo 'delete';
     } else {
         if (isset($_POST['objects'])) {
             // Множественное востановление
             while (list($id, $val) = each($_POST['objects'])) {
                 if (is_numeric($id)) {
                     $obj = new ormObject($id);
                     if ($obj->isInheritor('section')) {
                         $obj = new ormPage($id);
                     }
                     $obj->restore();
                 }
             }
             echo 'delete';
         }
     }
     ormPages::clearCache();
     system::stop();
 }
Beispiel #2
0
 /**
  * @return HTML
  * @param int $form_id - ID формы обратной связи. Форма предварительно должна быть создана в настройках модуля "Обратная связь".
  * @param string $templ_name - Шаблон оформления
  * @desc МАКРОС: Автоватически генерирует форму обратной связи (добавления отзыва, вопрос-ответа и пр.)
  */
 public function autoForm($form_id, $templ_name = 'default')
 {
     if ($form_obj = ormObjects::get($form_id, 'feedback_form')) {
         $obj = new ormPage();
         $obj->setClass($form_obj->form_class);
         $form = new ormEditForm($obj, languages::pre() . '/feedback/send_message');
         $form->tabuList('pseudo_url', 'h1', 'keywords', 'title', 'description', 'active', 'is_home_page', 'view_in_menu', 'view_submenu', 'in_search', 'answer', 'in_index', 'in_new_window', 'other_link', 'img_act', 'img_no_act', 'img_h1');
         page::assign('form_id', $form_obj->id);
         if ($form_obj->captcha) {
             $form->showCaptcha();
         }
         // Парсим текст сообщения
         page::parseError('feedback');
         return $form->getHTML('feedback/' . $templ_name);
     }
 }
Beispiel #3
0
 public function send_messageAction()
 {
     if ($form_obj = ormObjects::get(system::POST('form_id'))) {
         $issetErrors = false;
         $answer = array();
         // Проверка капчи
         if ($form_obj->captcha && !system::validCapcha('random_image')) {
             $issetErrors = true;
             $answer = array('field' => 'random_image', 'msg' => lang::get('FEEDBACK_ERROR1'));
         }
         // Если указанно куда, добавляем объект в БД
         if (($form_obj->any_sections || $form_obj->section) && !$issetErrors) {
             // Определяем раздел, в который будем добавлять отзыв
             if ($form_obj->any_sections) {
                 $section = system::POST('section_id', isInt);
             } else {
                 $section = $form_obj->section;
                 $section = !empty($section) ? $section[0] : 0;
             }
             // Создаем объект обратной связи
             $obj = new ormPage();
             $obj->setParent($section);
             $obj->setClass($form_obj->form_class);
             $obj->tabuList('pseudo_url', 'h1', 'keywords', 'title', 'description', 'answer', 'active', 'is_home_page', 'view_in_menu', 'view_submenu', 'in_search', 'in_index', 'in_new_window', 'other_link', 'img_act', 'img_no_act', 'img_h1');
             $obj->loadFromPost();
             $obj->active = 0;
             $obj->view_in_menu = 1;
             $obj->view_submenu = 1;
             $obj->in_search = 1;
             $obj->in_index = 1;
             $obj->is_home_page = 0;
             if ($obj->name != '') {
                 $obj->h1 = $obj->name;
                 $obj->title = $obj->name;
             }
             $obj->pseudo_url = rand(1000, 9999);
             $obj->template_id = ($sect = ormPages::get($form_obj->section)) ? $sect->template_id : 1;
             $obj->form_id = $form_obj->id;
             $obj->setRightForAll(2);
             $obj_id = $obj->save();
             if ($obj_id) {
                 $obj->pseudo_url = $obj_id;
                 $obj->save();
                 $obj = new ormPage($obj_id);
             } else {
                 $issetErrors = true;
                 $f = $obj->getErrorFields();
                 $answer = array('field' => $f['focus'], 'msg' => $obj->getErrorListText(' '));
             }
         }
         if (!$issetErrors) {
             // Отправка нужных писем
             page::assign('site_name', domains::curDomain()->getSiteName());
             page::assign('site_url', domains::curDomain()->getName());
             page::assign('base_email', domains::curDomain()->getEmail());
             while (list($key, $val) = each($_POST)) {
                 page::assign($key, system::checkVar($val, isText));
             }
             if (isset($obj)) {
                 $fields = $obj->getClass()->loadFields();
                 foreach ($fields as $field) {
                     if (in_array($field['f_type'], array(70, 75, 80, 85))) {
                         $fsname = $field['f_sname'];
                         $fvalue = $obj->{$fsname};
                         if ($fvalue != '') {
                             page::assign($fsname, $fvalue);
                         }
                     }
                 }
             }
             // Если указан список адресатов, отправляем письма
             if ($form_obj->mailing_list != '') {
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->admin_sender_address);
                 $mail->FromName = $this->parse($form_obj->admin_sender_name);
                 /*
                                   if (!empty($this->files))
                 for($i = 0; $i < count($this->files); $i++)
                    $mail->AddAttachment($this->files[$i][0], $this->files[$i][1]);
                 */
                 $mail->AddAddress($form_obj->mailing_list);
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->admin_subject);
                 $mail->Body = $this->parse($form_obj->admin_template);
                 $mail->Send();
             }
             // Если нужно, отправляем уведомление пользователю
             if ($form_obj->send_notice && !$issetErrors) {
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->notice_sender_address);
                 $mail->FromName = $this->parse($form_obj->notice_sender_name);
                 $mail->AddAddress(system::POST('email'));
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->notice_subject);
                 $mail->Body = $this->parse($form_obj->notice_template);
                 $mail->Send();
             }
             // Показываем результат
             if (system::isAjax()) {
                 if ($form_obj->msg != '') {
                     $text = $form_obj->msg;
                 } else {
                     $text = lang::get('FEEDBACK_MSG_1');
                 }
                 system::json(array('field' => 0, 'msg' => strip_tags($text)));
             } else {
                 system::redirect('/feedback/ok/' . $form_obj->id);
             }
         } else {
             // Произошли ошибки
             if (system::isAjax()) {
                 system::json($answer);
             } else {
                 system::savePostToSession();
                 system::saveErrorToSession('feedback', $answer);
                 if (empty($_POST['back_url'])) {
                     $_POST['back_url'] = '/structure/map';
                 }
                 system::redirect($_POST['back_url'], true);
             }
         }
         system::stop();
     } else {
         system::stop();
     }
 }
Beispiel #4
0
 public function copy($with_child = true, $copyTo = 0)
 {
     if (!empty($this->id)) {
         $copy = new ormPage();
         $copy->setClass($this->getClass()->id());
         // Перенос данных полей
         $fields = $this->getClass()->loadFields();
         while (list($fname, $field) = each($fields)) {
             if (!empty($field['f_type']) && $field['f_type'] != 97 && $field['f_relation'] < 2 && $fname != 'pseudo_url' && $fname != 'tags') {
                 $copy->__set($fname, $this->__get($fname));
             }
         }
         if (empty($copyTo)) {
             $copy->__set('name', $this->__get('name') . lang::get('copy'));
             $copy->__set('h1', $this->__get('h1') . lang::get('copy'));
             $copy->__set('title', $this->__get('title') . lang::get('copy'));
             $copy->__set('pseudo_url', $this->__get('pseudo_url') . rand(1000, 9999));
         } else {
             $copy->__set('pseudo_url', $this->__get('pseudo_url'));
         }
         $copy->__set('template_id', $this->__get('template_id'));
         $copy->__set('template2_id', $this->__get('template2_id'));
         $copy->__set('tags', $this->__get('_tags'));
         // Устанавливаем родителя
         if (empty($copyTo)) {
             $parents = $this->getParents();
             while (list($id, $parent) = each($parents)) {
                 // $parent['position']
                 $copy->setNewParent($id);
             }
         } else {
             $copy->setNewParent($copyTo);
         }
         // Права доступа
         $rights = db::q('SELECT r_state, r_group_id FROM <<rights>> WHERE r_obj_id = "' . $this->id . '";', records);
         if (count($rights) === 1 && empty($rights[0]['r_group_id'])) {
             $copy->setRightForAll($rights[0]['r_state']);
         } else {
             while (list($key, $right) = each($rights)) {
                 $copy->setRight($right['r_group_id'], $right['r_state']);
             }
         }
         $copy->save();
         if (!$copy->issetErrors() && $with_child) {
             while ($child = $this->getChild()) {
                 $child->copy(true, $copy->id);
             }
             return true;
         } else {
             if ($copy->issetErrors()) {
                 //echo $copy->getErrorListText();
                 return false;
             }
         }
     }
 }
Beispiel #5
0
 /**
  * @return string - URL указанного раздела сайта
  * @param int $section_id - ID раздела сайта.
  * @desc МАКРОС: Возвращает URL указанного раздела сайта, либо пустоту.
  */
 public function getObjURL($obj_id)
 {
     if (!is_numeric($obj_id)) {
         echo $obj_id;
         $info = ormPages::getSectionByPath($obj_id);
         if ($info['section'] === false) {
             return '';
         }
         if ($info['section'] instanceof ormObject) {
             $obj_id = $info['section']->id;
         }
     }
     $page = new ormPage($obj_id);
     return $page->__get('_url');
 }
Beispiel #6
0
 public function proc_upd()
 {
     $mini_action = substr(system::action(), -3);
     $this->createTemplate('template_id');
     $this->createTemplate('template2_id');
     if (system::action() == "proc_upd") {
         // Говорим какой объект нужно изменить
         $obj = new ormPage(system::POST('obj_id'));
     } else {
         if (system::action() == "proc_add") {
             // Говорим какой объект нужно создать
             $obj = new ormPage();
             $obj->setClass(system::POST('class_id'));
             $obj->setParent(system::POST('obj_id'));
         }
     }
     // Если произошли ошибки, перенаправляем на главную страницу модуля
     if ($obj->issetErrors()) {
         system::redirect('/structure/tree');
     }
     // Присваиваем пришедшие значения полям в объекте
     $obj->loadFromPost($mini_action);
     rights::setListForObject($obj);
     // Сохраняем изменения
     $obj_id = $obj->save();
     // Если объект не сохранился, выводим пользователю текст ошибки.
     if ($obj_id === false) {
         system::savePostToSession();
         ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), $obj->getErrorListText());
         ui::selectErrorFields($obj->getErrorFields());
         $class = $mini_action == 'add' ? '/' . system::POST('class_id') : '';
         system::redirect('/structure/page_' . $mini_action . '/' . $_POST['obj_id'] . $class);
     } else {
         // Присваиваем выбранные шаблоны для всех вложенных объектов, если выбрано.
         if (system::POST('template_id_all', isBool)) {
             $this->inheritTemplate($_POST['template_id'], false, $obj_id);
         }
         if (system::POST('template2_id_all', isBool)) {
             $this->inheritTemplate($_POST['template2_id'], true, $obj_id);
         }
     }
     // Если данные изменились корректно перенаправляем на соответствующию страницу
     if ($_POST['parram'] == 'apply') {
         system::redirect('/structure/page_upd/' . $obj_id);
     } else {
         if (isset($_SESSION['STRUCTURE_LIST_FLAG']) && $_SESSION['STRUCTURE_LIST_FLAG']) {
             system::redirect('/structure/list/' . $obj->getParentId());
         } else {
             system::redirect('/structure/tree');
         }
     }
 }