Ejemplo n.º 1
0
 function save_order_action()
 {
     ForumPerm::check('sort_area', $this->getId());
     foreach (Request::getArray('areas') as $category_id => $areas) {
         $pos = 0;
         foreach ($areas as $area_id) {
             ForumPerm::checkCategoryId($this->getId(), $category_id);
             ForumPerm::check('sort_area', $this->getId(), $area_id);
             ForumCat::addArea($category_id, $area_id);
             ForumCat::setAreaPosition($area_id, $pos);
             $pos++;
         }
     }
     $this->render_nothing();
 }
Ejemplo n.º 2
0
 private function getAreas($category_id, $offset = 0, $limit = 10)
 {
     $offset = (int) $offset;
     $limit = (int) $limit;
     $areas = array();
     foreach (\ForumCat::getAreas($category_id, $offset, $limit) as $area) {
         $url = $this->urlf('/forum_entry/%s', array(htmlReady($area['topic_id'])));
         $areas[$url] = $this->convertEntry($area);
     }
     return $areas;
 }
Ejemplo n.º 3
0
 /**
  * returns a hashmap with arrays containing id and name with the entries
  * which lead to the passed topic
  *
  * @param string $topic_id the topic to get the path for
  *
  * @return array
  */
 static function getPathToPosting($topic_id)
 {
     $data = ForumEntry::getConstraints($topic_id);
     $ret = array();
     $stmt = DBManager::get()->prepare("SELECT * FROM forum_entries\n            WHERE lft <= ? AND rgt >= ? AND seminar_id = ? ORDER BY lft ASC");
     $stmt->execute(array($data['lft'], $data['rgt'], $data['seminar_id']));
     while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $ret[$data['topic_id']] = $data;
         $ret[$data['topic_id']]['id'] = $data['topic_id'];
     }
     // set the name of the first entry to the name of the category the entry is in
     if (sizeof($ret) > 1) {
         reset($ret);
         $area = array_pop(array_slice($ret, 1, 1));
         $top = current($ret);
         $ret[$top['id']]['name'] = ForumCat::getCategoryNameForArea($area['id']) ?: _('Allgemein');
     }
     return $ret;
 }
Ejemplo n.º 4
0
 /**
  * Save the ordering of the categories
  */
 function savecats_action()
 {
     ForumPerm::check('sort_category', $this->getId());
     $pos = 0;
     foreach (Request::getArray('categories') as $category_id) {
         ForumPerm::checkCategoryId($this->getId(), $category_id);
         ForumCat::setPosition($category_id, $pos);
         $pos++;
     }
     $this->render_nothing();
 }
Ejemplo n.º 5
0
 /**
  * check if the passed category_id belongs to the passed seminar_id.
  * Throws an AccessDenied denied exception if this is not the case
  * 
  * @param type $seminar_id   id of the seminar, the category should belong to
  * @param type $category_id  the id of the category to check
  */
 static function checkCategoryId($seminar_id, $category_id)
 {
     $data = ForumCat::get($category_id);
     if ($data['seminar_id'] != $seminar_id) {
         throw new AccessDeniedException(sprintf(_('Forum: Sie haben keine Berechtigung auf die Kategorie mit der ID %s zuzugreifen!'), $category_id));
     }
 }
Ejemplo n.º 6
0
 /**
  * move the submitted topics[] to the passed destination
  * 
  * @param string $destination id of seminar to move topics to
  */
 function move_action($destination)
 {
     // check if destination is a category_id. if yes, use seminar_id instead
     if (ForumCat::get($destination)) {
         $category_id = $destination;
         $destination = $this->getId();
     }
     ForumPerm::check('admin', $this->getId(), $destination);
     foreach (Request::getArray('topics') as $topic_id) {
         // make sure every passed topic_id is checked against the current seminar
         ForumPerm::check('admin', $this->getId(), $topic_id);
         // if the source is an area and the target a category, just move this area to the category
         $entry = ForumEntry::getEntry($topic_id);
         if ($entry['depth'] == 1 && $category_id) {
             ForumCat::removeArea($topic_id);
             ForumCat::addArea($category_id, $topic_id);
         } else {
             // first step: move the whole topic with all childs
             ForumEntry::move($topic_id, $destination);
             // if the current topic id is an area, remove it from any categories
             ForumCat::removeArea($topic_id);
             // second step: move all to deep childs a level up (depth > 3)
             $data = ForumEntry::getList('depth_to_large', $topic_id);
             foreach ($data['list'] as $entry) {
                 $path = ForumEntry::getPathToPosting($entry['topic_id']);
                 array_shift($path);
                 // Category
                 array_shift($path);
                 // Area
                 $thread = array_shift($path);
                 // Thread
                 ForumEntry::move($entry['topic_id'], $thread['id']);
             }
             // add entry to passed category when moving to the top
             if ($category_id) {
                 ForumCat::addArea($category_id, $topic_id);
             }
         }
     }
     $this->render_nothing();
 }