Issues (149)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

admin/equipment.php (21 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
 * Module: Equipment
14
 *
15
 * @category        Module
16
 * @package         equipment
17
 * @author          swt02026 (https://github.com/swt02026/)
18
 * @author          XOOPS Development Team <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\Database\Tables;
27
use Xmf\Debug;
28
use Xmf\Module\Helper;
29
use Xmf\Module\Helper\Permission;
30
use Xmf\Request;
31
32
require_once __DIR__ . '/admin_header.php';
33
xoops_cp_header();
34
//It recovered the value of argument op in URL$
35
$op    = Request::getString('op', 'list');
36
$order = Request::getString('order', 'desc');
37
$sort  = Request::getString('sort', '');
38
39
$adminObject->displayNavigation(basename(__FILE__));
40
/** @var Permission $permHelper */
41
$permHelper = new Permission($moduleDirName);
42
$uploadDir  = XOOPS_UPLOAD_PATH . '/equipment/images/';
43
$uploadUrl  = XOOPS_UPLOAD_URL . '/equipment/images/';
44
45
switch ($op) {
46
    case 'list':
47
    default:
48
        $adminObject->addItemButton(AM_EQUIPMENT_ADD_EQUIPMENT, 'equipment.php?op=new', 'add');
49
        echo $adminObject->displayButton('left');
50
        $start                    = Request::getInt('start', 0);
51
        $equipmentPaginationLimit = $GLOBALS['xoopsModuleConfig']['userpager'];
52
53
        $criteria = new CriteriaCompo();
54
        $criteria->setSort('id ASC, name');
55
        $criteria->setOrder('ASC');
56
        $criteria->setLimit($equipmentPaginationLimit);
57
        $criteria->setStart($start);
58
        $equipmentTempRows  = $equipmentHandler->getCount();
59
        $equipmentTempArray = $equipmentHandler->getAll($criteria);/*
60
//
61
// 
62
                    <th class='center width5'>".AM_EQUIPMENT_FORM_ACTION."</th>
63
//                    </tr>";
64
//            $class = "odd";
65
*/
66
67
        // Display Page Navigation
68 View Code Duplication
        if ($equipmentTempRows > $equipmentPaginationLimit) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
            require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
70
71
            $pagenav = new XoopsPageNav($equipmentTempRows, $equipmentPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . '');
72
            $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : '');
73
        }
74
75
        $GLOBALS['xoopsTpl']->assign('equipmentRows', $equipmentTempRows);
76
        $equipmentArray = array();
77
78
        //    $fields = explode('|', id:smallint:5:unsigned:NOT NULL::primary:ID|owner:varchar:10::NOT NULL::index:Owner|name:varchar:30::NOT NULL::index:Name|amount:int:10:unsigned:NOT NULL:::Amount|total:int:10:unsigned:NOT NULL:::Total|image:varchar:100::NOT NULL:::Image);
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
79
        //    $fieldsCount    = count($fields);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
80
81
        $criteria = new CriteriaCompo();
82
83
        //$criteria->setOrder('DESC');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
84
        $criteria->setSort($sort);
85
        $criteria->setOrder($order);
86
        $criteria->setLimit($equipmentPaginationLimit);
87
        $criteria->setStart($start);
88
89
        $equipmentCount     = $equipmentHandler->getCount($criteria);
90
        $equipmentTempArray = $equipmentHandler->getAll($criteria);
91
92
        //    for ($i = 0; $i < $fieldsCount; ++$i) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
93
        if ($equipmentCount > 0) {
94
            foreach (array_keys($equipmentTempArray) as $i) {
95
96
97
                //        $field = explode(':', $fields[$i]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
98
99
                $selectorid = EquipmentUtility::selectSorting(AM_EQUIPMENT_EQUIPMENT_ID, 'id');
100
                $GLOBALS['xoopsTpl']->assign('selectorid', $selectorid);
101
                $equipmentArray['id'] = $equipmentTempArray[$i]->getVar('id');
102
103
                $selectorowner = EquipmentUtility::selectSorting(AM_EQUIPMENT_EQUIPMENT_OWNER, 'owner');
104
                $GLOBALS['xoopsTpl']->assign('selectorowner', $selectorowner);
105
                $equipmentArray['owner'] = $equipmentTempArray[$i]->getVar('owner');
106
107
                $selectorname = EquipmentUtility::selectSorting(AM_EQUIPMENT_EQUIPMENT_NAME, 'name');
108
                $GLOBALS['xoopsTpl']->assign('selectorname', $selectorname);
109
                $equipmentArray['name'] = $equipmentTempArray[$i]->getVar('name');
110
111
                $selectoramount = EquipmentUtility::selectSorting(AM_EQUIPMENT_EQUIPMENT_AMOUNT, 'amount');
112
                $GLOBALS['xoopsTpl']->assign('selectoramount', $selectoramount);
113
                $equipmentArray['amount'] = $equipmentTempArray[$i]->getVar('amount');
114
115
                $selectortotal = EquipmentUtility::selectSorting(AM_EQUIPMENT_EQUIPMENT_TOTAL, 'total');
116
                $GLOBALS['xoopsTpl']->assign('selectortotal', $selectortotal);
117
                $equipmentArray['total'] = $equipmentTempArray[$i]->getVar('total');
118
119
                $selectorimage = EquipmentUtility::selectSorting(AM_EQUIPMENT_EQUIPMENT_IMAGE, 'image');
120
                $GLOBALS['xoopsTpl']->assign('selectorimage', $selectorimage);
121
                $equipmentArray['image']       = "<img src='" . $uploadUrl . $equipmentTempArray[$i]->getVar('image') . "' name='" . 'name' . "' id=" . 'id' . " alt='' style='max-width:100px'>";
122
                $equipmentArray['edit_delete'] = "<a href='equipment.php?op=edit&id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a>
123
               <a href='equipment.php?op=delete&id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a>
124
               <a href='equipment.php?op=clone&id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>";
125
126
                $GLOBALS['xoopsTpl']->append_by_ref('equipmentArrays', $equipmentArray);
127
                unset($equipmentArray);
128
            }
129
            unset($equipmentTempArray);
130
            // Display Navigation
131 View Code Duplication
            if ($equipmentCount > $equipmentPaginationLimit) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
132
                require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
133
                $pagenav = new XoopsPageNav($equipmentCount, $equipmentPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . '');
134
                $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
135
            }
136
137
            //                     echo "<td class='center width5'>
138
139
            //                    <a href='equipment.php?op=edit&id=".$i."'><img src=".$pathIcon16."/edit.png alt='"._EDIT."' title='"._EDIT."'></a>
140
            //                    <a href='equipment.php?op=delete&id=".$i."'><img src=".$pathIcon16."/delete.png alt='"._DELETE."' title='"._DELETE."'></a>
141
            //                    </td>";
142
143
            //                echo "</tr>";
144
145
            //            }
146
147
            //            echo "</table><br><br>";
148
149
            //        } else {
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
150
151
            //            echo "<table width='100%' cellspacing='1' class='outer'>
152
153
            //                    <tr>
154
155
            //                     <th class='center width5'>".AM_EQUIPMENT_FORM_ACTION."XXX</th>
156
            //                    </tr><tr><td class='errorMsg' colspan='7'>There are noXXX equipment</td></tr>";
157
            //            echo "</table><br><br>";
158
159
            //-------------------------------------------
160
161
            echo $GLOBALS['xoopsTpl']->fetch(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/equipment_admin_equipment.tpl');
162
        }
163
164
        break;
165
166 View Code Duplication
    case 'new':
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
167
        $adminObject->addItemButton(AM_EQUIPMENT_EQUIPMENT_LIST, 'equipment.php', 'list');
168
        echo $adminObject->displayButton('left');
169
170
        $equipmentObject = $equipmentHandler->create();
171
        $form            = $equipmentObject->getForm();
172
        $form->display();
173
        break;
174
175
    case 'save':
176
        if (!$GLOBALS['xoopsSecurity']->check()) {
177
            redirect_header('equipment.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
178
        }
179
        if (0 != Request::getInt('id', 0)) {
180
            $equipmentObject = $equipmentHandler->get(Request::getInt('id', 0));
181
        } else {
182
            $equipmentObject = $equipmentHandler->create();
183
        }
184
        // Form save fields
185
        $equipmentObject->setVar('owner', Request::getVar('owner', ''));
186
        $equipmentObject->setVar('name', Request::getVar('name', ''));
187
        $equipmentObject->setVar('amount', Request::getVar('amount', ''));
188
        $equipmentObject->setVar('total', Request::getVar('total', ''));
189
190
        require_once XOOPS_ROOT_PATH . '/class/uploader.php';
191
        $uploadDir = XOOPS_UPLOAD_PATH . '/equipment/images/';
192
        $uploader  = new XoopsMediaUploader($uploadDir, xoops_getModuleOption('mimetypes', 'equipment'), xoops_getModuleOption('maxsize', 'equipment'), null, null);
193
        if ($uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0])) {
194
195
            //$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '' , $_FILES['attachedfile']['name']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
196
            //$imgName = str_replace(' ', '', $_POST['']).'.'.$extension;
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
197
198
            $uploader->setPrefix('image_');
199
            $uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0]);
