Inheritance: extends Model
コード例 #1
0
 /**
  * modify comment
  */
 public function modify()
 {
     if ($this->isPost()) {
         $uid = $this->user['uid'];
         if (empty($uid)) {
             Message::showError('please login');
         }
         $comment_id = trim($_POST['id']);
         if (!is_numeric($comment_id)) {
             Message::showError('comment id necessay');
         }
         $content = trim($_POST['content']);
         if (empty($content)) {
             Message::showError('content is empty');
         }
         if (!is_numeric($_POST['star'])) {
             Message::showError('star is not number');
         }
         $star = trim($_POST['star']);
         $commentModel = new CommentModel();
         $result = $commentModel->modify($uid, $comment_id, $star, $content);
         if (!empty($result)) {
             Message::showSucc('modify comment success');
         } else {
             Message::showError('modify comment failed');
         }
     }
     $this->display('comment.html');
 }
コード例 #2
0
 private function sus_opp()
 {
     $comment = new CommentModel();
     $comment->cid = $_GET['cid'];
     //支持
     if ($_GET['action'] == 'sustain') {
         $comment->sustain() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $comment->cid) : Tool::alertBack('对不起,请重试');
     }
     //反对
     if ($_GET['action'] == 'oppose') {
         $comment->oppose() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $comment->cid) : Tool::alertBack('对不起,请重试');
     }
 }
 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: POST');
     $valid = true;
     $errors = [];
     if (CommentModel::exists($this->pdo, htmlentities($_POST['id']))) {
         $id = htmlentities($_POST['id']);
     } else {
         return json_encode($errors['id'] = '<span class="errors">Cet article n\'existe pas</span>');
     }
     $content = trim(htmlentities($_POST['content']));
     $timestamp = time();
     if (!isset($content) || empty($content)) {
         $errors['content'] = '<span class="errors">Non saisi</span>';
         $valid = false;
     } elseif (strlen($content) > 200) {
         $errors['content'] = '<span class="errors">200 caractères max</span>';
         $valid = false;
     }
     $errors['valid'] = $valid;
     if ($valid) {
         CommentModel::edit($this->pdo, $id, $content, $timestamp);
     }
     echo json_encode($errors);
 }
コード例 #4
0
ファイル: IndexController.php プロジェクト: Sladeck/Blog
 public function indexAction()
 {
     $articles = ArticlesModel::getList($this->pdo);
     $commentaires = CommentModel::getList($this->pdo);
     include "../view/home.php";
     return;
 }
コード例 #5
0
 public function edit()
 {
     $this->assign('userInfo', $this->userInfo);
     $id = request('id');
     if (isset($_POST['id'])) {
         $content = request('content');
         $reply = request('reply');
         if (mb_strlen($content, 'utf8') > 200) {
             $this->error('留言的长度不能超过200字符');
         }
         if (mb_strlen($reply, 'utf8') > 200) {
             $this->error('回复的长度不能超过200字符');
         }
         $data['content'] = $content;
         $data['reply'] = $reply;
         $data['replytime'] = time();
         $data['status'] = 'replied';
         if (CommentModel::update($id, $data)) {
             $this->success(request('reffer'));
         } else {
             $this->error();
         }
     } else {
         $comment = CommentModel::get($id);
         $this->assign('comment', $comment);
         $this->assign('reffer', $this->reffer());
         $this->display();
     }
 }
 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: GET');
     echo json_encode(CommentModel::showAllComments($this->pdo));
 }
コード例 #7
0
ファイル: UserCtrl.class.php プロジェクト: Jnnock/myyyk
 public function index()
 {
     //header('content-type:text/html;charset=utf-8');
     $userId = $_SESSION['qq']['userId'];
     $collect = new CollectModel();
     //查询收藏
     $user_collect = $collect->getCollectByuserId($userId);
     $article = new ArticleModel();
     $arr = array();
     foreach ($user_collect as $v) {
         //根据收藏的文章id查询文章
         $a = $article->getArticleById($v['articleId']);
         //取出admin的昵称
         $a['adminName'] = $this->getAdmin($a['adminId']);
         $arr[] = $a;
     }
     $comment = new CommentModel();
     $commentAlbum = $comment->getCommentByAlbum($userId);
     $album = new AlbumModel();
     $articles = array();
     $albums = array();
     foreach ($commentAlbum as $v) {
         if ($v['albumId'] != null) {
             $c = $album->getAlbumById($v['albumId']);
             $c['adminName'] = $this->getAdmin($v['adminId']);
             $albums[] = $c;
         }
     }
     $commentArticle = $comment->getCommentByArticle($userId);
     foreach ($commentArticle as $v) {
         if ($v['articleId'] != null) {
             $a = $article->getArticleById($v['articleId']);
             $a['adminName'] = $this->getAdmin($v['adminId']);
             $articles[] = $a;
         }
     }
     var_dump($albums);
     $this->assign('user', $_SESSION['qq']['userName']);
     //评论过的相册
     $this->assign('albums', $albums);
     //评论过的文章
     $this->assign('articles', $articles);
     //收藏
     $this->assign('user_collect', $arr);
     $this->display();
 }
