public function run() { $controller = $this->getController(); $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Comments') . ' - ' . $controller->_setting['site_name']; //我的评论 $uid = Yii::app()->user->id; $comment_mod = new Comment(); $criteria = new CDbCriteria(); $criteria->addColumnCondition(array('t.user_id' => $uid)); $criteria->order = 't.id DESC'; //分页 $count = $comment_mod->count($criteria); $pages = new CPagination($count); $pages->pageSize = 15; $pages->applyLimit($criteria); $datalist = $comment_mod->findAll($criteria); foreach ((array) $datalist as $k => $v) { $c_mod_class = $controller->_content_models[$v->type]; $c_mod_name = strtolower($c_mod_class); $content_mod = new $c_mod_class(); $content = $content_mod->findByPk($v->content_id); $datalist[$k]['title'] = $content->title; $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $content->id)); } $controller->render('my_comments', array('datalist' => $datalist, 'pages' => $pages)); }
/** * 评论管理 * */ public function actionIndex() { $this->_model_type = ModelType::model()->findAll(); $model = new Comment(); $criteria = new CDbCriteria(); $condition = '1'; $status = $this->_request->getParam('status'); $title = $this->_request->getParam('postTitle'); $content = $this->_request->getParam('content'); $type = $this->_request->getParam('type') ? $this->_request->getParam('type') : $this->_type_ids['post']; $type && ($condition .= " AND type={$type}"); $status && ($condition .= " AND t.status='{$status}'"); $table = array_search($type, $this->_type_ids); if ($table == 'goods') { $title && ($condition .= " AND {$table}.goods_name LIKE '%{$title} %'"); } else { $title && ($condition .= " AND {$table}.title LIKE '%{$title} %'"); } $content && ($condition .= ' AND t.content LIKE \'%' . $content . '%\''); $criteria->condition = $condition; $criteria->order = 't.id DESC'; $criteria->with = array($table); $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 13; $pageParams = $this->buildCondition($_GET, array('postTitle', 'status', 'content', 'type')); $pages->params = is_array($pageParams) ? $pageParams : array(); $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END); $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'table' => $table)); }
public function index($request) { $data = []; $counts = []; $counts['videos'] = Video::count(); $counts['users'] = User::count(); $counts['channels'] = UserChannel::count(); $counts['comments'] = Comment::count(); $counts['total_views'] = Video::sumViews(); $counts['channel_user_ratio'] = round($counts['channels'] / $counts['users'], 2); $counts['videos_that_has_comments'] = Statistic::countVideosHavingComments(); $counts['channels_having_videos'] = Video::find_by_sql('SELECT count(DISTINCT poster_id) as count from `videos`')[0]->count; $counts['part_of_commented_videos'] = round($counts['videos_that_has_comments'] / $counts['videos'] * 100, 2); $counts['part_of_channels_having_videos'] = round($counts['channels_having_videos'] / $counts['channels'] * 100, 2); $counts['user_1_channel'] = Statistic::countUserHavingChannels('= 1'); $counts['user_2_channel'] = Statistic::countUserHavingChannels('= 2'); $counts['user_3_channel'] = Statistic::countUserHavingChannels('= 3'); $counts['user_more3_channel'] = Statistic::countUserHavingChannels('> 3'); $counts['user_1_channel_part'] = round($counts['user_1_channel'] / $counts['users'] * 100, 2); $counts['user_2_channel_part'] = round($counts['user_2_channel'] / $counts['users'] * 100, 2); $counts['user_3_channel_part'] = round($counts['user_3_channel'] / $counts['users'] * 100, 2); $counts['user_more3_channel_part'] = round($counts['user_more3_channel'] / $counts['users'] * 100, 2); $data['counts'] = $counts; return new ViewResponse('admin/statistic/index', $data); }
private function admin() { $today = strtotime('today'); $month = strtotime('first day of this month'); $last30 = strtotime('-30 days'); // Users statistics $users['today'] = number_format(User::whereGt('reg_date', $today)->count()); $users['month'] = number_format(User::whereGt('reg_date', $month)->count()); $users['last30'] = number_format(User::whereGt('reg_date', $last30)->count()); $users['total'] = number_format(User::count()); View::set('users', $users); // Playlists statistics $playlists['today'] = number_format(Playlist::whereGt('date', $today)->count()); $playlists['month'] = number_format(Playlist::whereGt('date', $month)->count()); $playlists['last30'] = number_format(Playlist::whereGt('date', $last30)->count()); $playlists['total'] = number_format(Playlist::count()); View::set('playlists', $playlists); // Tracks statistics $tracks = number_format(Track::count()); View::set('tracks', $tracks); // Tags statistics $tags = number_format(Tag::count()); View::set('tags', $tags); // Comments statistics $comments = number_format(Comment::count()); View::set('comments', $comments); // Likes $likes = number_format(PlaylistLike::count()); View::set('likes', $likes); // Reports $reports = number_format(Report::count()); View::set('reports', $reports); View::show('admin/admin'); }
public function run() { $model = new Comment(); //条件 $criteria = new CDbCriteria(); $type = trim(Yii::app()->request->getParam('type')); $type && $criteria->addColumnCondition(array('type' => $type)); $status = trim(Yii::app()->request->getParam('status')); $status && $criteria->addColumnCondition(array('status' => $status)); $title = trim(Yii::app()->request->getParam('content')); $title && $criteria->addSearchCondition('content', $title); $criteria->order = 't.id DESC'; $count = $model->count($criteria); //分页 $pages = new CPagination($count); $pages->pageSize = 10; $pages->applyLimit($criteria); //查询 $result = $model->findAll($criteria); //全部类型 $model_types = ModelType::model()->findAll(); Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css"); Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END); $this->controller->render('index', array('model' => $model, 'model_types' => $model_types, 'datalist' => $result, 'pagebar' => $pages)); }
public function run() { $controller = $this->getController(); $this->_setting = $controller->_setting; $this->_stylePath = $controller->_stylePath; $this->_static_public = $controller->_static_public; $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Comments') . ' - ' . $this->_setting['site_name']; //加载css,js Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/user.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js"); //我的评论 $uid = Yii::app()->user->id; $comment_mod = new Comment(); $model_type = new ModelType(); $uid = Yii::app()->user->id; $criteria = new CDbCriteria(); $criteria->condition = 't.user_id=' . $uid; $criteria->order = 't.id DESC'; //分页 $count = $comment_mod->count($criteria); $pages = new CPagination($count); $pages->pageSize = 15; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $datalist = $comment_mod->findAll($criteria); foreach ((array) $datalist as $k => $v) { $c_mod_class = $controller->_content_models[$v->type]; $c_mod_name = strtolower($c_mod_class); $content_mod = new $c_mod_class(); $content = $content_mod->findByPk($v->topic_id); $datalist[$k]['title'] = $content->title; $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $content->id)); } $controller->render('my_comments', array('datalist' => $datalist)); }
public function index($request) { $appConfig = new Config(CONFIG . 'app.json'); $appConfig->parseFile(); $data = []; $data['stats'] = ["videos_suspended" => ["Vidéo(s) suspendue(s)", Video::getSizeOfSuspendedVideos(), 'videos/suspended'], "videos_flagged" => ["Vidéo(s) reportée(s)", Video::getSizeOfReportedVideos(), 'videos/reported'], "comments_flagged" => ["Commentaire(s) reporté(s)", Comment::count(['flagged' => 1]), 'comments']]; $data['view_icons'] = ["videos_suspended" => ["fa-ban", "fa-video-camera"], "videos_flagged" => ["fa-flag", "fa-video-camera"], "comments_flagged" => ["fa-flag", "fa-comments"]]; $data['view_colors'] = ["videos_suspended" => "red", "videos_flagged" => "yellow", "comments_flagged" => "yellow"]; return new ViewResponse('admin/moderation/index', $data); }
function smarty_function_mtentrycommentcount($args, &$ctx) { $entry = $ctx->stash('entry'); if (isset($args['top']) and $args['top'] == 1) { $where = "(comment_parent_id is NULL\n or comment_parent_id = 0)\n and comment_visible = 1 \n and comment_entry_id = " . $entry->entry_id; require_once 'class.mt_comment.php'; $comment = new Comment(); $count = $comment->count(array('where' => $where)); } else { $count = $entry->entry_comment_count; } return $ctx->count_format($count, $args); }
function execute() { global $wgUser, $wgOut, $wgVoteDirectory, $wgCommentsDirectory, $IP; require_once "{$wgVoteDirectory}/VoteClass.php"; require_once "{$wgVoteDirectory}/Publish.php"; require_once "{$wgVoteDirectory}/RSS.php"; require_once "{$wgCommentsDirectory}/CommentClass.php"; if ($_POST["mk"] == md5($_POST["pid"] . 'pants' . $wgUser->mName)) { require_once "{$IP}/extensions/UserStats/UserStatsClass.php"; $stats = new UserStatsTrack(1, $wgUser->mId, $wgUser->mName); if (($_GET["Action"] == 1 || $_GET["Action"] == 2) && is_numeric($_POST["pid"]) && (is_numeric($_POST["TheVote"]) || $_GET["Action"] == 2)) { //echo 'test2'; $Vote = new Vote($_POST["pid"]); $Vote->setUser($wgUser->mName, $wgUser->mId); if ($_GET["Action"] == 1) { $Vote->insert($_POST["TheVote"]); $stats->incVoteCount(); } else { $Vote->delete(); } $CommentList = new Comment($_POST["pid"]); $publish = new Publish(); $publish->PageID = $_POST["pid"]; $publish->VoteCount = $Vote->count(1); $publish->CommentCount = $CommentList->count(); $publish->check_score(); echo $Vote->count(1); } if ($_GET["Action"] == 3) { $Vote = new VoteStars($_POST["pid"]); $Vote->setUser($wgUser->mName, $wgUser->mId); $Vote->insert($_POST["TheVote"]); $stats->incVoteCount(); echo $Vote->display(); } if ($_GET["Action"] == 4) { $Vote = new VoteStars($_POST["pid"]); $Vote->setUser($wgUser->mName, $wgUser->mId); $Vote->delete(); echo $Vote->display(); } } // This line removes the navigation and everything else from the // page, if you don't set it, you get what looks like a regular wiki // page, with the body you defined above. $wgOut->setArticleBodyOnly(true); }
function index($name) { $a = new Account(); if ($name != "") { $c = new Campaign(); $c->where('nickname', $name)->get(); if ($c->id > 0) { $data['campaign_id'] = $c->id; $data['name'] = $c->name; $data['description'] = $c->description; $data['photo'] = $c->photo; $data['countryid'] = $c->countryid; $data['categoryid'] = $c->categoryid; $data['isInfo'] = $c->isInfo; $data['title'] = $c->name; /* * get comments for the campaign */ $com = new Comment(); $com->where('campaign_id', $c->id)->get(); //$comments = new ArrayObject(); $commentsStr = "["; $flag = 0; foreach ($com->all as $comment) { $usr = new Account(); $usr->where('id', $comment->user_id)->get(); $preCom = "<img src = '" . base_url() . "/images/profile/" . $usr->photo . "' align='left'><i>says </i>"; if ($flag) { $commentsStr = $commentsStr . ","; } $flag = 1; $commentsStr = $commentsStr . "\"" . $preCom . $comment->comment . "\""; //$data['comments'][] = $comment->comment; //$data['comments_uid'][] = $comment->user_id; } $commentsStr = $commentsStr . "]"; $data['commentsStr'] = $commentsStr; $data['commentsNum'] = $com->count(); } } $data['a'] = $a; $_SESSION['url'] = site_url('destination/index/' . $name); $this->load->view('destination', $data); }
/** * Comments list * * @param $request * @return mixed */ public function comments_list($request) { // Delete page if ($request->get('delete')) { $delete = $request->get('delete'); if ($delete != 'all') { $comment = \Comment::find_by_id(intval($delete)); if ($comment) { // Delete child comments \Comment::table()->delete('parent_id = ' . $comment->id); if ($comment->delete()) { $this->view->assign('message', $this->lang->translate('form.deleted')); } } } else { \Comment::table()->delete('1'); $this->view->assign('message', $this->lang->translate('form.deleted')); } } // Filter $filter = []; if ($request->get('author')) { $author = \User::find($request->get('author')); if ($author) { $filter['conditions'] = ['author_id = ?', $author->id]; } } $filter['order'] = 'id DESC'; if ($request->order) { $filter['order'] = $request->order; } /** @var Listing $paginator */ $paginator = NCService::load('Paginator.Listing', [$request->page, \Comment::count('all')]); $filter = array_merge($filter, $paginator->limit()); // Filter users $comments = \Comment::all($filter); $comments = \Comment::as_array($comments); return $this->view->render('comment/list.twig', ['title' => $this->lang->translate('comment.list'), 'comments_list' => $comments, 'listing' => $paginator->pages(), 'page' => $paginator->cur_page]); }
/** * Count the comments that are related to this download. * * @return int */ public function countComments() { return Comment::count('downloads', $this->id); }
/** * Count the comments that are related to this video. * * @return int */ public function countComments() { return Comment::count('videos', $this->id); }
public function run() { $this->controller->layout = false; $view_url = Yii::app()->request->getParam('view_url'); $content_id = Yii::app()->request->getParam('content_id'); $topic_type = Yii::app()->request->getParam('topic_type'); $cur_url = Yii::app()->request->hostinfo . Yii::app()->request->getUrl(); $post = false; //评论类型 switch ($topic_type) { case 'post': $post = Post::model()->findByPk($content_id); break; case 'image': $post = Image::model()->findByPk($content_id); break; case 'soft': $post = Soft::model()->findByPk($content_id); break; case 'video': $post = Video::model()->findByPk($content_id); break; } if (!$post) { throw new CHttpException(404, Yii::t('admin', 'Loading Error')); } //评论内容 $model = new Comment('create'); $criteria = new CDbCriteria(); $criteria->with = array('user'); $criteria->addColumnCondition(array('content_id' => $content_id)); $criteria->addColumnCondition(array('t.status' => Comment::STATUS_SHOW)); $criteria->addColumnCondition(array('type' => $this->controller->_type_ids[$topic_type])); $criteria->addCondition('u.uid > 0'); $criteria->order = 't.id DESC'; $criteria->select = 't.id, user_id, content_id, content, t.create_time '; //分页 $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $comments = $model->findAll($criteria); //回复 if ($comments) { foreach ($comments as $c) { $replies[$c->id] = Reply::model()->with('user')->findAll(array('condition' => 'cid = ' . $c->id . ' AND t.status = "' . Reply::STATUS_SHOW . '" AND u.uid > 0', 'order' => 'id')); } } else { $comments = array(); $replies = array(); } if (Yii::app()->request->isPostRequest) { $uid = Yii::app()->user->id; if (!$uid) { $this->message('script', Yii::t('common', 'You Need Login')); } $model->attributes = $_POST['Comment']; $model->content_id = $content_id; $model->type = $this->controller->_type_ids[$topic_type]; $model->user_id = $uid; $model->status = 'N'; $model->client_ip = Yii::app()->request->userHostAddress; $model->create_time = time(); $ret_url = $_POST['ret_url']; if ($model->save()) { $this->controller->message('script', Yii::t('common', 'Submit Success, Waiting Pass'), $ret_url); } } $data = array('model' => $model, 'view_url' => $view_url, 'cur_url' => $cur_url, 'comments' => $comments, 'pagebar' => $pages, 'replies' => $replies); $this->controller->render('create', $data); }
public function category_comment_count($args) { $cat_id = intval($args['category_id']); $where = "placement_category_id = {$cat_id}\n and entry_status=2\n and comment_visible=1"; $join['mt_entry'] = array('condition' => 'comment_entry_id = entry_id'); $join['mt_placement'] = array('condition' => 'entry_id = placement_entry_id'); require_once 'class.mt_comment.php'; $comment = new Comment(); $result = $comment->count(array('where' => $where, 'join' => $join)); return $result; }
/** * Count the comments that are related to this video. * * @return int */ public function countComments() { return Comment::count('streams', $this->id); }
/** * 提交评论 * * @return [type] [description] */ public function actionCreate() { $this->layout = false; $view_url = $this->_request->getParam('view_url'); $topic_id = $this->_request->getParam('topic_id'); $topic_type = $this->_request->getParam('topic_type'); $cur_url = $this->_request->hostinfo . $this->_request->getUrl(); $post = false; //评论类型 switch ($topic_type) { case 'post': $post = Post::model()->findByPk($topic_id); break; case 'image': $post = Image::model()->findByPk($topic_id); break; case 'soft': $post = Soft::model()->findByPk($topic_id); break; case 'video': $post = Video::model()->findByPk($topic_id); break; } if (!$post) { throw new CHttpException(404, Yii::t('admin', 'Submit Error')); break; } //评论内容 $model = new Comment('create'); $criteria = new CDbCriteria(); $condition = "topic_id={$topic_id} AND status='Y' AND type={$this->_type_ids[$topic_type]}"; $criteria->condition = $condition; $criteria->order = 'id DESC'; $criteria->select = "id, user_id, topic_id, content, create_time "; //分页 $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $comments = $model->findAll($criteria); //回复 if ($comments) { foreach ((array) $comments as $c) { $replies[$c->id] = Reply::model()->findAll('cid=:cid AND status=:status ORDER BY id', array(':cid' => $c->id, ':status' => 'Y')); } } //加载css,js Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/comment.css"); Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END); if ($this->_request->isPostRequest) { $uid = Yii::app()->user->id; if (!$uid) { $this->message('script', Yii::t('common', 'You Need Login')); } $model->attributes = $_POST['Comment']; $model->topic_id = $topic_id; $model->type = $this->_type_ids[$topic_type]; $model->user_id = $uid; $model->status = 'N'; $model->client_ip = $this->_request->userHostAddress; $model->create_time = time(); $ret_url = $_POST['ret_url']; if ($model->save()) { $this->message('script', Yii::t('common', 'Submit Success, Waiting Pass'), $ret_url); //$this->redirect($ret_url); } } $data = array('model' => $model, 'view_url' => $view_url, 'cur_url' => $cur_url, 'comments' => $comments, 'pagebar' => $pages, 'replies' => $replies); $this->render('create', $data); }
function displayComments($video, $parent, $i) { $comments = $video->getComments($parent); if (empty($comments)) { ?> <p>Aucun commentaire à propos de cette video</p> <?php } foreach ($comments as $comment) { $comment->comment = Utils::makeLinks(Utils::secure($comment->comment)); $margin = $i * 8; ?> <div style="width: <?php echo 100 - $margin; ?> %; margin-left:<?php echo $margin; ?> %" class="comment" id="c-<?php echo $comment->id; ?> "> <div class="comment-head"> <div class="user"> <img src="<?php echo UserChannel::find($comment->poster_id)->getAvatar(); ?> " alt="[Avatar]"> <a href="<?php echo WEBROOT . 'channel/' . UserChannel::find($comment->poster_id)->name; ?> "><?php echo UserChannel::getNameById($comment->poster_id); ?> </a> </div> <div class="date"> <p><?php echo Utils::relative_time($comment->timestamp); echo $comment->last_updated_timestamp ? ' (Edité ' . Utils::relative_time($comment->last_updated_timestamp) . ')' : ''; ?> </p> </div> </div> <div class="comment-text"> <p style="word-wrap:break-word"><?php echo $comment->comment; ?> </p> </div> <div class="comment-notation"> <ul> <li class="plus" id="plus-<?php echo $comment->id; ?> " onclick="likeComment('<?php echo $comment->id; ?> ')">+<?php echo $comment->likes; ?> </li> <li class="moins" id="moins-<?php echo $comment->id; ?> " onclick="dislikeComment('<?php echo $comment->id; ?> ')">-<?php echo $comment->dislikes; ?> </li> <li onclick="reportComment('<?php echo $comment->id; ?> ', this)" style="cursor:pointer">Signaler</li> <li onclick="document.location.href='#comments';document.getElementById('response').innerHTML='<b>Répondre à <?php echo UserChannel::getNameById($comment->poster_id); ?> :</b>';document.getElementById('textarea-comment').focus();document.getElementById('parent-comment').value='<?php echo $comment->id; ?> ';" style="cursor:pointer">Répondre</li> <?php if (Session::isActive() && (Session::get()->isModerator() || Session::get()->isAdmin() || $comment->getAuthor()->belongToUser(Session::get()->id))) { ?> <li onclick="editComment('<?php echo $comment->id; ?> ', this)" style="cursor:pointer">Editer</li> <?php } ?> <?php if (Session::isActive() && (Session::get()->isModerator() || Session::get()->isAdmin() || $video->getAuthor()->belongToUser(Session::get()->id) || $comment->getAuthor()->belongToUser(Session::get()->id))) { ?> <li onclick="deleteComment('<?php echo $comment->id; ?> ', this)" style="cursor:pointer">Supprimer</li> <?php } ?> </ul> </div> </div> <?php if (Comment::count(array('conditions' => array('parent = ?', $comment->id))) >= 1) { displayComments($video, $comment->id, $i + 1); } } }
/** * Comments list * * @param $request * @param $matches * @return mixed */ public function comments_list($request, $matches) { $post = trim($this->view->get('com', $matches->get('post'))); $filter = ['conditions' => ['post = ?', $post], 'order' => 'created_at DESC']; /** @var Listing $paginator */ $paginator = NCService::load('Paginator.Listing', [$request->page, \Comment::count($filter)]); $filter = array_merge($filter, $paginator->limit()); // Comments $comments = \Comment::find('all', $filter); $comments = \Comment::as_array($comments); // Context $context = ['com' => $post, 'comments' => $comments, 'page' => $paginator->cur_page, 'listing' => $paginator->pages()]; // Add comment status if ($status = $this->view->get('status', false)) { $context['status'] = $status; } // Build response if ($request->get('type', 'html') == 'json') { unset($context['listing']); $context['pages'] = $paginator->pages; $context['rows'] = $paginator->num_rows; return static::json_response($context); } return $this->view->render('comment/list.twig', $context); }
/** * Count the comments that are related to this match. * * @return int */ public function countComments() { return Comment::count('match', $this->id); }
"> <?php echo PostVotes::count(array('conditions' => array("user_id = {$user->id} AND score = {$i}"))); ?> <span class="score-on score-voted score-visible">★</span> </a> <?php } ?> </span> </td> </tr> <tr> <td><strong>Comments</strong></td> <td><?php echo link_to(Comment::count(array('conditions' => "user_id = {$user->id}")), array('comment#search', 'query' => "user:{$user->name}")); ?> </td> </tr> <tr> <td><strong>Edits</strong></td> <td>0<?php //echo link_to History.count(:all, :conditions => "user_id = #{@user.id}"), :controller => "history", :action => "index", :search => "user:#{@user.name}" ?> </td> </tr> <tr> <td><strong>Tag Edits</strong></td> <td>0<?php //echo link_to History.count(:all, :conditions => "user_id = #{@user.id} AND group_by_table = 'posts'"), :controller => "history", :action => "post", :search => "user:#{@user.name}" ?>
function execute() { global $wgUser, $wgOut, $wgVoteDirectory, $IP; require_once 'CommentClass.php'; require_once "{$wgVoteDirectory}/VoteClass.php"; require_once "{$wgVoteDirectory}/Publish.php"; require_once "{$IP}/extensions/UserStats/UserStatsClass.php"; $stats = new UserStatsTrack(1, $wgUser->mId, $wgUser->mName); // Vote for a Comment if ($_POST["mk"] == md5($_POST["cid"] . 'pants' . $wgUser->mName)) { if (is_numeric($_GET["Action"]) && $_GET["Action"] == 1 && is_numeric($_POST["cid"])) { if (is_numeric($_POST["cid"]) && is_numeric($_POST["vt"])) { $dbr =& wfGetDB(DB_MASTER); $sql = "SELECT comment_page_id,comment_user_id, comment_username FROM Comments WHERE CommentID = " . $_POST["cid"]; $res = $dbr->query($sql); $row = $dbr->fetchObject($res); if ($row) { $PageID = $row->comment_page_id; $Comment = new Comment($PageID); $Comment->setUser($wgUser->mName, $wgUser->mId); $Comment->CommentID = $_POST["cid"]; $Comment->setCommentVote($_POST["vt"]); $Comment->setVoting($_POST["vg"]); $Comment->addVote(); $out = $Comment->getCommentScore(); //must update stats for user doing the voting $stats->incCommentScoreGiven($_POST["vt"]); //also must update the stats for user receiving the vote $stats_comment_owner = new UserStatsTrack(1, $row->comment_user_id, $row->comment_username); $stats_comment_owner->updateCommentScoreRec($_POST["vt"]); echo $out; } } } } // get new Comment list if (is_numeric($_GET["Action"]) && $_GET["Action"] == 2 && is_numeric($_POST["pid"])) { $Comment = new Comment($_POST["pid"]); $Comment->setUser($wgUser->mName, $wgUser->mId); $Comment->setOrderBy($_POST["ord"]); if ($_POST["shwform"] == 1) { $output .= $Comment->displayOrderForm(); } $output .= $Comment->display(); if ($_POST["shwform"] == 1) { $output .= $Comment->diplayForm(); } echo $output; } if ($_POST['ct'] != "" && is_numeric($_GET["Action"]) && $_GET["Action"] == 3) { $input = $_POST['ct']; $host = $_SERVER['SERVER_NAME']; $input = str_replace($host, "", $input); $AddComment = true; if ($AddComment == true) { $Comment = new Comment($_POST["pid"]); $Comment->setUser($wgUser->mName, $wgUser->mId); $Comment->setCommentText($_POST['ct']); $Comment->setCommentParentID($_POST['par']); $Comment->add(); //$stats->incCommentCount(); //score check after comment add $Vote = new Vote($_POST["pid"]); $publish = new Publish(); $publish->PageID = $_POST["pid"]; $publish->VoteCount = $Vote->count(1); $publish->CommentCount = $Comment->count(); $publish->check_score(); } } if (is_numeric($_GET["Action"]) && $_GET["Action"] == 4 && is_numeric($_GET["pid"])) { $Comment = new Comment($_GET["pid"]); $Comment->setUser($wgUser->mName, $wgUser->mId); echo $Comment->getLatestCommentID(); } // This line removes the navigation and everything else from the // page, if you don't set it, you get what looks like a regular wiki // page, with the body you defined above. $wgOut->setArticleBodyOnly(true); }
<?php if (User::is('<=20') && Request::$params->commit == "Post" && Comment::count(array('conditions' => array("user_id = ? AND created_at > ?", User::$current->id, gmd_math('sub', '1H'))) >= CONFIG::member_comment_limit)) { # TODO: move this to the model respond_to_error("Hourly limit exceeded", "#index", array('status' => 421)); } $user_id = User::$current->id; Request::$params->comment = array_merge(Request::$params->comment, array('ip_addr' => Request::$remote_ip, 'user_id' => $user_id)); // $comment = new Comment('empty', Request::$params->comment); $comment = Comment::blank(Request::$params->comment); // vde(Request::$params->comment); // vde($comment); if (Request::$params->commit == "Post without bumping") { $comment->do_not_bump_post = true; } if ($comment->save()) { respond_to_success("Comment created", "#index"); } else { respond_to_error($comment, "#index"); }