当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::add方法代码示例

本文整理汇总了PHP中Comment::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::add方法的具体用法?PHP Comment::add怎么用?PHP Comment::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comment的用法示例。


在下文中一共展示了Comment::add方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wfCommentSubmit

function wfCommentSubmit($page_id, $parent_id, $comment_text)
{
    global $wgUser;
    // Blocked users cannot submit new comments
    if ($wgUser->isBlocked()) {
        return '';
    }
    if ($comment_text != '') {
        $comment = new Comment($page_id);
        $comment->setCommentText($comment_text);
        $comment->setCommentParentID($parent_id);
        $comment->add();
        if (class_exists('UserStatsTrack')) {
            $stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName());
            $stats->incStatField('comment');
        }
    }
    return 'ok';
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:Comments_AjaxFunctions.php

示例2: addComment

 public function addComment()
 {
     if (isset($this->params[0])) {
         $alias = strtolower($this->params[0]);
         $page = $this->model->getByAlias($alias);
     } else {
         Router::redirect('/');
     }
     $page_id = $page['id'];
     $comments_model = new Comment();
     $comment_id = $comments_model->add($page_id, $_POST);
     if ($comment_id) {
         // Выводим обратно блок с комментарием
         ob_start();
         $comment = $comments_model->getById($comment_id);
         include VIEWS_PATH . DS . 'helpers' . DS . 'comment.html';
         $result = ob_get_clean();
         echo $result;
     } else {
         echo "Ошибка!!!";
     }
     exit;
 }
开发者ID:oleg-shumar,项目名称:php-academy.kiev.ua,代码行数:23,代码来源:pages.controller.php

示例3: add

 function add()
 {
     // Check necessary vars are present
     if (isset($_POST['item_id']) && $_POST['content'] != '') {
         // Add comment
         $comment_id = Comment::add($_SESSION['user_id'], $_POST['item_id'], $_POST['content']);
         $item = Item::get_by_id($_POST['item_id']);
         if ($item->user->email_notifications['item_comment']) {
             $to = array('name' => $item->user->username, 'email' => $item->user->email);
             $subject = '[' . $this->config->name . '] Someone left a ' . strtolower($this->config->items->comments->name) . ' on your ' . strtolower($this->config->items->titles->name) . ' on ' . $this->config->name . '!';
             $link = substr($this->config->url, 0, -1) . $this->url_for('items', 'show', $item->id);
             $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/item_comment.html"), array('link' => $link, 'app' => $this, 'user' => $item->user));
             // Email user
             $this->email->send_email($to, $subject, $body);
         }
         // Log new comment
         if (isset($this->plugins->log)) {
             $this->plugins->log->add($_SESSION['user_id'], 'comment', $comment_id, 'add', $_POST['content']);
         }
     }
     // Return comments for the relevant item
     $this->show($_POST['item_id']);
 }
开发者ID:Geekathon,项目名称:rat,代码行数:23,代码来源:comments_controller.php

示例4: add

 /**
  * 添加评论 
  */
 public function add()
 {
     if (IS_POST) {
         foreach ($_POST as $k => $v) {
             $_POST[$k] = Input::hsc($v);
         }
         $catid = (int) $_POST['comment_catid'];
         $id = (int) $_POST['comment_id'];
         if ($this->comoff($catid, $id) == false) {
             $this->error("该信息不允许评论!");
         }
         $co = $this->cookie("c-{$catid}-" . $id);
         if (!empty($co)) {
             if (IS_AJAX) {
                 $this->ajaxReturn(array("error" => "expire"), "评论发布间隔为" . $this->setting['expire'] . "秒!", false);
             } else {
                 $this->error("评论发布间隔为" . $this->setting['expire'] . "秒!");
             }
         }
         //判断游客是否有发表权限
         if ((int) $this->setting['guest'] < 1) {
             if (!isset(AppframeAction::$Cache['uid']) && empty(AppframeAction::$Cache['uid'])) {
                 if (IS_AJAX) {
                     $this->ajaxReturn(array("error" => "guest"), "游客不允许参与评论!", false);
                 } else {
                     $this->error("游客不允许参与评论!");
                 }
             }
         }
         //验证码判断开始
         if ($this->setting['code'] == 1) {
             if (empty($_POST['verify']) || !$this->verify($_POST['verify'])) {
                 if (IS_AJAX) {
                     $this->ajaxReturn(array("error" => "verify"), "验证码错误,请重新输入!", false);
                 } else {
                     $this->error("验证码错误,请重新输入!");
                 }
             }
         }
         if (iconv_strlen($_POST['content']) > (int) $this->setting['strlength']) {
             return $this->error("评论内容超出系统设置允许的最大长度" . $this->setting['strlength'] . "字节!");
         }
         $db = M("Comments");
         C("TOKEN_ON", false);
         if ($data = $db->create()) {
             $Comment = new Comment();
             $data = array_merge($_POST, $data);
             $data['user_id'] = AppframeAction::$Cache['uid'];
             if (empty($catid) || empty($_POST['comment_id'])) {
                 $this->error("参数有误!");
             }
             $data['comment_id'] = "c-{$catid}-" . $_POST['comment_id'];
             $status = $Comment->add($data);
             if ($status['status']) {
                 if (!empty($this->setting['expire'])) {
                     $this->cookie($data['comment_id'], 1, array("expire" => $this->setting['expire']));
                 }
                 if ($this->setting['check'] > 0) {
                     $status['status'] = 3;
                     $status["info"] = "评论发送成功,但需要审核后才显示!";
                 }
                 if (IS_AJAX) {
                     $this->ajaxReturn($status['data'], $status["info"], $status['status']);
                 } else {
                     $this->success($status["info"]);
                 }
             } else {
                 $this->error($status['info']);
             }
         } else {
             $this->error($db->getError());
         }
     } else {
         $this->error("请使用post方式新增评论!");
     }
 }
