Example #1
0
 /**
  * Mark an item as deleted
  *
  * @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     string
  */
 public function deleteReportedItem($refid, $parent, $category, $message)
 {
     if (!$this->_canHandle($category)) {
         return null;
     }
     require_once PATH_CORE . DS . 'components' . DS . 'com_blog' . DS . 'models' . DS . 'comment.php';
     $comment = \Components\Blog\Models\Comment::oneOrFail($refid);
     $comment->set('state', 2);
     $comment->save();
     return '';
 }
Example #2
0
 /**
  * Delete a comment
  *
  * @return     string
  */
 private function _deletecomment()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $this->setError(Lang::txt('GROUPS_LOGIN_NOTICE'));
         return;
     }
     // Incoming
     $id = Request::getInt('comment', 0);
     if (!$id) {
         return $this->_entry();
     }
     // Initiate a blog comment object
     $comment = \Components\Blog\Models\Comment::oneOrFail($id);
     // Delete all comments on an entry
     $comment->set('state', $comment::STATE_DELETED);
     // Delete the entry itself
     if (!$comment->save()) {
         $this->setError($comment->getError());
     }
     // Record the activity
     $recipients = array(['group', $this->group->get('gidNumber')]);
     if (!in_array($comment->get('created_by'), $this->group->get('managers'))) {
         $recipients[] = ['user', $comment->get('created_by')];
     }
     foreach ($this->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     $entry = \Components\Blog\Models\Entry::oneOrFail($comment->get('entry_id'));
     Event::trigger('system.logActivity', ['activity' => ['action' => 'deleted', 'scope' => 'blog.entry.comment', 'scope_id' => $comment->get('id'), 'description' => Lang::txt('PLG_GROUPS_BLOG_ACTIVITY_COMMENT_DELETED', $comment->get('id'), '<a href="' . Route::url($entry->link()) . '">' . $entry->get('title') . '</a>'), 'details' => array('title' => $entry->get('title'), 'entry_id' => $entry->get('id'), 'url' => $entry->link())], 'recipients' => $recipients]);
     // Return the topics list
     return $this->_entry();
 }
Example #3
0
 /**
  * Delete a comment
  *
  * @return  void
  */
 public function deletecommentTask()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $this->setError(Lang::txt('COM_BLOG_LOGIN_NOTICE'));
         return $this->entryTask();
     }
     // Incoming
     $id = Request::getInt('comment', 0);
     $year = Request::getVar('year', '');
     $month = Request::getVar('month', '');
     $alias = Request::getVar('alias', '');
     if (!$id) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&year=' . $year . '&month=' . $month . '&alias=' . $alias, false));
         return;
     }
     // Initiate a blog comment object
     $comment = Comment::oneOrFail($id);
     if (User::get('id') != $comment->get('created_by') && !$this->config->get('access-delete-comment')) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&year=' . $year . '&month=' . $month . '&alias=' . $alias, false));
         return;
     }
     // Mark all comments as deleted
     $comment->set('state', Comment::STATE_DELETED);
     $comment->save();
     // 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');
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => 'deleted', 'scope' => 'blog.entry.comment', 'scope_id' => $comment->get('id'), 'description' => Lang::txt('COM_BLOG_ACTIVITY_COMMENT_DELETED', $comment->get('id'), '<a href="' . Route::url($entry->link()) . '">' . $entry->get('title') . '</a>'), 'details' => array('title' => $entry->get('title'), 'entry_id' => $entry->get('id'), 'url' => $entry->link())], 'recipients' => $recipients]);
     // Return the topics list
     App::redirect(Route::url('index.php?option=' . $this->_option . '&year=' . $year . '&month=' . $month . '&alias=' . $alias), $this->getError() ? $this->getError() : null, $this->getError() ? 'error' : null);
 }
Example #4
0
 /**
  * Delete a comment
  *
  * @return  void
  */
 public function deletecommentTask()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $this->setError(Lang::txt('COM_BLOG_LOGIN_NOTICE'));
         return $this->entryTask();
     }
     // Incoming
     $id = Request::getInt('comment', 0);
     $year = Request::getVar('year', '');
     $month = Request::getVar('month', '');
     $alias = Request::getVar('alias', '');
     if (!$id) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&year=' . $year . '&month=' . $month . '&alias=' . $alias));
         return;
     }
     // Initiate a blog comment object
     $comment = Comment::oneOrFail($id);
     if (User::get('id') != $comment->get('created_by') && !$this->config->get('access-delete-comment')) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&year=' . $year . '&month=' . $month . '&alias=' . $alias));
         return;
     }
     // Mark all comments as deleted
     $comment->set('state', 2);
     $comment->save();
     // Return the topics list
     App::redirect(Route::url('index.php?option=' . $this->_option . '&year=' . $year . '&month=' . $month . '&alias=' . $alias), $this->getError() ? $this->getError() : null, $this->getError() ? 'error' : null);
 }
Example #5
0
 /**
  * Delete one or more entries
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     if (count($ids) > 0) {
         $removed = 0;
         // Loop through all the IDs
         foreach ($ids as $id) {
             // Delete the entry
             $entry = Comment::oneOrFail(intval($id));
             if (!$entry->destroy()) {
                 Notify::error($entry->getError());
                 continue;
             }
             $removed++;
         }
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&entry_id=' . Request::getInt('entry_id', 0), false), $removed ? Lang::txt('COM_BLOG_COMMENT_DELETED') : null);
 }
Example #6
0
 /**
  * Delete one or more entries
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     if (!User::authorise('core.delete', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // Incoming
     $ids = Request::getVar('id', array());
     if (count($ids) > 0) {
         $removed = 0;
         // Loop through all the IDs
         foreach ($ids as $id) {
             // Delete the entry
             $entry = Comment::oneOrFail(intval($id));
             if (!$entry->destroy()) {
                 Notify::error($entry->getError());
                 continue;
             }
             $removed++;
         }
     }
     if ($removed) {
         Notify::success(Lang::txt('COM_BLOG_COMMENT_DELETED'));
     }
     // Set the redirect
     $this->cancelTask();
 }
Example #7
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();
 }
Example #8
0
 /**
  * Delete a comment
  *
  * @return     string
  */
 private function _deletecomment()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $this->setError(Lang::txt('GROUPS_LOGIN_NOTICE'));
         return;
     }
     // Incoming
     $id = Request::getInt('comment', 0);
     if (!$id) {
         return $this->_entry();
     }
     // Initiate a blog comment object
     $comment = \Components\Blog\Models\Comment::oneOrFail($id);
     // Delete all comments on an entry
     $comment->set('state', 2);
     // Delete the entry itself
     if (!$comment->save()) {
         $this->setError($comment->getError());
     }
     // Return the topics list
     return $this->_entry();
 }