Wedge

Public area => The Pub => Bug reports => Topic started by: live627 on May 11th, 2012, 09:22 AM

Title: My fixes to Subs-Boards
Post by: live627 on May 11th, 2012, 09:22 AM

@@ -649,6 +649,18 @@
       $boardUpdateParameters['language'] = $boardOptions['language'];
    }
 
+   if (isset($boardOptions['board_type']))
+   {
+      $boardUpdates[] = 'board_type = {string:board_type}';
+      $boardUpdateParameters['board_type'] = $boardOptions['board_type'];
+   }
+
+   if (isset($boardOptions['id_owner']))
+   {
+      $boardUpdates[] = 'id_owner = {int:id_owner}';
+      $boardUpdateParameters['id_owner'] = $boardOptions['id_owner'];
+   }
+
    // Do the updates (if any).
    if (!empty($boardUpdates))
       wesql::query('
@@ -1100,12 +1112,12 @@
 
 // Load a lot of useful information regarding the boards and categories.
 // Restrict to their own boards anyone who's not an admin
-function getBoardTree($restrict = false)
+function getBoardTree($restrict = false, $id_owner = null)
 {
-   global $cat_tree, $boards, $boardList, $txt, $settings, $user_info;
+   global $cat_tree, $boards, $boardList, $txt, $settings;
 
-   $restriction = $user_info['is_admin'] || !$restrict ? '' : '
-            AND b.id_owner = ' . (int) $user_info['id'];
+   $restriction = $id_owner && $restrict ? '
+            AND b.id_owner = ' . (int) $id_owner : '';
 
    // Getting all the board and category information you'd ever wanted.
    $request = wesql::query('
@@ -1115,7 +1127,7 @@
          b.redirect_newtab, b.num_posts, b.language, b.num_topics, c.id_cat, c.name AS cat_name, c.cat_order, c.can_collapse
       FROM {db_prefix}categories AS c
          LEFT JOIN {db_prefix}boards AS b ON (b.id_cat = c.id_cat)' . $restriction . '
-      ORDER BY c.cat_order, b.child_level, b.board_order',
+      ORDER BY c.cat_order, b.board_order, b.child_level',
       array()
    );
    $cat_tree = array();
@@ -1170,7 +1182,7 @@
          $prevBoard = $row['id_board'];
          $last_board_order = $row['board_order'];
 
-         if (empty($row['child_level']))
+         if (empty($row['child_level']) || !$boards[$row['id_parent']])
          {
             $cat_tree[$row['id_cat']]['children'][$row['id_board']] = array(
                'node' => &$boards[$row['id_board']],