开发者ID:BGCX262,项目名称:ztoa-svn-to-git,代码行数:79,代码来源:IndexAction.class.php

示例5: importer

function importer($path, $node, $line)
{
    global $blogid, $migrational, $items, $item;
    switch ($path) {
        case '/blog/setting':
            setProgress($item++ / $items * 100, _t('블로그 설정을 복원하고 있습니다.'));
            $setting = new BlogSetting();
            if (isset($node['title'][0]['.value'])) {
                $setting->title = $node['title'][0]['.value'];
            }
            if (isset($node['description'][0]['.value'])) {
                $setting->description = $node['description'][0]['.value'];
            }
            if (isset($node['banner'][0]['name'][0]['.value'])) {
                $setting->banner = $node['banner'][0]['name'][0]['.value'];
            }
            if (isset($node['useSloganOnPost'][0]['.value'])) {
                $setting->useSloganOnPost = $node['useSloganOnPost'][0]['.value'];
            }
            if (isset($node['postsOnPage'][0]['.value'])) {
                $setting->postsOnPage = $node['postsOnPage'][0]['.value'];
            }
            if (isset($node['postsOnList'][0]['.value'])) {
                $setting->postsOnList = $node['postsOnList'][0]['.value'];
            }
            if (isset($node['postsOnFeed'][0]['.value'])) {
                $setting->postsOnFeed = $node['postsOnFeed'][0]['.value'];
            }
            if (isset($node['publishWholeOnFeed'][0]['.value'])) {
                $setting->publishWholeOnFeed = $node['publishWholeOnFeed'][0]['.value'];
            }
            if (isset($node['acceptGuestComment'][0]['.value'])) {
                $setting->acceptGuestComment = $node['acceptGuestComment'][0]['.value'];
            }
            if (isset($node['acceptcommentOnGuestComment'][0]['.value'])) {
                $setting->acceptcommentOnGuestComment = $node['acceptcommentOnGuestComment'][0]['.value'];
            }
            if (isset($node['language'][0]['.value'])) {
                $setting->language = $node['language'][0]['.value'];
            }
            if (isset($node['timezone'][0]['.value'])) {
                $setting->timezone = $node['timezone'][0]['.value'];
            }
            if (!$setting->save()) {
                user_error(__LINE__ . $setting->error);
            }
            if (!empty($setting->banner) && !empty($node['banner'][0]['content'][0]['.stream'])) {
                Attachment::confirmFolder();
                Utils_Base64Stream::decode($node['banner'][0]['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                fclose($node['banner'][0]['content'][0]['.stream']);
                unset($node['banner'][0]['content'][0]['.stream']);
            }
            return true;
        case '/blog/category':
            setProgress($item++ / $items * 100, _t('분류를 복원하고 있습니다.'));
            $category = new Category();
            $category->name = $node['name'][0]['.value'];
            $category->priority = $node['priority'][0]['.value'];
            if (isset($node['root'][0]['.value'])) {
                $category->id = 0;
            }
            if (!$category->add()) {
                user_error(__LINE__ . $category->error);
            }
            if (isset($node['category'])) {
                for ($i = 0; $i < count($node['category']); $i++) {
                    $childCategory = new Category();
                    $childCategory->parent = $category->id;
                    $cursor =& $node['category'][$i];
                    $childCategory->name = $cursor['name'][0]['.value'];
                    $childCategory->priority = $cursor['priority'][0]['.value'];
                    if (!$childCategory->add()) {
                        user_error(__LINE__ . $childCategory->error);
                    }
                }
            }
            return true;
        case '/blog/post':
            setProgress($item++ / $items * 100, _t('글을 복원하고 있습니다.'));
            $post = new Post();
            $post->id = $node['id'][0]['.value'];
            $post->slogan = @$node['.attributes']['slogan'];
            $post->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $post->starred = $node['starred'][0]['.value'];
            } else {
                $post->starred = 0;
            }
            $post->title = $node['title'][0]['.value'];
            $post->content = $node['content'][0]['.value'];
            $post->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : 'ttml';
            $post->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : 'modern';
            $post->location = $node['location'][0]['.value'];
            $post->password = isset($node['password'][0]['.value']) ? $node['password'][0]['.value'] : null;
            $post->acceptcomment = $node['acceptComment'][0]['.value'];
            $post->accepttrackback = $node['acceptTrackback'][0]['.value'];
            $post->published = $node['published'][0]['.value'];
            if (isset($node['longitude'][0]['.value'])) {
                $post->longitude = $node['longitude'][0]['.value'];
//.........这里部分代码省略.........
开发者ID:webhacking,项目名称:Textcube,代码行数:101,代码来源:index.php

示例6: import_movabletype_post

 static function import_movabletype_post($array, $post, $link)
 {
     $get_comments = mysql_query("SELECT * FROM mt_comment WHERE comment_entry_id = {$array["entry_id"]} ORDER BY comment_id ASC", $link) or error(__("Database Error"), mysql_error());
     while ($comment = mysql_fetch_array($get_comments)) {
         Comment::add($comment["comment_text"], $comment["comment_author"], $comment["comment_url"], $comment["comment_email"], $comment["comment_ip"], "", $comment["comment_visible"] ? "approved" : "denied", "", $comment["comment_created_on"], $comment["comment_modified_on"], $post, 0);
     }
 }
开发者ID:relisher,项目名称:chyrp,代码行数:7,代码来源:comments.php

示例7: trim

		if ( !$proposal->allowed_add_comments($comment->rubric) ) {
			warning(_("Adding or rating comments is not allowed in this phase."));
			redirect();
		}
		$comment->proposal = $proposal->id;
		$comment->title = trim($_POST['title']);
		if (!$comment->title) {
			warning(_("The title of the comment must be not empty."));
			break;
		}
		$comment->content = trim($_POST['content']);
		if (!$comment->content) {
			warning(_("The content of the comment must be not empty."));
			break;
		}
		$comment->add($proposal);
		Comments::redirect_append_show($comment->id);
		break;
	case "update_comment":
		if ( !Login::access_allowed("comment") ) {
			warning(_("You don't have permissions to write comments."));
			redirect();
		}
		action_required_parameters("title", "content", "id");
		$comment = new Comment($_POST['id']);
		if (!$comment->id) {
			warning(_("This comment does not exist."));
			redirect();
		}
		$comment->title = trim($_POST['title']);
		if (!$comment->title) {
开发者ID:ppschweiz,项目名称:basisentscheid,代码行数:31,代码来源:proposal.php

示例8: header

<?php

session_start();
if (!isset($_SESSION['login'])) {
    header('location: accueil.php');
} else {
    include_once "./class/Members.php";
    include_once "./class/Comment.php";
    include_once "./class/Notification.php";
    $content_comment = $_POST['my_comment'];
    $id_article = $_POST['id_article'];
    $author = $_SESSION['login'];
    $new_comment = new Comment($id_article, $author, $content_comment);
    $new_comment->add();
    $bdd = new PDO('mysql:host=localhost;dbname=bavn', 'root', '');
    $auteur_article = $bdd->query('SELECT id FROM members  WHERE id IN(SELECT id_author FROM articles WHERE id="' . $id_article . '")');
    $auteur_article = $auteur_article->fetch()[0];
    $commentateurs_article = $bdd->query('SELECT id, pseudo FROM members  WHERE pseudo IN(SELECT pseudo FROM comments WHERE id_article="' . $id_article . '")');
    $commentateurs_article = $commentateurs_article->fetchAll();
    $nombre_commentateurs = count($commentateurs_article);
    for ($i = 0; $i < $nombre_commentateurs + 1; $i++) {
        if ($i < $nombre_commentateurs) {
            $cur_id = $commentateurs_article[$i]['id'];
            $cur_pseudo = $commentateurs_article[$i]['pseudo'];
            if ($cur_pseudo != $author) {
                $new_not = new Notification($cur_id, $id_article, "Un nouveau commentaire sur une publication que vous suivez est apparu", '', 0);
            } else {
                $auteur_article = -1;
            }
        } else {
            if ($auteur_article != -1) {
开发者ID:bsamel,项目名称:bavn,代码行数:31,代码来源:post_comment.php

示例9: execute

 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);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:80,代码来源:CommentAction.php

示例10: replycomment

 /**
  * 回复评论 
  */
 public function replycomment()
 {
     if (IS_POST) {
         $db = M("Comments");
         C("TOKEN_ON", false);
         $data = $db->create();
         if ($data) {
             $Comment = new Comment();
             $data = array_merge($_POST, $data);
             $data['user_id'] = AppframeAction::$Cache['uid'];
             $catid = $_POST['comment_catid'];
             if (empty($catid) || empty($_POST['comment_id'])) {
                 $this->error("参数有误!");
             }
             $data['comment_id'] = "c-{$catid}-" . $_POST['comment_id'];
             $status = $Comment->add($data, 1);
             if ($status['status']) {
                 $this->success("评论回复成功!", U("Comments/index"));
             } else {
                 $this->error($status['info']);
             }
         } else {
             $this->error($db->getError());
         }
     } else {
         $id = (int) $this->_get("id");
         if ($id <= 0) {
             $this->error("参数有误!");
         }
         $r = M("Comments")->where(array("id" => $id))->find();
         if ($r) {
             $r2 = M("Comments_data_" . $r['stb'])->where(array("id" => $id))->find();
             $data = array_merge($r, $r2);
             $data['content'] = Input::forTarea($data['content']);
             //取得自定义字段
             $field = M("Comments_field")->where(array("system" => 0))->order(array("fid" => "DESC"))->select();
             $ca = explode("-", $data["comment_id"]);
             //如果是回复评论,也就是approved不等于0的评论
             if (!$r['parent'] == 0) {
                 $this->assign("parent", $data['parent']);
             } else {
                 $this->assign("parent", $data['id']);
             }
             import("Form");
             $this->assign("author_url", AppframeAction::$Cache['Config']['siteurl']);
             $this->assign("author_email", AppframeAction::$Cache['User']['email']);
             $this->assign("author", AppframeAction::$Cache['username']);
             $this->assign("data", $data);
             $this->assign("catid", $ca[1]);
             $this->assign("commentid", $ca[2]);
             $this->assign("field", $field);
             $this->display();
         } else {
             $this->error("该评论不存在!");
         }
     }
 }
开发者ID:BGCX262,项目名称:ztoa-svn-to-git,代码行数:60,代码来源:CommentsAction.class.php

示例11: comments

/**
 * generate comments
 *
 * @param Proposal $proposal
 */
function comments(Proposal $proposal) {
	global $lorem_ipsum;

	$rubrics = array("pro", "contra", "discussion");
	$parents = $rubrics;

	for ( $i = 1; $i <= 500; $i++ ) {

		$author = rand(0, 999);
		login($author);

		$parent_id = $parents[array_rand($parents)];

		$comment = new Comment;
		if (in_array($parent_id, $rubrics)) {
			$comment->parent = 0;
			$comment->rubric = $parent_id;
		} else {
			$parent = new Comment($parent_id);
			$comment->parent = $parent->id;
			$comment->rubric = $parent->rubric;
		}
		$comment->proposal = $proposal->id;
		$comment->member = Login::$member->id;
		$comment->title = mb_substr($lorem_ipsum, 0, rand(1, 100));;
		$comment->content = mb_substr($lorem_ipsum, 0, rand(1, 1000));
		$comment->add($proposal);

		$parents[] = $comment->id;

		for ( $j = 1; $j <= rand(0, 100); $j++ ) {
			$user = rand(0, 999);
			// don't try to rate own comments
			if ($user == $author) continue;
			login($user);
			$comment->set_rating(rand(0, 2));
		}

	}

}
开发者ID:ppschweiz,项目名称:basisentscheid,代码行数:46,代码来源:test_demo.php

示例12: header

$action = $_SERVER['REQUEST_METHOD'];
if ($get_action = filter_input(INPUT_POST, "action")) {
    if ($user_id != $_SESSION['user_id']) {
        header("Location: /bbs/");
        exit;
    }
    $action = filter_input(INPUT_POST, "action");
}
switch ($action) {
    case 'UPDATE':
        //update comment
        $params = array('id' => $comment_id, 'text' => $text);
        $comment->update($params);
        header("Location: /bbs/view/threads?id=" . $thread_id);
        exit;
    case 'POST':
        //new comment
        $user_id = $_SESSION["user_id"];
        $params = array('user_id' => $user_id, 'thread_id' => $thread_id, 'text' => $text);
        $comment->add($params);
        header("Location: /bbs/view/threads?id=" . $thread_id);
        exit;
    case 'DELETE':
        print $comment_id;
        if ($comment_id) {
            //DELETE
            $comment->deleteRow($comment_id);
        }
        header("Location: /bbs/view/threads?id=" . $thread_id);
        exit;
}
开发者ID:nagamoto,项目名称:php_bbs,代码行数:31,代码来源:comments_receiver.php


注:本文中的Comment::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。