Project

General

Profile

1
<?php
2

    
3
// $Id: index.php 519 2007-12-23 14:37:02Z Ruebenwurzel $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2008, 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
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
51
if($result->numRows() > 0) {
52
	while($addon = $result->fetchRow()) {
53
		// Insert code and name
54
		$template->set_var(array(
55
								'CODE' => $addon['directory'],
56
								'NAME' => $addon['name']
57
								));
58
		// Check if it is selected
59
		if(LANGUAGE == $addon['directory']) {
60
			$template->set_var('SELECTED', ' selected');
61
		} else {
62
			$template->set_var('SELECTED', '');
63
		}
64
		$template->parse('language_list', 'language_list_block', true);
65
	}
66
}
67

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

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

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

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

    
148
// Parse template for preferences form
149
$template->parse('main', 'main_block', false);
150
$template->pparse('output', 'page');
151

    
152
$admin->print_footer();
153

    
154
?>
(3-3/5)