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
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('start.htt'));
78
// Create new template object
79
$template = new Template($ThemePath);
80 1397 Luisehahne
$template->set_file('page', 'start.htt');
81
$template->set_block('page', 'main_block', 'main');
82
83
// Insert values into the template object
84
$template->set_var(array(
85 1457 Luisehahne
					'WELCOME_MESSAGE' => $MESSAGE['START']['WELCOME_MESSAGE'],
86
					'CURRENT_USER' => $MESSAGE['START']['CURRENT_USER'],
87
					'DISPLAY_NAME' => $admin->get_display_name(),
88
					'ADMIN_URL' => ADMIN_URL,
89
					'WB_URL' => WB_URL,
90
					'THEME_URL' => THEME_URL,
91
					'WB_VERSION' => WB_VERSION
92
				)
93
			);
94 1397 Luisehahne
95
// Insert permission values into the template object
96
if($admin->get_permission('pages') != true)
97
{
98
	$template->set_var('DISPLAY_PAGES', 'display:none;');
99
}
100
if($admin->get_permission('media') != true)
101
{
102
	$template->set_var('DISPLAY_MEDIA', 'display:none;');
103
}
104
if($admin->get_permission('addons') != true)
105
{
106
	$template->set_var('DISPLAY_ADDONS', 'display:none;');
107
}
108
if($admin->get_permission('access') != true)
109
{
110
	$template->set_var('DISPLAY_ACCESS', 'display:none;');
111
}
112
if($admin->get_permission('settings') != true)
113
{
114
	$template->set_var('DISPLAY_SETTINGS', 'display:none;');
115
}
116
if($admin->get_permission('admintools') != true)
117
{
118
	$template->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
119
}
120
121 1562 Luisehahne
$msg .= (file_exists(WB_PATH.'/install/')) ?  $MESSAGE['START']['INSTALL_DIR_EXISTS'] : '';
122 1414 Luisehahne
123 1397 Luisehahne
// Check if installation directory still exists
124 1414 Luisehahne
if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
125 1397 Luisehahne
	// Check if user is part of Adminstrators group
126
	if(in_array(1, $admin->get_groups_id()))
127
    {
128 1414 Luisehahne
		$template->set_var('WARNING', $msg );
129 1397 Luisehahne
	} else {
130
		$template->set_var('DISPLAY_WARNING', 'display:none;');
131
	}
132
} else {
133
	$template->set_var('DISPLAY_WARNING', 'display:none;');
134
}
135
136
// Insert "Add-ons" section overview (pretty complex compared to normal)
137
$addons_overview = $TEXT['MANAGE'].' ';
138
$addons_count = 0;
139
if($admin->get_permission('modules') == true)
140
{
141
	$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
142
	$addons_count = 1;
143
}
144
if($admin->get_permission('templates') == true)
145
{
146
	if($addons_count == 1) { $addons_overview .= ', '; }
147
	$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
148
	$addons_count = 1;
149
}
150
if($admin->get_permission('languages') == true)
151
{
152
	if($addons_count == 1) { $addons_overview .= ', '; }
153
	$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
154
}
155
156
// Insert "Access" section overview (pretty complex compared to normal)
157
$access_overview = $TEXT['MANAGE'].' ';
158
$access_count = 0;
159
if($admin->get_permission('users') == true) {
160
	$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
161
	$access_count = 1;
162
}
163
if($admin->get_permission('groups') == true) {
164
	if($access_count == 1) { $access_overview .= ', '; }
165
	$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
166
	$access_count = 1;
167
}
168
169
// Insert section names and descriptions
170
$template->set_var(array(
171 1457 Luisehahne
					'PAGES' => $MENU['PAGES'],
172
					'MEDIA' => $MENU['MEDIA'],
173
					'ADDONS' => $MENU['ADDONS'],
174
					'ACCESS' => $MENU['ACCESS'],
175
					'PREFERENCES' => $MENU['PREFERENCES'],
176
					'SETTINGS' => $MENU['SETTINGS'],
177
					'ADMINTOOLS' => $MENU['ADMINTOOLS'],
178
					'HOME_OVERVIEW' => $OVERVIEW['START'],
179
					'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
180
					'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
181
					'ADDONS_OVERVIEW' => $addons_overview,
182
					'ACCESS_OVERVIEW' => $access_overview,
183
					'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
184
					'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
185
					'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
186
				)
187
			);
188 1397 Luisehahne
189
// Parse template object
190
$template->parse('main', 'main_block', false);
191
$template->pparse('output', 'page');
192
193
// Print admin footer
194
$admin->print_footer();