forked from fisharebest/webtrees
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_modules.php
164 lines (155 loc) · 6.31 KB
/
admin_modules.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
// Module Administration User Interface.
//
// webtrees: Web based Family History software
// Copyright (C) 2013 webtrees development team.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
define('WT_SCRIPT_NAME', 'admin_modules.php');
require 'includes/session.php';
require WT_ROOT.'includes/functions/functions_edit.php';
$controller=new WT_Controller_Page();
$controller
->requireAdminLogin()
->setPageTitle(WT_I18N::translate('Module administration'));
$modules = WT_Module::getInstalledModules('disabled');
$module_status = WT_DB::prepare("SELECT module_name, status FROM `##module`")->fetchAssoc();
switch (WT_Filter::post('action')) {
case 'update_mods':
if (WT_Filter::checkCsrf()) {
foreach ($modules as $module_name=>$status) {
$new_status=WT_Filter::post("status-{$module_name}", '[01]');
if ($new_status!==null) {
$new_status=$new_status ? 'enabled' : 'disabled';
if ($new_status!=$status) {
WT_DB::prepare("UPDATE `##module` SET status=? WHERE module_name=?")->execute(array($new_status, $module_name));
$module_status[$module_name]=$new_status;
}
}
}
}
break;
}
switch (WT_Filter::get('action')) {
case 'delete_module':
$module_name=WT_Filter::get('module_name');
WT_DB::prepare(
"DELETE `##block_setting`".
" FROM `##block_setting`".
" JOIN `##block` USING (block_id)".
" JOIN `##module` USING (module_name)".
" WHERE module_name=?"
)->execute(array($module_name));
WT_DB::prepare(
"DELETE `##block`".
" FROM `##block`".
" JOIN `##module` USING (module_name)".
" WHERE module_name=?"
)->execute(array($module_name));
WT_DB::prepare("DELETE FROM `##module_setting` WHERE module_name=?")->execute(array($module_name));
WT_DB::prepare("DELETE FROM `##module_privacy` WHERE module_name=?")->execute(array($module_name));
WT_DB::prepare("DELETE FROM `##module` WHERE module_name=?")->execute(array($module_name));
unset($modules[$module_name]);
break;
}
$controller
->pageHeader()
->addExternalJavascript(WT_JQUERY_DATATABLES_URL)
->addInlineJavascript('
function reindexMods(id) {
jQuery("#"+id+" input").each(
function (index, value) {
value.value = index+1;
});
}
var oTable = jQuery("#installed_table").dataTable( {
"sDom": \'<"H"pf<"dt-clear">irl>t<"F"pl>\',
'.WT_I18N::datatablesI18N().',
"bJQueryUI": true,
"bAutoWidth":false,
"aaSorting": [[ 1, "asc" ]],
"iDisplayLength": 10,
"sPaginationType": "full_numbers",
"bStateSave": true,
"iCookieDuration": 180,
"aoColumns" : [
{ bSortable: false, sClass: "center" },
null,
null,
{ sClass: "center" },
{ sClass: "center" },
{ sClass: "center" },
{ sClass: "center" },
{ sClass: "center", bVisible: false }, // The WT_Module system does not yet include charts
{ sClass: "center" },
{ sClass: "center", bVisible: false } // The WT_Module system does not yet include themes
]
});
');
?>
<div align="center">
<div id="tabs">
<form method="post" action="<?php echo WT_SCRIPT_NAME; ?>">
<input type="hidden" name="action" value="update_mods">
<?php echo WT_Filter::getCsrf(); ?>
<table id="installed_table" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
<th><?php echo WT_I18N::translate('Enabled'); ?></th>
<th width="100px"><?php echo WT_I18N::translate('Module'); ?></th>
<th><?php echo WT_I18N::translate('Description'); ?></th>
<th><?php echo WT_I18N::translate('Menu'); ?></th>
<th><?php echo WT_I18N::translate('Tab'); ?></th>
<th><?php echo WT_I18N::translate('Sidebar'); ?></th>
<th><?php echo WT_I18N::translate('Block'); ?></th>
<th><?php echo WT_I18N::translate('Chart'); ?></th>
<th><?php echo WT_I18N::translate('Report'); ?></th>
<th><?php echo WT_I18N::translate('Theme'); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($module_status as $module_name=>$status) {
if (array_key_exists($module_name, $modules)) {
$module=$modules[$module_name];
echo
'<tr><td>', two_state_checkbox('status-'.$module_name, $status=='enabled'), '</td>',
'<td>', $module->getTitle(), '</td>',
'<td>', $module->getDescription(), '</td>',
'<td>', $module instanceof WT_Module_Menu ? WT_I18N::translate('Menu') : '-', '</td>',
'<td>', $module instanceof WT_Module_Tab ? WT_I18N::translate('Tab') : '-', '</td>',
'<td>', $module instanceof WT_Module_Sidebar ? WT_I18N::translate('Sidebar') : '-', '</td>',
'<td>', $module instanceof WT_Module_Block ? (($module->isUserBlock() ? '<div>'.WT_I18N::translate('My page').'</div>' : '').($module->isGedcomBlock() ? '<div>'.WT_I18N::translate('Home page').'</div>' : '')) : '-', '</td>',
'<td>', $module instanceof WT_Module_Chart ? WT_I18N::translate('Chart') : '-', '</td>',
'<td>', $module instanceof WT_Module_Report ? WT_I18N::translate('Report') : '-', '</td>',
'<td>', $module instanceof WT_Module_Theme ? WT_I18N::translate('Theme') : '-', '</td>',
'</tr>';
} else {
// Module can’t be found on disk?
// Don't delete it automatically. It may be temporarily missing, after a re-installation, etc.
echo
'<tr class="error"><td> </td><td>', $module_name, '</td><td>',
'<a href="'.WT_SCRIPT_NAME.'?action=delete_module&module_name='.$module_name.'">',
WT_I18N::translate('This module cannot be found. Delete its configuration settings.'),
'</a></td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>';
}
}
?>
</tbody>
</table>
<input type="submit" value="<?php echo WT_I18N::translate('save'); ?>">
</form>
</div>
</div>