Project

General

Profile

1 1397 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         start
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1397 Luisehahne
 * @copyright       2009-2011, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id$
13
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15
 *
16
*/
17
18
require('../../config.php');
19
require_once(WB_PATH.'/framework/class.admin.php');
20
$admin = new admin('Start','start');
21 1479 Luisehahne
// ---------------------------------------
22 1560 Luisehahne
23 1479 Luisehahne
if(defined('FINALIZE_SETUP')) {
24
	require_once(WB_PATH.'/framework/functions.php');
25
	$dirs = array( 'modules'   => WB_PATH.'/modules/',
26
	               'templates' => WB_PATH.'/templates/',
27
	               'languages' => WB_PATH.'/languages/'
28
	             );
29
	foreach($dirs AS $type => $dir) {
30
		if( ($handle = opendir($dir)) ) {
31
			while(false !== ($file = readdir($handle))) {
32
				if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
33
					// Get addon type
34
					if($type == 'modules') {
35
						load_module($dir.'/'.$file, true);
36
						// Pretty ugly hack to let modules run $admin->set_error
37
						// See dummy class definition admin_dummy above
38
						if(isset($admin->error) && $admin->error != '') {
39
							$admin->print_error($admin->error);
40
						}
41
					} elseif($type == 'templates') {
42
						load_template($dir.'/'.$file);
43
					} elseif($type == 'languages') {
44
						load_language($dir.'/'.$file);
45
					}
46
				}
47
			}
48
		closedir($handle);
49
		}
50
	}
51
	$sql = 'DELETE FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'FINALIZE_SETUP\'';
52 1560 Luisehahne
	if($database->query($sql)) { }
53 1479 Luisehahne
}
54
// ---------------------------------------
55 1565 Luisehahne
$msg = '<br />';
56 1560 Luisehahne
// check if it is neccessary to start the uograde-script
57 1562 Luisehahne
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
58 1561 Luisehahne
	// check if it is neccessary to start the uograde-script
59
	$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
60
	if($wb_revision=$database->get_one($sql)) {
61 1589 Luisehahne
	}
62
	if (version_compare($wb_revision, REVISION ) < 0) {
63
		if(!headers_sent()) {
64
			header('Location: '.WB_URL.'/upgrade-script.php');
65
		    exit;
66 1562 Luisehahne
		} else {
67 1589 Luisehahne
		    echo "<p style=\"text-align:center;\"> The <strong>upgrade script</strong> could not be start automatically.\n" .
68
		         "Please click <a style=\"font-weight:bold;\" " .
69
		         "href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
70
		    exit;
71 1560 Luisehahne
		}
72
	}
73 1589 Luisehahne
	$msg .= ''.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />';
74 1560 Luisehahne
}
75
76 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
77
// Create new template object
78 1625 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('start.htt')));
79 1397 Luisehahne
$template->set_file('page', 'start.htt');
80
$template->set_block('page', 'main_block', 'main');
81
82
// Insert values into the template object
83
$template->set_var(array(
84 1457 Luisehahne
					'WELCOME_MESSAGE' => $MESSAGE['START']['WELCOME_MESSAGE'],
85
					'CURRENT_USER' => $MESSAGE['START']['CURRENT_USER'],
86
					'DISPLAY_NAME' => $admin->get_display_name(),
87
					'ADMIN_URL' => ADMIN_URL,
88
					'WB_URL' => WB_URL,
89
					'THEME_URL' => THEME_URL,
90
					'WB_VERSION' => WB_VERSION
91
				)
92
			);
93 1397 Luisehahne
94
// Insert permission values into the template object
95
if($admin->get_permission('pages') != true)
96
{
97
	$template->set_var('DISPLAY_PAGES', 'display:none;');
98
}
99
if($admin->get_permission('media') != true)
100
{
101
	$template->set_var('DISPLAY_MEDIA', 'display:none;');
102
}
103
if($admin->get_permission('addons') != true)
104
{
105
	$template->set_var('DISPLAY_ADDONS', 'display:none;');
106
}
107
if($admin->get_permission('access') != true)
108
{
109
	$template->set_var('DISPLAY_ACCESS', 'display:none;');
110
}
111
if($admin->get_permission('settings') != true)
112
{
113
	$template->set_var('DISPLAY_SETTINGS', 'display:none;');
114
}
115
if($admin->get_permission('admintools') != true)
116
{
117
	$template->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
118
}
119
120 1562 Luisehahne
$msg .= (file_exists(WB_PATH.'/install/')) ?  $MESSAGE['START']['INSTALL_DIR_EXISTS'] : '';
121 1414 Luisehahne
122 1397 Luisehahne
// Check if installation directory still exists
123 1414 Luisehahne
if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
124 1397 Luisehahne
	// Check if user is part of Adminstrators group
125
	if(in_array(1, $admin->get_groups_id()))
126
    {
127 1414 Luisehahne
		$template->set_var('WARNING', $msg );
128 1397 Luisehahne
	} else {
129
		$template->set_var('DISPLAY_WARNING', 'display:none;');
130
	}
131
} else {
132
	$template->set_var('DISPLAY_WARNING', 'display:none;');
133
}
134
135
// Insert "Add-ons" section overview (pretty complex compared to normal)
136
$addons_overview = $TEXT['MANAGE'].' ';
137
$addons_count = 0;
138
if($admin->get_permission('modules') == true)
139
{
140
	$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
141
	$addons_count = 1;
142
}
143
if($admin->get_permission('templates') == true)
144
{
145
	if($addons_count == 1) { $addons_overview .= ', '; }
146
	$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
147
	$addons_count = 1;
148
}
149
if($admin->get_permission('languages') == true)
150
{
151
	if($addons_count == 1) { $addons_overview .= ', '; }
152
	$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
153
}
154
155
// Insert "Access" section overview (pretty complex compared to normal)
156
$access_overview = $TEXT['MANAGE'].' ';
157
$access_count = 0;
158
if($admin->get_permission('users') == true) {
159
	$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
160
	$access_count = 1;
161
}
162
if($admin->get_permission('groups') == true) {
163
	if($access_count == 1) { $access_overview .= ', '; }
164
	$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
165
	$access_count = 1;
166
}
167
168
// Insert section names and descriptions
169
$template->set_var(array(
170 1457 Luisehahne
					'PAGES' => $MENU['PAGES'],
171
					'MEDIA' => $MENU['MEDIA'],
172
					'ADDONS' => $MENU['ADDONS'],
173
					'ACCESS' => $MENU['ACCESS'],
174
					'PREFERENCES' => $MENU['PREFERENCES'],
175
					'SETTINGS' => $MENU['SETTINGS'],
176
					'ADMINTOOLS' => $MENU['ADMINTOOLS'],
177
					'HOME_OVERVIEW' => $OVERVIEW['START'],
178
					'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
179
					'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
180
					'ADDONS_OVERVIEW' => $addons_overview,
181
					'ACCESS_OVERVIEW' => $access_overview,
182
					'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
183
					'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
184
					'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
185
				)
186
			);
187 1397 Luisehahne
188
// Parse template object
189
$template->parse('main', 'main_block', false);
190
$template->pparse('output', 'page');
191
192
// Print admin footer
193
$admin->print_footer();