示例#1
0
 /**
  * Редактирование комментария:
  */
 public static function EditComment($id, $params, $safeMode = true)
 {
     if (Blog_BlogPostsModel::PostExists($params['post_id'])) {
         $session = Session::getInstance();
         $cache = KVS::getInstance();
         // Обработка:
         $params['text'] = TexyHelper::markup($params['text'], !$session->isAdminSession());
         $record = array('text' => $params['text']);
         if (!$safeMode) {
             $record = array_merge($record, array('special_comment' => @$params['special_comment']));
         }
         $dbh = PDOQuery::getInstance();
         $dbh->update('1chan_comment', $record, 'id = ' . $dbh->q($id));
         EventModel::getInstance()->Broadcast('edit_comment', $record);
         return $id;
     }
     return false;
 }
示例#2
0
 /**
  * Установка "инфорации" канала:
  */
 public static function SetInfo($id, $message)
 {
     $cache = KVS::getInstance();
     $message = TexyHelper::markup($message, true, false);
     $cache->set(__CLASS__, $id, 'info', $message);
     return $message;
 }
示例#3
0
 /**
  * Редактирование поста:
  */
 public static function EditPost($id, $params, $safeMode = true)
 {
     $session = Session::getInstance();
     $dbh = PDOQuery::getInstance();
     $post = self::GetPost($id);
     if ($post['category'] != $params['category']) {
         Blog_BlogCategoryModel::CountCategory($post['category'], false);
         Blog_BlogCategoryModel::CountCategory($params['category'], true);
     }
     $params['title'] = TexyHelper::typo($params['title']);
     $params['text'] = TexyHelper::markup($params['text'], !$session->isAdminSession());
     $params['text_full'] = TexyHelper::markup($params['text_full'], !$session->isAdminSession());
     $record = array('category' => $params['category'], 'link' => $params['link'], 'title' => $params['title'], 'text' => $params['text'], 'text_full' => $params['text_full']);
     if (!$safeMode) {
         $record = array_merge($record, array('ip' => $params['ip'], 'hidden' => (bool) $params['hidden'], 'pinned' => (bool) $params['pinned'], 'rated' => (bool) $params['rated'], 'closed' => (bool) $params['closed'], 'rateable' => (bool) $params['rateable'], 'bumpable' => (bool) $params['bumpable'], 'special_comment' => (bool) $params['special_comment']));
     }
     EventModel::getInstance()->Broadcast('edit_post', $id, $record);
     return $dbh->update('1chan_post', $record, 'id = ' . $dbh->q($id));
 }
示例#4
0
 /**
  * Отправка сообщения в канал:
  */
 public static function AddMessage($id, $message, $password = false)
 {
     $cache = KVS::getInstance();
     $session = Session::getInstance();
     $channel = self::GetChatChannel($id, $password);
     $message_id = $cache->incr(__CLASS__, $id, 'nextId');
     $message = TexyHelper::markup($message, !$session->isAdminSession(), false);
     $date = time();
     $cache->set(__CLASS__, $id, $message_id . ':ip', $_SERVER['REMOTE_ADDR']);
     $cache->expire(__CLASS__, $id, $message_id . ':ip', 60 * 5);
     EventModel::getInstance()->ClientBroadcast('chat_' . $channel, 'message', array('type' => 'normal', 'id' => $message_id, 'message' => $message, 'date' => date('H:i:s', $date)));
     /**
      * Отправка сообщения администратору:
      */
     if ($id == '475266264b1e9696e0370039311f83ee4cee8d413c47c') {
         JabberBot::send('-=# ' . '>>' . $message_id . "\n" . strip_tags($message));
     }
     self::LogMessage($channel, $message, $message_id, $date);
     return $message_id;
 }
示例#5
0
 /**
  * Действие предпросмотра поста (ajax):
  */
 public function previewPostAjaxAction(Application $application)
 {
     $preview = array();
     $preview['title'] = TexyHelper::typo(@$_POST['title']);
     $preview['text'] = TexyHelper::markup(@$_POST['text'], true);
     $preview['text_full'] = TexyHelper::markup(@$_POST['text_full'], true);
     $preview['icon'] = @$_POST['link'] ? TemplateHelper::getIcon(@$_POST['link']) : 'http://' . TemplateHelper::getSiteUrl() . '/ico/favicons/1chan.ru.gif';
     if (array_key_exists('category', $_POST) && !empty($_POST['category'])) {
         if (Blog_BlogCategoryModel::CategoryExists($_POST['category'])) {
             $category = Blog_BlogCategoryModel::GetCategoryByCode($_POST['category']);
             $preview['category'] = TemplateHelper::BlogCategory($category['id'], 'title');
         }
     }
     return $preview;
 }