Esempio n. 1
0
 /**
  * Populate the forum with defaulta section and category
  *
  * @return  boolean
  */
 public function setup()
 {
     // Create a default section
     $section = new Section(0, $this->get('scope'), $this->get('scope_id'));
     $section->bind(array('title' => Lang::txt('COM_FORUM_SECTION_DEFAULT'), 'scope' => $this->get('scope'), 'scope_id' => $this->get('scope_id'), 'state' => 1));
     if (!$section->store(true)) {
         $this->setError($section->getError());
         return false;
     }
     // Create a default category
     $category = new Category(0);
     $category->bind(array('title' => Lang::txt('COM_FORUM_CATEGORY_DEFAULT'), 'description' => Lang::txt('COM_FORUM_CATEGORY_DEFAULT_DESCRIPTION'), 'section_id' => $section->get('id'), 'scope' => $this->get('scope'), 'scope_id' => $this->get('scope_id'), 'state' => 1));
     if (!$category->store(true)) {
         $this->setError($category->getError());
         return false;
     }
     $this->_cache['sections'] = new ItemList(array($section));
     return true;
 }
Esempio n. 2
0
 /**
  * Sets the state of one or more entries
  *
  * @return  void
  */
 public function accessTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     // Incoming
     $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, false), Lang::txt('COM_FORUM_SELECT_ENTRY_TO_CHANGE_ACCESS'), 'error');
         return;
     }
     foreach ($ids as $id) {
         // Update record(s)
         $row = new Section(intval($id));
         if (!$row->exists()) {
             continue;
         }
         $row->set('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, false), Lang::txt('COM_FORUM_ITEMS_ACCESS_CHANGED', count($ids)));
 }
Esempio n. 3
0
 /**
  * Saves a section and redirects to main page afterward
  *
  * @return     void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming posted data
     $fields = Request::getVar('fields', array(), 'post');
     $fields = array_map('trim', $fields);
     // Instantiate a new table row and bind the incoming data
     $section = new Section($fields['id']);
     if (!$section->bind($fields)) {
         App::redirect(Route::url('index.php?option=' . $this->_option), $section->getError(), 'error');
         return;
     }
     // Store new content
     if (!$section->store(true)) {
         App::redirect(Route::url('index.php?option=' . $this->_option), $section->getError(), 'error');
         return;
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option));
 }