Project

General

Profile

1
<?php
2

    
3
// $Id: index.php 944 2009-02-22 09:39:58Z Ruebenwurzel $
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
								));
65
		// Check if it is selected
66
		if(LANGUAGE == $l_codes[$l_name]) {
67
			$template->set_var('SELECTED', ' selected');
68
		} else {
69
			$template->set_var('SELECTED', '');
70
		}
71
		$template->parse('language_list', 'language_list_block', true);
72
	}
73
}
74

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

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

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

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

    
155
// Parse template for preferences form
156
$template->parse('main', 'main_block', false);
157
$template->pparse('output', 'page');
158

    
159
$admin->print_footer();
160

    
161
?>
(3-3/4)