Project

General

Profile

1
<?php
2

    
3
// $Id: index.php 1215 2009-12-14 14:54:21Z MaGnaL $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
require('../../config.php');
27
require_once(WB_PATH.'/framework/class.admin.php');
28
$admin = new admin('Preferences');
29

    
30
require_once(WB_PATH.'/framework/functions-utf8.php');
31

    
32
// Create new template object for the preferences form
33
$template = new Template(THEME_PATH.'/templates');
34
$template->set_file('page', 'preferences.htt');
35
$template->set_block('page', 'main_block', 'main');
36

    
37
// Get existing value from database
38
$database = new database();
39
$query = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."'";
40
$results = $database->query($query);
41
if($database->is_error()) {
42
	$admin->print_error($database->get_error(), 'index.php');
43
}
44
$details = $results->fetchRow();
45

    
46
// Insert values into form
47
$template->set_var('DISPLAY_NAME', $details['display_name']);
48
$template->set_var('EMAIL', $details['email']);
49

    
50
// Insert language values
51
$template->set_block('main_block', 'language_list_block', 'language_list');
52
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' order by name");
53
if($result->numRows() > 0) {
54
	while($addon = $result->fetchRow()) {
55
		$l_codes[$addon['name']] = $addon['directory'];
56
		$l_names[$addon['name']] = entities_to_7bit($addon['name']); // sorting-problem workaround
57
	}
58
	asort($l_names);
59
	foreach($l_names as $l_name=>$v) {
60
		// Insert code and name
61
		$template->set_var(array(
62
								'CODE' => $l_codes[$l_name],
63
								'NAME' => $l_name,
64
								'FLAG' => THEME_URL.'/images/flags/'.strtolower($l_codes[$l_name]),
65
								));
66
		// Check if it is selected
67
		if(LANGUAGE == $l_codes[$l_name]) {
68
			$template->set_var('SELECTED', ' selected="selected"');
69
		} else {
70
			$template->set_var('SELECTED', '');
71
		}
72
		$template->parse('language_list', 'language_list_block', true);
73
	}
74
}
75

    
76
// Insert default timezone values
77
require(ADMIN_PATH.'/interface/timezones.php');
78
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
79
foreach($TIMEZONES AS $hour_offset => $title) {
80
	$template->set_var('VALUE', $hour_offset);
81
	$template->set_var('NAME', $title);
82
	if($admin->get_timezone() == $hour_offset*60*60) {
83
		$template->set_var('SELECTED', ' selected="selected"');
84
	} else {
85
		$template->set_var('SELECTED', '');
86
	}
87
	$template->parse('timezone_list', 'timezone_list_block', true);
88
}
89

    
90
// Insert date format list
91
$user_time = true;
92
require(ADMIN_PATH.'/interface/date_formats.php');
93
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
94
foreach($DATE_FORMATS AS $format => $title) {
95
	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
96
	if($format != 'system_default') {
97
		$template->set_var('VALUE', $format);
98
	} else {
99
		$template->set_var('VALUE', '');
100
	}
101
	$template->set_var('NAME', $title);
102
	if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
103
		$template->set_var('SELECTED', ' selected="selected"');
104
	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
105
		$template->set_var('SELECTED', ' selected="selected"');
106
	} else {
107
		$template->set_var('SELECTED', '');
108
	}
109
	$template->parse('date_format_list', 'date_format_list_block', true);
110
}
111

    
112
// Insert time format list
113
require(ADMIN_PATH.'/interface/time_formats.php');
114
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
115
foreach($TIME_FORMATS AS $format => $title) {
116
	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
117
	if($format != 'system_default') {
118
		$template->set_var('VALUE', $format);
119
	} else {
120
		$template->set_var('VALUE', '');
121
	}
122
	$template->set_var('NAME', $title);
123
	if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
124
		$template->set_var('SELECTED', ' selected="selected"');
125
	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
126
		$template->set_var('SELECTED', 'selected');
127
	} else {
128
		$template->set_var('SELECTED', '');
129
	}
130
	$template->parse('time_format_list', 'time_format_list_block', true);
131
}
132

    
133
// Insert language headings
134
$template->set_var(array(
135
								'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
136
								'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
137
								'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD']
138
								)
139
						);
140
// insert urls
141
$template->set_var(array(
142
								'ADMIN_URL' => ADMIN_URL,
143
								'WB_URL' => WB_URL,
144
								'WB_PATH' => WB_PATH,
145
								'THEME_URL' => THEME_URL
146
								)
147
						);
148
// Insert language text and messages
149
$template->set_var(array(
150
								'TEXT_SAVE' => $TEXT['SAVE'],
151
								'TEXT_RESET' => $TEXT['RESET'],
152
								'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
153
								'TEXT_EMAIL' => $TEXT['EMAIL'],
154
								'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
155
								'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
156
								'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
157
								'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
158
								'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
159
								'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
160
								'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD']
161
								)
162
						);
163

    
164
// Parse template for preferences form
165
$template->parse('main', 'main_block', false);
166
$template->pparse('output', 'page');
167

    
168
$admin->print_footer();
169

    
170
?>
(3-3/4)