Esempio n. 1
0
 /**
  * Standard function to create the standardised category tree
  *
  * @param  ID_TEXT		Notification code
  * @param  ?ID_TEXT		The ID of where we're looking under (NULL: N/A)
  * @return array 			Tree structure
  */
 function create_category_tree($notification_code, $id)
 {
     require_code('ocf_forums2');
     $notification_category = get_param('id', NULL);
     $done_in_url = is_null($notification_category);
     $total = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'COUNT(*)');
     if ($total > 300) {
         return parent::create_category_tree($notification_code, $id);
     }
     // Too many, so just allow removing UI
     if (!is_null($id)) {
         if (substr($id, 0, 6) != 'forum:') {
             warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
         }
         $id = substr($id, 6);
     }
     $_pagelinks = ocf_get_forum_tree_secure(NULL, is_null($id) ? NULL : intval($id), false, NULL, '', NULL, NULL, false, 1);
     $pagelinks = array();
     foreach ($_pagelinks as $p) {
         $p['id'] = 'forum:' . strval($p['id']);
         $p['title'] = do_lang('A_FORUM', $p['title']);
         $pagelinks[] = $p;
         if (!$done_in_url) {
             if ('forum:' . $p['id'] == $notification_category) {
                 $done_in_url = true;
             }
         }
     }
     if (is_null($id)) {
         $max_topic_rows = max(0, 200 - $total);
         $types2 = $GLOBALS['SITE_DB']->query_select('notifications_enabled', array('l_code_category'), array('l_notification_code' => 'ocf_topic', 'l_member_id' => get_member()), 'ORDER BY id DESC', $max_topic_rows);
         if (count($types2) == $max_topic_rows) {
             $types2 = array();
         }
         // Too many to consider
         foreach ($types2 as $type) {
             if (is_numeric($type['l_code_category'])) {
                 $title = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_cache_first_title', array('id' => intval($type['l_code_category'])));
                 if (!is_null($title)) {
                     $pagelinks[] = array('id' => $type['l_code_category'], 'title' => do_lang('A_TOPIC', $title));
                     if (!$done_in_url) {
                         if ($type['l_code_category'] == $notification_category) {
                             $done_in_url = true;
                         }
                     }
                 }
             }
         }
     }
     if (!$done_in_url && is_numeric($notification_category)) {
         $title = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_cache_first_title', array('id' => intval($notification_category)));
         $pagelinks[] = array('id' => $notification_category, 'title' => do_lang('A_TOPIC', $title));
     }
     return $pagelinks;
 }
Esempio n. 2
0
 /**
  * Standard function to create the standardised category tree
  *
  * @param  ID_TEXT		Notification code
  * @param  ?ID_TEXT		The ID of where we're looking under (NULL: N/A)
  * @return array 			Tree structure
  */
 function create_category_tree($notification_code, $id)
 {
     require_code('galleries');
     if (is_null($id)) {
         $total = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'COUNT(*)');
         if ($total > 300) {
             return parent::create_category_tree($notification_code, $id);
         }
         // Too many, so just allow removing UI
     }
     $pagelinks = get_gallery_tree($id, '', NULL, true, NULL, false, false, true, false, is_null($id) ? 0 : 1);
     $filtered = array();
     foreach ($pagelinks as $p) {
         if ($p['id'] !== $id) {
             $filtered[] = $p;
         }
     }
     return $filtered;
 }
Esempio n. 3
0
 /**
  * Standard function to create the standardised category tree
  *
  * @param  ID_TEXT		Notification code
  * @param  ?ID_TEXT		The ID of where we're looking under (NULL: N/A)
  * @return array 			Tree structure
  */
 function create_category_tree($notification_code, $id)
 {
     require_code('downloads');
     if (is_null($id)) {
         $total = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories', 'COUNT(*)');
         if ($total > 300) {
             return parent::create_category_tree($notification_code, $id);
         }
         // Too many, so just allow removing UI
     }
     $pagelinks = get_downloads_tree(NULL, is_null($id) ? NULL : intval($id), NULL, NULL, NULL, is_null($id) ? 0 : 1);
     $filtered = array();
     foreach ($pagelinks as $p) {
         if (strval($p['id']) !== $id) {
             $filtered[] = $p;
         }
     }
     return $filtered;
 }
Esempio n. 4
0
 /**
  * Standard function to create the standardised category tree
  *
  * @param  ID_TEXT		Notification code
  * @param  ?ID_TEXT		The ID of where we're looking under (NULL: N/A)
  * @return array 			Tree structure
  */
 function create_category_tree($notification_code, $id)
 {
     require_code('catalogues');
     $name = substr($notification_code, strlen('catalogue_entry__'));
     if (is_null($id)) {
         $total = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'COUNT(*)', array('c_name' => $name));
         if ($total > 300) {
             return parent::create_category_tree($notification_code, $id);
         }
         // Too many, so just allow removing UI
     }
     $pagelinks = get_catalogue_category_tree($name, is_null($id) ? NULL : intval($id), NULL, NULL, 1);
     $filtered = array();
     foreach ($pagelinks as $p) {
         if (strval($p['id']) !== $id) {
             $filtered[] = $p;
         }
     }
     return $filtered;
 }
Esempio n. 5
0
 /**
  * Standard function to create the standardised category tree
  *
  * @param  ID_TEXT		Notification code
  * @param  ?ID_TEXT		The ID of where we're looking under (NULL: N/A)
  * @return array 			Tree structure
  */
 function create_category_tree($notification_code, $id)
 {
     $categories = parent::create_category_tree($notification_code, $id);
     $notification_category = get_param('id', NULL);
     if (!is_null($notification_category)) {
         $found = false;
         foreach ($categories as $i => $c) {
             if ($c['id'] == $notification_category) {
                 $found = true;
             }
         }
         if (!$found) {
             $categories[] = array('id' => $notification_category, 'title' => do_lang('UNKNOWN'));
         }
     }
     // See if we can get better titles
     require_code('feedback');
     $num_done = 0;
     foreach ($categories as $i => $c) {
         $matches = array();
         if (preg_match('#^([^\\_]*)\\_(.*)$#', preg_replace('#^catalogues__\\w+_#', 'catalogues_', $c['id']), $matches) != 0) {
             $details = get_details_behind_feedback_code($matches[1], $matches[2]);
             $new_title = $details[0];
             if (!is_null($new_title) && $new_title != '') {
                 $categories[$i]['title'] = $new_title;
                 $num_done++;
                 if ($num_done > 200) {
                     unset($categories[$i]);
                 }
             } else {
                 unset($categories[$i]);
             }
         }
     }
     global $M_SORT_KEY;
     $M_SORT_KEY = 'title';
     usort($categories, 'multi_sort');
     return $categories;
 }