Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         modules
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 2098 2014-02-11 01:37:03Z darkviper $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/modules/index.php $
14
 * @lastmodified    $Date: 2014-02-11 02:37:03 +0100 (Tue, 11 Feb 2014) $
15
 *
16
 */
17

    
18
// Print admin header
19
$config_file = realpath('../../config.php');
20
if(file_exists($config_file) && !defined('WB_URL'))
21
{
22
	require_once($config_file);
23
}
24
$oReg = WbAdaptor::getInstance();
25
if(!class_exists('admin', false)){ include($oReg->AppPath.'framework/class.admin.php'); }
26
$admin = new admin('Addons', 'modules');
27
// Make news post access files dir
28
if(!function_exists('get_variable_content')) {require($oReg->AppPath.'framework/functions.php');}
29
$oReg->getWbConstants();
30
$oTrans = Translate::getInstance();
31
$oTrans->enableAddon('admin\\modules');
32

    
33
// Setup template object, parse vars to it, then parse it
34
// Create new template object
35
$template = new Template(dirname($admin->correct_theme_source('modules.htt')),'keep');
36
// $template->debug = true;
37
$template->set_file('page', 'modules.htt');
38
$template->set_block('page', 'main_block', 'main');
39
$template->set_var($oTrans->getLangArray());
40
// Insert values into module list
41
$template->set_block('main_block', 'module_list_block', 'module_list');
42
$aAddonsList = array();
43
$sql = 'SELECT `directory`,`name` FROM  `'.$database->TablePrefix.'addons` '
44
     . 'WHERE `type` = \'module\' '
45
     . 'ORDER BY `name` ';
46
if($result = $database->query($sql)){
47

    
48
	while ($addon = $result->fetchRow(MYSQL_ASSOC))
49
	{
50
        $aAddonsList[$addon['directory']] = $addon['name'];
51
	}
52
    natcasesort ($aAddonsList);
53
    foreach ($aAddonsList as $sModule => $sModuleName)
54
    {
55
		if ($admin->get_permission($sModule,'module')==false) { continue;}
56
		$template->set_var('VALUE', $sModule);
57
		$template->set_var('NAME', $sModuleName);
58
		$template->parse('module_list', 'module_list_block', true);
59
    }
60

    
61
}
62
$aModuleList = array();
63
// Insert modules which includes a install.php file to install list
64
foreach (glob($oReg->AppPath.'modules/*', GLOB_MARK|GLOB_ONLYDIR) as $sTmp) {
65
    $sModulePath = str_replace('\\','/',$sTmp);
66
    $sModule = basename($sModulePath);
67
// list all module names not directories 
68
    $sModuleName = 'failed';
69
    if(function_exists('file_get_contents') && is_readable($sModulePath.'info.php')) {
70
    	$sData = file_get_contents($sModulePath.'info.php');
71
    	$sModuleName = get_variable_content('module_name', $sData, false, false);
72
    }
73
    $aModuleList[$sModule] = $sModuleName;
74
}
75
natcasesort ($aModuleList);
76
$template->set_block('main_block', 'install_list_block', 'install_list');
77
$template->set_block('main_block', 'upgrade_list_block', 'upgrade_list');
78
$template->set_block('main_block', 'uninstall_list_block', 'uninstall_list');
79
$template->set_var(array('INSTALL_VISIBLE' => 'hide', 'UPGRADE_VISIBLE' => 'hide', 'UNINSTALL_VISIBLE' => 'hide'));
80
$show_block = false;
81
foreach ($aModuleList as $sModule => $sModuleName)
82
{
83
	if ( $admin->get_permission($sModule,'module')==false ) { continue;}
84
	if (is_readable($oReg->AppPath.'modules/'.$sModule.'/install.php')) {
85
		$show_block = true;
86
		$template->set_var('INSTALL_VISIBLE', '');
87
		$template->set_var('VALUE', $sModule);
88
		$template->set_var('NAME', $sModuleName);
89
		$template->parse('install_list', 'install_list_block', true);
90
	}
91

    
92
	if (is_readable($oReg->AppPath.'modules/'.$sModule.'/upgrade.php')) {
93
		$show_block = true;
94
		$template->set_var('UPGRADE_VISIBLE', '');
95
		$template->set_var('VALUE', $sModule);
96
		$template->set_var('NAME', $sModuleName);
97
		$template->parse('upgrade_list', 'upgrade_list_block', true);
98
	}
99

    
100
	if (is_readable($oReg->AppPath.'modules/'.$sModule.'/uninstall.php')) {
101
		$show_block = true;
102
		$template->set_var('UNINSTALL_VISIBLE', '');
103
		$template->set_var('VALUE', $sModule);
104
		$template->set_var('NAME', $sModuleName);
105
		$template->parse('uninstall_list', 'uninstall_list_block', true);
106
	}
107

    
108
}
109
// Insert permissions values
110
if($admin->get_permission('modules_install') != true) {
111
	$template->set_var('DISPLAY_INSTALL', 'hide');
112
}
113
if($admin->get_permission('modules_uninstall') != true) {
114
	$template->set_var('DISPLAY_UNINSTALL', 'hide');
115
}
116
if($admin->get_permission('modules_view') != true) {
117
	$template->set_var('DISPLAY_LIST', 'hide');
118
}
119
// only show block if there is something to show
120
if(!$show_block || count($aModuleList) == 0 || !isset($_GET['advanced']) || $admin->get_permission('settings_advanced') != true) {
121
	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
122
}
123

    
124
// insert urls
125
$template->set_var(array(
126
/** @todo the following 3 rtrims can be removed, after using of WB_PATH/s.o is changed in templates **/
127
					'ADMIN_URL' => rtrim($oReg->AcpUrl, '/'),
128
					'WB_URL' => rtrim($oReg->AppUrl, '/'),
129
					'THEME_URL' => rtrim($oReg->ThemeUrl, '/'),
130
					'FTAN' => $admin->getFTAN()
131
					)
132
				);
133
// Insert language text and messages
134
$template->set_var(array(
135
	'URL_TEMPLATES' => $admin->get_permission('templates')
136
	                   ? '<a href="'.$oReg->AcpUrl.'templates/index.php">'.$oTrans->MENU_TEMPLATES.'</a>'
137
	                   : '<b>'.$oTrans->MENU_TEMPLATES.'</b>',
138
	'URL_LANGUAGES' => $admin->get_permission('languages') 
139
	                   ? '<a href="'.$oReg->AcpUrl.'languages/index.php">'.$oTrans->MENU_LANGUAGES.'</a>'
140
	                   : '<b>'.$oTrans->MENU_LANGUAGES.'</b>',
141
	'URL_ADVANCED'  => $admin->get_permission('modules_advanced') 
142
	                   ? '<a href="' . $oReg->AcpUrl.'modules/index.php?advanced">'.$oTrans->TEXT_ADVANCED.'</a>'
143
	                   : '<b>'.$oTrans->TEXT_ADVANCED.'</b>', 'HEADING_CHANGE_TEMPLATE_NOTICE' => ''
144
	)
145
);
146

    
147
// Parse template object
148
$template->parse('main', 'main_block', false);
149
$template->pparse('output', 'page');
150

    
151
// Print admin footer
152
$admin->print_footer();
(2-2/5)