Project

General

Profile

1 1397 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         start
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1711 Luisehahne
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8 1397 Luisehahne
 * @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 1711 Luisehahne
 */
17
//$string = "pages,pages_view,pages_add,pages_add_l0,pages_settings,pages_modify,pages_intro,pages_delete,media,media_view,media_upload,media_rename,media_delete,media_create,addons,modules,modules_view,modules_install,modules_uninstall,templates,templates_view,templates_install,templates_uninstall,languages,languages_view,languages_install,languages_uninstall,settings,settings_basic,settings_advanced,access,users,users_view,users_add,users_modify,users_delete,groups,groups_view,groups_add,groups_modify,groups_delete,admintools
18
//media,media_create,media_upload,media_view,preferences,preferences_view,pages,pages_modify,pages_view";
19
//$regex = "/(pages)+[a-z]*[_]([a-z_0-9]+)[^,]/im";
20
//preg_match_all ($regex, $string, $output);
21
//
22 1397 Luisehahne
require('../../config.php');
23
require_once(WB_PATH.'/framework/class.admin.php');
24
$admin = new admin('Start','start');
25 1479 Luisehahne
// ---------------------------------------
26 1711 Luisehahne
//	$database = WbDatabase::getInstance();
27 1560 Luisehahne
28 1479 Luisehahne
if(defined('FINALIZE_SETUP')) {
29
	require_once(WB_PATH.'/framework/functions.php');
30
	$dirs = array( 'modules'   => WB_PATH.'/modules/',
31
	               'templates' => WB_PATH.'/templates/',
32
	               'languages' => WB_PATH.'/languages/'
33
	             );
34
	foreach($dirs AS $type => $dir) {
35
		if( ($handle = opendir($dir)) ) {
36
			while(false !== ($file = readdir($handle))) {
37
				if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
38
					// Get addon type
39
					if($type == 'modules') {
40
						load_module($dir.'/'.$file, true);
41
						// Pretty ugly hack to let modules run $admin->set_error
42
						// See dummy class definition admin_dummy above
43
						if(isset($admin->error) && $admin->error != '') {
44
							$admin->print_error($admin->error);
45
						}
46
					} elseif($type == 'templates') {
47
						load_template($dir.'/'.$file);
48
					} elseif($type == 'languages') {
49
						load_language($dir.'/'.$file);
50
					}
51
				}
52
			}
53
		closedir($handle);
54
		}
55
	}
56
	$sql = 'DELETE FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'FINALIZE_SETUP\'';
57 1560 Luisehahne
	if($database->query($sql)) { }
58 1479 Luisehahne
}
59
// ---------------------------------------
60 1560 Luisehahne
// check if it is neccessary to start the uograde-script
61 1711 Luisehahne
$msg = '';
62
63
// ---------------------------------------
64
// check if it is neccessary to start the uograde-script
65
// ---------------------------------------
66 1562 Luisehahne
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
67 1561 Luisehahne
	// check if it is neccessary to start the uograde-script
68
	$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
69
	if($wb_revision=$database->get_one($sql)) {
70 1589 Luisehahne
	}
71
	if (version_compare($wb_revision, REVISION ) < 0) {
72
		if(!headers_sent()) {
73
			header('Location: '.WB_URL.'/upgrade-script.php');
74
		    exit;
75 1562 Luisehahne
		} else {
76 1589 Luisehahne
		    echo "<p style=\"text-align:center;\"> The <strong>upgrade script</strong> could not be start automatically.\n" .
77
		         "Please click <a style=\"font-weight:bold;\" " .
78
		         "href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
79
		    exit;
80 1560 Luisehahne
		}
81
	}
82 1589 Luisehahne
	$msg .= ''.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />';
83 1560 Luisehahne
}
84 1711 Luisehahne
// ---------------------------------------
85
// workout to upgrade the groups system_permissions
86
// ---------------------------------------
87
if( ($admin->get_user_id()==1) &&
88
	file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') &&
89
	!defined('GROUPS_UPDATED') )
90
{
91
	// check if it is neccessary to start the uograde-script
92
	$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
93
	if($wb_revision = $database->get_one($sql)) {
94 1560 Luisehahne
95 1711 Luisehahne
	}
96
	if (version_compare($wb_revision, '1691' ) < 0) {
97
		require_once (ADMIN_PATH.'/groups/upgradePermissions.php');
98
		// build new or changed $sTempPermissions
99
		if(upgrade_group_system_permissions()){
100
			$cfg = array(
101
				'groups_updated' => time()
102
			);
103
			if(db_update_key_value( 'settings', $cfg )) {
104
			    echo "<div class=\"note center rounded\"><h3>Hello Systemadministrator!</h3>".
105
				     "<p style=\"text-align:center;\">".
106
				     "The <strong>Administrator Groups Rights </strong> were updated automatically.\n" .
107
			         "Please click <a style=\"font-weight:bold;\" " .
108
			         "href=\"".ADMIN_URL."/logout/index.php\">on this link</a> to login again!</p>\n".
109
			         "<h3>Upgrading only start, if groups rights are not up to date!</h3></div>";
110
				// Print admin footer
111
				$admin->print_footer();
112
			    exit(0);
113
114
			}
115
		}
116
	}
117
}
118
119
// ---------------------------------------
120 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
121
// Create new template object
122 1711 Luisehahne
$oTpl = new Template(dirname($admin->correct_theme_source('start.htt')),'keep');
123
$oTpl->set_file('page', 'start.htt');
124
$oTpl->set_block('page', 'main_block', 'main');
125 1397 Luisehahne
126
// Insert values into the template object
127 1711 Luisehahne
$oTpl->set_var(array(
128
					'WELCOME_MESSAGE' => $MESSAGE['START_WELCOME_MESSAGE'],
129
					'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
130 1457 Luisehahne
					'DISPLAY_NAME' => $admin->get_display_name(),
131
					'ADMIN_URL' => ADMIN_URL,
132
					'WB_URL' => WB_URL,
133
					'THEME_URL' => THEME_URL,
134 1711 Luisehahne
					'WB_VERSION' => WB_VERSION,
135
					'NO_CONTENT' => ''
136 1457 Luisehahne
				)
137
			);
138 1397 Luisehahne
139 1711 Luisehahne
140 1397 Luisehahne
// Insert permission values into the template object
141 1711 Luisehahne
$oTpl->set_block('main_block', 'show_pages_block', 'show_pages');
142 1397 Luisehahne
if($admin->get_permission('pages') != true)
143
{
144 1711 Luisehahne
	$oTpl->set_block('show_pages', '');
145
} else {
146
	$oTpl->parse('show_pages', 'show_pages_block', true);
147 1397 Luisehahne
}
148 1711 Luisehahne
149
$oTpl->set_block('main_block', 'show_addons_block', 'show_addons');
150
if($admin->get_permission('addons') != true)
151
{
152
	$oTpl->set_block('show_addons', '');
153
} else {
154
	$oTpl->parse('show_addons', 'show_addons_block', true);
155
}
156
157
$oTpl->set_block('main_block', 'show_settings_block', 'show_settings');
158
if($admin->get_permission('settings') != true)
159
{
160
	$oTpl->set_block('show_settings', '');
161
} else {
162
	$oTpl->parse('show_settings', 'show_settings_block', true);
163
}
164
165
$oTpl->set_block('main_block', 'show_access_block', 'show_access');
166
if($admin->get_permission('access') != true)
167
{
168
	$oTpl->set_block('show_access', '');
169
} else {
170
	$oTpl->parse('show_access', 'show_access_block', true);
171
}
172
173
$oTpl->set_block('main_block', 'show_media_block', 'show_media');
174 1397 Luisehahne
if($admin->get_permission('media') != true)
175
{
176 1711 Luisehahne
	$oTpl->set_block('show_media', '');
177
} else {
178
	$oTpl->parse('show_media', 'show_media_block', true);
179 1397 Luisehahne
}
180 1711 Luisehahne
181
$oTpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
182
if($admin->get_permission('admintools') != true)
183
{
184
	$oTpl->set_block('show_admintools', '');
185
} else {
186
	$oTpl->parse('show_admintools', 'show_admintools_block', true);
187
}
188
189
$oTpl->set_block('main_block', 'show_preferences_block', 'show_preferences');
190
if($admin->get_permission('preferences') != true)
191
{
192
	$oTpl->set_block('show_preferences', '');
193
} else {
194
	$oTpl->parse('show_preferences', 'show_preferences_block', true);
195
}
196
197
$oTpl->set_block('main_block', 'show_install_block', 'show_install');
198
if($admin->ami_group_member('1') != true)
199
{
200
	$oTpl->set_block('show_install', '');
201
} else {
202
	$oTpl->parse('show_install', 'show_install_block', true);
203
}
204
205
/*
206
if($admin->get_permission('pages') != true)
207
{
208
	$oTpl->set_var('DISPLAY_PAGES', 'display:none;');
209
}
210
if($admin->get_permission('media') != true)
211
{
212
	$oTpl->set_var('DISPLAY_MEDIA', 'display:none;');
213
}
214 1397 Luisehahne
if($admin->get_permission('addons') != true)
215
{
216 1711 Luisehahne
	$oTpl->set_var('DISPLAY_ADDONS', 'display:none;');
217 1397 Luisehahne
}
218
if($admin->get_permission('access') != true)
219
{
220 1711 Luisehahne
	$oTpl->set_var('DISPLAY_ACCESS', 'display:none;');
221 1397 Luisehahne
}
222
if($admin->get_permission('settings') != true)
223
{
224 1711 Luisehahne
	$oTpl->set_var('DISPLAY_SETTINGS', 'display:none;');
225 1397 Luisehahne
}
226
if($admin->get_permission('admintools') != true)
227
{
228 1711 Luisehahne
	$oTpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
229 1397 Luisehahne
}
230 1711 Luisehahne
*/
231 1397 Luisehahne
232 1711 Luisehahne
$msg .= (file_exists(WB_PATH.'/install/')) ?  $MESSAGE['START_INSTALL_DIR_EXISTS'] : '';
233 1414 Luisehahne
234 1397 Luisehahne
// Check if installation directory still exists
235 1414 Luisehahne
if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
236 1397 Luisehahne
	// Check if user is part of Adminstrators group
