1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package preferences
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2010, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 4.4.9 && higher
|
13
|
* @version $Id: index.php 1315 2010-04-11 19:13:50Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/preferences/index.php $
|
15
|
* @lastmodified $Date: 2010-04-11 21:13:50 +0200 (Sun, 11 Apr 2010) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
// prevent this file from being accessed directly
|
20
|
//if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
21
|
//Workaround if this is first page (WBAdmin in use)
|
22
|
|
23
|
// put all inside a function to prevent global vars
|
24
|
function build_page( &$admin, &$database )
|
25
|
{
|
26
|
global $HEADING, $TEXT;
|
27
|
include_once(WB_PATH.'/framework/functions-utf8.php');
|
28
|
// Create new template object, assign template file, start main-block
|
29
|
$template = new Template( THEME_PATH.'/templates' );
|
30
|
$template->set_file( 'page', 'preferences.htt' );
|
31
|
$template->set_block( 'page', 'main_block', 'main' );
|
32
|
// read user-info from table users && assign it to template
|
33
|
$sql = 'SELECT `display_name`, `username`, `email` FROM `'.TABLE_PREFIX.'users` ';
|
34
|
$sql .= 'WHERE `user_id` = '.(int)$admin->get_user_id();
|
35
|
if( $res_user = $database->query($sql) )
|
36
|
{
|
37
|
if( $rec_user = $res_user->fetchRow() )
|
38
|
{
|
39
|
$template->set_var('DISPLAY_NAME', $rec_user['display_name']);
|
40
|
$template->set_var('USERNAME', $rec_user['username']);
|
41
|
$template->set_var('EMAIL', $rec_user['email']);
|
42
|
$template->set_var('ADMIN_URL', ADMIN_URL);
|
43
|
}
|
44
|
}
|
45
|
// read available languages from table addons && assign it to the template
|
46
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
|
47
|
$sql .= 'WHERE `type` = "language" ORDER BY `directory`';
|
48
|
if( $res_lang = $database->query($sql) )
|
49
|
{
|
50
|
$template->set_block('main_block', 'language_list_block', 'language_list');
|
51
|
while( $rec_lang = $res_lang->fetchRow() )
|
52
|
{
|
53
|
$template->set_var('CODE', $rec_lang['directory']);
|
54
|
$template->set_var('NAME', $rec_lang['name']);
|
55
|
$template->set_var('FLAG', THEME_URL.'/images/flags/'.strtolower($rec_lang['directory']));
|
56
|
$template->set_var('SELECTED', (LANGUAGE == $rec_lang['directory'] ? ' selected="selected"' : '') );
|
57
|
$template->parse('language_list', 'language_list_block', true);
|
58
|
}
|
59
|
}
|
60
|
// Insert default timezone values
|
61
|
include_once( ADMIN_PATH.'/interface/timezones.php' );
|
62
|
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
|
63
|
foreach( $TIMEZONES AS $hour_offset => $title )
|
64
|
{
|
65
|
$template->set_var('VALUE', $hour_offset);
|
66
|
$template->set_var('NAME', $title);
|
67
|
$template->set_var('SELECTED', ($admin->get_timezone() == ($hour_offset * 3600) ? ' selected="selected"' : '') );
|
68
|
$template->parse('timezone_list', 'timezone_list_block', true);
|
69
|
}
|
70
|
// Insert date format list
|
71
|
$user_time = true;
|
72
|
include_once( ADMIN_PATH.'/interface/date_formats.php' );
|
73
|
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
|
74
|
foreach( $DATE_FORMATS AS $format => $title )
|
75
|
{
|
76
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
77
|
$template->set_var( 'VALUE', ($format != 'system_default' ? $format : 'system_default') );
|
78
|
$template->set_var( 'NAME', $title );
|
79
|
if( (DATE_FORMAT == $format && !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) ||
|
80
|
('system_default' == $format && isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) )
|
81
|
{
|
82
|
$template->set_var('SELECTED', ' selected="selected"');
|
83
|
}else {
|
84
|
$template->set_var('SELECTED', '');
|
85
|
}
|
86
|
$template->parse('date_format_list', 'date_format_list_block', true);
|
87
|
}
|
88
|
// Insert time format list
|
89
|
include_once( ADMIN_PATH.'/interface/time_formats.php' );
|
90
|
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
|
91
|
foreach( $TIME_FORMATS AS $format => $title )
|
92
|
{
|
93
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
94
|
$template->set_var('VALUE', $format != 'system_default' ? $format : 'system_default' );
|
95
|
$template->set_var('NAME', $title);
|
96
|
if( (TIME_FORMAT == $format && !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) ||
|
97
|
('system_default' == $format && isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) )
|
98
|
{
|
99
|
$template->set_var('SELECTED', ' selected="selected"');
|
100
|
} else {
|
101
|
$template->set_var('SELECTED', '');
|
102
|
}
|
103
|
$template->parse('time_format_list', 'time_format_list_block', true);
|
104
|
}
|
105
|
|
106
|
// assign systemvars to template
|
107
|
$template->set_var(array( 'ADMIN_URL' => ADMIN_URL,
|
108
|
'WB_URL' => WB_URL,
|
109
|
'WB_PATH' => WB_PATH,
|
110
|
'THEME_URL' => THEME_URL,
|
111
|
'ACTION_URL' => ADMIN_URL.'/preferences/save.php'
|
112
|
)
|
113
|
);
|
114
|
$template->set_var('FTAN', $admin->getFTAN());
|
115
|
$template->set_var('FORM_NAME', 'preferences_save');
|
116
|
// assign language vars
|
117
|
$template->set_var(array( 'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
|
118
|
'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
|
119
|
'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD'],
|
120
|
'TEXT_SAVE' => $TEXT['SAVE'],
|
121
|
'TEXT_RESET' => $TEXT['RESET'],
|
122
|
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
|
123
|
'TEXT_USERNAME' => $TEXT['USERNAME'],
|
124
|
'TEXT_EMAIL' => $TEXT['EMAIL'],
|
125
|
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
|
126
|
'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
|
127
|
'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
|
128
|
'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
|
129
|
'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
|
130
|
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
|
131
|
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'],
|
132
|
'EMPTY_STRING' => ''
|
133
|
)
|
134
|
);
|
135
|
// Parse template for preferences form
|
136
|
$template->parse('main', 'main_block', false);
|
137
|
$output = $template->finish($template->parse('output', 'page'));
|
138
|
return $output;
|
139
|
}
|
140
|
// test if valid $admin-object already exists (bit complicated about PHP4 Compatibility)
|
141
|
if( !(isset($admin) && is_object($admin) && (get_class($admin) == 'admin')) )
|
142
|
{
|
143
|
require( '../../config.php' );
|
144
|
require_once( WB_PATH.'/framework/class.admin.php' );
|
145
|
$admin = new admin('Preferences');
|
146
|
}
|
147
|
echo build_page($admin, $database);
|
148
|
$admin->print_footer();
|
149
|
|
150
|
?>
|