コード例 #8
0
ファイル: CommentController.php プロジェクト: LattyS/my_blog
 public function deleteAction()
 {
     if (!isset($_POST['comment_id'])) {
         return json_encode(["error" => "comment_id missing"]);
     }
     $comment_id = $_POST['comment_id'];
     CommentModel::delete($this->pdo, $comment_id);
     return json_encode(["message" => "Supprimé !", "comment_id" => $comment_id]);
 }
コード例 #9
0
    protected function AddReplyButton($Sender)
    {
        if (!Gdn::Session()->UserID) {
            return;
        }
        if (isset($Sender->EventArguments['Comment'])) {
            $Model = new CommentModel();
            $Data = $Model->GetID($Sender->EventArguments['Comment']->CommentID);
        } else {
            $Model = new DiscussionModel();
            $Data = $Model->GetID($Sender->Data['Discussion']->DiscussionID);
        }
        $ReplyURL = "#" . "{$Data->InsertName}";
        $ReplyText = T('Reply');
        echo <<<QUOTE
      <span class="CommentReply"><a href="{$ReplyURL}">{$ReplyText}</a></span>
QUOTE;
    }
コード例 #10
0
ファイル: ArticleCtrl.class.php プロジェクト: Jnnock/myyyk
 public function comment()
 {
     if (!empty($_POST)) {
         $_POST['userId'] = $_SESSION['qq']['userId'];
         $arr = $_POST;
         $comment = new CommentModel();
         $row = $comment->addComment($_POST);
         if ($row) {
             $user = new UserModel();
             $arr['addTime'] = data('Y-m-d H:i:s');
             $user = $user->getUser($_POST['userId']);
             $arr['face'] = $user['face'];
             $arr['userName'] = $user['userName'];
             echo json_encode($arr);
         } else {
             exit('发表失败');
         }
     }
 }
コード例 #11
0
 public function countComment($diary_id)
 {
     if (empty(self::$conn)) {
         self::$conn = $this->connectPdo();
     }
     $sql = "SELECT COUNT(content) FROM comment WHERE diary_id=?";
     $stmt = self::$conn->prepare($sql);
     $stmt->bindParam(1, $diary_id);
     $dem = $stmt->execute();
     $dem = $stmt->fetchColumn();
     return $dem;
 }
 public function indexAction()
 {
     if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
         header('Location: /');
         exit;
     } else {
         $id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
     }
     if (CommentModel::exists($this->pdo, $id)) {
         if ($_SESSION['auth']['username'] === CommentModel::getAuthor($this->pdo, $id)) {
             include '../app/views/editcomment.php';
             return;
         }
     } else {
         header('Location: /404');
         exit;
     }
 }
 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: POST');
     $comments = CommentModel::showComments($this->pdo, htmlentities($_POST['id']));
     if (isset($_SESSION['auth'])) {
         $needed = $_SESSION['auth']['username'];
     } else {
         $needed = '';
     }
     for ($i = 0; $i < count($comments); $i++) {
         if ($comments[$i]['author'] == $needed) {
             $comments[$i]['author'] = 'Moi';
         }
     }
     echo json_encode($comments);
 }
 public function indexAction()
 {
     if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
         header('Location: /');
         exit;
     } else {
         $article_id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
     }
     if (CommentModel::exists($this->pdo, $article_id)) {
         if ($_SESSION['auth']['username'] === CommentModel::getAuthor($this->pdo, $article_id) || $_SESSION['auth']['permissions'] === 'superadmin') {
             CommentModel::delete($this->pdo, $article_id);
             header('Location: /');
             exit;
         }
     } else {
         header('Location: /404');
         exit;
     }
 }
