Beispiel #1
0
 /**
  * Save a category record and redirects to listing
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     User::setState('com_forum.edit.category.data', null);
     // Incoming
     $fields = Request::getVar('fields', array(), 'post');
     $fields = array_map('trim', $fields);
     // Initiate extended database class
     $category = Category::oneOrNew($fields['id'])->set($fields);
     // Bind the rules.
     $data = Request::getVar('jform', array(), 'post');
     if (isset($data['rules']) && is_array($data['rules'])) {
         $model = new AdminCategory();
         $form = $model->getForm($data, false);
         $validData = $model->validate($form, $data);
         $category->assetRules = new \JAccessRules($validData['rules']);
     }
     if (!$category->get('scope')) {
         $section = Section::oneOrFail($fields['section_id']);
         $category->set('scope', $section->get('scope'));
         $category->set('scope_id', $section->get('scope_id'));
     }
     // Store new content
     if (!$category->save()) {
         Notify::error($category->getError());
         return $this->editTask($category);
     }
     Notify::success(Lang::txt('COM_FORUM_CATEGORY_SAVED'));
     if ($this->getTask() == 'apply') {
         return $this->editTask($category);
     }
     // Redirect
     $this->cancelTask();
 }
Beispiel #2
0
 /**
  * Sets the access of one or more entries
  *
  * @return  void
  */
 public function accessTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     if (!User::authorise('core.edit.state', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // 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) {
         Notify::warning(Lang::txt('COM_FORUM_SELECT_ENTRY_TO_CHANGE_ACCESS'));
         return $this->cancelTask();
     }
     $i = 0;
     foreach ($ids as $id) {
         // Update record(s)
         $row = Section::oneOrFail(intval($id));
         $row->set('access', $state);
         if (!$row->save()) {
             Notify::error($row->getError());
             continue;
         }
         $i++;
     }
     if ($i) {
         Notify::success(Lang::txt('COM_FORUM_ITEMS_ACCESS_CHANGED', $i));
     }
     $this->cancelTask();
 }
Beispiel #3
0
 /**
  * Deletes a section and redirects to main page afterwards
  *
  * @return  void
  */
 public function deleteTask()
 {
     // Is the user logged in?
     if (User::isGuest()) {
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode(Route::url('index.php?option=' . $this->_option, false, true))), Lang::txt('COM_FORUM_LOGIN_NOTICE'), 'warning');
         return;
     }
     $this->_authorize('section');
     // Load the section
     $section = Section::all()->whereEquals('alias', Request::getVar('section'))->whereEquals('scope', $this->forum->get('scope'))->whereEquals('scope_id', $this->forum->get('scope_id'))->where('state', '!=', Section::STATE_DELETED)->row();
     // Make the sure the section exist
     if (!$section->get('id')) {
         App::redirect(Route::url('index.php?option=' . $this->_option), Lang::txt('COM_FORUM_MISSING_ID'), 'error');
         return;
     }
     // Check if user is authorized to delete entries
     $this->_authorize('section', $section->get('id'));
     if (!$this->config->get('access-delete-section')) {
         App::redirect(Route::url('index.php?option=' . $this->_option), Lang::txt('COM_FORUM_NOT_AUTHORIZED'), 'warning');
         return;
     }
     // Set the section to "deleted"
     $section->set('state', $section::STATE_DELETED);
     if (!$section->save()) {
         Notify::error($section->getError());
     } else {
         Notify::success(Lang::txt('COM_FORUM_SECTION_DELETED'));
     }
     // Log activity
     Event::trigger('system.logActivity', ['activity' => ['action' => 'deleted', 'scope' => 'forum.section', 'scope_id' => $section->get('id'), 'description' => Lang::txt('PLG_GROUPS_FORUM_ACTIVITY_SECTION_DELETED', '<a href="' . Route::url('index.php?option=' . $this->_option) . '">' . $section->get('title') . '</a>'), 'details' => array('title' => $section->get('title'), 'url' => Route::url('index.php?option=' . $this->_option))], 'recipients' => array(['forum.site', 1], ['forum.section', $section->get('id')], ['user', $section->get('created_by')])]);
     // Redirect to main listing
     App::redirect(Route::url('index.php?option=' . $this->_option));
 }
