Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /***************************************************
- * Subs-NewTopic.php *
- *--------------------------------------------------*
- * Project Name: Post Topic from Anywhere *
- * Version: 1.0 *
- * Written by: Labradoodle-360 *
- * Requested by: aw06 *
- *--------------------------------------------------*
- * Copyright 2011 Matthew Kerle *
- ***************************************************/
- if (!defined('SMF'))
- die ('Hacking Attempt...');
- function getStuff()
- {
- // Globalize everything we'll need...
- global $smcFunc, $context;
- // Queriesss
- $categories = $smcFunc['db_query']('', '
- SELECT id_cat, cat_order, name
- FROM {db_prefix}categories
- ORDER BY cat_order'
- );
- $context['new_topic']['categories'] = array();
- while ($row = $smcFunc['db_fetch_assoc']($categories))
- {
- $context['new_topic']['categories'][$row['id_cat']] = array();
- $context['new_topic']['categories'][$row['id_cat']] = array(
- 'id_cat' => $row['id_cat'],
- 'cat_order' => $row['cat_order'],
- 'name' => $row['name'],
- );
- }
- $boards = $smcFunc['db_query']('', '
- SELECT id_board, id_cat, child_level, id_parent, board_order,
- member_groups, name, num_topics, num_posts, redirect
- FROM {db_prefix}boards
- WHERE redirect={int:null}
- ORDER BY board_order',
- array(
- 'null' => 0,
- )
- );
- while ($row = $smcFunc['db_fetch_assoc']($boards))
- {
- // We need an array of all board permissions.
- if (!empty($context['new_topic']['possible_perms']))
- {
- $current_perms = explode(',', $context['new_topic']['possible_perms']);
- $new_perms = explode(',', $row['member_groups']);
- $updated_perms = array_diff($new_perms, $current_perms);
- if ($updated_perms == $current_perms)
- $final = array_merge($updated_perms, $current_perms);
- else
- $final = $current_perms;
- $context['new_topic']['final_perms'] = $final;
- unset($context['new_topic']['possible_perms']);
- }
- else
- {
- $context['new_topic']['possible_perms'] = $row['member_groups'];
- }
- // In this case, it's a regular board.
- if (empty($row['id_parent']))
- {
- $context['new_topic']['categories'][$row['id_cat']]['boards'][$row['id_board']] = array();
- $context['new_topic']['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
- 'id_board' => $row['id_board'],
- 'id_cat' => $row['id_cat'],
- 'child_level' => $row['child_level'],
- 'id_parent' => $row['id_parent'],
- 'board_order' => $row['board_order'],
- 'member_groups' => explode(',', $row['member_groups']),
- 'name' => $row['name'],
- 'num_topics' => $row['num_topics'],
- 'num_posts' => $row['num_posts'],
- );
- }
- // Otherwise, a childboard.
- else
- {
- $context['new_topic']['categories'][$row['id_cat']]['boards'][$row['id_parent']]['childboards'][$row['id_board']] = array();
- $context['new_topic']['categories'][$row['id_cat']]['boards'][$row['id_parent']]['childboards'][$row['id_board']] = array(
- 'id_board' => $row['id_board'],
- 'id_cat' => $row['id_cat'],
- 'child_level' => $row['child_level'],
- 'id_parent' => $row['id_parent'],
- 'board_order' => $row['board_order'],
- 'member_groups' => explode(',', $row['member_groups']),
- 'name' => $row['name'],
- 'num_topics' => $row['num_topics'],
- 'num_posts' => $row['num_posts'],
- );
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement