3 /***************************************************************************
\r
6 * copyright : (C) 2003 - 2005 CyberAlien
\r
7 * support : http://www.phpbbstyles.com
\r
11 * file revision : 72
\r
12 * project revision : 78
\r
13 * last modified : 05 Dec 2005 13:54:54
\r
15 ***************************************************************************/
\r
17 /***************************************************************************
\r
19 * This program is free software; you can redistribute it and/or modify
\r
20 * it under the terms of the GNU General Public License as published by
\r
21 * the Free Software Foundation; either version 2 of the License, or
\r
22 * (at your option) any later version.
\r
24 ***************************************************************************/
\r
26 define('IN_PHPBB', 1);
\r
27 $phpbb_root_path = "./../";
\r
28 $no_page_header = true;
\r
29 require($phpbb_root_path . 'extension.inc');
\r
30 require('./pagestart.' . $phpEx);
\r
32 // check if mod is installed
\r
33 if(empty($template->xs_version) || $template->xs_version !== 8)
\r
35 message_die(GENERAL_ERROR, isset($lang['xs_error_not_installed']) ? $lang['xs_error_not_installed'] : 'eXtreme Styles mod is not installed. You forgot to upload includes/template.php');
\r
38 define('IN_XS', true);
\r
39 include_once('xs_include.' . $phpEx);
\r
41 $template->assign_block_vars('nav_left',array('ITEM' => '» <a href="' . append_sid('xs_styles.'.$phpEx) . '">' . $lang['xs_default_style'] . '</a>'));
\r
44 // set new default style
\r
46 if(!empty($HTTP_GET_VARS['setdefault']) && !defined('DEMO_MODE'))
\r
48 $board_config['default_style'] = intval($HTTP_GET_VARS['setdefault']);
\r
49 $sql = "UPDATE " . CONFIG_TABLE . " SET config_value='" . $board_config['default_style'] . "' WHERE config_name='default_style'";
\r
50 if(defined('XS_MODS_ADMIN_TEMPLATES'))
\r
52 $sql = str_replace(' WHERE config_name', ', theme_public=\'1\' WHERE config_name', $sql);
\r
54 $db->sql_query($sql);
\r
55 if(defined('XS_MODS_CATEGORY_HIERARCHY210'))
\r
57 // recache config table
\r
58 if ( !empty($config) )
\r
60 $config->read(true);
\r
66 // change "override" variable
\r
68 if(isset($HTTP_GET_VARS['setoverride']) && !defined('DEMO_MODE'))
\r
70 $board_config['override_user_style'] = intval($HTTP_GET_VARS['setoverride']);
\r
71 $sql = "UPDATE " . CONFIG_TABLE . " SET config_value='" . $board_config['override_user_style'] . "' WHERE config_name='override_user_style'";
\r
72 $db->sql_query($sql);
\r
73 // recache config table
\r
74 if(defined('XS_MODS_CATEGORY_HIERARCHY210') && !empty($config))
\r
76 $config->read(true);
\r
81 // move all users to some style
\r
83 if(!empty($HTTP_GET_VARS['moveusers']) && !defined('DEMO_MODE'))
\r
85 $id = intval($HTTP_GET_VARS['moveusers']);
\r
86 $sql = "UPDATE " . USERS_TABLE . " SET user_style='" . $id . "' WHERE user_id > 0";
\r
87 $db->sql_query($sql);
\r
91 // move all users from some style
\r
93 if(!empty($HTTP_GET_VARS['moveaway']) && !defined('DEMO_MODE'))
\r
95 $id = intval($HTTP_GET_VARS['moveaway']);
\r
96 $id2 = intval($HTTP_GET_VARS['movestyle']);
\r
99 $sql = "UPDATE " . USERS_TABLE . " SET user_style='" . $id2 . "' WHERE user_style = " . $id;
\r
103 $sql = "UPDATE " . USERS_TABLE . " SET user_style = NULL WHERE user_style = " . $id;
\r
105 $db->sql_query($sql);
\r
109 // set admin-only style (Admin Templates mod)
\r
111 if(!empty($HTTP_GET_VARS['setadmin']) && !defined('DEMO_MODE'))
\r
113 $id = intval($HTTP_GET_VARS['setadmin']);
\r
114 $setadmin = empty($HTTP_GET_VARS['admin']) ? 0 : 1;
\r
115 $sql = "UPDATE " . THEMES_TABLE . " SET theme_public='{$setadmin}' WHERE themes_id='{$id}'";
\r
116 $db->sql_query($sql);
\r
117 if(defined('XS_MODS_CATEGORY_HIERARCHY210'))
\r
119 // recache themes table
\r
120 if ( empty($themes) )
\r
122 $themes = new themes();
\r
124 if ( !empty($themes) )
\r
126 $themes->read(true);
\r
132 // get list of installed styles
\r
134 $sql = 'SELECT themes_id, template_name, style_name FROM ' . THEMES_TABLE . ' ORDER BY template_name';
\r
135 if(defined('XS_MODS_ADMIN_TEMPLATES'))
\r
137 $sql = str_replace(', style_name', ', style_name, theme_public', $sql);
\r
139 if(!$result = $db->sql_query($sql))
\r
141 xs_error($lang['xs_no_style_info'], __LINE__, __FILE__);
\r
143 $style_rowset = $db->sql_fetchrowset($result);
\r
145 $style_override = $board_config['override_user_style'];
\r
146 $style_default = $board_config['default_style'];
\r
148 $style_ids = array();
\r
150 for($i=0; $i<count($style_rowset); $i++)
\r
152 $id = $style_rowset[$i]['themes_id'];
\r
153 $style_ids[] = $id;
\r
154 $sql = 'SELECT count(user_id) as total FROM ' . USERS_TABLE . ' WHERE user_style = ' . $id;
\r
155 $result = $db->sql_query($sql);
\r
162 $total = $db->sql_fetchrow($result);
\r
163 $total = $total['total'];
\r
164 $num_users += $total;
\r
167 $row_class = $xs_row_class[$i % 2];
\r
168 $template->assign_block_vars('styles', array(
\r
169 'ROW_CLASS' => $row_class,
\r
170 'STYLE' => $style_rowset[$i]['style_name'],
\r
171 'TEMPLATE' => $style_rowset[$i]['template_name'],
\r
174 'U_TOTAL' => append_sid('xs_styles.' . $phpEx . '?list=' . $id),
\r
175 'U_DEFAULT' => append_sid('xs_styles.' . $phpEx . '?setdefault=' . $id),
\r
176 'U_OVERRIDE' => append_sid('xs_styles.' . $phpEx . '?setoverride=' . ($style_override ? '0' : '1')),
\r
177 'U_SWITCHALL' => append_sid('xs_styles.' . $phpEx . '?moveusers=' . $id),
\r
182 $template->assign_block_vars('styles.users', array());
\r
184 if($id == $style_default)
\r
186 $template->assign_block_vars('styles.default', array());
\r
187 if($style_override)
\r
189 $template->assign_block_vars('styles.default.override', array());
\r
193 $template->assign_block_vars('styles.default.nooverride', array());
\r
198 $template->assign_block_vars('styles.nodefault', array());
\r
199 if(defined('XS_MODS_ADMIN_TEMPLATES'))
\r
201 if($style_rowset[$i]['theme_public'])
\r
203 $template->assign_block_vars('styles.nodefault.admin_only', array(
\r
204 'U_CHANGE' => append_sid('xs_styles.'.$phpEx.'?setadmin='.$id.'&admin=0')
\r
209 $template->assign_block_vars('styles.nodefault.public', array(
\r
210 'U_CHANGE' => append_sid('xs_styles.'.$phpEx.'?setadmin='.$id.'&admin=1')
\r
217 $template->assign_block_vars('styles.total', array());
\r
221 $template->assign_block_vars('styles.none', array());
\r
225 // get number of users using default style
\r
226 $sql = 'SELECT count(user_id) as total FROM ' . USERS_TABLE . ' WHERE user_style = NULL';
\r
227 $result = $db->sql_query($sql);
\r
230 $total = $db->sql_fetchrow($result);
\r
231 $num_default = $total['total'];
\r
232 $num_users += $num_default;
\r
235 // get number of users
\r
236 $sql = 'SELECT count(user_id) as total FROM ' . USERS_TABLE;
\r
237 $result = $db->sql_query($sql);
\r
244 $total = $db->sql_fetchrow($result);
\r
245 $total_users = $total['total'];
\r
248 $template->assign_vars(array(
\r
249 'U_SCRIPT' => 'xs_styles.' . $phpEx,
\r
250 'NUM_DEFAULT' => $num_default
\r
254 if($total_users > $num_users)
\r
257 $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = NULL WHERE user_style NOT IN (' . implode(', ', $style_ids) . ')';
\r
258 $db->sql_query($sql);
\r
262 // get list of users
\r
264 if(isset($HTTP_GET_VARS['list']))
\r
266 $id = intval($HTTP_GET_VARS['list']);
\r
267 $template->assign_block_vars('list_users', array());
\r
268 $sql = "SELECT user_id, username FROM " . USERS_TABLE . " WHERE user_style='{$id}' ORDER BY username ASC";
\r
269 if(!$result = $db->sql_query($sql))
\r
271 xs_error('Could not get users list!', __LINE__, __FILE__);
\r
273 $rowset = $db->sql_fetchrowset($result);
\r
274 for($i=0; $i<count($rowset); $i++)
\r
276 $template->assign_block_vars('list_users.user', array(
\r
278 'ID' => $rowset[$i]['user_id'],
\r
279 'NAME' => htmlspecialchars($rowset[$i]['username']),
\r
285 $template->set_filenames(array('body' => XS_TPL_PATH . 'styles.tpl'));
\r
286 $template->pparse('body');
\r