Beispiel #4
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)));
 }
Beispiel #5
0
 /**
  * Verifies no duplicate aliases within a secton's categories listing.
  * Returns true if duplicate detected.
  *
  * @param integer $id the id of the category object
  *
  * @return boolean
  */
 public function uniqueAliasCheck($id = null)
 {
     $alias = $this->get('alias');
     $section = new Section($this->get('section_id'));
     // all categories within a section
     $categories = $section->categories('list');
     // check for duplicate aliases within the same section;
     foreach ($categories as $category) {
         $existing = $category->get('alias');
         if ($alias == $existing && $category->get('id') != $id) {
             $this->setError(Lang::txt('The alias must be unique within a section.'));
             return true;
         } else {
             continue;
         }
     }
     return false;
 }
Beispiel #6
0
 /**
  * Displays a question response for editing
  *
  * @param   mixed  $post
  * @return  void
  */
 public function editTask($post = null)
 {
     Request::setVar('hidemainmenu', 1);
     if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.create', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // Incoming
     $parent = Request::getInt('parent', 0);
     if (!is_object($post)) {
         $id = Request::getVar('id', array(0));
         if (is_array($id)) {
             $id = intval($id[0]);
         }
         $post = Post::oneOrNew($id);
     }
     if ($post->isNew()) {
         $post->set('parent', $parent);
         $post->set('created_by', User::get('id'));
     }
     if ($post->get('parent')) {
         $threads = Post::all()->whereEquals('category_id', $post->get('category_id'))->whereEquals('parent', 0)->ordered()->rows();
     }
     // Get the category
     $category = Category::oneOrNew($post->get('category_id'));
     $categories = array();
     foreach (Category::all()->rows() as $c) {
         if (!isset($categories[$c->section_id])) {
             $categories[$c->section_id] = array();
         }
         $categories[$c->section_id][] = $c;
         asort($categories[$c->section_id]);
     }
     // Get the section
     $section = Section::oneOrNew($category->get('section_id'));
     // Get the sections for this group
     $sections = array();
     foreach (Section::all()->rows() as $s) {
         $ky = $s->scope . ' (' . $s->scope_id . ')';
         if ($s->scope == 'site') {
             $ky = '[ site ]';
         }
         if (!isset($sections[$ky])) {
             $sections[$ky] = array();
         }
         $s->categories = isset($categories[$s->id]) ? $categories[$s->id] : array();
         $sections[$ky][] = $s;
         asort($sections[$ky]);
     }
     User::setState('com_forum.edit.thread.data', array('id' => $post->get('id'), 'asset_id' => $post->get('asset_id')));
     $m = new AdminThread();
     $form = $m->getForm();
     // Get tags on this article
     $this->view->set('row', $post)->set('sections', $sections)->set('categories', $categories)->set('form', $form)->setLayout('edit')->display();
 }
Beispiel #7
0
 /**
  * Get all available scopes
  *
  * @return  array
  */
 public function scopes()
 {
     $section = Section::blank();
     $db = \App::get('db');
     $db->setQuery("\n\t\t\tSELECT DISTINCT s.scope, s.scope_id\n\t\t\tFROM " . $section->getTableName() . " AS s\n\t\t\tORDER BY s.scope, s.scope_id\n\t\t");
     $results = $db->loadObjectList();
     if (!$results || !is_array($results)) {
         $results = array();
     }
     $scope = $this->get('scope');
     $scope_id = $this->get('scope_id');
     foreach ($results as $i => $result) {
         $this->set('scope', $result->scope);
         $this->set('scope_id', $result->scope_id);
         $results[$i]->caption = $this->adapter()->name();
     }
     $this->set('scope', $scope);
     $this->set('scope_id', $scope_id);
     return $results;
 }
