コード例 #1
0
ファイル: Comment.php プロジェクト: schwarer2006/wikia
function DisplayComments($input)
{
    global $wgUser, $wgTitle, $wgOut, $wgVoteDirectory;
    $wgOut->addScript("<script type=\"text/javascript\" src=\"extensions/Comments/Comment.js\"></script>\n");
    require_once 'CommentClass.php';
    require_once "{$wgVoteDirectory}/VoteClass.php";
    getValue($scorecard, $input, "Scorecard");
    getValue($allow, $input, "Allow");
    getValue($voting, $input, "Voting");
    getValue($title, $input, "title");
    getValue($userRating, $input, "userrating");
    $Comment = new Comment($wgTitle->mArticleID);
    $Comment->setUser($wgUser->mName, $wgUser->mId);
    $Comment->setAllow($allow);
    $Comment->setVoting($voting);
    $Comment->setTitle($title);
    $Comment->setBool("ShowScorecard", $scorecard);
    $Comment->setBool("ShowUserRating", $userRating);
    if ($_POST['commentid']) {
        $Comment->setCommentID($_POST['commentid']);
        $Comment->delete();
    }
    $output = $Comment->displayOrderForm();
    if ($Comment->ShowScoreCard == 1) {
        $output .= "<div id=\"scorecard\"></div>";
    }
    $output .= "<div id=\"allcomments\">" . $Comment->display() . "</div>";
    $output .= $Comment->diplayForm();
    if ($Comment->ShowScoreCard == 1) {
        $output .= $Comment->displayCommentScorecard($scorecard);
    }
    return $output;
}
コード例 #2
0
 /**
  *
  * @param $comment
  * @return Comment 
  */
 private function buildComment($comment)
 {
     $cmt = new Comment($comment['datetime'], $comment['title'], $comment['text']);
     $user = new User($comment['nameUser'], null);
     $cmt->setUser($user);
     return $cmt;
 }
コード例 #3
0
 /**
  * Добавить коммент
  */
 public function executeNew()
 {
     $this->point = $this->getRoute()->getObject();
     $user = $this->getUser()->getGuardUser();
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setPoint($this->point);
     $this->form = new CommentForm($comment);
 }
コード例 #4
0
 public function findCommentById($id)
 {
     $stmt = $this->dtb->prepare('SELECT * FROM comments WHERE postID = :pid');
     $stmt->bindValue(':pid', $pid, PDO::PARAM_INT);
     $stmt->execute();
     $data = array();
     $um = new PdoUserManager();
     $pm = new PdoPostManager();
     $d = $stmt->fetch(PDO::FETCH_OBJ);
     $c = new Comment();
     $c->setId($d->id);
     $c->setBody($d->body);
     //$c->setPost($pm->findPostById($d->postID));
     $c->setUser($um->findUserById($d->userID));
     $c->setPublicationDate($d->publicationDate);
     $data[] = $c;
     $stmt->closeCursor();
     return $data;
 }
コード例 #5
0
 public function postProcess()
 {
     // Recherche d'un utilisateur
     if (Tools::isSubmit('submitSearchAccount')) {
         $this->setTemplate('comments/search.tpl');
         try {
             $accounts = Github::searchAccounts(Tools::getValue('search', Tools::getValue('term')));
             if (Tools::getIsset('term')) {
                 // Depuis ajax
                 $this->renderAjaxSearch($accounts);
             }
             $this->context->smarty->assign(array('total_count' => $accounts['total_count'], 'accounts' => $accounts['items']));
         } catch (Exception $e) {
             $this->errors[] = 'Impossible de récupérer les profils correspondant à votre recherche';
         }
     } elseif (Tools::isSubmit('submitAddComment')) {
         if (!$this->profile) {
             return $this->errors[] = 'Veuillez specifier un profil valide';
         } elseif (!Validate::isNonEmptyString($repository = Tools::getValue('repository'))) {
             return $this->errors[] = 'Veuillez specifier un nom de dépot valide';
         } elseif (!Validate::isCleanHTML($commentContent = Tools::getValue('comment'))) {
             return $this->errors[] = 'Veuillez fournir un commentaire valide';
         } elseif (!$this->isProfileRepository($repository)) {
             return $this->errors[] = "Ce dépot n'appartient pas à cet utilisateur";
         }
         $comment = new Comment();
         $comment->setUser(Auth::getUser())->setUsername($this->profile['login'])->setRepository($repository)->setComment(nl2br($commentContent));
         // @todo WYSIWYG
         if (!$comment->save()) {
             $this->errors[] = "Impossible d'enregistrer le commentaire (" . Db::getInstance()->getMsgError() . ")";
         } else {
             Flash::success('Votre commentaire a bien été ajouté!');
             Tools::redirect($this->context->link->getPageLink('comments', array('user' => $this->profile['login'])));
         }
     }
 }
