Viewing file: acp_forumrunner.php (5.91 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/**
*
* @author Robert Johnston
*
* @package Forum Runner
* @version CVS/SVN: $Id: $
* @copyright (c) 2010 End of Time Studios, LLC
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package acp
*/
class acp_forumrunner
{
var $u_action;
var $new_config;
function main ($id, $mode)
{
global $db, $user, $auth, $template, $cache, $config;
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('mods/forumrunner');
$this->u_action = append_sid("{$phpbb_root_path}adm/index.$phpEx", "i=forumrunner");
$action = request_var('action', '');
$update = (isset($_POST['update'])) ? true : false;
$submit = (isset($_POST['submit'])) ? true : false;
switch ($mode) {
case 'frsettings':
$this->u_action = $this->u_action . "&mode=frsettings";
if ($update) {
set_config('fr_prompt', request_var('fr_prompt', 0));
fr_set_config('fr_googleads', request_var('fr_googleads', 0));
fr_set_config('fr_signatures', request_var('fr_signatures', 0));
fr_set_config('fr_navbar_background', request_var('fr_navbar_background', ''));
fr_set_config('fr_googleads_threadlist', request_var('fr_googleads_threadlist', 0));
fr_set_config('fr_googleads_topthread', request_var('fr_googleads_topthread', 0));
fr_set_config('fr_googleads_bottomthread', request_var('fr_googleads_bottomthread', 0));
fr_set_config('fr_googleads_javascript', request_var('fr_googleads_javascript', ''));
fr_set_config('fr_googleads_usergroups', join(',', request_var('fr_googleads_usergroups', array(0 => 0))));
fr_set_config('fr_exclude_forums', join(',', request_var('fr_exclude_forums', array(0 => 0))));
}
$fr_prompt_checked = '';
$fr_googleads_checked = '';
$fr_googleads_threadlist_checked = '';
$fr_googleads_topthread_checked = '';
$fr_googleads_bottomthread_checked = '';
if ($config['fr_prompt'] == 1) {
$fr_prompt_checked = 'checked="checked"';
}
if (fr_get_config('fr_googleads') == 1) {
$fr_googleads_checked = 'checked="checked"';
}
if (fr_get_config('fr_googleads_threadlist') == 1) {
$fr_googleads_threadlist_checked = 'checked="checked"';
}
if (fr_get_config('fr_googleads_topthread') == 1) {
$fr_googleads_topthread_checked = 'checked="checked"';
}
if (fr_get_config('fr_googleads_bottomthread') == 1) {
$fr_googleads_bottomthread_checked = 'checked="checked"';
}
if (fr_get_config('fr_signatures') == 1) {
$fr_signatures = 'checked="checked"';
}
$fr_googleads_javascript = fr_get_config('fr_googleads_javascript');
$fr_navbar_background = fr_get_config('fr_navbar_background');
$fr_googleads_usergroups = gen_usergroup_html(split(',', fr_get_config('fr_googleads_usergroups')));
$fr_exclude_forums = gen_excludeforums_html(split(',', fr_get_config('fr_exclude_forums')));
$template->assign_vars(array(
'FR_PROMPT_CHECKED' => $fr_prompt_checked,
'FR_SIGNATURES_CHECKED' => $fr_signatures,
'FR_NAVBAR_BACKGROUND' => $fr_navbar_background,
'FR_EXCLUDE_FORUMS' => $fr_exclude_forums,
'FR_GOOGLEADS_CHECKED' => $fr_googleads_checked,
'FR_GOOGLEADS_THREADLIST_CHECKED' => $fr_googleads_threadlist_checked,
'FR_GOOGLEADS_TOPTHREAD_CHECKED' => $fr_googleads_topthread_checked,
'FR_GOOGLEADS_BOTTOMTHREAD_CHECKED' => $fr_googleads_bottomthread_checked,
'FR_GOOGLEADS_JAVASCRIPT' => $fr_googleads_javascript,
'FR_GOOGLEADS_USERGROUPS' => $fr_googleads_usergroups,
'U_ACTION' => $this->u_action,
));
$this->page_title = 'FR_SETTINGS';
$this->tpl_name = 'acp_forumrunner';
break;
}
}
}
function
gen_usergroup_html ($selected)
{
global $db, $user;
$result = $db->sql_query("
SELECT group_name, group_type, group_id
FROM " . GROUPS_TABLE . "
ORDER BY group_type DESC, group_name
");
$groups = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$html = '<select id="fr_googleads_usergroups" name="fr_googleads_usergroups[]" multiple="multiple">';
foreach ($groups as $group) {
$name = $group['group_name'];
$special = false;
if ($group['group_type'] == GROUP_SPECIAL) {
$name = $user->lang['G_' . $name];
$special = true;
}
$select = (in_array($group['group_id'], $selected));
$html .= '<option value="' . $group['group_id'] . '"' . ($select ? ' selected="selected"' : '') .
'>' . ($special ? '<b>' : '') . $name . ($special ? '</b>' : '') . '</option>';
}
$html .= '</select>';
return $html;
}
function
gen_excludeforums_html ($selected)
{
global $user, $config;
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$html = '<select id="fr_exclude_forums" name="fr_exclude_forums[]" multiple="multiple">';
foreach ($forum_list as $f_id => $f_row) {
$select = in_array($f_id, $selected);
if ($f_row['forum_type'] == FORUM_LINK) {
$f_row['disabled'] = false;
}
$html .= '<option value="' . $f_id . '"' . ($select ? ' selected="selected"' : '') .
($f_row['disabled'] ? ' disabled="disabled" class="disabled-option"' : '') .
'>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
}
$html .= '</select>';
return $html;
}
function
fr_set_config ($config_name, $config_value)
{
global $table_prefix, $db;
$db->sql_query("
REPLACE INTO {$table_prefix}forumrunner_config " . $db->sql_build_array('INSERT', array(
'config_name' => $config_name,
'config_value' => $config_value
)));
}
function
fr_get_config ($config_name)
{
global $table_prefix, $db;
$result = $db->sql_query("
SELECT config_value
FROM {$table_prefix}forumrunner_config
WHERE config_name = '" . $db->sql_escape($config_name) . "'
");
$out = $db->sql_fetchfield('config_value');
$db->sql_freeresult($result);
if ($out) {
return trim($out);
}
}
?>
|