Beispiel #8
0
 /**
  * Get the adapter
  *
  * @return  object
  */
 public function adapter()
 {
     if (!$this->_adapter) {
         $this->_adapter = $this->_adapter();
         $this->_adapter->set('thread', $this->get('thread'));
         $this->_adapter->set('parent', $this->get('parent'));
         $this->_adapter->set('post', $this->get('id'));
         if (!$this->get('category')) {
             $category = Category::getInstance($this->get('category_id'));
             $this->set('category', $category->get('alias'));
         }
         $this->_adapter->set('category', $this->get('category'));
         if (!$this->get('section')) {
             $category = Category::getInstance($this->get('category_id'));
             $this->set('section', Section::getInstance($category->get('section_id'))->get('alias'));
         }
         $this->_adapter->set('section', $this->get('section'));
     }
     return $this->_adapter;
 }
Beispiel #9
0
 /**
  * Show a form for editing an entry
  *
  * @param   mixed  $post
  * @return  void
  */
 public function editTask($post = null)
 {
     $id = Request::getInt('thread', 0);
     $category = Request::getCmd('category', '');
     $section = Request::getCmd('section', '');
     if (User::isGuest()) {
         $return = Route::url('index.php?option=' . $this->_option . '&section=' . $section . '&category=' . $category . '&task=new');
         if ($id) {
             $return = Route::url('index.php?option=' . $this->_option . '&section=' . $section . '&category=' . $category . '&thread=' . $id . '&task=edit');
         }
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($return)) . Lang::txt('COM_FORUM_LOGIN_NOTICE'), 'warning');
     }
     // Section
     $section = Section::all()->whereEquals('alias', $section)->whereEquals('scope', $this->forum->get('scope'))->whereEquals('scope_id', $this->forum->get('scope_id'))->where('state', '!=', Section::STATE_DELETED)->row();
     if (!$section->get('id')) {
         App::abort(404, Lang::txt('COM_FORUM_SECTION_NOT_FOUND'));
     }
     // Get the category
     $category = Category::all()->whereEquals('alias', $category)->whereEquals('scope', $this->forum->get('scope'))->whereEquals('scope_id', $this->forum->get('scope_id'))->where('state', '!=', Category::STATE_DELETED)->row();
     if (!$category->get('id')) {
         App::abort(404, Lang::txt('COM_FORUM_CATEGORY_NOT_FOUND'));
     }
     // Incoming
     if (!is_object($post)) {
         $post = Post::oneOrNew($id);
     }
     $this->_authorize('thread', $id);
     if ($post->isNew()) {
         $post->set('scope', $this->forum->get('scope'));
         $post->set('created_by', User::get('id'));
     } elseif ($post->get('created_by') != User::get('id') && !$this->config->get('access-edit-thread')) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&section=' . $section . '&category=' . $category), Lang::txt('COM_FORUM_NOT_AUTHORIZED'), 'warning');
     }
     // Set the page title
     $this->buildTitle($section, $category, $post);
     // Set the pathway
     $this->buildPathway($section, $category, $post);
     $this->view->set('config', $this->config)->set('forum', $this->forum)->set('section', $section)->set('category', $category)->set('post', $post)->setErrors($this->getErrors())->setLayout('edit')->display();
 }
Beispiel #10
0
 /**
  * Set and get a specific section
  *
  * @param   mixed   $id
  * @return  object
  */
 public function section($id = null)
 {
     if (!isset($this->_cache['section']) || $id !== null && (int) $this->_cache['section']->get('id') != $id && (string) $this->_cache['section']->get('alias') != $id) {
         $this->_cache['section'] = null;
         if ($this->_cache['sections'] instanceof ItemList) {
             foreach ($this->_cache['sections'] as $key => $section) {
                 if ((int) $section->get('id') == $id || (string) $section->get('alias') == $id) {
                     $this->_cache['section'] = $section;
                     break;
                 }
             }
         }
         if (!$this->_cache['section']) {
             $this->_cache['section'] = Section::getInstance($id, $this->get('scope'), $this->get('scope_id'));
         }
         if (!$this->_cache['section']->exists()) {
             $this->_cache['section']->set('scope', $this->get('scope'));
             $this->_cache['section']->set('scope_id', $this->get('scope_id'));
         }
     }
     return $this->_cache['section'];
 }
