Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         start
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker 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: index.php 1777 2012-10-01 16:16:26Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/start/index.php $
14
 * @lastmodified    $Date: 2012-10-01 18:16:26 +0200 (Mon, 01 Oct 2012) $
15
 *
16
 */
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
require('../../config.php');
23
require_once(WB_PATH.'/framework/class.admin.php');
24
$admin = new admin('Start','start');
25
// ---------------------------------------
26
//	$database = WbDatabase::getInstance();
27

    
28
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
	if($database->query($sql)) { }
58
}
59
// ---------------------------------------
60
// check if it is neccessary to start the uograde-script
61
$msg = '';
62

    
63
// ---------------------------------------
64
// check if it is neccessary to start the uograde-script
65
// ---------------------------------------
66
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
67
	// 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
	}
71
	if (version_compare($wb_revision, REVISION ) < 0) {
72
		if(!headers_sent()) {
73
			header('Location: '.WB_URL.'/upgrade-script.php');
74
		    exit;
75
		} else {
76
		    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
		}
81
	}
82
	$msg .= ''.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />';
83
}
84
// ---------------------------------------
85
// workout to upgrade the groups system_permissions
86
// ---------------------------------------
87
if( ($admin->get_user_id()==1) &&
88
	file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') && !defined('GROUPS_UPDATED') )
89
{
90
	// check if it is neccessary to start the uograde-script
91
	$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
92
	if($wb_revision = $database->get_one($sql)) {
93

    
94
	}
95

    
96
	if ((version_compare($wb_revision, '1800' )  < 0)&& !defined('GROUPS_UPDATED')) {
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
// Setup template object, parse vars to it, then parse it
121
// Create new template object
122
$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

    
126
// Insert values into the template object
127
$oTpl->set_var(array(
128
					'WELCOME_MESSAGE' => $MESSAGE['START_WELCOME_MESSAGE'],
129
					'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
130
					'DISPLAY_NAME' => $admin->get_display_name(),
131
                    'DISPLAY_WARNING' => '',
132
					'ADMIN_URL' => ADMIN_URL,
133
					'WB_URL' => WB_URL,
134
					'THEME_URL' => THEME_URL,
135
					'WB_VERSION' => WB_VERSION,
136
					'NO_CONTENT' => ''
137
				)
138
			);
139

    
140

    
141
// Insert permission values into the template object
142
$oTpl->set_block('main_block', 'show_pages_block', 'show_pages');
143
if($admin->get_permission('pages') != true)
144
{
145
	$oTpl->set_block('show_pages', '');
146
} else {
147
	$oTpl->parse('show_pages', 'show_pages_block', true);
148
}
149

    
150
$oTpl->set_block('main_block', 'show_addons_block', 'show_addons');
151
if($admin->get_permission('addons') != true)
152
{
153
	$oTpl->set_block('show_addons', '');
154
} else {
155
	$oTpl->parse('show_addons', 'show_addons_block', true);
156
}
157

    
158
$oTpl->set_block('main_block', 'show_settings_block', 'show_settings');
159
if($admin->get_permission('settings') != true)
160
{
161
	$oTpl->set_block('show_settings', '');
162
} else {
163
	$oTpl->parse('show_settings', 'show_settings_block', true);
164
}
165

    
166
$oTpl->set_block('main_block', 'show_access_block', 'show_access');
167
if($admin->get_permission('access') != true)
168
{
169
	$oTpl->set_block('show_access', '');
170
} else {
171
	$oTpl->parse('show_access', 'show_access_block', true);
172
}
173

    
174
$oTpl->set_block('main_block', 'show_media_block', 'show_media');
175
if($admin->get_permission('media') != true)
176
{
177
	$oTpl->set_block('show_media', '');
178
} else {
179
	$oTpl->parse('show_media', 'show_media_block', true);
180
}
181

    
182
$oTpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
183
if($admin->get_permission('admintools') != true)
184
{
185
	$oTpl->set_block('show_admintools', '');
186
} else {
187
	$oTpl->parse('show_admintools', 'show_admintools_block', true);
188
}
189

    
190
$oTpl->set_block('main_block', 'show_preferences_block', 'show_preferences');
191
if($admin->get_permission('preferences') != true)
192
{
193
	$oTpl->set_block('show_preferences', '');
194
} else {
195
	$oTpl->parse('show_preferences', 'show_preferences_block', true);
196
}
197

    
198
$oTpl->set_block('main_block', 'show_install_block', 'show_install');
199
if($admin->ami_group_member('1') != true)
200
{
201
	$oTpl->set_block('show_install', '');
202
} else {
203
	$oTpl->parse('show_install', 'show_install_block', true);
204
}
205

    
206
/*
207
if($admin->get_permission('pages') != true)
208
{
209
	$oTpl->set_var('DISPLAY_PAGES', 'display:none;');
210
}
211
if($admin->get_permission('media') != true)
212
{
213
	$oTpl->set_var('DISPLAY_MEDIA', 'display:none;');
214
}
215
if($admin->get_permission('addons') != true)
216
{
217
	$oTpl->set_var('DISPLAY_ADDONS', 'display:none;');
218
}
219
if($admin->get_permission('access') != true)
220
{
221
	$oTpl->set_var('DISPLAY_ACCESS', 'display:none;');
222
}
223
if($admin->get_permission('settings') != true)
224
{
225
	$oTpl->set_var('DISPLAY_SETTINGS', 'display:none;');
226
}
227
if($admin->get_permission('admintools') != true)
228
{
229
	$oTpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
230
}
231
*/
232

    
233
$msg .= (file_exists(WB_PATH.'/install/')) ?  $MESSAGE['START_INSTALL_DIR_EXISTS'] : '';
234

    
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
// Insert "Add-ons" section overview (pretty complex compared to normal)
249
$addons_overview = $TEXT['MANAGE'].' ';
250
$addons_count = 0;
251
if($admin->get_permission('modules') == true)
252
{
253
	$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
254
	$addons_count = 1;
255
}
256
if($admin->get_permission('templates') == true)
257
{
258
	if($addons_count == 1) { $addons_overview .= ', '; }
259
	$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
260
	$addons_count = 1;
261
}
262
if($admin->get_permission('languages') == true)
263
{
264
	if($addons_count == 1) { $addons_overview .= ', '; }
265
	$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
266
}
267

    
268
// Insert "Access" section overview (pretty complex compared to normal)
269
$access_overview = $TEXT['MANAGE'].' ';
270
$access_count = 0;
271
if($admin->get_permission('users') == true) {
272
	$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
273
	$access_count = 1;
274
}
275
if($admin->get_permission('groups') == true) {
276
	if($access_count == 1) { $access_overview .= ', '; }
277
	$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
278
	$access_count = 1;
279
}
280

    
281
// Insert section names and descriptions
282
$oTpl->set_var(array(
283
					'PAGES' => $MENU['PAGES'],
284
					'MEDIA' => $MENU['MEDIA'],
285
					'ADDONS' => $MENU['ADDONS'],
286
					'ACCESS' => $MENU['ACCESS'],
287
					'PREFERENCES' => $MENU['PREFERENCES'],
288
					'SETTINGS' => $MENU['SETTINGS'],
289
					'ADMINTOOLS' => $MENU['ADMINTOOLS'],
290
					'HOME_OVERVIEW' => $OVERVIEW['START'],
291
					'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
292
					'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
293
					'ADDONS_OVERVIEW' => $addons_overview,
294
					'ACCESS_OVERVIEW' => $access_overview,
295
					'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
296
					'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
297
					'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
298
				)
299
			);
300

    
301
// Parse template object
302
$oTpl->parse('main', 'main_block', false);
303
$oTpl->pparse('output', 'page');
304

    
305
// Print admin footer
306
$admin->print_footer();
    (1-1/1)