示例#1
0
 /**
  * Saves a comment to an article
  * Displays article
  *
  * @return  void
  */
 public function savecommentTask()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $return = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_option), 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($return)));
         return;
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $comment = Request::getVar('comment', array(), 'post', 'none', 2);
     // Instantiate a new comment object and pass it the data
     $row = Comment::oneOrNew($comment['id'])->set($comment);
     if ($row->isNew()) {
         $row->set('created', \Date::toSql());
     }
     // Store new content
     if (!$row->save(true)) {
         $this->setError($row->getError());
         return $this->articleTask();
     }
     App::redirect(Route::url($row->link() . '#comments'));
 }
示例#2
0
 /**
  * Retrieves a row from the database
  *
  * @param      string $refid    ID of the database table row
  * @param      string $parent   If the element has a parent element
  * @param      string $category Element type (determines table to look in)
  * @param      string $message  If the element has a parent element
  * @return     array
  */
 public function deleteReportedItem($refid, $parent, $category, $message)
 {
     if ($category != 'kb') {
         return null;
     }
     require_once PATH_CORE . DS . 'components' . DS . 'com_kb' . DS . 'models' . DS . 'comment.php';
     $comment = \Components\Kb\Models\Comment::oneOrFail($refid);
     $comment->set('state', 2);
     $comment->save();
     return '';
 }
示例#3
0
 /**
  * Saves a comment to an article
  * Displays article
  *
  * @return  void
  */
 public function savecommentTask()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $return = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_option), 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($return)), Lang::txt('COM_KB_LOGIN_NOTICE'), 'warning');
         return;
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $comment = Request::getVar('comment', array(), 'post', 'none', 2);
     // Instantiate a new comment object and pass it the data
     $row = Comment::oneOrNew($comment['id'])->set($comment);
     if ($row->isNew()) {
         $row->set('created', \Date::toSql());
     }
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->articleTask();
     }
     // Log the activity
     $article = Article::oneOrFail($row->get('entry_id'));
     $recipients = array($row->get('created_by'));
     if ($row->get('parent')) {
         $recipients[] = $row->parent()->get('created_by');
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => $comment['id'] ? 'updated' : 'created', 'scope' => 'kb.article.comment', 'scope_id' => $row->get('id'), 'anonymous' => $row->get('anonymous', 0), 'description' => Lang::txt('COM_KB_ACTIVITY_COMMENT_' . ($comment['id'] ? 'UPDATED' : 'CREATED'), $row->get('id'), '<a href="' . Route::url($article->link() . '#c' . $row->get('id')) . '">' . $article->get('title') . '</a>'), 'details' => array('title' => $article->get('title'), 'entry_id' => $article->get('id'), 'url' => $article->link())], 'recipients' => $recipients]);
     App::redirect(Route::url($article->link() . '#comments'));
 }
示例#4
0
    echo Lang::txt('COM_KB_POST_COMMENT');
    ?>
			</h3>
			<form method="post" action="<?php 
    echo Route::url($this->article->link());
    ?>
" id="commentform">
				<p class="comment-member-photo">
					<img src="<?php 
    echo User::picture(!User::isGuest() ? 0 : 1);
    ?>
" alt="" />
				</p>
				<fieldset>
					<?php 
    $replyto = \Components\Kb\Models\Comment::oneOrNew(Request::getInt('replyto'));
    if (!User::isGuest()) {
        if (!$replyto->isNew()) {
            $name = Lang::txt('COM_KB_ANONYMOUS');
            if (!$replyto->get('anonymous')) {
                $name = $this->escape(stripslashes($replyto->creator->get('name')));
                if (in_array($replyto->creator->get('access'), User::getAuthorisedViewLevels())) {
                    $name = '<a href="' . Route::url($replyto->creator->link()) . '">' . $name . '</a>';
                }
            }
            ?>
							<blockquote cite="c<?php 
            echo $replyto->get('id');
            ?>
">
								<p>