Project

General

Profile

1
<?php
2

    
3
/****************************************************************************
4
* SVN Version information:
5
*
6
* $Id: index.php 1289 2010-02-10 15:13:21Z kweitzel $
7
*
8
*****************************************************************************
9
*
10
*****************************************************************************
11
*                          WebsiteBaker
12
*
13
* WebsiteBaker Project <http://www.websitebaker2.org/>
14
* Copyright (C) 2009, Website Baker Org. e.V.
15
*         http://start.websitebaker2.org/impressum-datenschutz.php
16
* Copyright (C) 2004-2009, Ryan Djurovich
17
*
18
*                        About WebsiteBaker
19
*
20
* Website Baker is a PHP-based Content Management System (CMS)
21
* designed with one goal in mind: to enable its users to produce websites
22
* with ease.
23
*
24
*****************************************************************************
25
*
26
*****************************************************************************
27
*                   WebsiteBaker Extra Information
28
*
29
* @author       : Ryan Djurovich, stefan, Matthias Gallas, thorn, Manuel Lang
30
* @platform     : WebsiteBaker 2.8
31
*
32
*****************************************************************************
33
*
34
*****************************************************************************
35
*                        LICENSE INFORMATION
36
*
37
* WebsiteBaker is free software; you can redistribute it and/or
38
* modify it under the terms of the GNU General Public License
39
* as published by the Free Software Foundation; either version 2
40
* of the License, or (at your option) any later version.
41
*
42
* WebsiteBaker is distributed in the hope that it will be useful,
43
* but WITHOUT ANY WARRANTY; without even the implied warranty of
44
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
45
* See the GNU General Public License for more details.
46
*
47
* You should have received a copy of the GNU General Public License
48
* along with this program; if not, write to the Free Software
49
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
50
*****************************************************************************/
51

    
52
require('../../config.php');
53
require_once(WB_PATH.'/framework/class.admin.php');
54
$admin = new admin('Preferences');
55

    
56
require_once(WB_PATH.'/framework/functions-utf8.php');
57

    
58
// Create new template object for the preferences form
59
$template = new Template(THEME_PATH.'/templates');
60
$template->set_file('page', 'preferences.htt');
61
$template->set_block('page', 'main_block', 'main');
62

    
63
// Get existing value from database
64
$database = new database();
65
$query = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."'";
66
$results = $database->query($query);
67
if($database->is_error()) {
68
	$admin->print_error($database->get_error(), 'index.php');
69
}
70
$details = $results->fetchRow();
71

    
72
// Insert values into form
73
$template->set_var('DISPLAY_NAME', $details['display_name']);
74
$template->set_var('EMAIL', $details['email']);
75

    
76
// Insert language values
77
$template->set_block('main_block', 'language_list_block', 'language_list');
78
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' order by name");
79
if($result->numRows() > 0) {
80
	while($addon = $result->fetchRow()) {
81
		$l_codes[$addon['name']] = $addon['directory'];
82
		$l_names[$addon['name']] = entities_to_7bit($addon['name']); // sorting-problem workaround
83
	}
84
	asort($l_names);
85
	foreach($l_names as $l_name=>$v) {
86
		// Insert code and name
87
		$template->set_var(array(
88
								'CODE' => $l_codes[$l_name],
89
								'NAME' => $l_name,
90
								'FLAG' => THEME_URL.'/images/flags/'.strtolower($l_codes[$l_name]),
91
								));
92
		// Check if it is selected
93
		if(LANGUAGE == $l_codes[$l_name]) {
94
			$template->set_var('SELECTED', ' selected="selected"');
95
		} else {
96
			$template->set_var('SELECTED', '');
97
		}
98
		$template->parse('language_list', 'language_list_block', true);
99
	}
100
}
101

    
102
// Insert default timezone values
103
require(ADMIN_PATH.'/interface/timezones.php');
104
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
105
foreach($TIMEZONES AS $hour_offset => $title) {
106
	$template->set_var('VALUE', $hour_offset);
107
	$template->set_var('NAME', $title);
108
	if($admin->get_timezone() == $hour_offset*60*60) {
109
		$template->set_var('SELECTED', ' selected="selected"');
110
	} else {
111
		$template->set_var('SELECTED', '');
112
	}
113
	$template->parse('timezone_list', 'timezone_list_block', true);
114
}
115

    
116
// Insert date format list
117
$user_time = true;
118
require(ADMIN_PATH.'/interface/date_formats.php');
119
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
120
foreach($DATE_FORMATS AS $format => $title) {
121
	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
122
	if($format != 'system_default') {
123
		$template->set_var('VALUE', $format);
124
	} else {
125
		$template->set_var('VALUE', '');
126
	}
127
	$template->set_var('NAME', $title);
128
	if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
129
		$template->set_var('SELECTED', ' selected="selected"');
130
	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
131
		$template->set_var('SELECTED', ' selected="selected"');
132
	} else {
133
		$template->set_var('SELECTED', '');
134
	}
135
	$template->parse('date_format_list', 'date_format_list_block', true);
136
}
137

    
138
// Insert time format list
139
require(ADMIN_PATH.'/interface/time_formats.php');
140
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
141
foreach($TIME_FORMATS AS $format => $title) {
142
	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
143
	if($format != 'system_default') {
144
		$template->set_var('VALUE', $format);
145
	} else {
146
		$template->set_var('VALUE', '');
147
	}
148
	$template->set_var('NAME', $title);
149
	if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
150
		$template->set_var('SELECTED', ' selected="selected"');
151
	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
152
		$template->set_var('SELECTED', ' selected="selected"');
153
	} else {
154
		$template->set_var('SELECTED', '');
155
	}
156
	$template->parse('time_format_list', 'time_format_list_block', true);
157
}
158

    
159
// Insert language headings
160
$template->set_var(array(
161
								'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
162
								'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
163
								'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD']
164
								)
165
						);
166
// insert urls
167
$template->set_var(array(
168
								'ADMIN_URL' => ADMIN_URL,
169
								'WB_URL' => WB_URL,
170
								'WB_PATH' => WB_PATH,
171
								'THEME_URL' => THEME_URL
172
								)
173
						);
174
// Insert language text and messages
175
$template->set_var(array(
176
								'TEXT_SAVE' => $TEXT['SAVE'],
177
								'TEXT_RESET' => $TEXT['RESET'],
178
								'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
179
								'TEXT_EMAIL' => $TEXT['EMAIL'],
180
								'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
181
								'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
182
								'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
183
								'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
184
								'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
185
								'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
186
								'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'],
187
								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT']
188
								)
189
						);
190

    
191
// Parse template for preferences form
192
$template->parse('main', 'main_block', false);
193
$template->pparse('output', 'page');
194

    
195
$admin->print_footer();
196

    
197
?>
(3-3/4)