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