Beispiel #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 = \Plugins\Hubzero\Comments\Models\Comment::oneOrNew($comment['id'])->set($comment);
     if ($row->get('id') && !$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');
     }
     // Store new content
     if (!$row->save()) {
         User::setState('failed_comment', $row->get('content'));
         App::redirect($this->url, $row->getError(), 'error');
     }
     $upload = Request::getVar('comment_file', '', 'files', 'array');
     if (!empty($upload) && $upload['name']) {
         if ($upload['error']) {
             $this->setError(\Lang::txt('PLG_HUBZERO_COMMENTS_ERROR_UPLOADING_FILE'));
         }
         $file = new \Plugins\Hubzero\Comments\Models\File();
         $file->set('comment_id', $row->get('id'));
         $file->setUploadDir($this->params->get('comments_uploadpath', '/site/comments'));
         $fileName = $upload['name'];
         $fileTemp = $upload['tmp_name'];
         if (!$file->upload($fileName, $fileTemp)) {
             $this->setError($file->getError());
         } else {
             $file->save();
         }
     }
     App::redirect($this->url, Lang::txt('PLG_HUBZERO_COMMENTS_SAVED'), 'message');
 }
Beispiel #2
0
        if ($comment->isNew()) {
            $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->picture($comment->get('anonymous'));
        ?>
" alt="" />
						</p>
						<fieldset>
							<?php 
        if (!User::isGuest()) {
            if ($replyto = Request::getInt('commentreply', 0)) {
                $reply = \Plugins\Hubzero\Comments\Models\Comment::oneOrNew($replyto);
                $name = Lang::txt('COM_KB_ANONYMOUS');
                if (!$reply->get('anonymous')) {
                    $name = $this->escape(stripslashes($repy->creator->get('name')));
                    if (in_array($reply->creator->get('access'), User::getAuthorisedViewLevels())) {
                        $name = '<a href="' . Route::url($reply->creator->link()) . '">' . $name . '</a>';
                    }
                }
                ?>
									<blockquote cite="c<?php 
                echo $reply->get('id');
                ?>
">
										<p>
											<strong><?php 
                echo $name;