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 2091 darkviper
$mLang = Translate::getInstance();
31 1992 Luisehahne
$mLang->enableAddon('admin\addons');
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
40
// 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 1712 Luisehahne
/*-- insert all needed vars from language files ----------------------------------------*/
125
$template->set_var($mLang->getLangArray());
126
127 1112 Ruebenwurz
// insert urls
128
$template->set_var(array(
129 1992 Luisehahne
/** @todo the following 3 rtrims can be removed, after using of WB_PATH/s.o is changed in templates **/
130
					'ADMIN_URL' => rtrim($oReg->AcpUrl, '/'),
131
					'WB_URL' => rtrim($oReg->AppUrl, '/'),
132
					'THEME_URL' => rtrim($oReg->ThemeUrl, '/'),
133 1457 Luisehahne
					'FTAN' => $admin->getFTAN()
134 1381 Luisehahne
					)
135
				);
136 238 stefan
// Insert language text and messages
137
$template->set_var(array(
138 1992 Luisehahne
	'URL_TEMPLATES' => $admin->get_permission('templates')
139
	                   ? '<a href="'.$oReg->AcpUrl.'templates/index.php">'.$mLang->MENU_TEMPLATES.'</a>'
140
	                   : '<b>'.$mLang->MENU_TEMPLATES.'</b>',
141
	'URL_LANGUAGES' => $admin->get_permission('languages')
142
	                   ? '<a href="'.$oReg->AcpUrl.'languages/index.php">'.$mLang->MENU_LANGUAGES.'</a>'
143
	                   : '<b>'.$mLang->MENU_LANGUAGES.'</b>',
144
	'URL_ADVANCED'  => $admin->get_permission('modules_advanced')
145
	                   ? '<a href="' . $oReg->AcpUrl.'modules/index.php?advanced">'.$mLang->TEXT_ADVANCED.'</a>'
146
	                   : '<b>'.$mLang->TEXT_ADVANCED.'</b>', 'HEADING_CHANGE_TEMPLATE_NOTICE' => ''
147 928 doc
	)
148
);
149 238 stefan
150
// Parse template object
151
$template->parse('main', 'main_block', false);
152
$template->pparse('output', 'page');
153
154
// Print admin footer
155
$admin->print_footer();