/** * @param array $value * @return boolean indicating is any valid data of interest was passed */ protected function _isValid($value) { $partialHappened = false; $isPost = 'post' == $this->getMethodContext(); // comment is set optional for put, required for post if (isset($value['comment'])) { $partialHappened = true; $validate = new Zend_Validate_StringLength(array(1, 1000)); if (!$validate->isValid($value['comment'])) { $this->_addValidateMessagesAndErrors($validate); } } elseif ($isPost) { $this->_error(self::COMMENT_REQUIRED); } // creator_user_id required for post // creator can't be changed for put, so if not post, then don't bother // checking this, it will be ignored later if (isset($value['creator_user_id']) && $isPost) { $userTable = new Default_Model_DbTable_User(); if (false === current($userTable->find($value['creator_user_id']))) { $this->_error(self::CREATOR_USER_ID_INVALID, $value['creator_user_id']); } } elseif ($isPost) { $this->_error(self::CREATOR_USER_ID_REQUIRED); } return $partialHappened; }
/** * Constructor * * @param Zend_Db_Adapter_Abstract $db * @param int $user_id * @param int $post_id */ public function __construct($db, $user_id, $post_id = 0) { $this->db = $db; $this->user = new Default_Model_DbTable_User($db); $this->user->load($user_id); $this->post = new Default_Model_DbTable_BlogPost($db); $this->post->loadForUser($this->user->getId(), $post_id); if (!$this->post->isSaved()) { $this->post->user_id = $this->user->getId(); } parent::__construct(); }
/** * Resolve username/realm to password/hash/etc. * * @param string $username Username * @param string $realm Authentication Realm * @return string|false User's shared secret, if the user is found in the * realm, false otherwise. */ public function resolve($username, $realm) { require_once 'models/DbTable/User.php'; $userTable = new Default_Model_DbTable_User(); $user = $userTable->fetchRow(array('username = ?' => $username)); if (null === $user) { return false; } // passwords aren't implemented, currently the same as the username if ('digest' == $this->getAuthType()) { return hash('md5', $username . ':' . $realm . ':' . $username); } if ('basic' == $this->getAuthType()) { return $username; } return false; }
/** * Action - get user password * * Access to the action is possible in the following paths: * - /utility/userpassword * * @return void */ public function userpasswordAction() { if ($this->_isAjaxRequest) { $request = $this->getRequest(); $params = $request->getParams(); //Создадим обьект формы $loginForm = new Default_Form_UserLogin(); //Проверим правильность заполнения полей формы if ($loginForm->isValid($params)) { $user = new Default_Model_DbTable_User($this->db); $username = $loginForm->getValue('username'); if ($user->loadByUsername($username)) { if ($this->_isAdmin && ($user->user_type == 'editor' || $user->user_type == 'member')) { $json = array('password' => $user->password); } elseif ($this->_isEditor && $user->user_type == 'member') { $json = array('password' => $user->password); } else { $json = array('class_message' => 'warning', 'messages' => array('<em>' . $this->Translate('Запрещено редактировать сообщение пользователя -') . $username . '"</em>', $this->Translate('У вас недостаточно прав для редактирования сообщения этого пользователя'))); } } } else { $json = array('class_message' => 'warning', 'messages' => $this->getFormMessages($loginForm)); } // Запишем в лог if (isset($json['password'])) { $my_usertype = $this->_identity->user_type; $my_username = $this->_identity->username; $username = $user->username; $usertype = $user->user_type; $post_url = $params['url']; $post_title = $params['title']; $message = sprintf('User - "%s"(%s) login to site with a user name - "%s"(%s), to edit the post - "%s"(%s)', $my_username, $my_usertype, $username, $usertype, $post_title, $post_url); // Запомним в логе сообщений $this->_logMsg->admin_post_edit($message); } $this->sendJson($json); } }
/** * @param array $value * @return boolean indicating is any valid data of interest was passed */ protected function _isValid($value) { $partialHappened = false; $isPost = 'post' == $this->getMethodContext(); // validate that the name is set if (isset($value['name'])) { $partialHappened = true; $validate = new Zend_Validate_StringLength(array(1, 50)); if (!$validate->isValid($value['name'])) { $this->_addValidateMessagesAndErrors($validate); } } elseif ($isPost) { $this->_error(self::NAME_REQUIRED); } // validate that the username is set, and doesn't already exist if (isset($value['username'])) { $partialHappened = true; $validate = new Zend_Validate_StringLength(array(1, 50)); if (!$validate->isValid($value['username'])) { $this->_addValidateMessagesAndErrors($validate); } $userTable = new Default_Model_DbTable_User(); if ($userTable->fetchRow(array('username = ?' => $value['username']))) { $this->_error(self::USERNAME_ALREADY_EXISTS, $value['username']); } } elseif ($isPost) { $this->_error(self::USERNAME_REQUIRED); } return $partialHappened; }
/** * Action - feed * actions with news user tape * you can get all the news * and the user can receive news only on a separate tag * * Access to the action is possible in the following paths: * router pattern - user/all/feed/:tag/* or controller/:action/* * * - /user/all/feed/reports * or * - /index/feed * * @return void */ public function feedAction() { //Получим параметр метки $tag = trim($this->_request->getUserParam('tag')); // first retrieve all recent posts $options = array('status' => Default_Model_DbTable_BlogPost::STATUS_LIVE, 'limit' => 10, 'order' => 'p.ts_created desc', 'public_only' => true); if ($tag) { $options['tag'] = $tag; } $recentPosts = Default_Model_DbTable_BlogPost::GetPosts($this->db, $options); // base URL for generated links if ($this->getRequest()->getServer('HTTPS') == 'on') { $domain = 'https://'; } else { $domain = 'http://'; } $domain .= $this->getRequest()->getServer('HTTP_HOST'); // url for web feed if ($tag) { $url = $this->getCustomUrl(array('tag' => $tag), 'feed_tag_all'); } else { $url = $this->getUrl('feed'); } $feedData = array('link' => $domain . $url, 'charset' => 'UTF-8', 'entries' => array()); if ($tag) { $tagLabel = Default_Model_DbTable_BlogPost::getLabelForTag($this->db, $tag); $title = $this->Translate('Сообщения авторов') . ' ' . $this->Translate('для метки') . ' - ' . $tagLabel; } else { $title = $this->Translate('Сообщения всех авторов'); } $feedData['title'] = $title; // determine which users' posts were retrieved $user_ids = array(); foreach ($recentPosts as $post) { $user_ids[$post->user_id] = $post->user_id; } // load the user records if (count($user_ids) > 0) { $options = array('user_id' => $user_ids); $users = Default_Model_DbTable_User::GetUsers($this->db, $options); } else { $users = array(); } // build feed entries based on returned posts foreach ($recentPosts as $post) { $user = $users[$post->user_id]; $url = $this->getCustomUrl(array('username' => $user->username, 'url' => $post->url), 'post'); $entry = array('title' => $post->profile->title, 'link' => $domain . $url, 'description' => $post->getTeaser(200), 'lastUpdate' => $post->ts_created, 'category' => array()); // attach tags to each entry foreach ($post->getTags() as $tag) { $entry['category'][] = array('term' => $tag); } $feedData['entries'][] = $entry; } // create feed based on created data $feed = Zend_Feed::importArray($feedData, 'atom'); // disable auto-rendering since we're outputting an image $this->_helper->viewRenderer->setNoRender(); // output the feed to the browser $feed->send(); }
/** * @param array $item */ protected function _post_pre_persist(array &$item) { // force the user to be that from the acl context $item['creator_user_id'] = $this->getAclContextUser()->id; $item['modified'] = date('Y-m-d H:i:s'); // make sure that the user is valid require_once 'models/DbTable/User.php'; $userTable = new Default_Model_DbTable_User(); $resultSet = $userTable->find($item['creator_user_id']); if (false === current($resultSet)) { throw new Rest_Model_BadRequestException('creator_user_id does not match with an existing user'); } }
/** * Action - detailscomplete * end edit detailed information about the user * * Access to the action is possible in the following paths: * - /account/detailscomplete * * @return void */ public function detailscompleteAction() { $user = new Default_Model_DbTable_User($this->db); $user_id = Zend_Auth::getInstance()->getIdentity()->user_id; $user->load($user_id); $this->view->user = $user; //Добавим путь к действию $this->_breadcrumbs->addStep($this->Translate('Редактировать профиль'), $this->getUrl('details')); $this->_breadcrumbs->addStep($this->Translate('Профиль изменен')); }
/** * Get the data to build a tree Comments * * @param Zend_Db_Adapter_Abstract $db * @param int $post_id * @return array */ public static function getTreeComments($db, $user_id, $params) { $sortcomm = array(); $newComments = array(); //----------------------------------------- // Получим комментарии $comments = self::GetComments_Array($db, $params); // Получим не повторяющийся массив Ids пользователей $arrBox = new Default_Plugin_ArrayBox($comments); if ($arrBox->count() == 0) { return $sortcomm; } $arrUser_ids = $arrBox->slice('user_id', TRUE); // Добавим в массив Ids пользователей id автора, если его там нет if (!$arrUser_ids->isValue($user_id)) { $arrUser_ids = $arrUser_ids->push($user_id); } $arrUser_ids = $arrUser_ids->get(); // Получим массив пользователей из их Ids $options = array('user_id' => $arrUser_ids); $users = Default_Model_DbTable_User::GetUsers($db, $options); foreach ($comments as $comment) { if (isset($comment['user_id']) && isset($users[$comment['user_id']])) { $user = $users[$comment['user_id']]; // Установим имя пользователя $comment['username'] = $user->username; // Установим дату создания комментария $date = new Zend_Date($comment['ts'], 'U'); $dtFormat = $date->get('dd MMMM YYYY, HH:mm'); $comment['date'] = $dtFormat; // Установим признак авторства $isAutor = $user_id == $comment['user_id']; $comment['is_autor'] = $isAutor; // Установим изображение пользователя if ($user->profile->user_img) { $user_img = $user->profile->user_img; } else { if ($comment['is_autor']) { $user_img = "/images/system/user_new.png"; } else { if ($user->profile->sex) { if ($user->profile->sex == 'male') { $user_img = "/images/system/user_male.png"; } else { $user_img = "/images/system/user_female.png"; } } else { $user_img = "/images/system/user_message.png"; } } } $comment['user_img'] = $user_img; // Установим URL пользователя $comment['user_url'] = "/user/{$user->username}"; // Добавим в новый массив $newComments[] = $comment; } } //------ Создадим дерево комментариев ------ if (count($newComments) > 0) { // subcomments foreach ($newComments as $item) { if ($item['reply_id'] == 0) { $sortcomm[$item['id']]['parent'] = $item; } if ($item['reply_id'] > 0) { if (isset($path[$item['reply_id']])) { $str = '$sortcomm'; foreach ($path[$item['reply_id']] as $pitem) { $rep = $item['reply_id']; $str .= "[{$pitem}][sub]"; } $str .= "[{$item['reply_id']}][sub]"; $str .= "[{$item['id']}]['parent']"; $str .= '=$item;'; eval($str); foreach ($path[$item['reply_id']] as $pitem) { $path[$item['id']][] = $pitem; } $path[$item['id']][] = $item['reply_id']; } else { $sortcomm[$item['reply_id']]['sub'][$item['id']]['parent'] = $item; $path[$item['id']][] = $item['reply_id']; } } } } return $sortcomm; }
/** * Get the values of a field in a table * * @param array $options * * @return array */ public function getValuesForCol($options = NULL) { // Обращение идет к таблице "users" if ($options['joinTableForSort'] == 'admin.users') { $options['joinTableForSort'] = ''; $rows = Default_Model_DbTable_User::GetValuesForCol($this->db, $options); return $rows; } // Обращение идет к таблице "users_profile" if ($options['joinTableForSort'] == 'admin.users_profile') { $options['joinTableForSort'] = 'users_profile'; $rows = Default_Model_DbTable_User::GetValuesForCol($this->db, $options); return $rows; } // Обращение идет к таблице "blog_post" или присоединенным таблицам: // blog_post_profile; blog_post_tags; blog_post_images; blog_post_locations $rows = Default_Model_DbTable_BlogPost::GetValuesForCol($this->db, $options); return $rows; }
/** * Get the array of posts satisfying the criteria specified in the parameter $options * * @param Zend_Db_Adapter_Abstract $db * @param array $options * @return array */ public static function GetPosts_Array($db, $options = array()) { $arrPosts = FALSE; $user_ids = array(); //---------------------- // initialize the options $defaults = array('offset' => 0, 'limit' => 0, 'order' => 'p.ts_created', 'sort' => true); foreach ($defaults as $k => $v) { $options[$k] = array_key_exists($k, $options) ? $options[$k] : $v; } $select = self::_GetBaseQuery($db, $options); // set the fields to select $select->from(null, 'p.*'); // set the offset, limit, and ordering of results if ($options['limit'] > 0) { $select->limit($options['limit'], $options['offset']); } // Установим параметры сортировки для таблицы if ($options['sort']) { $select = self::GetSelectForSort($select, $options); } $strSelect = $select->__toString(); //------ Применить кеширование ------- $dbCache = Default_Plugin_SysBox::getCache('db'); if ($dbCache->getOption('caching')) { // Получим TAG для кеширования $arrItems = array($select, $options); $strSerialize = serialize($arrItems); $tagCache = md5($strSerialize); // Очистим кеш if (Default_Plugin_SysBox::isCleanCache()) { $dbCache->clean(Zend_Cache::CLEANING_MODE_ALL); } // Получим данные из кеша по тегу $tagCache $arrPosts = $dbCache->load($tagCache); } // проверка, есть ли уже данные в кэше: if ($arrPosts === FALSE) { // fetch user data from database $data = $db->fetchAll($select); // turn data into array of DatabaseObject_User objects $posts = parent::BuildMultiple_Array($db, __CLASS__, $data); if (count($posts) == 0) { return $posts; } $post_ids = array_keys($posts); // load the profile data for loaded posts $profiles = Default_Model_Profile::BuildMultiple_Array($db, 'Default_Model_DbTable_BlogPostProfile', array($post_ids)); $arrPosts = array(); foreach ($posts as $post_id => $post) { if (array_key_exists($post_id, $profiles)) { $arrPosts[$post_id] = $posts[$post_id] + $profiles[$post_id]; } else { $arrPosts[$post_id] = $posts[$post_id]; } // Получим ids пользователей для всех сообщениий $user_ids[] = $post['user_id']; } // Уберем повторяющиеся значения из массива $user_ids = array_unique($user_ids); // Получим всех пользователей $options = array('user_id' => $user_ids); $users = Default_Model_DbTable_User::GetUsers_Array($db, $options); // Добавим пользователя для каждого сообщения foreach ($posts as $post_id => $post) { $postuser_id = $post['user_id']; foreach ($users as $user) { $user_id = $user['id']; if ($user_id == $postuser_id) { $arrPosts[$post_id]['_user_'] = $user; break; } } } // Загрузим изображения для каждого сообщения $options = array('post_id' => $post_ids); $images = Default_Model_DbTable_BlogPostImage::GetImages_Array($db, $options); foreach ($images as $image) { $post_id = $image['post_id']; $image_id = $image['id']; $arrPosts[$post_id]['_images_'][$image_id] = $image; } // Загрузим координаты для каждого сообщения $locations = Default_Model_DbTable_BlogPostLocation::GetLocations_Array($db, $options); foreach ($locations as $location) { $post_id = $location['post_id']; $location_id = $location['id']; $arrPosts[$post_id]['_locations_'][$location_id] = $location; } // Загрузим метки для каждого сообщения $tags = Default_Model_DbTable_BlogPostTag::GetTags_Array($db, $options); foreach ($tags as $tag) { $post_id = $tag['post_id']; $tag_id = $tag['id']; $arrPosts[$post_id]['_tags_'][$tag_id] = $tag; } // Загрузим audio для каждого сообщения $audios = Default_Model_DbTable_BlogPostAudio::GetAudio_Array($db, $options); foreach ($audios as $audio) { $post_id = $audio['post_id']; $audio_id = $audio['id']; $arrPosts[$post_id]['_audio_'][$audio_id] = $audio; } // Загрузим video для каждого сообщения $videos = Default_Model_DbTable_BlogPostVideo::GetVideo_Array($db, $options); foreach ($videos as $video) { $post_id = $video['post_id']; $video_id = $video['id']; $arrPosts[$post_id]['_video_'][$video_id] = $video; } // Загрузим comments для каждого сообщения $comments = Default_Model_DbTable_BlogPostComment::GetComments_Array($db, $options); foreach ($comments as $comment) { $post_id = $comment['post_id']; $comment_id = $comment['id']; $arrPosts[$post_id]['_comments_'][$comment_id] = $comment; } // Если разрешено кеширование, то сохраним данные в кеше if ($dbCache->getOption('caching')) { $dbCache->save($arrPosts, $tagCache); } } else { $result = $arrPosts; } return $arrPosts; }
/** * Action - index * search posts for request * * Access to the action is possible in the following paths: * - /search/index * - /search/ * @return void */ public function indexAction() { $searchZendAuth = $this->_sessZendAuth->search; //------------------ $request = $this->getRequest(); $params = $request->getParams(); $itemCountPerPage = isset($params['itemCountPerPage']) ? $params['itemCountPerPage'] : 0; $page = isset($params['page']) ? $params['page'] : 0; // Получим запрос для поиска $query = trim($params['q']); // Получим url MVC $urlMVC = $this->_url_mvc; // Скорректируем url MVC $addQuery = '/q/' . $query; $arrMVC = explode('/q/', $urlMVC); $urlMVC = $arrMVC[0] . $addQuery; // Подготовка запроса для поиска $q = Zend_Search_Lucene_Search_QueryParser::parse($query, 'utf-8'); // Параметры поиска $search = array('performed' => false, 'limit' => $this->_config['paginator']['itemCountPerPage'], 'total' => 0, 'start' => 0, 'finish' => 0, 'page' => 1, 'pages' => 1, 'results' => array()); // Установим параметры для Paginator if ($itemCountPerPage) { $search['limit'] = (int) $itemCountPerPage; } if ($page) { $search['page'] = (int) $page; } // Поиск по запросу try { if (strlen($q) == 0) { throw new Exception('No search term specified'); } // Преобразуем строку запроса через translit(); $search_query = new Default_Plugin_String($query); $search_query = (string) $search_query->translit()->Strip('-'); // Проверим если результаты запроса в сессии пользователя // если есть, то берем их из сессии и отсылаем пользователю if (isset($searchZendAuth[$search_query])) { $post_ids = $searchZendAuth[$search_query]; $post_ids = explode(';', $post_ids); } else { $path = Default_Model_DbTable_BlogPost::getIndexFullpath(); $index = Zend_Search_Lucene::open($path); $hits = $index->find($q); $post_ids = array(); foreach ($hits as $hit) { $post_ids[] = (int) $hit->post_id; } // ВАЖНО!!! привильно запоминать $this->_sessZendAuth->search[$search_query] = implode(";", $post_ids); // НЕ ПРАВИЛЬНО!!! } // $searchZendAuth[$search_query] = implode(";", $post_ids); //------ Создадим обьект Zend_Paginator $paginator = Zend_Paginator::factory($post_ids); // Установим максимальное количество отображаемых на странице элементов $paginator->setItemCountPerPage($search['limit']); // Установим текущую страницу $paginator->setCurrentPageNumber($search['page']); // Получим массив "ids" для заданной страницы $post_ids = array(); foreach ($paginator as $post_id) { $post_ids[] = $post_id; } // Получим обьект управления страницами $pages = $paginator->getPages(); $search['performed'] = true; $search['total'] = $pages->totalItemCount; $search['pages'] = $pages->pageCount; $search['start'] = $pages->firstItemNumber; $search['finish'] = $pages->lastItemNumber; // Получим найденные сообщения для текущей страницы $options = array('status' => Default_Model_DbTable_BlogPost::STATUS_LIVE, 'post_id' => $post_ids); $posts = Default_Model_DbTable_BlogPost::GetPosts($this->db, $options); foreach ($post_ids as $post_id) { if (array_key_exists($post_id, $posts)) { $search['results'][$post_id] = $posts[$post_id]; } } // determine which users' posts were retrieved $user_ids = array(); foreach ($posts as $post) { $user_ids[$post->user_id] = $post->user_id; } // load the user records if (count($user_ids) > 0) { $options = array('user_id' => $user_ids); $users = Default_Model_DbTable_User::GetUsers($this->db, $options); } else { $users = array(); } } catch (Exception $ex) { // no search performed or an error occurred } if ($search['performed']) { $this->_breadcrumbs->addStep($this->Translate('Поиск')); } else { $this->_breadcrumbs->addStep($this->Translate('Поиск')); } $this->view->q = $query; $this->view->search = $search; $this->view->users = $users; $this->view->pages = $pages; $this->view->url_mvc = $urlMVC; }
/** * Get the values of a field in a table * * @param array $fields * * @return array */ public function getValuesForCol($options = NULL) { $rows = Default_Model_DbTable_User::GetValuesForCol($this->db, $options); return $rows; }
/** * @param array $prop * @return array */ public function post(array $prop) { require_once 'models/DbTable/User.php'; $userTable = new Default_Model_DbTable_User(); if (isset($prop['user_id'])) { $user = $userTable->fetchRow(array('id = ?' => $prop['user_id'])); $user = $user ? (object) $user : false; } elseif (isset($prop['user_username'])) { $user = $userTable->fetchRow(array('username = ?' => $prop['user_username'])); $user = $user ? (object) $user : false; } else { $user = null; } $session = $this->getSession(); $session->unsetAll(); $session->realm = 'App'; $session->identity = $user ? (object) array('id' => $user->id, 'username' => $user->username, 'name' => $user->name) : null; require_once 'Zend/Auth.php'; Zend_Auth::getInstance()->getStorage()->write($session->identity); if (false === $user) { return null; } return $this->get(array('id' => 1)); }
/** * Action - comments * actions for user comments * * Access to the action is possible in the following paths: * шаблон раутера - user/:username/post/:post_id/comments/* * * - /user/user1/post/27/comments * * @return void */ public function commentsAction() { $json = array(); $result = TRUE; //----------------------- // Получим обьект запроса $request = $this->getRequest(); $params = $request->getParams(); $type_action = $params['type_action']; $post_id = (int) $request->getUserParam('post_id'); $username = trim($request->getUserParam('username')); try { if ($type_action == 'delete') { // Удалим комментарий // Получим массив комментариев для удаления $comment_ids = $params["comment_ids"]; $comment_ids = Zend_Json::decode($comment_ids); $parent_comment_id = $comment_ids[0]; // Удалим комментарии из базы данных $comment = new Default_Model_DbTable_BlogPostComment($this->db); foreach ($comment_ids as $comment_id) { if ($comment->loadForPost($post_id, $comment_id)) { $comment->delete(); } else { $result = FALSE; break; } } if ($result) { $json = array('deleted' => true, 'result' => $this->Translate('Комментарий удален из сообщения блога'), 'comment_id' => $parent_comment_id); } else { $json = array('class_message' => 'warning', 'messages' => array('<em>' . $this->Translate('Ошибка при добавлении / удалении комментария в блог') . '</em>')); } } else { if ($type_action == 'add' || $type_action == 'reply' || $type_action == 'edit') { // Добавим/изменим комментарий на сообщение $allParams = $this->_getAllParams(); $reply_id = $params["reply_id"]; $formAddComment = new Default_Form_AddComment($username, $post_id); $result = $formAddComment->isValid($allParams); if ($result) { $comment = new Default_Model_DbTable_BlogPostComment($this->db); if ($type_action == 'edit') { if ($comment->loadForPost($post_id, $reply_id)) { $comment->comment = $formAddComment->getValue('ckeditor_comment'); } else { $json = array('class_message' => 'warning', 'messages' => array('<em>' . $this->Translate('Ошибка при сохранении данных') . '</em>')); } } else { $comment->user_id = $this->_identity->user_id; $comment->post_id = $post_id; $comment->reply_id = $reply_id; $comment->comment = $formAddComment->getValue('ckeditor_comment'); } if ($comment->save()) { if ($type_action == 'edit') { $html = $formAddComment->getValue('ckeditor_comment'); $result = $this->Translate('Комментарий изменен'); } else { // Получим параметр для шаблона $treeComments = Default_Model_DbTable_BlogPostComment::getTreeComments($this->db, $this->user->getId(), array('post_id' => $post_id, 'comment_id' => $comment->getId())); // Создадим обьект шаблона $templater = Default_Plugin_SysBox::createViewSmarty(); //Установим параметры шаблона $templater->treeComments = $treeComments; $templater->authenticated = true; $templater->isAdmin = $this->_isAdmin; $templater->identity = $this->_identity; // Получим результат шаблона $html = $templater->render('user/lib/comment-item.tpl'); $result = $this->Translate('Добавлен комментарий к сообщению блога'); } $json = array('added' => true, 'result' => $result, 'comment_id' => $comment->getId(), 'html' => $html); } else { // Ошибка записи в базу данных $json = array('class_message' => 'warning', 'messages' => array('<em>' . $this->Translate('Ошибка при сохранении данных') . '</em>')); } } else { // неверно заполнены поля формы $json = array('class_message' => 'warning', 'messages' => $this->getFormMessages($formAddComment)); } } } } catch (Exception $e) { $json = array('class_message' => 'warning', 'messages' => array('<em>' . $this->Translate('Ошибка при добавлении / удалении комментария в блог') . '</em>', Default_Plugin_SysBox::getMessageError($e))); } $this->sendJson($json); }