Project

General

Profile

1
<?php
2

    
3
/*
4

    
5
 Website Baker Project <http://www.websitebaker.org/>
6
 Copyright (C) 2004-2005, Ryan Djurovich
7

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

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

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

    
22
*/
23

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

    
28
// Create new template object for the preferences form
29
$template = new Template(ADMIN_PATH.'/preferences');
30
$template->set_file('page', 'template.html');
31
$template->set_block('page', 'main_block', 'main');
32

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

    
42
// Insert values into form
43
$template->set_var('DISPLAY_NAME', $details['display_name']);
44
$template->set_var('EMAIL', $details['email']);
45

    
46
// Insert language values
47
$template->set_block('main_block', 'language_list_block', 'language_list');
48
if($handle = opendir(WB_PATH.'/languages/')) {
49
   while (false !== ($file = readdir($handle))) {
50
		if($file != '.' AND $file != '..' AND !is_dir($file) AND $file != 'index.php') {
51
			// Get language name
52
			require(WB_PATH.'/languages/'.$file);
53
			// Insert code and name
54
			$template->set_var(array(
55
											'CODE' => $language_code,
56
											'NAME' => $language_name
57
											)
58
									);
59
			// Check if it is selected
60
			if(LANGUAGE == $language_code) {
61
				$template->set_var('SELECTED', ' selected');
62
			} else {
63
				$template->set_var('SELECTED', '');
64
			}
65
			$template->parse('language_list', 'language_list_block', true);
66
		}
67
	}
68
	// Restore language to original file
69
	require(WB_PATH.'/languages/'.LANGUAGE.'.php');
70
}
71

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

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

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

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

    
152
// Parse template for preferences form
153
$template->parse('main', 'main_block', false);
154
$template->pparse('output', 'page');
155

    
156
$admin->print_footer();
157

    
158
?>
(3-3/5)