コード例 #6
0
 /**
  * Save changes to comment.
  * @return int the comment ID
  */
 function execute()
 {
     $journal =& Request::getJournal();
     $enableComments = $journal->getSetting('enableComments');
     $commentDao =& DAORegistry::getDAO('CommentDAO');
     $comment = $this->comment;
     if (!isset($comment)) {
         $comment = new Comment();
     }
     $user =& Request::getUser();
     $comment->setTitle($this->getData('title'));
     $comment->setBody($this->getData('body'));
     if (($enableComments == COMMENTS_ANONYMOUS || $enableComments == COMMENTS_UNAUTHENTICATED) && (Request::getUserVar('anonymous') || $user == null)) {
         $comment->setPosterName($this->getData('posterName'));
         $comment->setPosterEmail($this->getData('posterEmail'));
         $comment->setUser(null);
     } else {
         $comment->setPosterName($user->getFullName());
         $comment->setPosterEmail($user->getEmail());
         $comment->setUser($user);
     }
     $comment->setParentCommentId($this->parentId);
     if (isset($this->comment)) {
         $commentDao->updateComment($comment);
     } else {
         $comment->setSubmissionId($this->articleId);
         $comment->setChildCommentCount(0);
         $commentDao->insertComment($comment);
         $this->commentId = $comment->getId();
     }
     return $this->commentId;
 }
コード例 #7
0
 /**
  * Creates and returns a submission comment object from a row
  * @param $row array
  * @return Comment object
  */
 function &_returnCommentFromRow($row, $childLevels = 0)
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $comment = new Comment();
     $comment->setId($row['comment_id']);
     $comment->setSubmissionId($row['submission_id']);
     $comment->setUser($userDao->getUser($row['user_id']), true);
     $comment->setPosterIP($row['poster_ip']);
     $comment->setPosterName($row['poster_name']);
     $comment->setPosterEmail($row['poster_email']);
     $comment->setTitle($row['title']);
     $comment->setBody($row['body']);
     $comment->setDatePosted($this->datetimeFromDB($row['date_posted']));
     $comment->setDateModified($this->datetimeFromDB($row['date_modified']));
     $comment->setParentCommentId($row['parent_comment_id']);
     $comment->setChildCommentCount($row['num_children']);
     if (!HookRegistry::call('CommentDAO::_returnCommentFromRow', array(&$comment, &$row, &$childLevels))) {
         if ($childLevels > 0) {
             $comment->setChildren($this->getCommentsByParentId($row['comment_id'], $childLevels - 1));
         } else {
             if ($childLevels == SUBMISSION_COMMENT_RECURSE_ALL) {
                 $comment->setChildren($this->getCommentsByParentId($row['comment_id'], SUBMISSION_COMMENT_RECURSE_ALL));
             }
         }
     }
     return $comment;
 }
