Exemplo n.º 1
0
 /**
  * Save an entry
  *
  * @return    void
  */
 protected function _save()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         return $this->_login();
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $comment = Request::getVar('comment', array(), 'post', 'none', 2);
     // Instantiate a new comment object
     $row = new \Plugins\Hubzero\Comments\Models\Comment($comment['id']);
     // pass data to comment object
     if (!$row->bind($comment)) {
         App::redirect($this->url, $row->getError(), 'error');
         return;
     }
     $row->set('uploadDir', $this->params->get('comments_uploadpath', '/site/comments'));
     $row->set('created', Date::toSql());
     if ($row->exists() && !$this->params->get('access-edit-comment')) {
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($this->url)), Lang::txt('PLG_HUBZERO_COMMENTS_NOTAUTH'), 'warning');
         return;
     }
     // Store new content
     if (!$row->store(true)) {
         $key = 'failed_comment';
         $value = $row->content('raw');
         User::setState($key, $value);
         App::redirect($this->url, $row->getError(), 'error');
         return;
     }
     App::redirect($this->url, Lang::txt('PLG_HUBZERO_COMMENTS_SAVED'), 'message');
 }
Exemplo n.º 2
0
" id="commentform" enctype="multipart/form-data">
						<p class="comment-member-photo">
							<?php 
        $edit = 0;
        // Make sure editing capaibilites are available before even accepting an ID to edit
        if ($this->params->get('access-edit-comment') || $this->params->get('access-manage-comment')) {
            $edit = Request::getInt('commentedit', 0);
        }
        // Load the comment
        $comment = new \Plugins\Hubzero\Comments\Models\Comment($edit);
        // If the comment exists and the editor is NOT the creator and the editor is NOT a manager...
        if ($comment->exists() && $comment->get('created_by') != User::get('id') && !$this->params->get('access-manage-comment')) {
            // Disallow editing
            $comment = new \Plugins\Hubzero\Comments\Models\Comment(0);
        }
        if (!$comment->exists()) {
            $comment->set('parent', Request::getInt('commentreply', 0));
            $comment->set('created_by', !User::isGuest() ? User::get('id') : 0);
            $comment->set('anonymous', !User::isGuest() ? 0 : 1);
        }
        ?>
							<img src="<?php 
        echo $comment->creator()->getPicture($comment->get('anonymous'));
        ?>
" alt="" />
						</p>
						<fieldset>
							<?php 
        if (!User::isGuest()) {
            if ($replyto = Request::getInt('commentreply', 0)) {
                $reply = new \Plugins\Hubzero\Comments\Models\Comment($replyto);