Beispiel #11
0
 /**
  * Remove all items associated with the gorup being deleted
  *
  * @param   object  $course  Course being deleted
  * @return  string  Log of items removed
  */
 public function onCourseDelete($course)
 {
     if (!$course->exists()) {
         return '';
     }
     $log = Lang::txt('PLG_COURSES_FORUM') . ': ';
     $sections = array();
     foreach ($course->offerings() as $offering) {
         if (!$offering->exists()) {
             continue;
         }
         $sec = Section::all()->whereEquals('scope', 'course')->whereEquals('scope_id', $offering->get('id'))->rows();
         foreach ($sec as $s) {
             $sections[] = $s;
         }
     }
     // Do we have any IDs?
     if (count($sections) > 0) {
         // Loop through each ID
         foreach ($sections as $section) {
             // Get the categories in this section
             $categories = $section->categories()->rows();
             if ($categories->count()) {
                 // Build a list of category IDs
                 foreach ($categories as $category) {
                     $log .= 'forum.section.' . $section->get('id') . '.category.' . $category->get('id') . '.post' . "\n";
                     $log .= 'forum.section.' . $section->get('id') . '.category.' . $category->get('id') . "\n";
                 }
             }
             $log .= 'forum.section.' . $section->get('id') . ' ' . "\n";
             // Set the section to "deleted"
             // Set all the categories to "deleted"
             // Set all the threads/posts in all the categories to "deleted"
             $section->set('state', $section::STATE_DELETED);
             if (!$section->save()) {
                 $this->setError($sModel->getError());
                 return '';
             }
         }
     } else {
         $log .= Lang::txt('PLG_COURSES_DISCUSSIONS_NO_RESULTS') . "\n";
     }
     return $log;
 }
