Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         start
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @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: index.php 1560 2012-01-04 21:31:39Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/start/index.php $
14
 * @lastmodified    $Date: 2012-01-04 22:31:39 +0100 (Wed, 04 Jan 2012) $
15
 *
16
*/
17

    
18
require('../../config.php');
19
require_once(WB_PATH.'/framework/class.admin.php');
20
$admin = new admin('Start','start');
21
// ---------------------------------------
22

    
23
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
	if($database->query($sql)) { }
53
}
54
// ---------------------------------------
55
// check if it is neccessary to start the uograde-script
56
$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
57
if($wb_revision=$database->get_one($sql)) {
58
	if (version_compare($wb_revision, REVISION ) < 0) {
59
		if(!headers_sent()) {
60
			header('Location: '.WB_URL.'/upgrade-script.php');
61
		    exit;
62
		} else {
63
		    echo "<p style=\"text-align:center;\"> The <strong>upgrade script</strong> could not be start automatically.\n" .
64
		         "Please click <a style=\"font-weight:bold;\" " .
65
		         "href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
66
		    exit;
67
		}
68
	}
69
}
70

    
71
// Setup template object, parse vars to it, then parse it
72
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('start.htt'));
73
// Create new template object
74
$template = new Template($ThemePath);
75
$template->set_file('page', 'start.htt');
76
$template->set_block('page', 'main_block', 'main');
77

    
78
// Insert values into the template object
79
$template->set_var(array(
80
					'WELCOME_MESSAGE' => $MESSAGE['START']['WELCOME_MESSAGE'],
81
					'CURRENT_USER' => $MESSAGE['START']['CURRENT_USER'],
82
					'DISPLAY_NAME' => $admin->get_display_name(),
83
					'ADMIN_URL' => ADMIN_URL,
84
					'WB_URL' => WB_URL,
85
					'THEME_URL' => THEME_URL,
86
					'WB_VERSION' => WB_VERSION
87
				)
88
			);
89

    
90
// Insert permission values into the template object
91
if($admin->get_permission('pages') != true)
92
{
93
	$template->set_var('DISPLAY_PAGES', 'display:none;');
94
}
95
if($admin->get_permission('media') != true)
96
{
97
	$template->set_var('DISPLAY_MEDIA', 'display:none;');
98
}
99
if($admin->get_permission('addons') != true)
100
{
101
	$template->set_var('DISPLAY_ADDONS', 'display:none;');
102
}
103
if($admin->get_permission('access') != true)
104
{
105
	$template->set_var('DISPLAY_ACCESS', 'display:none;');
106
}
107
if($admin->get_permission('settings') != true)
108
{
109
	$template->set_var('DISPLAY_SETTINGS', 'display:none;');
110
}
111
if($admin->get_permission('admintools') != true)
112
{
113
	$template->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
114
}
115

    
116
$msg = (file_exists(WB_PATH.'/install/')) ?  $MESSAGE['START']['INSTALL_DIR_EXISTS'] : '';
117
$msg .= (file_exists(WB_PATH.'/upgrade-script.php')) ? '<br />'.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'] : '';
118

    
119
// Check if installation directory still exists
120
if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
121
	// Check if user is part of Adminstrators group
122
	if(in_array(1, $admin->get_groups_id()))
123
    {
124
		$template->set_var('WARNING', $msg );
125
	} else {
126
		$template->set_var('DISPLAY_WARNING', 'display:none;');
127
	}
128
} else {
129
	$template->set_var('DISPLAY_WARNING', 'display:none;');
130
}
131

    
132
// Insert "Add-ons" section overview (pretty complex compared to normal)
133
$addons_overview = $TEXT['MANAGE'].' ';
134
$addons_count = 0;
135
if($admin->get_permission('modules') == true)
136
{
137
	$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
138
	$addons_count = 1;
139
}
140
if($admin->get_permission('templates') == true)
141
{
142
	if($addons_count == 1) { $addons_overview .= ', '; }
143
	$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
144
	$addons_count = 1;
145
}
146
if($admin->get_permission('languages') == true)
147
{
148
	if($addons_count == 1) { $addons_overview .= ', '; }
149
	$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
150
}
151

    
152
// Insert "Access" section overview (pretty complex compared to normal)
153
$access_overview = $TEXT['MANAGE'].' ';
154
$access_count = 0;
155
if($admin->get_permission('users') == true) {
156
	$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
157
	$access_count = 1;
158
}
159
if($admin->get_permission('groups') == true) {
160
	if($access_count == 1) { $access_overview .= ', '; }
161
	$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
162
	$access_count = 1;
163
}
164

    
165
// Insert section names and descriptions
166
$template->set_var(array(
167
					'PAGES' => $MENU['PAGES'],
168
					'MEDIA' => $MENU['MEDIA'],
169
					'ADDONS' => $MENU['ADDONS'],
170
					'ACCESS' => $MENU['ACCESS'],
171
					'PREFERENCES' => $MENU['PREFERENCES'],
172
					'SETTINGS' => $MENU['SETTINGS'],
173
					'ADMINTOOLS' => $MENU['ADMINTOOLS'],
174
					'HOME_OVERVIEW' => $OVERVIEW['START'],
175
					'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
176
					'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
177
					'ADDONS_OVERVIEW' => $addons_overview,
178
					'ACCESS_OVERVIEW' => $access_overview,
179
					'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
180
					'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
181
					'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
182
				)
183
			);
184

    
185
// Parse template object
186
$template->parse('main', 'main_block', false);
187
$template->pparse('output', 'page');
188

    
189
// Print admin footer
190
$admin->print_footer();
    (1-1/1)