コード例 #15
0
ファイル: class.qna.plugin.php プロジェクト: vanilla/addons
 /**
  * Give point(s) to the current user if the right conditions are met.
  *
  * @param CommentModel $sender Sending controller instance.
  * @param array $args Event arguments.
  */
 public function commentModel_afterSaveComment_handler($sender, $args)
 {
     if (!c('QnA.Points.Enabled', false) || !$args['Insert']) {
         return;
     }
     $discussionModel = new DiscussionModel();
     $discussion = $discussionModel->getID($args['CommentData']['DiscussionID'], DATASET_TYPE_ARRAY);
     $isCommentAnAnswer = $discussion['Type'] === 'Question';
     $isQuestionResolved = $discussion['QnA'] === 'Accepted';
     $isCurrentUserOriginalPoster = $discussion['InsertUserID'] == GDN::session()->UserID;
     if (!$isCommentAnAnswer || $isQuestionResolved || $isCurrentUserOriginalPoster) {
         return;
     }
     $userAnswersToQuestion = $sender->getWhere(array('DiscussionID' => $args['CommentData']['DiscussionID'], 'InsertUserId' => GDN::session()->UserID));
     // Award point(s) only for the first answer to the question
     if ($userAnswersToQuestion->count() > 1) {
         return;
     }
     UserModel::givePoints(GDN::session()->UserID, c('QnA.Points.Answer', 1), 'QnA');
 }
コード例 #16
0
 private function getDetails()
 {
     if (isset($_GET['id'])) {
         parent::__construct($this->_tpl, new ContentModel());
         $this->_model->id = $_GET['id'];
         if (!$this->_model->getOneContent()) {
             Tool::alertBack('警告:不存在此文档!');
         }
         $_content = $this->_model->getOneContent();
         $_comment = new CommentModel();
         $_comment->cid = $this->_model->id;
         $_tarArr = explode(',', $_content->tag);
         if (is_array($_tarArr)) {
             foreach ($_tarArr as $_value) {
                 $_content->tag = str_replace($_value, '<a href="search.php?type=3&inputkeyword=' . $_value . '">' . $_value . '</a>', $_content->tag);
             }
         }
         $this->_tpl->assign('id', $_content->id);
         $this->_tpl->assign('titlec', $_content->title);
         $this->_tpl->assign('date', $_content->date);
         $this->_tpl->assign('source', $_content->source);
         $this->_tpl->assign('author', $_content->author);
         $this->_tpl->assign('info', $_content->info);
         $this->_tpl->assign('tag', $_content->tag);
         $this->_tpl->assign('content', Tool::unHtml($_content->content));
         $this->getNav($_content->nav);
         if (IS_CAHCE) {
             $this->_tpl->assign('count', '<script type="text/javascript">getContentCount();</script>');
         } else {
             $this->_tpl->assign('count', $_content->count);
         }
         $this->_tpl->assign('comment', $_comment->getCommentTotal());
         $_object = $_comment->getNewThreeComment();
         if ($_object) {
             foreach ($_object as $_value) {
                 switch ($_value->manner) {
                     case -1:
                         $_value->manner = '反对';
                         break;
                     case 0:
                         $_value->manner = '中立';
                         break;
                     case 1:
                         $_value->manner = '支持';
                         break;
                 }
                 if (empty($_value->face)) {
                     $_value->face = '00.gif';
                 }
                 if (!empty($_value->oppose)) {
                     $_value->oppose = '-' . $_value->oppose;
                 }
             }
         }
         $this->_tpl->assign('NewThreeComment', $_object);
         $this->_model->nav = $_content->nav;
         $_object = $this->_model->getMonthNavRec();
         $this->setObject($_object);
         $this->_tpl->assign('MonthNavRec', $_object);
         $_object = $this->_model->getMonthNavHot();
         $this->setObject($_object);
         $this->_tpl->assign('MonthNavHot', $_object);
         $_object = $this->_model->getMonthNavPic();
         $this->setObject($_object);
         $this->_tpl->assign('MonthNavPic', $_object);
     } else {
         Tool::alertBack('警告:非法操作!');
     }
 }
コード例 #17
0
ファイル: class.hooks.php プロジェクト: ru4/arabbnota
 public function Gdn_Statistics_Tick_Handler($Sender, $Args)
 {
     $Path = GetValue('Path', $Args);
     if (preg_match('`discussion\\/(\\d+)`i', $Path, $Matches)) {
         $DiscussionID = $Matches[1];
     } elseif (preg_match('`discussion\\/comment\\/(\\d+)`i', $Path, $Matches)) {
         $CommentID = $Matches[1];
         $CommentModel = new CommentModel();
         $Comment = $CommentModel->GetID($CommentID);
         $DiscussionID = GetValue('DiscussionID', $Comment);
     }
     if (isset($DiscussionID)) {
         $DiscussionModel = new DiscussionModel();
         $Discussion = $DiscussionModel->GetID($DiscussionID);
         $DiscussionModel->AddView($DiscussionID, GetValue('CountViews', $Discussion));
     }
 }