Beispiel #12
0
 /**
  * Display a list of threads
  *
  * @apiMethod GET
  * @apiUri    /forum/list
  * @apiParameter {
  * 		"name":          "limit",
  * 		"description":   "Number of result to return.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       25
  * }
  * @apiParameter {
  * 		"name":          "limitstart",
  * 		"description":   "Number of where to start returning results.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "search",
  * 		"description":   "A word or phrase to search for.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "section",
  * 		"description":   "Section ID. Find all posts for all categories within a section.",
  * 		"type":          "integer",
  * 		"required":      false,
  *      "default":       0
  * }
  * @apiParameter {
  * 		"name":          "category",
  * 		"description":   "Category ID. Find all posts within a category.",
  * 		"type":          "integer",
  * 		"required":      false,
  *      "default":       0
  * }
  * @apiParameter {
  * 		"name":          "threads_only",
  * 		"description":   "Return only thread starter posts (true) or any post (false).",
  * 		"type":          "boolean",
  * 		"required":      false,
  *      "default":       false
  * }
  * @apiParameter {
  * 		"name":          "parent",
  * 		"description":   "Parent post ID. Find all immediate descendent (replies) posts.",
  * 		"type":          "integer",
  * 		"required":      false,
  *      "default":       null
  * }
  * @apiParameter {
  * 		"name":          "thread",
  * 		"description":   "Thread ID. Find all posts in a specified thread.",
  * 		"type":          "integer",
  * 		"required":      false,
  *      "default":       0
  * }
  * @apiParameter {
  * 		"name":          "scope",
  * 		"description":   "Scope (site, groups, members, etc.)",
  * 		"type":          "string",
  * 		"required":      false,
  *      "default":       "site"
  * }
  * @apiParameter {
  * 		"name":          "scope_id",
  * 		"description":   "Scope ID",
  * 		"type":          "integer",
  * 		"required":      false,
  *      "default":       0
  * }
  * @return    void
  */
 public function listTask()
 {
     $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'section_id' => Request::getInt('section', 0), 'category_id' => Request::getInt('category', 0), 'parent' => Request::getInt('parent', 0), 'thread' => Request::getInt('thread', 0), 'threads' => Request::getVar('threads_only', false), 'search' => Request::getVar('search', ''), 'scope' => Request::getWord('scope', 'site'), 'scope_id' => Request::getInt('scope_id', 0), 'state' => Post::STATE_PUBLISHED, 'parent' => 0, 'access' => User::getAuthorisedViewLevels());
     $filters['threads'] = !$filters['threads'] || $filters['threads'] == 'false' ? false : true;
     if ($filters['scope'] == 'group') {
         $group = \Hubzero\User\Group::getInstance($filters['scope_id']);
         if ($group && in_array(User::get('id'), $group->get('members'))) {
             $filters['access'][] = 5;
             // Private
         }
     }
     $entries = Post::all()->whereEquals('state', $filters['state'])->whereIn('access', $filters['access'])->whereEquals('scope', $filters['scope'])->whereEquals('scope_id', $filters['scope_id']);
     if ($filters['thread']) {
         $entries->whereEquals('thread', $filters['thread']);
     }
     if ($filters['parent']) {
         $entries->whereEquals('parent', $filters['parent']);
     }
     if ($filters['threads']) {
         $entries->whereEquals('parent', 0);
     }
     if ($filters['section_id']) {
         // Make sure the section exists and is available
         $section = Section::oneOrFail($filters['section_id']);
         if (!$section->get('id')) {
             throw new Exception(Lang::txt('COM_FORUM_ERROR_SECTION_NOT_FOUND'), 404);
         }
         if ($section->get('state') == Section::STATE_DELETED) {
             throw new Exception(Lang::txt('COM_FORUM_ERROR_SECTION_NOT_FOUND'), 404);
         }
         if (!$filters['category_id']) {
             $categories = $section->categories()->whereEquals('state', $filters['state'])->whereIn('access', $filters['access'])->rows();
             $filters['category_id'] = array();
             foreach ($categories as $category) {
                 $filters['category_id'][] = $category->get('id');
             }
         }
     }
     if ($filters['category_id']) {
         // If one category, make sure it exists and is available
         if (is_int($filters['category_id'])) {
             $category = Category::oneOrFail($filters['category_id']);
             if (!$category->get('id')) {
                 throw new Exception(Lang::txt('COM_FORUM_ERROR_CATEGORY_NOT_FOUND'), 404);
             }
             if ($category->get('state') == Category::STATE_DELETED) {
                 throw new Exception(Lang::txt('COM_FORUM_ERROR_CATEGORY_NOT_FOUND'), 404);
             }
             if ($filters['section_id'] && $category->get('section_id') != $filters['section_id']) {
                 throw new Exception(Lang::txt('COM_FORUM_ERROR_CATEGORY_NOT_FOUND'), 404);
             }
         }
         $entries->whereIn('category_id', (array) $filters['category_id']);
     }
     if ($filters['search']) {
         $entries->whereLike('comment', $filters['search'], 1)->orWhereLike('title', $filters['search'], 1)->resetDepth();
     }
     $threads = $entries->ordered()->paginated()->rows();
     $response = new stdClass();
     $response->threads = array();
     $response->total = $threads->count();
     if ($response->total) {
         $base = str_replace('/api', '', rtrim(Request::base(), '/'));
         foreach ($threads as $thread) {
             $obj = new stdClass();
             $obj->id = $thread->get('id');
             $obj->title = $thread->get('title');
             $obj->created = with(new Date($thread->get('created')))->format('Y-m-d\\TH:i:s\\Z');
             $obj->modified = $thread->get('modified');
             $obj->anonymous = $thread->get('anonymous');
             //$obj->closed      = ($thread->get('closed') ? true : false);
             $obj->scope = $thread->get('scope');
             $obj->scope_id = $thread->get('scope_id');
             $obj->thread = $thread->get('thread');
             $obj->parent = $thread->get('parent');
             $obj->category_id = $thread->get('category_id');
             $obj->state = $thread->get('state');
             $obj->access = $thread->get('access');
             $obj->creator = new stdClass();
             $obj->creator->id = 0;
             $obj->creator->name = Lang::txt('COM_FORUM_ANONYMOUS');
             if (!$thread->get('anonymous')) {
                 $obj->creator->id = $thread->get('created_by');
                 $obj->creator->name = $thread->creator->get('name');
             }
             $obj->posts = $thread->thread()->whereEquals('state', $filters['state'])->whereIn('access', $filters['access'])->total();
             $obj->url = $base . '/' . ltrim(Route::url($thread->link()), '/');
             $response->threads[] = $obj;
         }
     }
     $response->success = true;
     $this->send($response);
 }
