From 42039bc31a39b3c29bb1700dc5b0a3ea5b8348ed Mon Sep 17 00:00:00 2001 From: James Atkinson Date: Fri, 20 Apr 2001 07:30:45 +0000 Subject: [PATCH] Added user selectable templates, and put the system template into the config database. Updated mysql_schema as well git-svn-id: file:///svn/phpbb/trunk@200 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/common.php | 51 ++++++++++---------- phpBB/db/mysql_basic.sql | 6 +-- phpBB/db/mysql_schema.sql | 39 +++++---------- phpBB/includes/functions.php | 39 ++++++++++++++- phpBB/language/lang_english.php | 2 + phpBB/profile.php | 9 ++++ phpBB/templates/Default/profile_add_body.tpl | 6 ++- 7 files changed, 94 insertions(+), 58 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index beb485fa30..0dba11a31b 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -1,38 +1,38 @@ sql_query($sql)) { + // Our template class hasn't been instantiated so we do it here. + $template = new Template("templates/Default"); error_die(SQL_QUERY, "Could not query config information.", __LINE__, __FILE__); } -else +else { $config = $db->sql_fetchrow($result); $sitename = stripslashes($config["sitename"]); @@ -93,7 +93,8 @@ else $default_lang = $config["default_lang"]; $require_activation = $config["require_activation"]; $sys_timezone = $config["system_timezone"]; - $sys_lang = $default_lang; + $sys_template = $config['sys_template']; + $sys_lang = $default_lang; } include('language/lang_'.$default_lang.'.'.$phpEx); diff --git a/phpBB/db/mysql_basic.sql b/phpBB/db/mysql_basic.sql index dea9ae5c2a..158d802415 100644 --- a/phpBB/db/mysql_basic.sql +++ b/phpBB/db/mysql_basic.sql @@ -1,7 +1,7 @@ # $id$ # Some basic inserts to get you started. -INSERT INTO phpbb_config VALUES (1,'Test forum',1,1,1,1,1,25,10,50,0,0,'With regards, the Admin','admin@yoursite.com','d M Y h:i:s a','english',0); +INSERT INTO phpbb_config VALUES (1,'Test forum',1,1,1,1,1,25,10,50,0,0,'With regards, the Admin','admin@yoursite.com','d M Y h:i:s a','english',0,'Default'); INSERT INTO phpbb_categories VALUES (1,'Test category 1','1'); @@ -9,5 +9,5 @@ INSERT INTO phpbb_forums VALUES (1,'Test Forum 1','This is just a test forum, no INSERT INTO phpbb_forum_mods VALUES (1,1,0); -INSERT INTO phpbb_users VALUES (1,'admin','Jan 09, 2001','21232f297a57a5a743894a0e4a801fc3','admin@yourdomain.com','','','','','','This is just a stupid sig',1,1,'','','',0,1,0,0,0,0,'',4,'','','',0,'-8',1); -INSERT INTO phpbb_users VALUES (-1,'Anonymous','May 12, 1978','','','','','','','','',0,0,'','','',0,0,0,0,0,0,'',0,'','','',0,'-8',1); +INSERT INTO phpbb_users VALUES (1,'admin',NOW(),'21232f297a57a5a743894a0e4a801fc3','admin@yourdomain.com','','','','','','This is just a stupid sig',1,1,'','','',0,1,0,0,0,0,'',4,'','','',0,'-8',1, ''); +INSERT INTO phpbb_users VALUES (-1,'Anonymous',NOW(),'','','','','','','','',0,0,'','','',0,0,0,0,0,0,'',0,'','','',0,'-8',1,'Default'); diff --git a/phpBB/db/mysql_schema.sql b/phpBB/db/mysql_schema.sql index 8c62291bd8..d5d7936194 100644 --- a/phpBB/db/mysql_schema.sql +++ b/phpBB/db/mysql_schema.sql @@ -1,26 +1,9 @@ -# *************************************************************************** -# * mysql_schema.sql -# * ------------------- -# * begin : Thursday, Apr 19, 2001 -# * copyright : (C) 2001 The phpBB Group -# * email : support@phpbb.com -# * -# * $Id$ -# * -# * -# *************************************************************************** -# -# -# *************************************************************************** -# * -# * This program is free software; you can redistribute it and/or modify -# * it under the terms of the GNU General Public License as published by -# * the Free Software Foundation; either version 2 of the License, or -# * (at your option) any later version. -# * -# * -# *************************************************************************** +# MySQL dump 8.13 # +# Host: localhost Database: phpBBtest +#-------------------------------------------------------- +# Server version 3.23.35 + # # Table structure for table 'phpbb_banlist' # @@ -28,7 +11,7 @@ CREATE TABLE phpbb_banlist ( ban_id int(10) NOT NULL auto_increment, ban_userid int(10) default NULL, - ban_ip char(8) default NULL, + ban_ip int(11) default NULL, ban_start int(10) default NULL, ban_end int(10) default NULL, ban_time_type int(10) default NULL, @@ -68,6 +51,7 @@ CREATE TABLE phpbb_config ( default_dateformat varchar(20) default NULL, default_lang varchar(255) default NULL, system_timezone smallint(6) default NULL, + sys_template varchar(20) default NULL, PRIMARY KEY (config_id), UNIQUE KEY selected (selected) ) TYPE=MyISAM; @@ -144,7 +128,7 @@ CREATE TABLE phpbb_posts ( forum_id int(10) NOT NULL default '0', poster_id int(10) NOT NULL default '0', post_time int(10) NOT NULL default '0', - poster_ip char(8) NOT NULL default '0', + poster_ip int(10) NOT NULL default '0', bbcode_uid varchar(10) NOT NULL default '', PRIMARY KEY (post_id), KEY forum_id (forum_id), @@ -171,7 +155,7 @@ CREATE TABLE phpbb_priv_msgs ( from_userid int(10) NOT NULL default '0', to_userid int(10) NOT NULL default '0', msg_time int(10) NOT NULL default '0', - poster_ip char(8) NOT NULL default '0', + poster_ip int(10) NOT NULL default '0', msg_status int(10) NOT NULL default '0', msg_text text NOT NULL, PRIMARY KEY (msg_id), @@ -203,7 +187,7 @@ CREATE TABLE phpbb_session ( session_id int(10) unsigned NOT NULL default '0', session_user_id int(10) NOT NULL default '0', session_time int(10) unsigned NOT NULL default '0', - session_ip char(8) default NULL, + session_ip char(10) default NULL, session_page int(10) NOT NULL default '0', session_logged_in tinyint(1) NOT NULL default '0', PRIMARY KEY (session_id) @@ -290,8 +274,9 @@ CREATE TABLE phpbb_users ( user_actkey varchar(32) default NULL, user_newpasswd varchar(32) default NULL, user_notify tinyint(3) default NULL, - user_timezone int(4) default NULL, + user_timezone float default NULL, user_active int(2) default NULL, + user_template varchar(20) default NULL, PRIMARY KEY (user_id), KEY user_id (user_id) ) TYPE=MyISAM; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8bd31ba54e..000c51696c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -140,6 +140,31 @@ function make_jumpbox() return($boxstring); } +// NOTE: This function should check is_dir($file), however the is_dir function seems to be buggy on my +// system so its not currently implemented that way +// - James +function template_select($default) +{ + $dir = opendir("templates"); + $template_select = ""; + closedir($dir); + return($template_select); +} + function language_select($default, $name="language", $dirname="language/") { global $phpEx; @@ -163,7 +188,7 @@ function language_select($default, $name="language", $dirname="language/") function theme_select($default) { global $db; - + $sql = "SELECT theme_id, theme_name FROM ".THEMES_TABLE." ORDER BY theme_name"; if($result = $db->sql_query($sql)) { @@ -197,7 +222,7 @@ function theme_select($default) function init_userprefs($userdata) { - global $override_user_theme; + global $override_user_theme, $template, $sys_template; global $bgcolor, $table_bgcolor, $textcolor, $category_title, $table_header; global $color1, $color2, $header_image, $newtopic_image; global $reply_locked_image, $reply_image, $linkcolor, $vlinkcolor; @@ -247,6 +272,16 @@ function init_userprefs($userdata) $sys_timezone = $userdata["user_timezone"]; } + // Setup user's Template + if($userdata['user_template'] != '') + { + $template = new Template("templates/".$userdata['user_template']); + } + else + { + $template = new Template("templates/".$sys_template); + } + // Include the appropriate language file ... if it exists. if(!strstr($PHP_SELF, "admin")) { diff --git a/phpBB/language/lang_english.php b/phpBB/language/lang_english.php index 1c7988ddfb..55da89235f 100755 --- a/phpBB/language/lang_english.php +++ b/phpBB/language/lang_english.php @@ -133,6 +133,8 @@ $l_itemsreq = "Items marked with a * are required"; $l_nouserid = "You must supply a user ID number in order to view profile data."; $l_viewingprofile = "Viewing profile of "; $l_hidden = "hidden"; +$l_boardtemplate = "Select Template"; + // Viewforum $l_viewforum = "View Forum"; diff --git a/phpBB/profile.php b/phpBB/profile.php index 9bf1863e11..c0f56b0b14 100644 --- a/phpBB/profile.php +++ b/phpBB/profile.php @@ -201,6 +201,7 @@ switch($mode) user_bbcode, user_timezone, user_lang, + user_template, user_active, user_actkey) VALUES ( @@ -226,6 +227,7 @@ switch($mode) '$alwaysbbcode', '$timezone', '$lang', + '$selected_template', "; if($require_activation || $coppa) { @@ -286,6 +288,11 @@ switch($mode) { $coppa = FALSE; } + + if(!isset($selected_template)) + { + $selected_template = $sys_template; + } $template->assign_vars(array("COPPA" => $coppa, "L_SUBMIT" => $l_submit, "USERNAME" => $username, @@ -314,6 +321,7 @@ switch($mode) "LANGUAGE_SELECT" => language_select($default_lang, "lang"), "THEME_SELECT" => theme_select($theme, $db), "TIMEZONE_SELECT" => tz_select($timezone), + "TEMPLATE_SELECT" => template_select($selected_template), "L_ICQNUMBER" => $l_icqnumber, "L_STORECOOKIE" => $l_storecookie, "L_MESSENGER" => $l_messenger, @@ -325,6 +333,7 @@ switch($mode) "L_ALWAYSSMILE" => $l_alwayssmile, "L_BOARDLANG" => $l_boardlang, "L_BOARDTHEME" => $l_boardtheme, + "L_BOARDTEMPLATE" => $l_boardtemplate, "L_TIMEZONE" => $l_timezone, "L_YES" => $l_yes, "L_NO" => $l_no, diff --git a/phpBB/templates/Default/profile_add_body.tpl b/phpBB/templates/Default/profile_add_body.tpl index 0364294344..d0bb5825c9 100755 --- a/phpBB/templates/Default/profile_add_body.tpl +++ b/phpBB/templates/Default/profile_add_body.tpl @@ -103,6 +103,10 @@ {L_BOARDTHEME}: {THEME_SELECT} + + {L_BOARDTEMPLATE}: + {TEMPLATE_SELECT} + {L_TIMEZONE}: {TIMEZONE_SELECT} @@ -111,7 +115,7 @@ - +