コード例 #18
0
ファイル: class.hooks.php プロジェクト: vanilla/vanilla
 /**
  * Discussion view counter.
  *
  * @param $Sender
  * @param $Args
  */
 public function gdn_statistics_tick_handler($Sender, $Args)
 {
     $Path = Gdn::request()->post('Path');
     $Args = Gdn::request()->post('Args');
     parse_str($Args, $Args);
     $ResolvedPath = trim(Gdn::request()->post('ResolvedPath'), '/');
     $ResolvedArgs = Gdn::request()->post('ResolvedArgs');
     $DiscussionID = null;
     $DiscussionModel = new DiscussionModel();
     // Comment permalink
     if ($ResolvedPath == 'vanilla/discussion/comment') {
         $CommentID = val('CommentID', $ResolvedArgs);
         $CommentModel = new CommentModel();
         $Comment = $CommentModel->getID($CommentID);
         $DiscussionID = val('DiscussionID', $Comment);
     } elseif ($ResolvedPath == 'vanilla/discussion/index') {
         $DiscussionID = val('DiscussionID', $ResolvedArgs, null);
     } elseif ($ResolvedPath == 'vanilla/discussion/embed') {
         $ForeignID = val('vanilla_identifier', $Args);
         if ($ForeignID) {
             // This will be hit a lot so let's try caching it...
             $Key = "DiscussionID.ForeignID.page.{$ForeignID}";
             $DiscussionID = Gdn::cache()->get($Key);
             if (!$DiscussionID) {
                 $Discussion = $DiscussionModel->getForeignID($ForeignID, 'page');
                 $DiscussionID = val('DiscussionID', $Discussion);
                 Gdn::cache()->store($Key, $DiscussionID, array(Gdn_Cache::FEATURE_EXPIRY, 1800));
             }
         }
     }
     if ($DiscussionID) {
         $DiscussionModel->addView($DiscussionID);
     }
 }
コード例 #19
0
 function __construct($id = 0)
 {
     parent::__construct('bookmarks_comments', 'bookmark_id', $id);
 }
コード例 #20
0
 /**
  * Add a method to the ModerationController to handle merging discussions.
  * @param Gdn_Controller $Sender
  */
 public function ModerationController_MergeDiscussions_Create($Sender)
 {
     $Session = Gdn::Session();
     $Sender->Form = new Gdn_Form();
     $Sender->Title(T('Merge Discussions'));
     $DiscussionModel = new DiscussionModel();
     $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
     if (!is_array($CheckedDiscussions)) {
         $CheckedDiscussions = array();
     }
     $DiscussionIDs = $CheckedDiscussions;
     $Sender->SetData('DiscussionIDs', $DiscussionIDs);
     $CountCheckedDiscussions = count($DiscussionIDs);
     $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
     $Sender->SetData('Discussions', $Discussions);
     // Perform the merge
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
             if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                 $MergeDiscussion = $Discussion;
                 break;
             }
         }
         $RedirectLink = $Sender->Form->GetFormValue('RedirectLink');
         if ($MergeDiscussion) {
             $ErrorCount = 0;
             // Verify that the user has permission to perform the merge.
             $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
             if ($Category && !$Category['PermsDiscussionsEdit']) {
                 throw PermissionException('Vanilla.Discussions.Edit');
             }
             $DiscussionModel->DefineSchema();
             $MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
             // Assign the comments to the new discussion record
             $DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $MergeDiscussionID)->WhereIn('DiscussionID', $DiscussionIDs)->Put();
             $CommentModel = new CommentModel();
             foreach ($Discussions as $Discussion) {
                 if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                     continue;
                 }
                 // Create a comment out of the discussion.
                 $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
                 $Comment['DiscussionID'] = $MergeDiscussionID;
                 $CommentModel->Validation->Results(TRUE);
                 $CommentID = $CommentModel->Save($Comment);
                 if ($CommentID) {
                     // Move any attachments (FileUpload plugin awareness)
                     if (class_exists('MediaModel')) {
                         $MediaModel = new MediaModel();
                         $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                     }
                     if ($RedirectLink) {
                         // The discussion needs to be changed to a moved link.
                         $RedirectDiscussion = array('Name' => SliceString(sprintf(T('Merged: %s'), $Discussion['Name']), $MaxNameLength), 'Type' => 'redirect', 'Body' => FormatString(T('This discussion has been <a href="{url,html}">merged</a>.'), array('url' => DiscussionUrl($MergeDiscussion))), 'Format' => 'Html');
                         $DiscussionModel->SetField($Discussion['DiscussionID'], $RedirectDiscussion);
                         $CommentModel->UpdateCommentCount($Discussion['DiscussionID']);
                         $CommentModel->RemovePageCache($Discussion['DiscussionID']);
                     } else {
                         // Delete discussion that was merged.
                         $DiscussionModel->Delete($Discussion['DiscussionID']);
                     }
                 } else {
                     $Sender->InformMessage($CommentModel->Validation->ResultsText());
                     $ErrorCount++;
                 }
             }
             // Update counts on all affected discussions.
             $CommentModel->UpdateCommentCount($MergeDiscussionID);
             $CommentModel->RemovePageCache($MergeDiscussionID);
             // Clear selections
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($Sender);
             if ($ErrorCount == 0) {
                 $Sender->JsonTarget('', '', 'Refresh');
             }
         }
     }
     $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
