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 1778 2012-10-05 09:47:39Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/start/index.php $
14
 * @lastmodified    $Date: 2012-10-05 11:47:39 +0200 (Fri, 05 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
$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

    
66
// ---------------------------------------
67
// check if it is neccessary to start the uograde-script
68
// ---------------------------------------
69
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
70
	// 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
	}
74
	if (version_compare($wb_revision, REVISION ) < 0) {
75
		if(!headers_sent()) {
76
			header('Location: '.WB_URL.'/upgrade-script.php');
77
		    exit;
78
		} else {
79
		    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
		}
84
	}
85
}
86
// ---------------------------------------
87
// workout to upgrade the groups system_permissions
88
// ---------------------------------------
89
if( ($admin->get_user_id()==1) &&
90
	file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') && !defined('GROUPS_UPDATED') )
91
{
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

    
96
	}
97

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

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

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

    
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
if($admin->get_permission('media') != true)
178
{
179
	$oTpl->set_block('show_media', '');
180
} else {
181
	$oTpl->parse('show_media', 'show_media_block', true);
182
}
183

    
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
if($admin->get_permission('addons') != true)
211
{
212
	$oTpl->set_var('DISPLAY_ADDONS', 'display:none;');
213
}
214
if($admin->get_permission('access') != true)
215
{
216
	$oTpl->set_var('DISPLAY_ACCESS', 'display:none;');
217
}
218
if($admin->get_permission('settings') != true)
219
{
220
	$oTpl->set_var('DISPLAY_SETTINGS', 'display:none;');
221
}
222
if($admin->get_permission('admintools') != true)
223
{
224
	$oTpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
225
}
226
*/
227

    
228

    
229
$oTpl->set_block('main_block', 'show_install_block', 'show_install');
230
if($admin->get_user_id() != 1)
231
{
232
	$oTpl->parse('show_install', '');
233
} else {
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
	$oTpl->parse('show_install', 'show_install_block', true);
249
}
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
$oTpl->set_var(array(
286
					'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

    
304
// Parse template object
305
$oTpl->parse('main', 'main_block', false);
306
$oTpl->pparse('output', 'page');
307

    
308
// Print admin footer
309
$admin->print_footer();
    (1-1/1)