200
            if (!$uploader->upload()) {
201
                $errors = $uploader->getErrors();
202
                redirect_header('javascript:history.go(-1)', 3, $errors);
203
            } else {
204
                $equipmentObject->setVar('image', $uploader->getSavedFileName());
205
            }
206
        } else {
207
            $equipmentObject->setVar('image', Request::getVar('image', ''));
208
        }
209
210
        //Permissions
211
        //===============================================================
212
213
        $mid = $GLOBALS['xoopsModule']->mid();
214
        /** @var XoopsGroupPermHandler $gpermHandler */
215
        $gpermHandler = xoops_getHandler('groupperm');
216
        $id           = Request::getInt('id', 0);
217
218
        /**
219
         * @param $myArray
220
         * @param $permissionGroup
221
         * @param $id
222
         * @param $gpermHandler
223
         * @param $permissionName
224
         * @param $mid
225
         */
226 View Code Duplication
        function setPermissions($myArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid)
0 ignored issues
show
The function setPermissions() has been defined more than once; this definition is ignored, only the first definition in admin/customer.php (L211-248) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
The parameter $permissionGroup is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
227
        {
228
            $permissionArray = $myArray;
229
            if ($id > 0) {
230
                $sql = 'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name` = '" . $permissionName . "' AND `gperm_itemid`= $id;";
231
                $GLOBALS['xoopsDB']->query($sql);
232
            }
233
            //admin
234
            $gperm = $gpermHandler->create();
235
            $gperm->setVar('gperm_groupid', XOOPS_GROUP_ADMIN);
236
            $gperm->setVar('gperm_name', $permissionName);
237
            $gperm->setVar('gperm_modid', $mid);
238
            $gperm->setVar('gperm_itemid', $id);
239
            $gpermHandler->insert($gperm);
240
            unset($gperm);
241
            //non-Admin groups
242
            if (is_array($permissionArray)) {
243
                foreach ($permissionArray as $key => $cat_groupperm) {
244
                    if ($cat_groupperm > 0) {
245
                        $gperm = $gpermHandler->create();
246
                        $gperm->setVar('gperm_groupid', $cat_groupperm);
247
                        $gperm->setVar('gperm_name', $permissionName);
248
                        $gperm->setVar('gperm_modid', $mid);
249
                        $gperm->setVar('gperm_itemid', $id);
250
                        $gpermHandler->insert($gperm);
251
                        unset($gperm);
252
                    }
253
                }
254
            } elseif ($permissionArray > 0) {
255
                $gperm = $gpermHandler->create();
256
                $gperm->setVar('gperm_groupid', $permissionArray);
257
                $gperm->setVar('gperm_name', $permissionName);
258
                $gperm->setVar('gperm_modid', $mid);
259
                $gperm->setVar('gperm_itemid', $id);
260
                $gpermHandler->insert($gperm);
261
                unset($gperm);
262
            }
263
        }
264
265
        //setPermissions for View items
266
        $permissionGroup   = 'groupsRead';
267
        $permissionName    = 'equipment_view';
268
        $permissionArray   = Request::getArray($permissionGroup, '');
269
        $permissionArray[] = XOOPS_GROUP_ADMIN;
270
        //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid);
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
271
        $permHelper->savePermissionForItem($permissionName, $id, $permissionArray);
272
273
        //setPermissions for Submit items
274
        $permissionGroup   = 'groupsSubmit';
275
        $permissionName    = 'equipment_submit';
276
        $permissionArray   = Request::getArray($permissionGroup, '');
277
        $permissionArray[] = XOOPS_GROUP_ADMIN;
278
        //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid);
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
279
        $permHelper->savePermissionForItem($permissionName, $id, $permissionArray);
280
281
        //setPermissions for Approve items
282
        $permissionGroup   = 'groupsModeration';
283
        $permissionName    = 'equipment_approve';
284
        $permissionArray   = Request::getArray($permissionGroup, '');
285
        $permissionArray[] = XOOPS_GROUP_ADMIN;
286
        //setPermissions($permissionArray, $permissionGroup, $id, $gpermHandler, $permissionName, $mid);
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
287
        $permHelper->savePermissionForItem($permissionName, $id, $permissionArray);
288
289
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
290
                    //Form equipment_view
291
                    $arr_equipment_view = Request::getArray('cat_gperms_read');
292
                    if ($id > 0) {
293
                        $sql
294
                            =
295
                            'DELETE FROM `' . $GLOBALS['xoopsDB']->prefix('group_permission') . "` WHERE `gperm_name`='equipment_view' AND `gperm_itemid`=$id;";
296
                        $GLOBALS['xoopsDB']->query($sql);
297
                    }
298
                    //admin
299
                    $gperm = $gpermHandler->create();
300
                    $gperm->setVar('gperm_groupid', XOOPS_GROUP_ADMIN);
301
                    $gperm->setVar('gperm_name', 'equipment_view');
302
                    $gperm->setVar('gperm_modid', $mid);
303
                    $gperm->setVar('gperm_itemid', $id);
304
                    $gpermHandler->insert($gperm);
305
                    unset($gperm);
306
                    if (is_array($arr_equipment_view)) {
307
                        foreach ($arr_equipment_view as $key => $cat_groupperm) {
308
                            $gperm = $gpermHandler->create();
309
                            $gperm->setVar('gperm_groupid', $cat_groupperm);
310
                            $gperm->setVar('gperm_name', 'equipment_view');
311
                            $gperm->setVar('gperm_modid', $mid);
312
                            $gperm->setVar('gperm_itemid', $id);
313
                            $gpermHandler->insert($gperm);
314
                            unset($gperm);
315
                        }
316
                    } else {
317
                        $gperm = $gpermHandler->create();
318
                        $gperm->setVar('gperm_groupid', $arr_equipment_view);
319
                        $gperm->setVar('gperm_name', 'equipment_view');
320
                        $gperm->setVar('gperm_modid', $mid);
321
                        $gperm->setVar('gperm_itemid', $id);
322
                        $gpermHandler->insert($gperm);
323
                        unset($gperm);
324
                    }
325
        */
326
327
        //===============================================================
328
329
        if ($equipmentHandler->insert($equipmentObject)) {
330
            redirect_header('equipment.php?op=list', 2, AM_EQUIPMENT_FORMOK);
331
        }
332
333
        echo $equipmentObject->getHtmlErrors();
334
        $form = $equipmentObject->getForm();
335
        $form->display();
336
        break;
337
338 View Code Duplication
    case 'edit':
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
339
        $adminObject->addItemButton(AM_EQUIPMENT_ADD_EQUIPMENT, 'equipment.php?op=new', 'add');
340
        $adminObject->addItemButton(AM_EQUIPMENT_EQUIPMENT_LIST, 'equipment.php', 'list');
341
        echo $adminObject->displayButton('left');
342
        $equipmentObject = $equipmentHandler->get(Request::getString('id', ''));
343
        $form            = $equipmentObject->getForm();
344
        $form->display();
345
        break;
346
347 View Code Duplication
    case 'delete':
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
348
        $equipmentObject = $equipmentHandler->get(Request::getString('id', ''));
349
        if (1 == Request::getInt('ok', 0)) {
350
            if (!$GLOBALS['xoopsSecurity']->check()) {
351
                redirect_header('equipment.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
352
            }
353
            if ($equipmentHandler->delete($equipmentObject)) {
354
                redirect_header('equipment.php', 3, AM_EQUIPMENT_FORMDELOK);
355
            } else {
356
                echo $equipmentObject->getHtmlErrors();
357
            }
358
        } else {
359
            xoops_confirm(array(
360
                              'ok' => 1,
361
                              'id' => Request::getString('id', ''),
362
                              'op' => 'delete'
363
                          ), Request::getCmd('REQUEST_URI', '', 'SERVER'), sprintf(AM_EQUIPMENT_FORMSUREDEL, $equipmentObject->getVar('name')));
364
        }
365
        break;
366
367 View Code Duplication
    case 'clone':
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
368
369
        $id_field = Request::getString('id', '');
370
371
        if (EquipmentUtility::cloneRecord('equipment_equipment', 'id', $id_field)) {
372
            redirect_header('equipment.php', 3, AM_EQUIPMENT_CLONED_OK);
373
        } else {
374
            redirect_header('equipment.php', 3, AM_EQUIPMENT_CLONED_FAILED);
375
        }
376
377
        break;
378
}
379
require_once __DIR__ . '/admin_footer.php';
380