コード例 #21
0
ファイル: class.hooks.php プロジェクト: elpum/TgaForumBundle
 public function Gdn_Statistics_Tick_Handler($Sender, $Args)
 {
     $Path = Gdn::Request()->Post('Path');
     $Args = Gdn::Request()->Post('Args');
     parse_str($Args, $Args);
     $ResolvedPath = trim(Gdn::Request()->Post('ResolvedPath'), '/');
     $ResolvedArgs = @json_decode(Gdn::Request()->Post('ResolvedArgs'));
     $DiscussionID = NULL;
     $DiscussionModel = new DiscussionModel();
     //      Gdn::Controller()->SetData('Path', $Path);
     //      Gdn::Controller()->SetData('Args', $Args);
     //      Gdn::Controller()->SetData('ResolvedPath', $ResolvedPath);
     //      Gdn::Controller()->SetData('ResolvedArgs', $ResolvedArgs);
     // Comment permalink
     if ($ResolvedPath == 'vanilla/discussion/comment') {
         $CommentID = GetValue('CommentID', $ResolvedArgs);
         $CommentModel = new CommentModel();
         $Comment = $CommentModel->GetID($CommentID);
         $DiscussionID = GetValue('DiscussionID', $Comment);
     } elseif ($ResolvedPath == 'vanilla/discussion/index') {
         $DiscussionID = GetValue('DiscussionID', $ResolvedArgs, NULL);
     } elseif ($ResolvedPath == 'vanilla/discussion/embed') {
         $ForeignID = GetValue('vanilla_identifier', $Args);
         if ($ForeignID) {
             // This will be hit a lot so let's try caching it...
             $Key = "DiscussionID.ForeignID.page.{$ForeignID}";
             $DiscussionID = Gdn::Cache()->Get($Key);
             if (!$DiscussionID) {
                 $Discussion = $DiscussionModel->GetForeignID($ForeignID, 'page');
                 $DiscussionID = GetValue('DiscussionID', $Discussion);
                 Gdn::Cache()->Store($Key, $DiscussionID, array(Gdn_Cache::FEATURE_EXPIRY, 1800));
             }
         }
     }
     if ($DiscussionID) {
         $DiscussionModel->AddView($DiscussionID);
     }
 }
コード例 #22
0
 /**
  * Add a method to the ModerationController to handle merging discussions.
  * @param Gdn_Controller $Sender
  */
 public function ModerationController_MergeDiscussions_Create($Sender)
 {
     $Session = Gdn::Session();
     $Sender->Form = new Gdn_Form();
     $Sender->Title(T('Merge Discussions'));
     $DiscussionModel = new DiscussionModel();
     $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
     if (!is_array($CheckedDiscussions)) {
         $CheckedDiscussions = array();
     }
     $DiscussionIDs = $CheckedDiscussions;
     $Sender->SetData('DiscussionIDs', $DiscussionIDs);
     $CountCheckedDiscussions = count($DiscussionIDs);
     $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
     $Sender->SetData('Discussions', $Discussions);
     // Perform the merge
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
             if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                 $MergeDiscussion = $Discussion;
                 break;
             }
         }
         if ($MergeDiscussion) {
             $ErrorCount = 0;
             // Verify that the user has permission to perform the merge.
             $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
             if ($Category && !$Category['PermsDiscussionsEdit']) {
                 throw PermissionException('Vanilla.Discussions.Edit');
             }
             // Assign the comments to the new discussion record
             $DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $MergeDiscussionID)->WhereIn('DiscussionID', $DiscussionIDs)->Put();
             $CommentModel = new CommentModel();
             foreach ($Discussions as $Discussion) {
                 if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                     continue;
                 }
                 // Create a comment out of the discussion.
                 $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
                 $Comment['DiscussionID'] = $MergeDiscussionID;
                 $CommentModel->Validation->Results(TRUE);
                 $CommentID = $CommentModel->Save($Comment);
                 if ($CommentID) {
                     // Move any attachments (FileUpload plugin awareness)
                     if (class_exists('MediaModel')) {
                         $MediaModel = new MediaModel();
                         $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                     }
                     // Delete discussion that was merged
                     $DiscussionModel->Delete($Discussion['DiscussionID']);
                 } else {
                     $Sender->InformMessage($CommentModel->Validation->ResultsText());
                     $ErrorCount++;
                 }
             }
             // Update counts on all affected discussions.
             $CommentModel->UpdateCommentCount($MergeDiscussionID);
             $CommentModel->RemovePageCache($MergeDiscussionID);
             // Clear selections
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($Sender);
             if ($ErrorCount == 0) {
                 $Sender->RedirectUrl = Url("/discussion/{$MergeDiscussionID}/" . Gdn_Format::Url($MergeDiscussion['Name']));
             }
         }
     }
     $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
