Exemple #1
0
 /**
  * Save a comment
  *
  * @return     string
  */
 private function _savecomment()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $blog = Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name, false, true);
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($blog)), Lang::txt('GROUPS_LOGIN_NOTICE'), 'warning');
         return;
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $data = Request::getVar('comment', array(), 'post', 'none', 2);
     // Instantiate a new comment object and pass it the data
     $comment = \Components\Blog\Models\Comment::oneOrNew($data['id'])->set($data);
     // Store new content
     if (!$comment->save()) {
         $this->setError($comment->getError());
         return $this->_entry();
     }
     // Record the activity
     $entry = \Components\Blog\Models\Entry::oneOrFail($comment->get('entry_id'));
     $recipients = array(['group', $this->group->get('gidNumber')]);
     if (!in_array($comment->get('created_by'), $this->group->get('managers'))) {
         $recipients[] = ['user', $comment->get('created_by')];
     }
     if ($comment->get('parent')) {
         if (!in_array($comment->parent()->get('created_by'), $this->group->get('managers'))) {
             $recipients[] = ['user', $comment->parent()->get('created_by')];
         }
     }
     foreach ($this->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => $data['id'] ? 'updated' : 'created', 'scope' => 'blog.entry.comment', 'scope_id' => $comment->get('id'), 'anonymous' => $comment->get('anonymous', 0), 'description' => Lang::txt('PLG_GROUPS_BLOG_ACTIVITY_COMMENT_' . ($data['id'] ? 'UPDATED' : 'CREATED'), $comment->get('id'), '<a href="' . Route::url($entry->link() . '#c' . $comment->get('id')) . '">' . $entry->get('title') . '</a>'), 'details' => array('title' => $entry->get('title'), 'entry_id' => $entry->get('id'), 'url' => $entry->link() . '#c' . $comment->get('id'))], 'recipients' => $recipients]);
     return $this->_entry();
 }
Exemple #2
0
 /**
  * Save a comment
  *
  * @return  void
  */
 public function savecommentTask()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $rtrn = 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($rtrn)), Lang::txt('COM_BLOG_LOGIN_NOTICE'), 'warning');
         return;
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $data = Request::getVar('comment', array(), 'post', 'none', 2);
     // Instantiate a new comment object and pass it the data
     $comment = Comment::oneOrNew($data['id'])->set($data);
     // Store new content
     if (!$comment->save()) {
         $this->setError($comment->getError());
         return $this->entryTask();
     }
     // Log the activity
     $entry = \Components\Blog\Models\Entry::oneOrFail($comment->get('entry_id'));
     $recipients = array($comment->get('created_by'));
     if ($comment->get('created_by') != $entry->get('created_by')) {
         $recipients[] = $entry->get('created_by');
     }
     if ($comment->get('parent')) {
         $recipients[] = $comment->parent()->get('created_by');
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => $data['id'] ? 'updated' : 'created', 'scope' => 'blog.entry.comment', 'scope_id' => $comment->get('id'), 'anonymous' => $comment->get('anonymous', 0), 'description' => Lang::txt('COM_BLOG_ACTIVITY_COMMENT_' . ($data['id'] ? 'UPDATED' : 'CREATED'), $comment->get('id'), '<a href="' . Route::url($entry->link() . '#c' . $comment->get('id')) . '">' . $entry->get('title') . '</a>'), 'details' => array('title' => $entry->get('title'), 'entry_id' => $entry->get('id'), 'url' => $entry->link())], 'recipients' => $recipients]);
     return $this->entryTask();
 }
