1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
You may not change or alter any portion of this comment or credits |
5
|
|
|
of supporting developers from this source code or any supporting source code |
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: Equipment |
15
|
|
|
* |
16
|
|
|
* @category Module |
17
|
|
|
* @package equipment |
18
|
|
|
* @author XOOPS Development Team <[email protected]> - <http://xoops.org> |
19
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
20
|
|
|
* @license GPL 2.0 or later |
21
|
|
|
* @link https://xoops.org/ |
22
|
|
|
* @since 1.0.0 |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use Xmf\Module\Admin; |
26
|
|
|
use Xmf\Request; |
27
|
|
|
|
28
|
|
|
require_once __DIR__ . '/admin_header.php'; |
29
|
|
|
xoops_cp_header(); |
30
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
31
|
|
|
if ('' != Request::getString('submit', '')) { |
32
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->dirname() . '/admin/permissions.php', 1, AM_EQUIPMENT_PERMISSIONS__GPERMUPDATED); |
33
|
|
|
} |
34
|
|
|
// Check admin have access to this page |
|
|
|
|
35
|
|
|
/*$group = $GLOBALS['xoopsUser']->getGroups (); |
36
|
|
|
$groups = xoops_getModuleOption ( 'admin_groups', $thisDirname ); |
37
|
|
|
if (count ( array_intersect ( $group, $groups ) ) <= 0) { |
38
|
|
|
redirect_header ( 'index.php', 3, _NOPERM ); |
39
|
|
|
}*/ |
40
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
41
|
|
|
|
42
|
|
|
$permission = Request::getInt('permission', 1, 'POST'); |
43
|
|
|
$selected = array('', '', '', ''); |
44
|
|
|
$selected[$permission - 1] = ' selected'; |
45
|
|
|
|
46
|
|
|
echo " |
47
|
|
|
<form method='post' name='fselperm' action='permissions.php'> |
48
|
|
|
<table border=0> |
49
|
|
|
<tr> |
50
|
|
|
<td> |
51
|
|
|
<select name='permission' onChange='document.fselperm.submit()'> |
52
|
|
|
<option value='1'" . $selected[0] . '>' . AM_EQUIPMENT_PERMISSIONS_GLOBAL . "</option> |
53
|
|
|
<option value='2'" . $selected[1] . '>' . AM_EQUIPMENT_PERMISSIONS_APPROVE . "</option> |
54
|
|
|
<option value='3'" . $selected[2] . '>' . AM_EQUIPMENT_PERMISSIONS_SUBMIT . "</option> |
55
|
|
|
<option value='4'" . $selected[3] . '>' . AM_EQUIPMENT_PERMISSIONS_VIEW . '</option> |
56
|
|
|
</select> |
57
|
|
|
</td> |
58
|
|
|
</tr> |
59
|
|
|
</table> |
60
|
|
|
</form>'; |
61
|
|
|
|
62
|
|
|
$module_id = $GLOBALS['xoopsModule']->getVar('mid'); |
63
|
|
|
switch ($permission) { |
64
|
|
|
case 1: |
65
|
|
|
$formTitle = AM_EQUIPMENT_PERMISSIONS_GLOBAL; |
66
|
|
|
$permName = 'equipment_ac'; |
67
|
|
|
$permDesc = AM_EQUIPMENT_PERMISSIONS_GLOBAL_DESC; |
68
|
|
|
$globalPerms = array( |
69
|
|
|
'4' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_4, |
70
|
|
|
'8' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_8, |
71
|
|
|
'16' => AM_EQUIPMENT_PERMISSIONS_GLOBAL_16 |
72
|
|
|
); |
73
|
|
|
break; |
74
|
|
|
case 2: |
75
|
|
|
$formTitle = AM_EQUIPMENT_PERMISSIONS_APPROVE; |
76
|
|
|
$permName = 'equipment_approve'; |
77
|
|
|
$permDesc = AM_EQUIPMENT_PERMISSIONS_APPROVE_DESC; |
78
|
|
|
break; |
79
|
|
|
case 3: |
80
|
|
|
$formTitle = AM_EQUIPMENT_PERMISSIONS_SUBMIT; |
81
|
|
|
$permName = 'equipment_submit'; |
82
|
|
|
$permDesc = AM_EQUIPMENT_PERMISSIONS_SUBMIT_DESC; |
83
|
|
|
break; |
84
|
|
|
case 4: |
85
|
|
|
$formTitle = AM_EQUIPMENT_PERMISSIONS_VIEW; |
86
|
|
|
$permName = 'equipment_view'; |
87
|
|
|
$permDesc = AM_EQUIPMENT_PERMISSIONS_VIEW_DESC; |
88
|
|
|
break; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
$permform = new XoopsGroupPermForm($formTitle, $module_id, $permName, $permDesc, 'admin/permissions.php'); |
92
|
|
|
if (1 == $permission) { |
93
|
|
|
foreach ($globalPerms as $perm_id => $perm_name) { |
94
|
|
|
$permform->addItem($perm_id, $perm_name); |
95
|
|
|
} |
96
|
|
|
echo $permform->render(); |
97
|
|
|
echo '<br><br>'; |
98
|
|
|
} else { |
99
|
|
|
$criteria = new CriteriaCompo(); |
100
|
|
|
$criteria->setSort('last'); |
101
|
|
|
$criteria->setOrder('ASC'); |
102
|
|
|
$customer_count = $customerHandler->getCount($criteria); |
103
|
|
|
$customerArray = $customerHandler->getObjects($criteria); |
104
|
|
|
unset($criteria); |
105
|
|
|
foreach (array_keys($customerArray) as $i) { |
106
|
|
|
$permform->addItem($customerArray[$i]->getVar('id'), $customerArray[$i]->getVar('last')); |
107
|
|
|
} |
108
|
|
|
// Check if customer exist before rendering the form and redirect, if there aren't customer |
109
|
|
|
if ($customer_count > 0) { |
110
|
|
|
echo $permform->render(); |
111
|
|
|
echo '<br><br>'; |
112
|
|
|
} else { |
113
|
|
|
redirect_header('customer.php?op=new', 3, AM_EQUIPMENT_PERMISSIONS_NOPERMSSET); |
114
|
|
|
//exit (); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
unset($permform); |
118
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
119
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.