Beispiel #13
0
 /**
  * Show a form for editing an entry
  *
  * @param   object  $category
  * @return  void
  */
 public function editTask($category = null)
 {
     if (User::isGuest()) {
         $return = Route::url('index.php?option=' . $this->_option, false, true);
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($return)));
     }
     // Get the section
     $section = Section::all()->whereEquals('alias', Request::getVar('section', ''))->whereEquals('scope', $this->forum->get('scope'))->whereEquals('scope_id', $this->forum->get('scope_id'))->where('state', '!=', Section::STATE_DELETED)->row();
     if (!$section->get('id')) {
         App::abort(404, Lang::txt('COM_FORUM_SECTION_NOT_FOUND'));
     }
     // Incoming
     if (!is_object($category)) {
         $category = Category::all()->whereEquals('alias', Request::getVar('category', ''))->whereEquals('scope', $this->forum->get('scope'))->whereEquals('scope_id', $this->forum->get('scope_id'))->whereEquals('section_id', $section->get('id'))->where('state', '!=', Category::STATE_DELETED)->row();
     }
     $this->_authorize('category', $category->get('id'));
     if ($category->isNew()) {
         $category->set('created_by', User::get('id'));
         $category->set('section_id', $section->get('id'));
     } elseif ($category->get('created_by') != User::get('id') && !$this->config->get('access-create-category')) {
         App::redirect(Route::url('index.php?option=' . $this->_option));
     }
     // Output the view
     $this->view->set('config', $this->config)->set('forum', $this->forum)->set('category', $category)->set('section', $section)->setLayout('edit')->display();
 }
Beispiel #14
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));
 }
Beispiel #15
0
 /**
  * Reorder a section
  *
  * @param   integer  $dir  Direction
  * @return  void
  */
 public function reorder($dir = 1)
 {
     if (User::isGuest()) {
         $this->setError(Lang::txt('GROUPS_LOGIN_NOTICE'));
         return;
     }
     if ($this->authorized != 'manager' && $this->authorized != 'admin') {
         $this->setError(Lang::txt('PLG_GROUPS_FORUM_NOT_AUTHORIZED'));
         return $this->sections();
     }
     // Get the section
     $section = Section::all()->whereEquals('alias', Request::getVar('section', ''))->whereEquals('scope', $this->forum->get('scope'))->whereEquals('scope_id', $this->forum->get('scope_id'))->row();
     // Move the section
     if (!$section->move($dir)) {
         Notify::error($section->getError());
     } else {
         // Record the activity
         $recipients = array(['group', $this->group->get('gidNumber')], ['forum.' . $this->forum->get('scope'), $this->forum->get('scope_id')], ['forum.section', $section->get('id')]);
         foreach ($this->group->get('managers') as $recipient) {
             $recipients[] = ['user', $recipient];
         }
         Event::trigger('system.logActivity', ['activity' => ['action' => 'reordered', 'scope' => 'forum.section', 'scope_id' => $section->get('id'), 'description' => Lang::txt('PLG_GROUPS_FORUM_ACTIVITY_SECTION_REORDERED', '<a href="' . Route::url($this->base) . '">' . $section->get('title') . '</a>'), 'details' => array('title' => $section->get('title'), 'url' => Route::url($this->base))], 'recipients' => $recipients]);
     }
     // Redirect to main lsiting
     App::redirect(Route::url($this->base));
 }