/** * Save a reply * * @return void */ private function savereply() { // Check for request forgeries Request::checkToken(); // Is the user logged in? if (User::isGuest()) { $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_LOGIN_NOTICE')); return; } $publication =& $this->publication; // Trim and addslashes all posted items $comment = Request::getVar('comment', array(), 'post', 'none', 2); if (!$publication->exists()) { // Cannot proceed $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_COMMENT_ERROR_NO_REFERENCE_ID')); return; } $database = App::get('db'); $row = \Hubzero\Item\Comment::blank()->set($comment); $message = $row->id ? Lang::txt('PLG_PUBLICATIONS_REVIEWS_EDITS_SAVED') : Lang::txt('PLG_PUBLICATIONS_REVIEWS_COMMENT_POSTED'); // Perform some text cleaning, etc. $row->set('content', \Hubzero\Utility\Sanitize::clean($row->get('content'))); $row->set('anonymous', $row->get('anonymous') ? $row->get('anonymous') : 0); $row->set('state', $row->get('id') ? $row->get('state') : 0); // Save the data if (!$row->save()) { $this->setError($row->getError()); return; } // Redirect App::redirect(Route::url($publication->link('reviews')), $message); }
/** * Save a comment * * @return string */ private function _savecomment() { // Ensure the user is logged in if (User::isGuest()) { return $this->_login(); } // Incoming $comment = Request::getVar('comment', array(), 'post'); // Instantiate a new comment object and pass it the data $row = \Hubzero\Item\Comment::blank()->set($comment); // Store new content if (!$row->save()) { $this->setError($row->getError()); return $this->_post(); } // Log activity $post = new \Components\Collections\Models\Post(Request::getInt('post', 0)); $recipients = array(['collection', $post->get('collection_id')], ['user', $comment->get('created_by')]); if ($comment->get('parent')) { $recipients[] = ['user', $comment->parent()->get('created_by')]; } $title = $post->item()->get('title'); $title = $title ? $title : $post->item()->get('description', '#' . $post->get('id')); $title = \Hubzero\Utility\String::truncate(strip_tags($title), 70); $url = Route::url('index.php?option=com_collections&controller=posts&post=' . $post->get('id') . '&task=comment'); Event::trigger('system.logActivity', ['activity' => ['action' => $data['id'] ? 'updated' : 'created', 'scope' => 'collections.comment', 'scope_id' => $comment->get('id'), 'description' => Lang::txt('PLG_MEMBERS_COLLECTIONS_ACTIVITY_COMMENT_' . ($data['id'] ? 'UPDATED' : 'CREATED'), $comment->get('id'), '<a href="' . $url . '#c' . $comment->get('id') . '">' . $title . '</a>'), 'details' => array('collection_id' => $post->get('collection_id'), 'post_id' => $post->get('id'), 'item_id' => $row->get('item_id'), 'url' => $url . '#c' . $comment->get('id'))], 'recipients' => $recipients]); return $this->_post(); }
/** * Save an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } // Incoming $fields = Request::getVar('fields', array(), 'post', 'none', 2); $fields = array_map('trim', $fields); // Initiate extended database class $row = Comment::blank()->set($fields); $row->set('anonymous', isset($fields['anonymous']) && $fields['anonymous'] ? 1 : 0); // Store new content if (!$row->save()) { Notify::error($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_WISHLIST_COMMENT_SAVED')); if ($this->getTask() == 'apply') { return $this->editTask($row); } // Redirect Request::setVar('wish', $row->item_id); $this->cancelTask(); }
/** * Save a comment * * @return string */ public function savecommentTask() { // Check for request forgeries Request::checkToken(); // Ensure the user is logged in if (User::isGuest()) { return $this->loginTask(); } // Incoming $comment = Request::getVar('comment', array(), 'post', 'none', 2); // Instantiate a new comment object and pass it the data $row = Comment::blank()->set($comment); // Store new content if (!$row->save()) { $this->setError($row->getError()); return $this->displayTask(); } // Log activity $post = new Post(Request::getInt('post', 0)); $title = $post->item()->get('title'); $title = $title ? $title : $post->item()->get('description', '#' . $post->get('id')); $title = \Hubzero\Utility\String::truncate(strip_tags($title), 70); $url = 'index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&post=' . $post->get('id'); $item = '<a href="' . Route::url($url) . '">' . $title . '</a>'; $recipients = array(['collection', $post->get('collection_id')], ['user', $row->get('created_by')], ['user', $post->item()->get('created_by')]); if ($row->get('parent')) { $parent = Comment::oneOrFail($row->get('parent')); $recipients[] = ['user', $parent->get('created_by')]; } Event::trigger('system.logActivity', ['activity' => ['action' => $comment['id'] ? 'updated' : 'created', 'scope' => 'collections.comment', 'scope_id' => $row->get('id'), 'description' => Lang::txt('COM_COLLECTIONS_ACTIVITY_COMMENT_' . ($comment['id'] ? 'UPDATED' : 'CREATED'), $row->get('id'), $item), 'details' => array('collection_id' => $post->get('collection_id'), 'post_id' => $post->get('id'), 'item_id' => $row->get('item_id'), 'url' => Route::url($url))], 'recipients' => $recipients]); $this->displayTask(); }