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 1561 2012-01-05 11:56:34Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/start/index.php $
14
 * @lastmodified    $Date: 2012-01-05 12:56:34 +0100 (Thu, 05 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

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

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

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

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

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

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

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

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

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

    
189
// Parse template object
190
$template->parse('main', 'main_block', false);
191
$template->pparse('output', 'page');
192

    
193
// Print admin footer
194
$admin->print_footer();
    (1-1/1)