Project

General

Profile

1 4 ryan
<?php
2
3
// $Id: index.php,v 1.2 2005/04/02 06:25:37 rdjurovich Exp $
4
5
/*
6
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, 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
// Create new template object for the preferences form
31
$template = new Template(ADMIN_PATH.'/preferences');
32
$template->set_file('page', 'template.html');
33
$template->set_block('page', 'main_block', 'main');
34
35
// Get existing value from database
36
$database = new database();
37
$query = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."'";
38
$results = $database->query($query);
39
if($database->is_error()) {
40
	$admin->print_error($database->get_error(), 'index.php');
41
}
42
$details = $results->fetchRow();
43
44
// Insert values into form
45
$template->set_var('DISPLAY_NAME', $details['display_name']);
46
$template->set_var('EMAIL', $details['email']);
47
48
// Insert language values
49
$template->set_block('main_block', 'language_list_block', 'language_list');
50
if($handle = opendir(WB_PATH.'/languages/')) {
51
   while (false !== ($file = readdir($handle))) {
52
		if($file != '.' AND $file != '..' AND $file != 'CVS' AND $file != 'index.php') {
53
			// Get language name
54
			require(WB_PATH.'/languages/'.$file);
55
			// Insert code and name
56
			$template->set_var(array(
57
											'CODE' => $language_code,
58
											'NAME' => $language_name
59
											)
60
									);
61
			// Check if it is selected
62
			if(LANGUAGE == $language_code) {
63
				$template->set_var('SELECTED', ' selected');
64
			} else {
65
				$template->set_var('SELECTED', '');
66
			}
67
			$template->parse('language_list', 'language_list_block', true);
68
		}
69
	}
70
	// Restore language to original file
71
	require(WB_PATH.'/languages/'.LANGUAGE.'.php');
72
}
73
74
// Insert default timezone values
75
require(ADMIN_PATH.'/interface/timezones.php');
76
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
77
foreach($TIMEZONES AS $hour_offset => $title) {
78
	$template->set_var('VALUE', $hour_offset);
79
	$template->set_var('NAME', $title);
80
	if($admin->get_timezone() == $hour_offset*60*60) {
81
		$template->set_var('SELECTED', 'selected');
82
	} else {
83
		$template->set_var('SELECTED', '');
84
	}
85
	$template->parse('timezone_list', 'timezone_list_block', true);
86
}
87
88
// Insert date format list
89
$user_time = true;
90
require(ADMIN_PATH.'/interface/date_formats.php');
91
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
92
foreach($DATE_FORMATS AS $format => $title) {
93
	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
94
	if($format != 'system_default') {
95
		$template->set_var('VALUE', $format);
96
	} else {
97
		$template->set_var('VALUE', '');
98
	}
99
	$template->set_var('NAME', $title);
100
	if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
101
		$template->set_var('SELECTED', 'selected');
102
	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
103
		$template->set_var('SELECTED', 'selected');
104
	} else {
105
		$template->set_var('SELECTED', '');
106
	}
107
	$template->parse('date_format_list', 'date_format_list_block', true);
108
}
109
110
// Insert time format list
111
require(ADMIN_PATH.'/interface/time_formats.php');
112
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
113
foreach($TIME_FORMATS AS $format => $title) {
114
	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
115
	if($format != 'system_default') {
116
		$template->set_var('VALUE', $format);
117
	} else {
118
		$template->set_var('VALUE', '');
119
	}
120
	$template->set_var('NAME', $title);
121
	if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
122
		$template->set_var('SELECTED', 'selected');
123
	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
124
		$template->set_var('SELECTED', 'selected');
125
	} else {
126
		$template->set_var('SELECTED', '');
127
	}
128
	$template->parse('time_format_list', 'time_format_list_block', true);
129
}
130
131
// Insert language headings
132
$template->set_var(array(
133
								'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
134
								'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
135
								'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD']
136
								)
137
						);
138
// Insert language text and messages
139
$template->set_var(array(
140
								'TEXT_SAVE' => $TEXT['SAVE'],
141
								'TEXT_RESET' => $TEXT['RESET'],
142
								'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
143
								'TEXT_EMAIL' => $TEXT['EMAIL'],
144
								'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
145
								'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
146
								'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
147
								'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
148
								'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
149
								'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
150
								'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD']
151
								)
152
						);
153
154
// Parse template for preferences form
155
$template->parse('main', 'main_block', false);
156
$template->pparse('output', 'page');
157
158
$admin->print_footer();
159
160
?>