Project

General

Profile

« Previous | Next » 

Revision 238

Added by stefan over 18 years ago

Fixed inconsistent line ending styles

View differences:

index.php
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
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
49
if($result->numRows() > 0) {
50
	while($addon = $result->fetchRow()) {
51
		// Insert code and name
52
		$template->set_var(array(
53
								'CODE' => $addon['directory'],
54
								'NAME' => $addon['name']
55
								));
56
		// Check if it is selected
57
		if(LANGUAGE == $addon['directory']) {
58
			$template->set_var('SELECTED', ' selected');
59
		} else {
60
			$template->set_var('SELECTED', '');
61
		}
62
		$template->parse('language_list', 'language_list_block', true);
63
	}
64
}
65

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

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

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

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

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

  
150
$admin->print_footer();
151

  
152
?>
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
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
49
if($result->numRows() > 0) {
50
	while($addon = $result->fetchRow()) {
51
		// Insert code and name
52
		$template->set_var(array(
53
								'CODE' => $addon['directory'],
54
								'NAME' => $addon['name']
55
								));
56
		// Check if it is selected
57
		if(LANGUAGE == $addon['directory']) {
58
			$template->set_var('SELECTED', ' selected');
59
		} else {
60
			$template->set_var('SELECTED', '');
61
		}
62
		$template->parse('language_list', 'language_list_block', true);
63
	}
64
}
65

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

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

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

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

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

  
150
$admin->print_footer();
151

  
152
?>

Also available in: Unified diff