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 1778 Luisehahne
$msg  = '';
62
$msg .= (is_readable(WB_PATH.'/install/')) ?  $MESSAGE['START_INSTALL_DIR_EXISTS'].'<br />' : $msg;
63
$msg .= (is_readable(WB_PATH.'/upgrade-script.php')) ?  $MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />' : '';
64
//$msg .= ''.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />';
65 1711 Luisehahne
66
// ---------------------------------------
67
// check if it is neccessary to start the uograde-script
68
// ---------------------------------------
69 1562 Luisehahne
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
70 1561 Luisehahne
	// check if it is neccessary to start the uograde-script
71
	$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
72
	if($wb_revision=$database->get_one($sql)) {
73 1589 Luisehahne
	}
74
	if (version_compare($wb_revision, REVISION ) < 0) {
75
		if(!headers_sent()) {
76
			header('Location: '.WB_URL.'/upgrade-script.php');
77
		    exit;
78 1562 Luisehahne
		} else {
79 1589 Luisehahne
		    echo "<p style=\"text-align:center;\"> The <strong>upgrade script</strong> could not be start automatically.\n" .
80
		         "Please click <a style=\"font-weight:bold;\" " .
81
		         "href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
82
		    exit;
83 1560 Luisehahne
		}
84
	}