237
	if(in_array(1, $admin->get_groups_id()))
238
    {
239 1711 Luisehahne
		$oTpl->set_var('WARNING', $msg );
240 1397 Luisehahne
	} else {
241 1711 Luisehahne
		$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
242 1397 Luisehahne
	}
243
} else {
244 1711 Luisehahne
	$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
245 1397 Luisehahne
}
246
247
// Insert "Add-ons" section overview (pretty complex compared to normal)
248
$addons_overview = $TEXT['MANAGE'].' ';
249
$addons_count = 0;
250
if($admin->get_permission('modules') == true)
251
{
252
	$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
253
	$addons_count = 1;
254
}
255
if($admin->get_permission('templates') == true)
256
{
257
	if($addons_count == 1) { $addons_overview .= ', '; }
258
	$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
259
	$addons_count = 1;
260
}
261
if($admin->get_permission('languages') == true)
262
{
263
	if($addons_count == 1) { $addons_overview .= ', '; }
264
	$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
265
}
266
267
// Insert "Access" section overview (pretty complex compared to normal)
268
$access_overview = $TEXT['MANAGE'].' ';
269
$access_count = 0;
270
if($admin->get_permission('users') == true) {
271
	$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
272
	$access_count = 1;
273
}
274
if($admin->get_permission('groups') == true) {
275
	if($access_count == 1) { $access_overview .= ', '; }
276
	$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
277
	$access_count = 1;
278
}
279
280
// Insert section names and descriptions
281 1711 Luisehahne
$oTpl->set_var(array(
282 1457 Luisehahne
					'PAGES' => $MENU['PAGES'],
283
					'MEDIA' => $MENU['MEDIA'],
284
					'ADDONS' => $MENU['ADDONS'],
285
					'ACCESS' => $MENU['ACCESS'],
286
					'PREFERENCES' => $MENU['PREFERENCES'],
287
					'SETTINGS' => $MENU['SETTINGS'],
288
					'ADMINTOOLS' => $MENU['ADMINTOOLS'],
289
					'HOME_OVERVIEW' => $OVERVIEW['START'],
290
					'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
291
					'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
292
					'ADDONS_OVERVIEW' => $addons_overview,
293
					'ACCESS_OVERVIEW' => $access_overview,
294
					'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
295
					'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
296
					'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
297
				)
298
			);
299 1397 Luisehahne
300
// Parse template object
301 1711 Luisehahne
$oTpl->parse('main', 'main_block', false);
302
$oTpl->pparse('output', 'page');
303 1397 Luisehahne
304
// Print admin footer
305
$admin->print_footer();