Ejemplo n.º 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_wiki' . DS . 'models' . DS . 'comment.php';
     $comment = \Components\Wiki\Models\Comment::oneOrFail($refid);
     $comment->set('state', \Components\Wiki\Models\Comment::STATE_DELETED);
     $comment->save();
     return '';
 }
Ejemplo n.º 2
0
 /**
  * Remove a comment
  *
  * @return  void
  */
 public function removeTask()
 {
     $msg = null;
     $cls = 'message';
     // Make sure we have a comment to delete
     if ($id = Request::getInt('comment', 0)) {
         // Make sure they're authorized to delete (must be an author)
         if ($this->page->access('delete', 'comment')) {
             $comment = new Comment($id);
             $comment->set('status', 2);
             if ($comment->store(false)) {
                 $msg = Lang::txt('COM_WIKI_COMMENT_DELETED');
             }
         } else {
             $msg = Lang::txt('COM_WIKI_ERROR_NOTAUTH');
             $cls = 'error';
         }
     }
     // Redirect to Comments page
     App::redirect(Route::url($this->page->link('comments')), $msg, $cls);
 }
Ejemplo n.º 3
0
 /**
  * Remove a comment
  *
  * @return  void
  */
 public function removeTask()
 {
     $msg = null;
     $cls = 'message';
     // Make sure we have a comment to delete
     if ($id = Request::getInt('comment', 0)) {
         // Make sure they're authorized to delete (must be an author)
         if ($this->page->access('delete', 'comment')) {
             $comment = Comment::oneOrFail($id);
             $comment->set('state', Comment::STATE_DELETED);
             if ($comment->save()) {
                 $msg = Lang::txt('COM_WIKI_COMMENT_DELETED');
             }
             // Log activity
             $recipients = array(['wiki.site', 1], ['user', $this->page->get('created_by')], ['user', $comment->get('created_by')]);
             if ($this->page->get('scope') != 'site') {
                 $recipients[] = [$this->page->get('scope'), $this->page->get('scope_id')];
                 $recipients[0] = ['wiki.' . $this->page->get('scope'), $this->page->get('scope_id')];
             }
             Event::trigger('system.logActivity', ['activity' => ['action' => 'deleted', 'scope' => 'wiki.comment', 'scope_id' => $this->page->get('id'), 'description' => Lang::txt('COM_WIKI_ACTIVITY_COMMENT_DELETED', $comment->get('id'), '<a href="' . Route::url($this->page->link('comments')) . '">' . $this->page->title . '</a>'), 'details' => array('title' => $this->page->title, 'url' => Route::url($this->page->link('comments')), 'name' => $this->page->get('pagename'), 'comment' => $comment->get('id'))], 'recipients' => $recipients]);
         } else {
             $msg = Lang::txt('COM_WIKI_ERROR_NOTAUTH');
             $cls = 'error';
         }
     }
     // Redirect to Comments page
     App::redirect(Route::url($this->page->link('comments')), $msg, $cls);
 }
Ejemplo n.º 4
0
 /**
  * Set the status on one or more entries
  *
  * @return  void
  */
 public function stateTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     if (!User::authorise('core.edit.state', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     $state = $this->getTask() == 'unpublish' ? Comment::STATE_UNPUBLISHED : Comment::STATE_PUBLISHED;
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     $pageid = Request::getInt('page_id', 0);
     // Check for an ID
     if (count($ids) < 1) {
         $action = $state == Comment::STATE_PUBLISHED ? Lang::txt('COM_WIKI_UNPUBLISH') : Lang::txt('COM_WIKI_PUBLISH');
         Notify::warning(Lang::txt('COM_WIKI_ERROR_SELECT_TO', $action));
         return $this->cancelTask();
     }
     // Loop through all the IDs
     $i = 0;
     foreach ($ids as $id) {
         $comment = Comment::oneOrFail(intval($id));
         $comment->set('state', $state);
         if (!$comment->save()) {
             Notify::error($comment->getError());
             continue;
         }
         $i++;
     }
     // Set message
     if ($i) {
         if ($state == Comment::STATE_PUBLISHED) {
             $message = Lang::txt('COM_WIKI_ITEMS_PUBLISHED', $i);
         } else {
             $message = Lang::txt('COM_WIKI_ITEMS_UNPUBLISHED', $i);
         }
         Notify::success($message);
     }
     // Set redirect
     $this->cancelTask();
 }
Ejemplo n.º 5
0
 /**
  * Set the status on one or more entries
  *
  * @return  void
  */
 public function stateTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     $state = $this->getTask() == 'unpublish' ? 2 : 0;
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     $pageid = Request::getInt('pageid', 0);
     // Check for an ID
     if (count($ids) < 1) {
         $action = $state == 1 ? Lang::txt('COM_WIKI_UNPUBLISH') : Lang::txt('COM_WIKI_PUBLISH');
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&pageid=' . $pageid, false), Lang::txt('COM_WIKI_ERROR_SELECT_TO', $action), 'error');
         return;
     }
     // Loop through all the IDs
     foreach ($ids as $id) {
         $entry = new Comment(intval($id));
         $entry->set('status', $state);
         if (!$entry->store()) {
             \Notify::error($entry->getError());
         }
     }
     // Set message
     if ($state == 1) {
         $message = Lang::txt('COM_WIKI_ITEMS_PUBLISHED', count($ids));
     } else {
         $message = Lang::txt('COM_WIKI_ITEMS_UNPUBLISHED', count($ids));
     }
     // Set redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&pageid=' . $pageid, false), $message);
 }