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