Example #1
0
 /**
  * Sets the state of one or more entries
  *
  * @return  void
  */
 public function accessTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     // Incoming
     $section = Request::getInt('section_id', 0);
     $state = Request::getInt('access', 0);
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Check for an ID
     if (count($ids) < 1) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&section_id=' . $section, false), Lang::txt('COM_FORUM_SELECT_ENTRY_TO_CHANGE_ACCESS'), 'error');
         return;
     }
     foreach ($ids as $id) {
         // Update record(s)
         $row = new Category($this->database);
         $row->load(intval($id));
         $row->access = $state;
         if (!$row->store()) {
             throw new Exception($row->getError(), 500);
         }
     }
     // set message
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&section_id=' . $section, false), Lang::txt('COM_FORUM_ITEMS_ACCESS_CHANGED', count($ids)));
 }