Project

General

Profile

1 1397 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         start
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1397 Luisehahne
 * @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$
13
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15
 *
16
*/
17
18
require('../../config.php');
19
require_once(WB_PATH.'/framework/class.admin.php');
20
$admin = new admin('Start','start');
21 1479 Luisehahne
// ---------------------------------------
22
if(defined('FINALIZE_SETUP')) {
23
	require_once(WB_PATH.'/framework/functions.php');
24
	$dirs = array( 'modules'   => WB_PATH.'/modules/',
25
	               'templates' => WB_PATH.'/templates/',
26
	               'languages' => WB_PATH.'/languages/'
27
	             );
28
	foreach($dirs AS $type => $dir) {
29
		if( ($handle = opendir($dir)) ) {
30
			while(false !== ($file = readdir($handle))) {
31
				if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
32
					// Get addon type
33
					if($type == 'modules') {
34
						load_module($dir.'/'.$file, true);
35
						// Pretty ugly hack to let modules run $admin->set_error
36
						// See dummy class definition admin_dummy above
37
						if(isset($admin->error) && $admin->error != '') {
38
							$admin->print_error($admin->error);
39
						}
40
					} elseif($type == 'templates') {
41
						load_template($dir.'/'.$file);
42
					} elseif($type == 'languages') {
43
						load_language($dir.'/'.$file);
44
					}
45
				}
46
			}
47
		closedir($handle);
48
		}
49
	}
50
	$sql = 'DELETE FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'FINALIZE_SETUP\'';
51
	$database->query($sql);
52
}
53
// ---------------------------------------
54 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
55
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('start.htt'));
56
// Create new template object
57
$template = new Template($ThemePath);
58 1397 Luisehahne
$template->set_file('page', 'start.htt');
59
$template->set_block('page', 'main_block', 'main');
60
61
// Insert values into the template object
62
$template->set_var(array(
63 1457 Luisehahne
					'WELCOME_MESSAGE' => $MESSAGE['START']['WELCOME_MESSAGE'],
64
					'CURRENT_USER' => $MESSAGE['START']['CURRENT_USER'],
65
					'DISPLAY_NAME' => $admin->get_display_name(),
66
					'ADMIN_URL' => ADMIN_URL,
67
					'WB_URL' => WB_URL,
68
					'THEME_URL' => THEME_URL,
69
					'WB_VERSION' => WB_VERSION
70
				)
71
			);
72 1397 Luisehahne
73
// Insert permission values into the template object
74
if($admin->get_permission('pages') != true)
75
{
76
	$template->set_var('DISPLAY_PAGES', 'display:none;');
77
}
78
if($admin->get_permission('media') != true)
79
{
80
	$template->set_var('DISPLAY_MEDIA', 'display:none;');
81
}
82
if($admin->get_permission('addons') != true)
83
{
84
	$template->set_var('DISPLAY_ADDONS', 'display:none;');
85
}
86
if($admin->get_permission('access') != true)
87
{
88
	$template->set_var('DISPLAY_ACCESS', 'display:none;');
89
}
90
if($admin->get_permission('settings') != true)
91
{
92
	$template->set_var('DISPLAY_SETTINGS', 'display:none;');
93
}
94
if($admin->get_permission('admintools') != true)
95
{
96
	$template->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
97
}
98
99 1414 Luisehahne
$msg = (file_exists(WB_PATH.'/install/')) ?  $MESSAGE['START']['INSTALL_DIR_EXISTS'] : '';
100 1475 Luisehahne
$msg .= (file_exists(WB_PATH.'/upgrade-script.php')) ? '<br />'.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'] : '';
101 1414 Luisehahne
102 1397 Luisehahne
// Check if installation directory still exists
103 1414 Luisehahne
if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
104 1397 Luisehahne
	// Check if user is part of Adminstrators group
105
	if(in_array(1, $admin->get_groups_id()))
106
    {
107 1414 Luisehahne
		$template->set_var('WARNING', $msg );
108 1397 Luisehahne
	} else {
109
		$template->set_var('DISPLAY_WARNING', 'display:none;');
110
	}
111
} else {
112
	$template->set_var('DISPLAY_WARNING', 'display:none;');
113
}
114
115
// Insert "Add-ons" section overview (pretty complex compared to normal)
116
$addons_overview = $TEXT['MANAGE'].' ';
117
$addons_count = 0;
118
if($admin->get_permission('modules') == true)
119
{
120
	$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
121
	$addons_count = 1;
122
}
123
if($admin->get_permission('templates') == true)
124
{
125
	if($addons_count == 1) { $addons_overview .= ', '; }
126
	$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
127
	$addons_count = 1;
128
}
129
if($admin->get_permission('languages') == true)
130
{
131
	if($addons_count == 1) { $addons_overview .= ', '; }
132
	$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
133
}
134
135
// Insert "Access" section overview (pretty complex compared to normal)
136
$access_overview = $TEXT['MANAGE'].' ';
137
$access_count = 0;
138
if($admin->get_permission('users') == true) {
139
	$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
140
	$access_count = 1;
141
}
142
if($admin->get_permission('groups') == true) {
143
	if($access_count == 1) { $access_overview .= ', '; }
144
	$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
145
	$access_count = 1;
146
}
147
148
// Insert section names and descriptions
149
$template->set_var(array(
150 1457 Luisehahne
					'PAGES' => $MENU['PAGES'],
151
					'MEDIA' => $MENU['MEDIA'],
152
					'ADDONS' => $MENU['ADDONS'],
153
					'ACCESS' => $MENU['ACCESS'],
154
					'PREFERENCES' => $MENU['PREFERENCES'],
155
					'SETTINGS' => $MENU['SETTINGS'],
156
					'ADMINTOOLS' => $MENU['ADMINTOOLS'],
157
					'HOME_OVERVIEW' => $OVERVIEW['START'],
158
					'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
159
					'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
160
					'ADDONS_OVERVIEW' => $addons_overview,
161
					'ACCESS_OVERVIEW' => $access_overview,
162
					'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
163
					'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
164
					'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
165
				)
166
			);
167 1397 Luisehahne
168
// Parse template object
169
$template->parse('main', 'main_block', false);
170
$template->pparse('output', 'page');
171
172
// Print admin footer
173
$admin->print_footer();