Exemple #3
0
 /**
  * Save a comment
  *
  * @return  void
  */
 public function savecommentTask()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $rtrn = 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($rtrn)), Lang::txt('COM_BLOG_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);
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->entryTask();
     }
     return $this->entryTask();
 }
 /**
  * Save changes to an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $fields = Request::getVar('fields', array(), 'post', 'none', 2);
     // Initiate extended database class
     $row = Comment::oneOrNew($fields['id'])->set($fields);
     // Store new content
     if (!$row->save()) {
         Notify::error($row->getError());
         return $this->editTask($row);
     }
     Notify::success(Lang::txt('COM_BLOG_COMMENT_SAVED'));
     if ($this->_task == 'apply') {
         return $this->editTask($row);
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&entry_id=' . $fields['entry_id'], false));
 }
Exemple #5
0
 /**
  * Save a comment
  *
  * @return     string
  */
 private function _savecomment()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $blog = Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name, false, true);
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($blog)), Lang::txt('GROUPS_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 = \Components\Blog\Models\Comment::oneOrNew($comment['id'])->set($comment);
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_entry();
     }
     return $this->_entry();
 }
Exemple #6
0
 /**
  * Save a comment
  *
  * @return  string
  */
 private function _savecomment()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         return $this->_login();
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $data = Request::getVar('comment', array(), 'post', 'none', 2);
     // Instantiate a new comment object and pass it the data
     $comment = \Components\Blog\Models\Comment::oneOrNew($data['id'])->set($data);
     // Store new content
     if (!$comment->save()) {
         $this->setError($comment->getError());
         return $this->_entry();
     }
     // Log the activity
     $entry = \Components\Blog\Models\Entry::oneOrFail($comment->get('entry_id'));
     $recipients = array($comment->get('created_by'));
     if ($comment->get('created_by') != $entry->get('created_by')) {
         $recipients[] = $entry->get('created_by');
     }
     if ($comment->get('parent')) {
         $recipients[] = $comment->parent()->get('created_by');
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => $data['id'] ? 'updated' : 'created', 'scope' => 'blog.entry.comment', 'scope_id' => $comment->get('id'), 'anonymous' => $comment->get('anonymous', 0), 'description' => Lang::txt('PLG_MEMBERS_BLOG_ACTIVITY_COMMENT_' . ($data['id'] ? 'UPDATED' : 'CREATED'), $comment->get('id'), '<a href="' . Route::url($entry->link() . '#c' . $comment->get('id')) . '">' . $entry->get('title') . '</a>'), 'details' => array('title' => $entry->get('title'), 'entry_id' => $entry->get('id'), 'url' => $entry->link() . '#c' . $comment->get('id'))], 'recipients' => $recipients]);
     return $this->_entry();
 }
Exemple #7
0
 /**
  * Save a comment
  *
  * @return  string
  */
 private function _savecomment()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $this->setError(Lang::txt('MEMBERS_LOGIN_NOTICE'));
         return $this->_login();
     }
     // 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 = \Components\Blog\Models\Comment::oneOrNew($comment['id'])->set($comment);
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_entry();
     }
     /*
     if ($row->get('created_by') != $this->member->get('uidNumber))
     {
     	$entry = \Components\Blog\Models\Entry::oneOrFail($row->get('entry_id'));
     
     	// Build the "from" data for the e-mail
     	$from = array(
     		'name'  => Config::get('sitename') . ' ' . Lang::txt('PLG_MEMBERS_BLOG'),
     		'email' => Config::get('mailfrom')
     	);
     
     	$subject = Lang::txt('PLG_MEMBERS_BLOG_SUBJECT_COMMENT_POSTED');
     
     	// Message
     	$message  = "The following comment has been posted to your blog entry:\r\n\r\n";
     	$message .= stripslashes($row->content)."\r\n\r\n";
     	$message .= "To view all comments on the blog entry, go to:\r\n";
     	$message .= rtrim(Request::base(), '/') . '/' . ltrim(Route::url($entry->link() . '#comments), '/') . "\r\n";
     
     	// Send the message
     	if (!Event::trigger('xmessage.onSendMessage', array('blog_comment', $subject, $message, $from, array($this->member->get('uidNumber')), $this->option)))
     	{
     		$this->setError(Lang::txt('PLG_MEMBERS_BLOG_ERROR_MSG_MEMBER_FAILED'));
     	}
     }
     */
     return $this->_entry();
 }