コード例 #23
0
ファイル: default.php プロジェクト: Nordic-T/Nordic-T
 public function DiscussionController_CommentOptions_Handler($Sender)
 {
     $Session = Gdn::Session();
     $User = $Session->User;
     $UID = $User->UserID;
     $DiscussionModel = new DiscussionModel();
     $CommentModel = new CommentModel();
     $Discussion = $DiscussionModel->GetID($DiscussionID);
     if ($Sender->EventArguments['Type'] == 'Discussion') {
         $DiscussionID = $Sender->EventArguments['Discussion']->DiscussionID;
         if ($Sender->Data['Comments'] instanceof Gdn_DataSet) {
             $this->LikeModel->PreloadLikes($Sender->Data['Comments']);
         }
         $ID = $DiscussionID;
         $Model = new DiscussionModel();
         $Data = $Model->GetID($ID);
         $Likes = $this->LikeModel->GetDiscussionLikes($ID);
         $Url = $DiscussionID;
     } else {
         $DiscussionID = $Sender->EventArguments['Object']->DiscussionID;
         $ID = $Sender->EventArguments['Object']->CommentID;
         $Model = new CommentModel();
         $Data = $Model->GetID($ID);
         $Likes = $this->LikeModel->GetCommentLikes($ID);
         $Url = $DiscussionID . '/comment/' . $ID;
     }
     $InsertID = $Data->InsertUserID;
     if ($InsertID == $UID) {
         $Self = TRUE;
     } else {
         $Self = FALSE;
     }
     // Check for permission.
     if (!Gdn::Session()->UserID) {
         $Self = TRUE;
     }
     if (!CheckPermission('Plugins.LikeThis.AllowedToLike')) {
         $Self = TRUE;
     }
     $LikeDisplay = $this->FormatLikes($Likes, $Url, $UID, $Self);
     echo '<span class="Like">' . $LikeDisplay . '</span>';
 }
コード例 #24
0
 /**
  * @desc 分享球员评分
  */
 public function actionPlayerComment()
 {
     $playerId = Yii::app()->request->getQuery('player', '');
     $gameId = Yii::app()->request->getQuery('game', '');
     $playerScoreModel = new PlayerScoreModel();
     $playerScoreData = $playerScoreModel->findCompetitionPlayerScore($playerId, $gameId, 1);
     $playerScore = array();
     if (isset($playerScoreData[0]) && !empty($playerScoreData[0])) {
         $playerScore = $playerScoreData[0];
     }
     $commentModel = new CommentModel();
     $comments = $commentModel->findPlayerComment($playerId, $gameId);
     $this->render('playerComment', array('playerScore' => $playerScore, 'comments' => $comments));
 }
コード例 #25
0
ファイル: functions.general.php プロジェクト: sitexa/vanilla
 /**
  * Get a record from the database.
  *
  * @param string $recordType The type of record to get. This is usually the un-prefixed table name of the record.
  * @param int $id The ID of the record.
  * @param bool $throw Whether or not to throw an exception if the record isn't found.
  * @return array|false Returns an array representation of the record or false if the record isn't found.
  * @throws Exception Throws an exception with a 404 code if the record isn't found and {@link $throw} is true.
  * @throws Gdn_UserException Throws an exception when {@link $recordType} is unknown.
  */
 function getRecord($recordType, $id, $throw = false)
 {
     $Row = false;
     switch (strtolower($recordType)) {
         case 'discussion':
             $Model = new DiscussionModel();
             $Row = $Model->getID($id);
             $Row->Url = DiscussionUrl($Row);
             $Row->ShareUrl = $Row->Url;
             if ($Row) {
                 return (array) $Row;
             }
             break;
         case 'comment':
             $Model = new CommentModel();
             $Row = $Model->getID($id, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Url'] = Url("/discussion/comment/{$id}#Comment_{$id}", true);
                 $Model = new DiscussionModel();
                 $Discussion = $Model->getID($Row['DiscussionID']);
                 if ($Discussion) {
                     $Discussion->Url = DiscussionUrl($Discussion);
                     $Row['ShareUrl'] = $Discussion->Url;
                     $Row['Name'] = $Discussion->Name;
                     $Row['Discussion'] = (array) $Discussion;
                 }
                 return $Row;
             }
             break;
         case 'activity':
             $Model = new ActivityModel();
             $Row = $Model->getID($id, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Name'] = formatString($Row['HeadlineFormat'], $Row);
                 $Row['Body'] = $Row['Story'];
                 return $Row;
             }
             break;
         default:
             throw new Gdn_UserException('Unknown record type requested.');
     }
     if ($throw) {
         throw NotFoundException();
     } else {
         return false;
     }
 }