コード例 #8
0
ファイル: acc.php プロジェクト: FastLizard4/waca
    }
    //Look for and detect IPv4/IPv6 addresses in comment text, and warn the commenter.
    if ((preg_match('/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/', $_POST['comment']) || preg_match('/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/', $_POST['comment'])) && $_POST['privpol-check-override'] != "override") {
        BootstrapSkin::displayAlertBox("IP address detected in comment text.  Warning acknowledgement checkbox must be checked.", "alert-error", "Error", true, false);
        $smarty->assign("request", $request);
        $smarty->assign("comment", $_POST['comment']);
        $smarty->assign("actionLocation", "comment-quick");
        $smarty->display("privpol-warning.tpl");
        BootstrapSkin::displayInternalFooter();
        die;
    }
    $comment = new Comment();
    $comment->setDatabase(gGetDb());
    $comment->setRequest($request->getId());
    $comment->setVisibility($visibility);
    $comment->setUser(User::getCurrent()->getId());
    $comment->setComment($_POST['comment']);
    $comment->save();
    Notification::commentCreated($comment);
    header("Location: acc.php?action=zoom&id=" . $request->getId());
} elseif ($action == "changepassword") {
    if (!isset($_POST['oldpassword']) || $_POST['oldpassword'] == "") {
        //Throw an error if old password is not specified.
        BootstrapSkin::displayAlertBox("You did not enter your old password.", "alert-error", "Error", true, false);
        BootstrapSkin::displayInternalFooter();
        die;
    }
    if (!isset($_POST['newpassword']) || $_POST['newpassword'] == "") {
        //Throw an error if new password is not specified.
        BootstrapSkin::displayAlertBox("You did not enter your new password.", "alert-error", "Error", true, false);
        BootstrapSkin::displayInternalFooter();
コード例 #9
0
ファイル: CommentAction.php プロジェクト: schwarer2006/wikia
 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);
 }
コード例 #10
0
 protected function handleComment(&$username, &$password, &$articleId, &$title, &$body)
 {
     $userDAO = DAORegistry::getDAO('UserDAO');
     $user = $userDAO->getUserByCredentials($username, $password);
     if ($user == null) {
         return 'ERROR_CREDENTIALS';
     }
     if ($title == null || $title == '' || $body == null || $body == '' || $articleId == null || $articleId == '') {
         return 'ERROR_PARAMS';
     }
     if (DAORegistry::getDAO('PublishedArticleDAO')->getPublishedArticleByArticleId($articleId) == null) {
         return 'ERROR_NO_ARTICLE';
     }
     $commentDao =& DAORegistry::getDAO('CommentDAO');
     $comment = new Comment();
     $comment->setSubmissionId($articleId);
     $comment->setBody($body);
     $comment->setTitle($title);
     $comment->setUser($user);
     $comment->setChildCommentCount(0);
     $comment->setPosterName($user->getFullName());
     $comment->setPosterEmail($user->getEmail());
     $result = $commentDao->insertComment($comment);
     echo (int) $result;
 }
コード例 #11
0
ファイル: CommentForm.inc.php プロジェクト: jalperin/ocs
 /**
  * Save changes to comment.
  * @return int the comment ID
  */
 function execute()
 {
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $enableComments = $conference->getSetting('enableComments');
     $commentsRequireRegistration = $conference->getSetting('commentsRequireRegistration');
     $commentsAllowAnonymous = $conference->getSetting('commentsAllowAnonymous');
     $commentDao =& DAORegistry::getDAO('CommentDAO');
     $comment = $this->comment;
     if (!isset($comment)) {
         $comment = new Comment();
     }
     $user =& Request::getUser();
     $comment->setTitle($this->getData('title'));
     $comment->setBody($this->getData('body'));
     if (($commentsAllowAnonymous || !$commentsRequireRegistration) && (Request::getUserVar('anonymous') || $user == null)) {
         $comment->setPosterName($this->getData('posterName'));
         $comment->setPosterEmail($this->getData('posterEmail'));
         $comment->setUser(null);
     } else {
         $comment->setPosterName($user->getFullName());
         $comment->setPosterEmail($user->getEmail());
         $comment->setUser($user);
     }
     $comment->setParentCommentId($this->parentId);
     if (isset($this->comment)) {
         $commentDao->updateComment($comment);
     } else {
         $comment->setPaperId($this->paperId);
         $comment->setChildCommentCount(0);
         $commentDao->insertComment($comment);
         $this->commentId = $comment->getId();
     }
     return $this->commentId;
 }
コード例 #12
0
ファイル: User.php プロジェクト: raigons/bureauinteligencia
 public function comment(Comment $comment, Analyse $analysis)
 {
     $comment->setUser($this);
     $analysis->addComment($comment);
 }