85
}
86 1711 Luisehahne
// ---------------------------------------
87
// workout to upgrade the groups system_permissions
88
// ---------------------------------------
89
if( ($admin->get_user_id()==1) &&
90 1770 Luisehahne
	file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') && !defined('GROUPS_UPDATED') )
91 1711 Luisehahne
{
92
	// check if it is neccessary to start the uograde-script
93
	$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
94
	if($wb_revision = $database->get_one($sql)) {
95 1560 Luisehahne
96 1711 Luisehahne
	}
97 1727 Luisehahne
98
	if ((version_compare($wb_revision, '1800' )  < 0)&& !defined('GROUPS_UPDATED')) {
99 1711 Luisehahne
		require_once (ADMIN_PATH.'/groups/upgradePermissions.php');
100
		// build new or changed $sTempPermissions
101
		if(upgrade_group_system_permissions()){
102
			$cfg = array(
103
				'groups_updated' => time()
104
			);
105
			if(db_update_key_value( 'settings', $cfg )) {
106
			    echo "<div class=\"note center rounded\"><h3>Hello Systemadministrator!</h3>".
107
				     "<p style=\"text-align:center;\">".
108
				     "The <strong>Administrator Groups Rights </strong> were updated automatically.\n" .
109
			         "Please click <a style=\"font-weight:bold;\" " .
110
			         "href=\"".ADMIN_URL."/logout/index.php\">on this link</a> to login again!</p>\n".
111
			         "<h3>Upgrading only start, if groups rights are not up to date!</h3></div>";
112
				// Print admin footer
113
				$admin->print_footer();
114
			    exit(0);
115
116
			}
117
		}
118
	}
119
}
120
121
// ---------------------------------------
122 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
123
// Create new template object
124 1711 Luisehahne
$oTpl = new Template(dirname($admin->correct_theme_source('start.htt')),'keep');
125
$oTpl->set_file('page', 'start.htt');
126
$oTpl->set_block('page', 'main_block', 'main');
127 1397 Luisehahne
128
// Insert values into the template object
129 1711 Luisehahne
$oTpl->set_var(array(
130
					'WELCOME_MESSAGE' => $MESSAGE['START_WELCOME_MESSAGE'],
131
					'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
132 1457 Luisehahne
					'DISPLAY_NAME' => $admin->get_display_name(),
133 1777 Luisehahne
                    'DISPLAY_WARNING' => '',
134 1778 Luisehahne
                    'WARNING' => '',
135 1457 Luisehahne
					'ADMIN_URL' => ADMIN_URL,
136
					'WB_URL' => WB_URL,
137
					'THEME_URL' => THEME_URL,
138 1711 Luisehahne
					'WB_VERSION' => WB_VERSION,
139
					'NO_CONTENT' => ''
140 1457 Luisehahne
				)
141
			);
142 1397 Luisehahne
143
// Insert permission values into the template object
144 1711 Luisehahne
$oTpl->set_block('main_block', 'show_pages_block', 'show_pages');
145 1397 Luisehahne
if($admin->get_permission('pages') != true)
146
{
147 1711 Luisehahne
	$oTpl->set_block('show_pages', '');
148
} else {
149
	$oTpl->parse('show_pages', 'show_pages_block', true);
150 1397 Luisehahne
}
151 1711 Luisehahne
152
$oTpl->set_block('main_block', 'show_addons_block', 'show_addons');
153
if($admin->get_permission('addons') != true)
154
{
155
	$oTpl->set_block('show_addons', '');
156
} else {
157
	$oTpl->parse('show_addons', 'show_addons_block', true);
158
}
159
160
$oTpl->set_block('main_block', 'show_settings_block', 'show_settings');
161
if($admin->get_permission('settings') != true)
162
{
163
	$oTpl->set_block('show_settings', '');
164
} else {
165
	$oTpl->parse('show_settings', 'show_settings_block', true);
166
}
167
168
$oTpl->set_block('main_block', 'show_access_block', 'show_access');
169
if($admin->get_permission('access') != true)
170
{
171
	$oTpl->set_block('show_access', '');
172
} else {
173
	$oTpl->parse('show_access', 'show_access_block', true);
174
}
175
176
$oTpl->set_block('main_block', 'show_media_block', 'show_media');
177 1397 Luisehahne
if($admin->get_permission('media') != true)
178
{
179 1711 Luisehahne
	$oTpl->set_block('show_media', '');
180
} else {
181
	$oTpl->parse('show_media', 'show_media_block', true);
182 1397 Luisehahne
}
183 1711 Luisehahne
184
$oTpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
185
if($admin->get_permission('admintools') != true)
186
{
187
	$oTpl->set_block('show_admintools', '');
188
} else {
189
	$oTpl->parse('show_admintools', 'show_admintools_block', true);
190
}
191
192
$oTpl->set_block('main_block', 'show_preferences_block', 'show_preferences');
193
if($admin->get_permission('preferences') != true)
194
{
195
	$oTpl->set_block('show_preferences', '');
196
} else {
197
	$oTpl->parse('show_preferences', 'show_preferences_block', true);
198
}
199
200
201
/*
202
if($admin->get_permission('pages') != true)
203
{
204
	$oTpl->set_var('DISPLAY_PAGES', 'display:none;');
205
}
206
if($admin->get_permission('media') != true)
207
{
208
	$oTpl->set_var('DISPLAY_MEDIA', 'display:none;');
209
}
210 1397 Luisehahne
if($admin->get_permission('addons') != true)
211
{
212 1711 Luisehahne
	$oTpl->set_var('DISPLAY_ADDONS', 'display:none;');
213 1397 Luisehahne
}
214
if($admin->get_permission('access') != true)
215
{
216 1711 Luisehahne
	$oTpl->set_var('DISPLAY_ACCESS', 'display:none;');
217 1397 Luisehahne
}
218
if($admin->get_permission('settings') != true)
219
{
220 1711 Luisehahne
	$oTpl->set_var('DISPLAY_SETTINGS', 'display:none;');
221 1397 Luisehahne
}
222
if($admin->get_permission('admintools') != true)
223
{
224 1711 Luisehahne
	$oTpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
225 1397 Luisehahne
}
226 1711 Luisehahne
*/
227 1397 Luisehahne
228 1414 Luisehahne
229 1778 Luisehahne
$oTpl->set_block('main_block', 'show_install_block', 'show_install');
230
if($admin->get_user_id() != 1)
231
{
232
	$oTpl->parse('show_install', '');
233 1397 Luisehahne
} else {
234 1778 Luisehahne
235
    // Check if installation directory still exists
236
    if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
237
    	// Check if user is part of Adminstrators group
238
    	if($admin->get_user_id()==1)
239
        {
240
    		$oTpl->set_var('WARNING', $msg );
241
    	} else {
242
    		$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
243
    	}
244
    } else {
245
    	$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
246
    }
247
248
	$oTpl->parse('show_install', 'show_install_block', true);
249 1397 Luisehahne
}
250
251
// Insert "Add-ons" section overview (pretty complex compared to normal)
252
$addons_overview = $TEXT['MANAGE'].' ';
253
$addons_count = 0;
254
if($admin->get_permission('modules') == true)
255
{
256
	$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
257
	$addons_count = 1;
258
}
259
if($admin->get_permission('templates') == true)
260
{
261
	if($addons_count == 1) { $addons_overview .= ', '; }
262
	$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
263
	$addons_count = 1;
264
}
265
if($admin->get_permission('languages') == true)
266
{
267
	if($addons_count == 1) { $addons_overview .= ', '; }
268
	$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
269
}
270
271
// Insert "Access" section overview (pretty complex compared to normal)
272
$access_overview = $TEXT['MANAGE'].' ';
273
$access_count = 0;
274
if($admin->get_permission('users') == true) {
275
	$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
276
	$access_count = 1;
277
}
278
if($admin->get_permission('groups') == true) {
279
	if($access_count == 1) { $access_overview .= ', '; }
280
	$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
281
	$access_count = 1;
282
}
283
284
// Insert section names and descriptions
285 1711 Luisehahne
$oTpl->set_var(array(
286 1457 Luisehahne
					'PAGES' => $MENU['PAGES'],
287
					'MEDIA' => $MENU['MEDIA'],
288
					'ADDONS' => $MENU['ADDONS'],
289
					'ACCESS' => $MENU['ACCESS'],
290
					'PREFERENCES' => $MENU['PREFERENCES'],
291
					'SETTINGS' => $MENU['SETTINGS'],
292
					'ADMINTOOLS' => $MENU['ADMINTOOLS'],
293
					'HOME_OVERVIEW' => $OVERVIEW['START'],
294
					'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
295
					'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
296
					'ADDONS_OVERVIEW' => $addons_overview,
297
					'ACCESS_OVERVIEW' => $access_overview,
298
					'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
299
					'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
300
					'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
301
				)
302
			);
303 1397 Luisehahne
304
// Parse template object
305 1711 Luisehahne
$oTpl->parse('main', 'main_block', false);
306
$oTpl->pparse('output', 'page');
307 1397 Luisehahne
308
// Print admin footer
309
$admin->print_footer();