コード例 #26
0
ファイル: class.replymodel.php プロジェクト: kidmax/Garden
 public function RecordActivity($ReplyCommentID, $ActivityUserID, $CommentID)
 {
     // Get the author of the discussion
     $CommentModel = new CommentModel();
     $Comment = $CommentModel->GetID($ReplyCommentID);
     if ($ActivityUserID != $Comment->InsertUserID) {
         AddActivity($ActivityUserID, 'CommentReply', '', $Comment->InsertUserID, 'discussion/reply/' . $CommentID . '/#Comment_' . $ReplyCommentID);
     }
 }
コード例 #27
0
 /**
  * Modify flow of discussion by pinning accepted answers.
  *
  * @param $Sender
  * @param $Args
  */
 public function DiscussionController_BeforeDiscussionRender_Handler($Sender, $Args)
 {
     if ($Sender->Data('Discussion.QnA')) {
         $Sender->CssClass .= ' Question';
     }
     if (strcasecmp($Sender->Data('Discussion.QnA'), 'Accepted') != 0) {
         return;
     }
     // Find the accepted answer(s) to the question.
     $CommentModel = new CommentModel();
     $Answers = $CommentModel->GetWhere(array('DiscussionID' => $Sender->Data('Discussion.DiscussionID'), 'Qna' => 'Accepted'))->Result();
     if (class_exists('ReplyModel')) {
         $ReplyModel = new ReplyModel();
         $Discussion = NULL;
         $ReplyModel->JoinReplies($Discussion, $Answers);
     }
     $Sender->SetData('Answers', $Answers);
     // Remove the accepted answers from the comments.
     // Allow this to be skipped via config.
     if (C('QnA.AcceptedAnswers.Filter', TRUE)) {
         if (isset($Sender->Data['Comments'])) {
             $Comments = $Sender->Data['Comments']->Result();
             $Comments = array_filter($Comments, function ($Row) {
                 return strcasecmp(GetValue('QnA', $Row), 'accepted');
             });
             $Sender->Data['Comments'] = new Gdn_DataSet(array_values($Comments));
         }
     }
 }
コード例 #28
0
ファイル: baidang.php プロジェクト: NguyenLuong/Diary_Web
<?php

// bai dang lay tu thong bao
session_start();
include '../model/diary_model.php';
include '../model/comment_model.php';
include '../model/notify_model.php';
include '../model/user_model.php';
include '../model/like_model.php';
include '../model/friend_model.php';
$f = new FriendModel();
$l = new LikeModel();
$t = new DIaryModel();
$c = new CommentModel();
$n = new NotifyModel();
$m = new NotifyModel();
$u = new userModel();
$diary_id = $_GET['diary_id'];
$diary = $t->getDiary($diary_id);
$id_notify = $_GET['id_nf'];
$m->notifyReed($id_notify);
include 'header.php';
$i = 0;
?>
  </div>
  </div>
    <div class="container">
  		<?php 
