Project

General

Profile

1 238 stefan
<?php
2 1361 Luisehahne
/**
3
 *
4
 * @category        admin
5
 * @package         modules
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1712 Luisehahne
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8 1361 Luisehahne
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11 1374 Luisehahne
 * @requirements    PHP 5.2.2 and higher
12 1361 Luisehahne
 * @version         $Id$
13 1457 Luisehahne
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15 1361 Luisehahne
 *
16
 */
17 238 stefan
18
// Print admin header
19 1992 Luisehahne
$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 238 stefan
$admin = new admin('Addons', 'modules');
27 1992 Luisehahne
// Make news post access files dir
28
if(!function_exists('get_variable_content')) {require($oReg->AppPath.'framework/functions.php');}
29
$oReg->getWbConstants();
30 2098 darkviper
$oTrans = Translate::getInstance();
31
$oTrans->enableAddon('admin\\modules');
32 238 stefan
33 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
34
// Create new template object
35 1712 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('modules.htt')),'keep');
36 1529 Luisehahne
// $template->debug = true;
37 944 Ruebenwurz
$template->set_file('page', 'modules.htt');
38 238 stefan
$template->set_block('page', 'main_block', 'main');
39 2098 darkviper
$template->set_var($oTrans->getLangArray());
40 238 stefan
// Insert values into module list
41
$template->set_block('main_block', 'module_list_block', 'module_list');
42 1992 Luisehahne
$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 1712 Luisehahne
	{
50 1992 Luisehahne
        $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 238 stefan
		$template->parse('module_list', 'module_list_block', true);
59 1992 Luisehahne
    }
60
61 238 stefan
}
62 1992 Luisehahne
$aModuleList = array();
63 934 doc
// Insert modules which includes a install.php file to install list
64 1992 Luisehahne
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 934 doc
$template->set_block('main_block', 'install_list_block', 'install_list');
77 938 doc
$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 1992 Luisehahne
foreach ($aModuleList as $sModule => $sModuleName)
82 1712 Luisehahne
{
83 1992 Luisehahne
	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 938 doc
92 1992 Luisehahne
	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 1712 Luisehahne
100 1992 Luisehahne
	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 938 doc
108 934 doc
}
109 238 stefan
// 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 938 doc
// only show block if there is something to show
120 1992 Luisehahne
if(!$show_block || count($aModuleList) == 0 || !isset($_GET['advanced']) || $admin->get_permission('settings_advanced') != true) {
121 934 doc
	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
122
}
123 238 stefan
124 1112 Ruebenwurz
// insert urls
125
$template->set_var(array(
126 1992 Luisehahne
/** @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 1457 Luisehahne
					'FTAN' => $admin->getFTAN()
131 1381 Luisehahne
					)
132
				);
133 238 stefan
// Insert language text and messages
134
$template->set_var(array(
135 1992 Luisehahne
	'URL_TEMPLATES' => $admin->get_permission('templates')
136 2098 darkviper
	                   ? '<a href="'.$oReg->AcpUrl.'templates/index.php">'.$oTrans->MENU_TEMPLATES.'</a>'
137
	                   : '<b>'.$oTrans->MENU_TEMPLATES.'</b>',
138 1992 Luisehahne
	'URL_LANGUAGES' => $admin->get_permission('languages')
139 2098 darkviper
	                   ? '<a href="'.$oReg->AcpUrl.'languages/index.php">'.$oTrans->MENU_LANGUAGES.'</a>'
140
	                   : '<b>'.$oTrans->MENU_LANGUAGES.'</b>',
141 1992 Luisehahne
	'URL_ADVANCED'  => $admin->get_permission('modules_advanced')
142 2098 darkviper
	                   ? '<a href="' . $oReg->AcpUrl.'modules/index.php?advanced">'.$oTrans->TEXT_ADVANCED.'</a>'
143
	                   : '<b>'.$oTrans->TEXT_ADVANCED.'</b>', 'HEADING_CHANGE_TEMPLATE_NOTICE' => ''
144 928 doc
	)
145
);
146 238 stefan
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();