Beispiel #1
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);
 }
Beispiel #2
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);
 }