if ($diary == NULL) {
    echo '<div class="well">';
    echo 'bai dang khong hop le </div>';
コード例 #29
0
 /**
  * Handle flagging process in a discussion.
  */
 public function DiscussionController_Flag_Create($Sender)
 {
     if (!C('Plugins.Flagging.Enabled')) {
         return;
     }
     // Signed in users only.
     if (!($UserID = Gdn::Session()->UserID)) {
         return;
     }
     $UserName = Gdn::Session()->User->Name;
     $Arguments = $Sender->RequestArgs;
     if (sizeof($Arguments) != 5) {
         return;
     }
     list($Context, $ElementID, $ElementAuthorID, $ElementAuthor, $EncodedURL) = $Arguments;
     $URL = base64_decode(str_replace('-', '=', $EncodedURL));
     $Sender->SetData('Plugin.Flagging.Data', array('Context' => $Context, 'ElementID' => $ElementID, 'ElementAuthorID' => $ElementAuthorID, 'ElementAuthor' => $ElementAuthor, 'URL' => $URL, 'UserID' => $UserID, 'UserName' => $UserName));
     if ($Sender->Form->AuthenticatedPostBack()) {
         $SQL = Gdn::SQL();
         $Comment = $Sender->Form->GetValue('Plugin.Flagging.Reason');
         $Sender->SetData('Plugin.Flagging.Reason', $Comment);
         $CreateDiscussion = C('Plugins.Flagging.UseDiscussions');
         if ($CreateDiscussion) {
             // Category
             $CategoryID = C('Plugins.Flagging.CategoryID');
             // New discussion name
             if ($Context == 'comment') {
                 $Result = $SQL->Select('d.Name')->Select('c.Body')->From('Comment c')->Join('Discussion d', 'd.DiscussionID = c.DiscussionID', 'left')->Where('c.CommentID', $ElementID)->Get()->FirstRow();
             } elseif ($Context == 'discussion') {
                 $DiscussionModel = new DiscussionModel();
                 $Result = $DiscussionModel->GetID($ElementID);
             }
             $DiscussionName = GetValue('Name', $Result);
             $PrefixedDiscussionName = T('FlagPrefix', 'FLAG: ') . $DiscussionName;
             // Prep data for the template
             $Sender->SetData('Plugin.Flagging.Report', array('DiscussionName' => $DiscussionName, 'FlaggedContent' => GetValue('Body', $Result)));
             // Assume no discussion exists
             $this->DiscussionID = NULL;
             // Get discussion ID if already flagged
             $FlagResult = Gdn::SQL()->Select('DiscussionID')->From('Flag fl')->Where('ForeignType', $Context)->Where('ForeignID', $ElementID)->Get()->FirstRow();
             if ($FlagResult) {
                 // New comment in existing discussion
                 $DiscussionID = $FlagResult->DiscussionID;
                 $ReportBody = $Sender->FetchView($this->GetView('reportcomment.php'));
                 $SQL->Insert('Comment', array('DiscussionID' => $DiscussionID, 'InsertUserID' => $UserID, 'Body' => $ReportBody, 'Format' => 'Html', 'DateInserted' => date('Y-m-d H:i:s')));
                 $CommentModel = new CommentModel();
                 $CommentModel->UpdateCommentCount($DiscussionID);
             } else {
                 // New discussion body
                 $ReportBody = $Sender->FetchView($this->GetView('report.php'));
                 $DiscussionID = $SQL->Insert('Discussion', array('InsertUserID' => $UserID, 'UpdateUserID' => $UserID, 'CategoryID' => $CategoryID, 'Name' => $PrefixedDiscussionName, 'Body' => $ReportBody, 'Format' => 'Html', 'CountComments' => 1, 'DateInserted' => date('Y-m-d H:i:s'), 'DateUpdated' => date('Y-m-d H:i:s'), 'DateLastComment' => date('Y-m-d H:i:s')));
                 // Update discussion count
                 $DiscussionModel = new DiscussionModel();
                 $DiscussionModel->UpdateDiscussionCount($CategoryID);
             }
         }
         try {
             // Insert the flag
             $SQL->Insert('Flag', array('DiscussionID' => $DiscussionID, 'InsertUserID' => $UserID, 'InsertName' => $UserName, 'AuthorID' => $ElementAuthorID, 'AuthorName' => $ElementAuthor, 'ForeignURL' => $URL, 'ForeignID' => $ElementID, 'ForeignType' => $Context, 'Comment' => $Comment, 'DateInserted' => date('Y-m-d H:i:s')));
         } catch (Exception $e) {
         }
         // Notify users with permission who've chosen to be notified
         if (!$FlagResult) {
             // Only send if this is first time it's being flagged.
             $Sender->SetData('Plugin.Flagging.DiscussionID', $DiscussionID);
             $Subject = isset($PrefixedDiscussionName) ? $PrefixedDiscussionName : T('FlagDiscussion', 'A discussion was flagged');
             $EmailBody = $Sender->FetchView($this->GetView('reportemail.php'));
             $NotifyUsers = C('Plugins.Flagging.NotifyUsers', array());
             // Send emails
             $UserModel = new UserModel();
             foreach ($NotifyUsers as $UserID) {
                 $User = $UserModel->GetID($UserID);
                 $Email = new Gdn_Email();
                 $Email->To($User->Email)->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $Subject))->Message($EmailBody)->Send();
             }
         }
         $Sender->InformMessage(T('FlagSent', "Your complaint has been registered."));
     }
     $Sender->Render($this->GetView('flag.php'));
 }
コード例 #30
0
ファイル: SocialCommentModel.php プロジェクト: amanai/next24
 function __construct($id = 0)
 {
     parent::__construct('social_comments', 'social_pos_id', $id);
 }