1
0
mirror of https://github.com/e107inc/e107.git synced 2025-09-03 11:22:40 +02:00

Add 'predefined list' type to extended user fields; uses a list of values and display text in e107_admin/sql directory.

Create 'timezone' type of extended user field as predefined list.
Move user timezone to extended user fields. Update routine only transfers existing data if its enabled in prefs. Delete the existing user_timezone, user_new fields from user table.
Add timezone data file
This commit is contained in:
e107steved
2008-01-15 21:57:53 +00:00
parent 48f844fc97
commit 01356e34fa
18 changed files with 468 additions and 305 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
| $Revision: 1.7 $
| $Date: 2008-01-11 22:13:43 $
| $Revision: 1.8 $
| $Date: 2008-01-15 21:57:10 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -67,7 +67,7 @@ CREATE TABLE audit_log (
dblog_remarks text NOT NULL,
PRIMARY KEY (dblog_id),
KEY dblog_datestamp (dblog_datestamp)
) TYPE=MyISAM;
) TYPE=MyISAM AUTO_INCREMENT=1;
# --------------------------------------------------------
@@ -161,7 +161,7 @@ CREATE TABLE dblog (
dblog_remarks text NOT NULL,
PRIMARY KEY (dblog_id),
KEY dblog_datestamp (dblog_datestamp)
) TYPE=MyISAM;
) TYPE=MyISAM AUTO_INCREMENT=1;
# --------------------------------------------------------
@@ -499,7 +499,6 @@ CREATE TABLE user (
user_email varchar(100) NOT NULL default '',
user_signature text NOT NULL,
user_image varchar(100) NOT NULL default '',
user_timezone varchar(3) NOT NULL default '',
user_hideemail tinyint(3) unsigned NOT NULL default '0',
user_join int(10) unsigned NOT NULL default '0',
user_lastvisit int(10) unsigned NOT NULL default '0',
@@ -511,7 +510,6 @@ CREATE TABLE user (
user_ip varchar(45) NOT NULL default '',
user_ban tinyint(3) unsigned NOT NULL default '0',
user_prefs text NOT NULL,
user_new text NOT NULL,
user_viewed text NOT NULL,
user_visits int(10) unsigned NOT NULL default '0',
user_admin tinyint(3) unsigned NOT NULL default '0',

View File

@@ -0,0 +1,78 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/sql/extended_timezones.php,v $
| $Revision: 1.1 $
| $Date: 2008-01-15 21:57:15 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
/*
This file is used with the extended user field 'predefined list' type. Its invoked when the value field is 'timezones'.
The variable name must be 'timezones_list', and is an array of possible values, each of which is a value => text pair
The text is displayed in a drop-down; the value is returned.
If function timezones_value() exists, it is called to create the displayed text
*/
global $timezones_list;
if (!is_array($timezones_list))
{
$timezones_list = array(
array('-12', "International DateLine West"),
array('-11', "Samoa"),
array('-10', "Hawaii"),
array( '-9', "Alaska"),
array( '-8', "Pacific Time (US and Canada)"),
array( '-7', "Mountain Time (US and Canada)"),
array( '-6', "Central Time (US and Canada), Central America"),
array( '-5', "Eastern Time (US and Canada)"),
array( '-4', "Atlantic Time (Canada)"),
array( '-3.30', 'Newfoundland'),
array( '-3', "Greenland, Brasilia, Buenos Aires, Georgetown"),
array( '-2', "Mid-Atlantic"),
array( '-1', "Azores, Cape Verde Islands"),
array( '+0', "UK, Ireland, Lisbon"),
array( '+1', "West Central Africa, Western Europe"),
array( '+2', "Greece, Egypt, parts of Africa"),
array( '+3', "Russia, Baghdad, Kuwait, Nairobi"),
array( '+3.30', 'Tehran, Iran'),
array( '+4', "Abu Dhabi, Kabul"),
array( '+4.30', 'Afghanistan'),
array( '+5', "Islamabad, Karachi"),
array( '+5.30', "Mumbai, Delhi, Calcutta"),
array( '+5.45', 'Kathmandu'),
array( '+6', "Astana, Dhaka"),
array( '+7', "Bangkok, Rangoon"),
array( '+8', "Hong Kong, Singapore, Perth, Beijing"),
array( '+9', "Tokyo, Seoul"),
array( '+9.30', 'Darwin, Adelaide'),
array('+10', "Brisbane, Canberra, Sydney, Melbourne"),
array('+10.30', 'Lord Howe Island'),
array('+11', "Soloman Islands"),
array('+11.30', 'Norfolk Island'),
array('+12', "New Zealand, Fiji, Marshall Islands"),
array('+13', "Tonga, Nuku'alofa, Rawaki Islands"),
array('+13.45', 'Chatham Island'),
array('+14', 'Kiribati: Line Islands')
);
}
if (!function_exists('timezones_value'))
{
function timezones_value($key, $value)
{
return 'GMT'.$key.' - '.$value;
}
}
?>

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $
| $Revision: 1.18 $
| $Date: 2008-01-12 16:51:43 $
| $Revision: 1.19 $
| $Date: 2008-01-15 21:57:15 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -184,7 +184,7 @@ function update_706_to_800($type='')
// List of unwanted $pref values which can go
$obs_prefs = array('frontpage_type','rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle',
'utf-compatmode','frontpage_method','standards_mode','image_owner','im_quality');
'utf-compatmode','frontpage_method','standards_mode','image_owner','im_quality', 'signup_option_timezone');
// List of DB tables not required (includes a few from 0.6xx)
$obs_tables = array('flood', 'headlines', 'stat_info', 'stat_counter', 'stat_last');
@@ -196,7 +196,7 @@ function update_706_to_800($type='')
// List of changed DB tables (defined in core_sql.php)
// (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
$changed_tables = array('dblog','admin_log', 'userclass_classes', 'banlist');
$changed_tables = array('user', 'dblog','admin_log', 'userclass_classes', 'banlist');
// List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
@@ -205,7 +205,6 @@ function update_706_to_800($type='')
'online' => 'online_ip',
'submitnews' => 'submitnews_ip',
'tmp' => 'tmp_ip',
'user' => 'user_ip',
'chatbox' => 'cb_ip'
);
@@ -337,18 +336,6 @@ function update_706_to_800($type='')
}
// Obsolete prefs (list at top)
foreach ($obs_prefs as $p)
{
if (isset($pref[$p]))
{
if ($just_check) return update_needed('Remove obsolete prefs');
unset($pref[$p]);
$do_save = TRUE;
}
}
if (mysql_table_exists('linkwords'))
{ // Need to extend field linkword_link varchar(200) NOT NULL default ''
if ($sql -> db_Query("SHOW FIELDS FROM ".MPREFIX."linkwords LIKE 'linkword_link'"))
@@ -364,6 +351,20 @@ function update_706_to_800($type='')
}
// Check need for user timezone before we delete the field
if (varsettrue($pref['signup_option_timezone']))
{
if ($sql->db_Field('user', 'user_timezone', '', TRUE) && !$sql->db_Field('user_extended','user_timezone','',TRUE))
{
if ($just_check) return update_needed('Move user timezone info');
if (!copy_user_timezone())
{ // Error doing the transfer
echo "Error transferring user timezone data - aborted<br />";
return FALSE;
}
}
}
// Tables defined in core_sql.php
//---------------------------------
@@ -468,6 +469,18 @@ function update_706_to_800($type='')
}
}
// Obsolete prefs (list at top)
// Intentionally do this last - we may check some of them during the update
foreach ($obs_prefs as $p)
{
if (isset($pref[$p]))
{
if ($just_check) return update_needed('Remove obsolete prefs');
unset($pref[$p]);
$do_save = TRUE;
}
}
if ($do_save) save_prefs();
@@ -558,6 +571,33 @@ function update_70x_to_706($type='')
}
// Carries out the copy of timezone data from the user record to an extended user field
// Return TRUE on success, FALSE on failure
function copy_user_timezone()
{
global $sql, $sql2, $tp;
require_once(e_HANDLER.'user_extended_class.php');
$ue = new e107_user_extended;
$tmp = $ue->parse_extended_xml('getfile');
$tmp['timezone']['parms'] = $tp->toDB($tmp['timezone']['parms']);
if(!$ue->user_extended_add($tmp['timezone']))
{
return FALSE;
}
// Created the field - now copy existing data
if ($sql->db_Select('user','user_id, user_timezone'))
{
while ($row = $sql->db_Fetch())
{
$sql2->db_Update('user_extended',"`user_timezone`='{$row['user_timezone']}' WHERE `user_extended_id`={$row['user_id']}");
}
}
return TRUE; // All done!
}
function update_needed($message='')
{
global $ns, $update_debug;

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/users_extended.php,v $
| $Revision: 1.8 $
| $Date: 2007-04-14 17:24:22 $
| $Revision: 1.9 $
| $Date: 2008-01-15 21:57:16 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -65,6 +65,7 @@ if (isset($_POST['up_x']))
$sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order-1 WHERE user_extended_struct_type > 0 AND user_extended_struct_parent = {$_parent} AND user_extended_struct_id='".$_id."'");
}
if (isset($_POST['down_x']))
{
$qs = explode(".", $_POST['id']);
@@ -85,6 +86,7 @@ if (isset($_POST['catup_x']))
$sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order-1 WHERE user_extended_struct_type = 0 AND user_extended_struct_id='".$_id."'");
}
if (isset($_POST['catdown_x']))
{
$qs = explode(".", $_POST['id']);
@@ -94,6 +96,7 @@ if (isset($_POST['catdown_x']))
$sql->db_Update("user_extended_struct", "user_extended_struct_order=user_extended_struct_order+1 WHERE user_extended_struct_type = 0 AND user_extended_struct_id='".$_id."'");
}
if (isset($_POST['add_field']))
{
$ue_field_name = str_replace(' ','_',trim($_POST['user_field'])); // Replace space with underscore - better security
@@ -126,7 +129,9 @@ if (isset($_POST['add_field']))
}
}
if (isset($_POST['update_field'])) {
if (isset($_POST['update_field']))
{
if($_POST['user_type']==4){
$_POST['user_values'] = array($_POST['table_db'],$_POST['field_id'],$_POST['field_value'],$_POST['field_order']);
}
@@ -135,18 +140,21 @@ if (isset($_POST['update_field'])) {
admin_update($ue->user_extended_modify($sub_action, $_POST['user_field'], $_POST['user_text'], $_POST['user_type'], $upd_parms, $upd_values, $_POST['user_default'], $_POST['user_required'], $_POST['user_read'], $_POST['user_write'], $_POST['user_applicable'], $_POST['user_parent']), 'update', EXTLAN_29);
}
if (isset($_POST['update_category']))
{
$name = trim($tp->toHTML($_POST['user_field']));
admin_update($sql->db_Update("user_extended_struct","user_extended_struct_name = '{$name}', user_extended_struct_read = '{$_POST['user_read']}', user_extended_struct_write = '{$_POST['user_write']}', user_extended_struct_applicable = '{$_POST['user_applicable']}' WHERE user_extended_struct_id = '{$sub_action}'"), 'update', EXTLAN_43);
}
if (isset($_POST['add_category']))
{
$name = $tp->toHTML($_POST['user_field']);
admin_update($sql->db_Insert("user_extended_struct","'0', '$name', '', 0, '', '', '', '{$_POST['user_read']}', '{$_POST['user_write']}', '0', '0', '{$_POST['user_applicable']}', '0', '0'"), 'insert', EXTLAN_40);
}
if ($_POST['eu_action'] == "delext")
{
list($_id, $_name) = explode(",",$_POST['key']);
@@ -627,6 +635,7 @@ class users_ext
$ns->tablerender(EXTLAN_9, $text);
}
function show_categories($current)
{
global $sql, $ns, $ue;
@@ -764,12 +773,13 @@ class users_ext
$ns->tablerender(EXTLAN_9, $text);
}
function show_options($action) {
// ##### Display options ---------------------------------------------------------------------------------------------------------
if ($action == "") {
function show_options($action)
{
if ($action == "")
{
$action = "main";
}
// ##### Display options ---------------------------------------------------------------------------------------------------------
$var['main']['text'] = EXTLAN_34;
$var['main']['link'] = e_SELF;
@@ -786,6 +796,7 @@ class users_ext
}
}
function users_extended_adminmenu() {
global $user, $action, $ns, $curtype, $action;
$user->show_options($action);
@@ -813,6 +824,7 @@ function make_delimited($var)
return $ret;
}
function show_predefined()
{
global $tp, $ns, $ue, $sql;
@@ -876,6 +888,7 @@ function show_predefined()
exit;
}
function show_field($var, $type='activate')
{
global $tp;
@@ -884,12 +897,11 @@ function show_field($var, $type='activate')
// $showlist = array('type','text', 'values', 'include_text', 'regex');
if($head_shown != 1)
{
$txt .= "
<tr>
<td class='forumheader'>".UE_LAN_9."</td>
<td class='forumheader'>".UE_LAN_10."</td>
<td class='forumheader'>".UE_LAN_11."</td>
<td class='forumheader'>".UE_LAN_21."</td>
<td class='forumheader'>".UE_LAN_22."</td>
<td class='forumheader'>".UE_LAN_23."</td>
<td class='forumheader' style='width: 5%'>&nbsp;</td>
</tr>
";
@@ -916,6 +928,7 @@ function show_field($var, $type='activate')
return $txt;
}
function field_activate()
{
global $ue, $ns, $tp;
@@ -943,6 +956,7 @@ function field_activate()
return $ret;
}
function field_deactivate()
{
global $ue, $ns, $tp,$sql;
@@ -965,7 +979,8 @@ function field_deactivate()
}
function process_sql($f){
function process_sql($f)
{
global $sql;
$filename = e_ADMIN."sql/extended_".$f.".php";
$fd = fopen ($filename, "r");
@@ -1007,7 +1022,7 @@ function headerjs()
var ftype;
var helptext;
";
for($i=1; $i<=8; $i++)
for($i=1; $i<=9; $i++)
{
$type_const = "UE_LAN_{$i}";
$help_const = "EXTLAN_HELP_{$i}";