コード例 #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
 /**
  * Adds a new comment to an article
  *     
  * @param int $articleId
  * @param string $commentTitle
  * @param string $commentText
  * @return Comment
  */
 public function addComment($articleId, $commentTitle, $commentText)
 {
     $comment = new Comment();
     $comment->setTitle($commentTitle);
     $comment->setText($commentText);
     $this->entityManager->persist($comment);
     $comment->setArticle($this->find($articleId));
     $this->entityManager->flush();
     return $comment;
 }
コード例 #3
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;
 }
コード例 #4
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;
 }
コード例 #5
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;
 }
コード例 #6
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;
 }
コード例 #7
0
ファイル: addComment.php プロジェクト: laiello/site-web-php
<?php

include 'control/ArticleControls.php';
include_once 'business/Comment.php';
$comment = new Comment();
$control = new ArticleControls();
$comment->setTitle($_POST['title']);
$comment->setContent($_POST['content']);
$comment->setUser_name($_POST['name']);
$comment->setNews_id($_POST['id']);
$comment->setIp($_POST['ip']);
if ($control->addComment($comment)) {
    header("location:../news.php?art_id=" . $_POST['id']);
} else {
    echo "La requête n'a pu être exécutée";
}