Example #1
0
 /**
  * Search threads and display a list of results
  *
  * @return  void
  */
 public function searchTask()
 {
     // Incoming
     $filters = array('scope' => $this->forum->get('scope'), 'scope_id' => $this->forum->get('scope_id'), 'state' => Category::STATE_PUBLISHED, 'access' => User::getAuthorisedViewLevels());
     $section = Section::blank();
     $section->set('scope', $this->forum->get('scope'));
     $section->set('title', Lang::txt('COM_FORUM_POSTS'));
     $section->set('alias', str_replace(' ', '-', $section->get('title')));
     $section->set('alias', preg_replace("/[^a-zA-Z0-9\\-]/", '', strtolower($section->get('title'))));
     // Get all sections
     $sections = array();
     foreach ($this->forum->sections($filters)->rows() as $section) {
         $sections[$section->get('id')] = $section;
     }
     $category = Category::blank();
     $category->set('scope', $this->forum->get('scope'));
     $category->set('scope_id', $this->forum->get('scope_id'));
     $category->set('title', Lang::txt('COM_FORUM_SEARCH'));
     $category->set('alias', str_replace(' ', '-', $category->get('title')));
     $category->set('alias', preg_replace("/[^a-zA-Z0-9\\-]/", '', strtolower($category->get('title'))));
     $categories = array();
     foreach ($this->forum->categories($filters)->rows() as $category) {
         $categories[$category->get('id')] = $category;
     }
     $filters['search'] = Request::getVar('q', '');
     if (!$filters['search']) {
         App::redirect(Route::url('index.php?option=' . $this->_option));
     }
     // Get authorization
     $this->_authorize('category');
     $this->_authorize('thread');
     // Set the page title
     $this->buildTitle($section, $category);
     // Set the pathway
     $this->buildPathway($section, $category);
     $this->view->set('config', $this->config)->set('forum', $this->forum)->set('sections', $sections)->set('categories', $categories)->set('filters', $filters)->display();
 }
Example #2
0
 /**
  * Populate the forum with defaulta section and category
  *
  * @return  boolean
  */
 public function setup()
 {
     // Create a default section
     $section = Section::blank()->set(array('title' => Lang::txt('COM_FORUM_SECTION_DEFAULT'), 'scope' => $this->get('scope'), 'scope_id' => $this->get('scope_id'), 'state' => 1));
     if (!$section->save()) {
         $this->setError($section->getError());
         return false;
     }
     // Create a default category
     $category = Category::blank()->set(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->save()) {
         $this->setError($category->getError());
         return false;
     }
     return true;
 }
Example #3
0
 /**
  * Search forum entries and display results
  *
  * @return  string
  */
 public function search()
 {
     // Incoming
     $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('q', ''), 'scope' => $this->forum->get('scope'), 'scope_id' => $this->forum->get('scope_id'), 'state' => 1, 'access' => array(1));
     if (!$filters['search']) {
         return $this->sections();
     }
     if (!User::isGuest()) {
         $filters['access'][] = 2;
         $filters['access'][] = 4;
     }
     if (in_array(User::get('id'), $this->members)) {
         $filters['access'][] = 5;
     }
     $section = Section::blank();
     $section->set('scope', $this->forum->get('scope'));
     $section->set('title', Lang::txt('PLG_GROUPS_FORUM_POSTS'));
     $section->set('alias', str_replace(' ', '-', $section->get('title')));
     $section->set('alias', preg_replace("/[^a-zA-Z0-9\\-]/", '', strtolower($section->get('title'))));
     // Get all sections
     $sections = array();
     foreach ($this->forum->sections($filters)->rows() as $section) {
         $sections[$section->get('id')] = $section;
     }
     $category = Category::blank();
     $category->set('scope', $this->forum->get('scope'));
     $category->set('scope_id', $this->forum->get('scope_id'));
     $category->set('title', Lang::txt('PLG_GROUPS_FORUM_SEARCH'));
     $category->set('alias', str_replace(' ', '-', $category->get('title')));
     $category->set('alias', preg_replace("/[^a-zA-Z0-9\\-]/", '', strtolower($category->get('title'))));
     $categories = array();
     foreach ($this->forum->categories($filters)->rows() as $category) {
         $categories[$category->get('id')] = $category;
     }
     $filters['search'] = Request::getVar('q', '');
     //get authorization
     $this->_authorize('category');
     $this->_authorize('thread');
     return $this->view('search', 'categories')->set('option', $this->option)->set('group', $this->group)->set('config', $this->params)->set('forum', $this->forum)->set('sections', $sections)->set('categories', $categories)->set('filters', $filters)->setErrors($this->getErrors())->loadTemplate();
 }