Esempio n. 1
0
 /**
  * Переключение избранного поста:
  */
 public static function ToggleFavoritePost($board, $id)
 {
     $board_obj = new Board_BoardModel($board);
     if ($board_obj->existsPost($id)) {
         $session = Session::getInstance();
         $favorites = $session->persistenceGet('board_favorites', array());
         if (($key = array_search(array($board, $id), $favorites)) !== false) {
             unset($favorites[$key]);
         } else {
             array_unshift($favorites, array($board, $id));
         }
         $session->persistenceSet('board_favorites', $favorites);
         return array_search(array($board, $id), $favorites) !== false;
     }
     return false;
 }
Esempio n. 2
0
 static function boardpostlink2($parser, $matches, $name)
 {
     list(, $board_name, $id) = $matches;
     $parser->again = false;
     if ($board_name != 'news') {
         $board = new Board_BoardModel($board_name);
         if ($board->existsPost($id)) {
             $post = $board->getPost($id);
             $href = 'http://1chan.ru/' . $board_name . '/res/';
             if ($post['parent_id'] == null) {
                 $href .= $id . '/#top';
             } else {
                 $href .= $post['parent_id'] . '/#' . $id;
             }
             $link = TexyHtml::el('a');
             $link->href($href);
             $link->attrs['class'] = 'js-cross-link';
             $link->attrs['name'] = $board_name . '/' . $id;
             $link->setText('>>' . $board_name . '/' . $id);
             return $link;
         }
         return '>>' . $board_name . '/' . $id;
     }
     if (Blog_BlogCommentsModel::CommentExists($id)) {
         $comment = Blog_BlogCommentsModel::GetComment($id);
         $post_id = $comment['post_id'];
     } elseif (Blog_BlogPostsModel::PostExists($id)) {
         $post_id = $id;
     } else {
         '>>news/' . $id;
     }
     $link = TexyHtml::el('a');
     $link->href('http://1chan.ru/news/res/' . $post_id . '/#' . $id);
     $link->attrs['class'] = 'js-cross-link';
     $link->attrs['name'] = 'news/' . $id;
     $link->setText('>>news/' . $id);
     return $link;
 }
Esempio n. 3
0
 /**
  * Удаление поста (ajax):
  */
 public function removeAjaxAction(Application $application)
 {
     $board = new Board_BoardModel($_GET['board']);
     $session = Session::getInstance();
     if ($board->existsPost($_GET['id'])) {
         $post = $board->getPost($_GET['id']);
         if (!empty($post['password']) && $post['password'] == $_GET['password']) {
             if ($board->existsThread($_GET['id'])) {
                 $board->removeThread($_GET['id']);
             } else {
                 $board->removePost($_GET['id']);
             }
             return true;
         }
         if ($session->isAdminSession()) {
             if (@$_GET['delall'] == true) {
                 $board->removePostsByAuthor($_GET['id']);
                 return true;
             } else {
                 if ($board->existsThread($_GET['id'])) {
                     $board->removeThread($_GET['id']);
                 } else {
                     $board->removePost($_GET['id']);
                 }
                 if ($board->getId() != 'alone') {
                     ControlModel::logModEvent(date("d-m-Y H:i:s") . ' ' . $_SESSION['auth']['name'] . '<br /> удалил пост №' . $_GET['id'] . ' в разделе ' . $_GET['board']);
                 }
             }
         }
         return false;
     }
     return true;
 }