Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.32 KB | None | 0 0
  1. <?php
  2. /***************************************************
  3. * Subs-NewTopic.php                                *
  4. *--------------------------------------------------*
  5. * Project Name: Post Topic from Anywhere           *
  6. * Version: 1.0                                     *
  7. * Written by: Labradoodle-360                      *
  8. * Requested by: aw06                               *
  9. *--------------------------------------------------*
  10. * Copyright 2011 Matthew Kerle                     *
  11. ***************************************************/
  12.  
  13. if (!defined('SMF'))
  14.     die ('Hacking Attempt...');
  15.  
  16. function getStuff()
  17. {
  18.  
  19.     // Globalize everything we'll need...
  20.     global $smcFunc, $context;
  21.  
  22.     // Queriesss
  23.     $categories = $smcFunc['db_query']('', '
  24.         SELECT id_cat, cat_order, name
  25.         FROM {db_prefix}categories
  26.         ORDER BY cat_order'
  27.     );
  28.     $context['new_topic']['categories'] = array();
  29.     while ($row = $smcFunc['db_fetch_assoc']($categories))
  30.     {
  31.         $context['new_topic']['categories'][$row['id_cat']] = array();
  32.         $context['new_topic']['categories'][$row['id_cat']] = array(
  33.             'id_cat' => $row['id_cat'],
  34.             'cat_order' => $row['cat_order'],
  35.             'name' => $row['name'],
  36.         );
  37.     }
  38.     $boards = $smcFunc['db_query']('', '
  39.         SELECT id_board, id_cat, child_level, id_parent, board_order,
  40.             member_groups, name, num_topics, num_posts, redirect
  41.         FROM {db_prefix}boards
  42.         WHERE redirect={int:null}
  43.         ORDER BY board_order',
  44.         array(
  45.             'null' => 0,
  46.         )
  47.     );
  48.     while ($row = $smcFunc['db_fetch_assoc']($boards))
  49.     {
  50.         // We need an array of all board permissions.
  51.         if (!empty($context['new_topic']['possible_perms']))
  52.         {
  53.             $current_perms = explode(',', $context['new_topic']['possible_perms']);
  54.             $new_perms = explode(',', $row['member_groups']);
  55.             $updated_perms = array_diff($new_perms, $current_perms);
  56.             if ($updated_perms == $current_perms)
  57.                 $final = array_merge($updated_perms, $current_perms);
  58.             else
  59.                 $final = $current_perms;
  60.             $context['new_topic']['final_perms'] = $final;
  61.             unset($context['new_topic']['possible_perms']);
  62.         }
  63.         else
  64.         {
  65.             $context['new_topic']['possible_perms'] = $row['member_groups'];
  66.         }
  67.  
  68.         // In this case, it's a regular board.
  69.         if (empty($row['id_parent']))
  70.         {
  71.             $context['new_topic']['categories'][$row['id_cat']]['boards'][$row['id_board']] = array();
  72.             $context['new_topic']['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
  73.                 'id_board' => $row['id_board'],
  74.                 'id_cat' => $row['id_cat'],
  75.                 'child_level' => $row['child_level'],
  76.                 'id_parent' => $row['id_parent'],
  77.                 'board_order' => $row['board_order'],
  78.                 'member_groups' => explode(',', $row['member_groups']),
  79.                 'name' => $row['name'],
  80.                 'num_topics' => $row['num_topics'],
  81.                 'num_posts' => $row['num_posts'],
  82.             );
  83.         }
  84.         // Otherwise, a childboard.
  85.         else
  86.         {
  87.             $context['new_topic']['categories'][$row['id_cat']]['boards'][$row['id_parent']]['childboards'][$row['id_board']] = array();
  88.             $context['new_topic']['categories'][$row['id_cat']]['boards'][$row['id_parent']]['childboards'][$row['id_board']] = array(
  89.                 'id_board' => $row['id_board'],
  90.                 'id_cat' => $row['id_cat'],
  91.                 'child_level' => $row['child_level'],
  92.                 'id_parent' => $row['id_parent'],
  93.                 'board_order' => $row['board_order'],
  94.                 'member_groups' => explode(',', $row['member_groups']),
  95.                 'name' => $row['name'],
  96.                 'num_topics' => $row['num_topics'],
  97.                 'num_posts' => $row['num_posts'],
  98.             );
  99.         }
  100.     }
  101. }
  102.  
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement