Completed
Pull Request — master (#9)
by Michael
01:20
created

admin/main.php (4 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
 * You may not change or alter any portion of this comment or credits of
4
 * supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit
6
 * authors.
7
 *
8
 * This program is distributed in the hope that it will be useful, but
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * -----------------------------------
13
 * Author: Raul Recio (AKA UNFOR)
14
 * Project: The XOOPS Project
15
 * -----------------------------------
16
*/
17
/**
18
 * Module: XoopsPartners - a partner affiliation links module
19
 *
20
 * @package      module\xoopspartners\admin
21
 * @author       Raul Recio (aka UNFOR)
22
 * @author       XOOPS Module Development Team
23
 * @copyright    {@link https://xoops.org 2001-2016 XOOPS Project}
24
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License}
25
 * @link         https://xoops.org XOOPS
26
 * @since        1.11
27
 */
28
use Xmf\Request;
29
use Xmf\Module\Admin;
30
31
require __DIR__ . '/admin_header.php';
32
$moduleAdmin   = Admin::getInstance();
33
$pathImageIcon = $GLOBALS['xoops']->url('www/' . $xpHelper->getModule()->getInfo('icons16'));
34
35
$myts = MyTextSanitizer::getInstance();
36
37
$op            = Request::getString('op', '');
38
$id            = Request::getInt('id', 0);
39
$del           = Request::getInt('del', XoopspartnersConstants::CONFIRM_NOT_OK, 'POST');
40
$hits          = Request::getInt('hits', 0, 'POST');
41
$url           = Request::getString('url', '', 'POST');
42
$image         = Request::getText('image', '', 'POST');
43
$title         = Request::getString('title', '', 'POST');
44
$description   = Request::getText('description', '', 'POST');
45
//$status        = isset($_POST['status']) ? Request::getInt('status', array(), 'POST') : null;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
46
$status        = isset($_POST['status'])
47
                     ? is_array($_POST['status'])
48
                         ? Request::getArray('status', array(), 'POST')
49
                         : Request::getInt('status', XoopspartnersConstants::STATUS_INACTIVE, 'POST')
50
                     : null;
51
$weight        = isset($_POST['weight'])
52
                     ? is_array($_POST['weight'])
53
                         ? Request::getArray('weight', array(), 'POST')
54
                         : Request::getInt('weight', XoopspartnersConstants::DEFAULT_WEIGHT, 'POST')
55
                     : null;
56
57
switch ($op) {
58
59
    case 'partnersAdmin':
60
    default:
61
        $xpPartnersHandler = $xpHelper->getHandler('partners');
62
63
        $moduleAdmin->displayNavigation('main.php');
64
        $moduleAdmin->addItemButton(_AM_XOOPSPARTNERS_ADD, 'main.php' . '?op=partnersAdminAdd', $icon = 'add');
65
        $moduleAdmin->displayButton();
66
67
        echo "  <form action='main.php' method='post' name='reorderform'>\n"
68
           . "    <table style='margin: 1px; padding: 0px;' class='outer width100 bnone'>\n"
69
           . "      <thead>\n"
70
           . "      <tr>\n"
71
           . "        <th class='center width20'>" . _AM_XOOPSPARTNERS_TITLE . "</th>\n"
72
           . "        <th class='center width10'>" . _AM_XOOPSPARTNERS_IMAGE . "</th>\n"
73
           . "        <th>" . _AM_XOOPSPARTNERS_DESCRIPTION . "</th>\n"
74
           . "        <th class='center width5'>" . _AM_XOOPSPARTNERS_ACTIVE . "</th>\n"
75
           . "        <th class='center width5'>" . _AM_XOOPSPARTNERS_WEIGHT . "</th>\n"
76
           . "        <th class='center width5'>" . _AM_XOOPSPARTNERS_HITS . "</th>\n"
77
           . "        <th class='center width10'>" . _AM_XOOPSPARTNERS_ACTIONS . "</th>\n"
78
           . "      </tr>\n"
79
           . "      </thead>\n"
80
           . "      <tbody\n";
81
82
        $criteria = new CriteriaCompo();
83
        $criteria->setSort('status DESC, weight ASC, title');
84
        $criteria->setOrder('DESC');
85
        $partnerObjs = $xpPartnersHandler->getAll($criteria);
86
        $class       = 'even';
87
        $maxWidth    = $GLOBALS['xoopsModuleConfig']['maxwidth'];
88
        $maxHeight   = $GLOBALS['xoopsModuleConfig']['maxheight'];
89
        foreach ($partnerObjs as $partnerObj) {
90
            $url         = formatURL($partnerObj->getVar('url'));
91
            $image       = formatURL($partnerObj->getVar('image'));
92
            $title       = $partnerObj->getVar('title');
93
            $description = $partnerObj->getVar('description');
94
            //@todo - find a way to check size of remote image if allow_url_fopen=0
95
            if ($imageInfo = @getimagesize($image)) {  //note this will "fail" if server allow_url_fopen=0
96
                $imageWidth  = $imageInfo[0];
97
                $imageHeight = $imageInfo[1];
98
                $errorMsg    = ($imageWidth > $maxWidth || $imageHeight > $maxHeight)
99
                               ? '<br>' . _AM_XOOPSPARTNERS_IMAGE_ERROR
100
                               : '';
101
            } else {
102
                $imageWidth  = $maxWidth;
103
                $imageHeight = $maxHeight;
104
                $errorMsg    = '';
105
            }
106
            if (1 == $partnerObj->getVar('status')) {
107
                $check1 = " selected";
108
                $check2 = '';
109
            } else {
110
                $check1 = '';
111
                $check2 = " selected";
112
            }
113
            echo "        <tr>\n"
114
               . "          <td class='{$class} width20 center middle'>"
115
                            . "<a href='{$url}' rel='external'>{$title}</a>"
116
                            . "</td>\n"
117
               . "          <td class='{$class} width3 center'>";
118
            if (!empty($image)) {
119
                echo "<img src='{$image}' alt='{$title}' "
120
                     . "style='width: " . (int)(.65 * $imageWidth) . "px; "
121
                     . "height: " . (int)(.65 * $imageHeight) . "px;'>"
122
                   . $errorMsg;
123
            } else {
124
                echo '&nbsp;';
125
            }
126
127
            echo         "</td>\n"
128
               . "        <td class='{$class} middle'>{$description}</td>\n"
129
               . "        <td class='{$class} width3 center middle'>\n"
130
               . "          <select name='status[" . $partnerObj->getVar('id') . "]'>\n"
131
               . "            <option value='0'{$check2}>" . _NO . "</option>\n"
132
               . "            <option value='1'{$check1}>" . _YES . "</option>\n"
133
               . "          </select>\n"
134
               . "        <td class='{$class} width3 center middle'>\n"
135
               . "          <input type='number' name='weight[" . $partnerObj->getVar('id') . "]' "
136
               .              "class='center' value='" . $partnerObj->getVar('weight') . "' min='0' size='3'>\n"
137
               . "        </td>\n"
138
               . "        <td class='{$class} width3 center middle'>" . $partnerObj->getVar('hits') . "</td>\n"
139
               . "        <td class='{$class} width3 center middle'>\n"
140
               . "          <a href='main.php?op=editPartner&amp;id=" . $partnerObj->getVar('id') . "'>"
141
               .              "<img src='" . Admin::iconUrl('edit.png', '16') . "' "
142
               .                "class='tooltip floatcenter1' "
143
               .                "alt='" . _EDIT . "' "
144
               .                "title='" . _EDIT . "'>"
145
               .            "</a>\n"
146
               . "          <a href='main.php?op=delPartner&amp;id=" . $partnerObj->getVar('id') . "'>"
147
               .              "<img src='" . Admin::IconUrl('delete.png', '16') . "' "
148
               .                "class='tooltip floatcenter1' "
149
               .                "alt='" . _DELETE . "' "
150
               .                "title='" . _DELETE . "'>"
151
               .            "</a>\n"
152
               . "           " . $GLOBALS['xoopsSecurity']->getTokenHTML() . "\n"
153
               . "        </td>\n"
154
               . "      </tr>\n";
155
            $class = ('odd' == $class) ? 'even' : 'odd';
156
        }
157
        if (empty($partnerObjs)) {
158
            echo "      <tr>\n"
159
               . "        <td class='{$class} center bold line140' colspan='7'>" . _AM_XOOPSPARTNERS_NOPARTNERS . "</td>\n"
160
               . "      </tr>\n";
161
            $adminButtons = '';
162
        } else {
163
            $adminButtons = "        <input type='button' "
164
                                     . "name='button' "
165
                                     . "onclick=\"location='main.php?op=reorderAutoPartners'\" "
166
                                     . "value='" . _AM_XOOPSPARTNERS_AUTOMATIC_SORT . "'>\n"
167
                          . "        <input type='submit' name='submit' value='" . _AM_XOOPSPARTNERS_UPDATE . "'>";
168
169
        }
170
        echo "      <tr>\n"
171
           . "        <td class='foot right' colspan='7'>\n"
172
           . "        <input type='hidden' name='op' value='reorderPartners'>\n"
173
           . "{$adminButtons}\n"
174
           . "        </td>\n"
175
           . "      </tr>\n"
176
           . "      </tbody>\n"
177
           . "    </table>\n"
178
           . "  </form>\n";
179
180
        unset($partnerObjs);
181
        include __DIR__ . '/admin_footer.php';
182
        break;
183
184
    case 'reorderPartners':
185 View Code Duplication
        if (!$GLOBALS['xoopsSecurity']->check()) {
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...
186
            $xpHelper->redirect('admin/main.php',
187
                            XoopsPartnersConstants::REDIRECT_DELAY_MEDIUM,
188
                            implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
189
        }
190
        $xpPartnersHandler = $xpHelper->getHandler('partners');
191
        $partnerCount      = $xpPartnersHandler->getCount();
192
        if ($partnerCount) {
193
            foreach ($weight as $id => $order) {
194
                if ((int)$id > XoopspartnersConstants::DEFAULT_PID) {
195
                    $order   = ((!empty($order)) && ((int)$order > XoopspartnersConstants::DEFAULT_WEIGHT))
196
                                ? (int)$order
197
                                : XoopspartnersConstants::DEFAULT_WEIGHT;
198
                    $stat    = (!empty($status[$id]) && ($status[$id] > XoopspartnersConstants::STATUS_INACTIVE))
199
                                ? (int)$status[$id]
200
                                : XoopspartnersConstants::STATUS_INACTIVE;
201
                    $thisObj = $xpPartnersHandler->get($id);
202
                    if (!empty($thisObj) && ($thisObj instanceof XoopspartnersPartners)) {
203
                        $thisObj->setVars(array('weight' => $order, 'status' => $stat));
204
                        $xpPartnersHandler->insert($thisObj);
205
                        unset($thisObj);
206
                    }
207
                }
208
            }
209
            $xpHelper->redirect('admin/main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XOOPSPARTNERS_UPDATED);
210
        } else {
211
            $xpHelper->redirect('admin/main.php?op=partnersAdminAdd',
212
                            XoopspartnersConstants::REDIRECT_DELAY_MEDIUM,
213
                            _AM_XOOPSPARTNERS_EMPTYDATABASE, false
214
            );
215
        }
216
        break;
217
218
    case 'reorderAutoPartners':
219
        $xpPartnersHandler = $xpHelper->getHandler('partners');
220
        $partnerObjs       = $xpPartnersHandler->getAll(null, array('weight'));
221
        $partnerCount     = count($partnerObjs);
222
        $weight           = XoopspartnersConstants::DEFAULT_WEIGHT;
223
        if ($partnerCount > 1) {
224
            foreach ($partnerObjs as $thisObj) {
225
                ++$weight;
226
                $thisObj->setVar('weight', $weight);
227
                $xpPartnersHandler->insert($thisObj);
228
                unset($thisObj);
229
            }
230
            $xpHelper->redirect('admin/main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XOOPSPARTNERS_UPDATED);
231
        } else {
232
            $xpHelper->redirect('admin/main.php?op=partnersAdminAdd',
233
                            XoopspartnersConstants::REDIRECT_DELAY_MEDIUM,
234
                            _AM_XOOPSPARTNERS_EMPTYDATABASE, false
235
            );
236
        }
237
        break;
238
239
    case 'partnersAdminAdd':
240
        $moduleAdmin->displayNavigation('main.php?op=partnersAdminAdd');
241
242
        include $GLOBALS['xoops']->path('/class/xoopsformloader.php');
243
        $form         = new XoopsThemeForm(_AM_XOOPSPARTNERS_ADDPARTNER, 'addform', 'main.php', 'post', true);
244
        $formWeight   = new XoopsFormText(_AM_XOOPSPARTNERS_WEIGHT,
245
                                          'weight',
246
                                          3,
247
                                          10,
248
                                          XoopspartnersConstants::DEFAULT_WEIGHT
249
        );
250
        $formImage    = new XoopsFormText(_AM_XOOPSPARTNERS_IMAGE, 'image', 50, 150, 'http://');
251
        $formUrl      = new XoopsFormText(_AM_XOOPSPARTNERS_URL, 'url', 50, 150, 'http://');
252
        $formTitle    = new XoopsFormText(_AM_XOOPSPARTNERS_TITLE, 'title', 50, 50);
253
        $formDesc     = new XoopsFormTextArea(_AM_XOOPSPARTNERS_DESCRIPTION, 'description', '', 5, 51);
254
        $statOnTxt    = "<img src='" . Admin::iconUrl('on.png', '16') . "' "
255
                      .   "class='tooltip floatcenter1' "
256
                      .   "alt='" . _AM_XOOPSPARTNERS_ACTIVE . "'>"
257
                      .   "&nbsp;" . _AM_XOOPSPARTNERS_ACTIVE;
258
        $statOffTxt   = "<img src='" . Admin::iconUrl('off.png', '16') . "' "
259
                      .   "class='tooltip floatcenter1' "
260
                      .   "alt='" . _AM_XOOPSPARTNERS_INACTIVE . "'>"
261
                      .   "&nbsp;" . _AM_XOOPSPARTNERS_INACTIVE;
262
        $formStat     = new XoopsFormRadioYN(_AM_XOOPSPARTNERS_STATUS,
263
                                             'status',
264
                                             XoopspartnersConstants::STATUS_ACTIVE,
265
                                             $statOnTxt,
266
                                             $statOffTxt
267
        );
268
        $opHidden     = new XoopsFormHidden('op', 'addPartner');
269
        $submitButton = new XoopsFormButton('', 'submit', _AM_XOOPSPARTNERS_ADDPARTNER, 'submit');
270
        $form->addElement($formTitle, true);
271
        $form->addElement($formImage);
272
        $form->addElement($formUrl, true);
273
        $form->addElement($formWeight);
274
        $form->addElement($formDesc, true);
275
        $form->addElement($formStat);
276
        $form->addElement($opHidden);
277
        $form->addElement($submitButton);
278
        $form->display();
279
        include __DIR__ . '/admin_footer.php';
280
        break;
281
282
    case 'addPartner':
283
        $xpPartnersHandler = $xpHelper->getHandler('partners');
284
        $newPartner        = $xpPartnersHandler->create();
285
        $status            = ((!empty($status)) && ((int)$status > 0))
286
                             ? (int)$status
287
                             : XoopspartnersConstants::STATUS_INACTIVE;
288
        $weight            = Request::getInt('weight', XoopspartnersConstants::DEFAULT_WEIGHT, 'POST');
289
        $title             = trim($title);
290
        $url               = trim($url);
291
        $image             = trim($image);
292
        $image            = $myts->addSlashes(formatURL($image));
293
        $description       = trim($description);
294 View Code Duplication
        if (empty($title) || empty($url) || empty($description)) {
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...
295
            $xpHelper->redirect('admin/main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XOOPSPARTNERS_BESURE);
296
        }
297
        $newPartner->setVars(array(
298
                                 'url'         => $myts->addSlashes(formatURL($url)),
299
                                 'image'       => $image,
300
                                 'title'       => $myts->addSlashes($title),
301
                                 'description' => $myts->addSlashes($description),
302
                                 'status'      => $status,
303
                                 'weight'      => $weight
304
                             ));
305
306
        if ($GLOBALS['xoopsSecurity']->check() && $xpPartnersHandler->insert($newPartner)) {
307
            $xpHelper->redirect('admin/main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XOOPSPARTNERS_UPDATED);
308
        } else {
309
            $xpHelper->redirect('admin/main.php',
310
                            XoopspartnersConstants::REDIRECT_DELAY_MEDIUM,
311
                            _AM_XOOPSPARTNERS_NOTUPDATED . '<br>'
312
                            . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
313
            );
314
        }
315
        break;
316
317
    case 'editPartner':
318
        $moduleAdmin->displayNavigation('main.php');
319
        $id = (int)$id > XoopspartnersConstants::DEFAULT_PID ? (int)$id : XoopspartnersConstants::DEFAULT_PID;
320
321
        $xpPartnersHandler = $xpHelper->getHandler('partners');
322
        $partnerObj        = $xpPartnersHandler->get($id);
323
        if (!empty($partnerObj) && ($partnerObj instanceof XoopspartnersPartners)) {
324
            $partnerVars = $partnerObj->getValues();
325
            /*url, image, title, and description are all txtboxes so they have gone through
326
             * htmlspecialchars via XoopsObject getVar
327
             */
328
            include $GLOBALS['xoops']->path('/class/xoopsformloader.php');
329
            $form       = new XoopsThemeForm(_AM_XOOPSPARTNERS_EDITPARTNER, 'editform', 'main.php', 'post', true);
330
            $formWeight = new XoopsFormText(_AM_XOOPSPARTNERS_WEIGHT, 'weight', 3, 10, $partnerVars['weight']);
331
            $formHits   = new XoopsFormText(_AM_XOOPSPARTNERS_HITS, 'hits', 3, 10, $partnerVars['hits']);
332
            $formImage  = new XoopsFormText(_AM_XOOPSPARTNERS_IMAGE, 'image', 50, 150, $partnerVars['image']);
333
            $formUrl    = new XoopsFormText(_AM_XOOPSPARTNERS_URL, 'url', 50, 150, $partnerVars['url']);
334
            $formTitle  = new XoopsFormText(_AM_XOOPSPARTNERS_TITLE, 'title', 50, 50, $partnerVars['title']);
335
            $formDesc   = new XoopsFormTextArea(_AM_XOOPSPARTNERS_DESCRIPTION,
336
                                                'description',
337
                                                $partnerVars['description'],
338
                                                5,
339
                                                51
340
            );
341
            $statOnTxt  = "<img src='" . Admin::iconUrl('on.png', '16') . "' "
342
                        .   "class='tooltip floatcenter1' "
343
                        .   "alt='" . _AM_XOOPSPARTNERS_ACTIVE . "'>"
344
                        .  _AM_XOOPSPARTNERS_ACTIVE;
345
            $statOffTxt = "<img src='" . Admin::iconUrl('off.png', '16') . "' "
346
                        .   "class='tooltip floatcenter1' "
347
                        .   "alt='" . _AM_XOOPSPARTNERS_INACTIVE . "'>"
348
                        .  _AM_XOOPSPARTNERS_INACTIVE;
349
            $formStat   = new XoopsFormRadioYN(_AM_XOOPSPARTNERS_STATUS,
350
                                               'status',
351
                                               $partnerVars['status'],
352
                                               $statOnTxt,
353
                                               $statOffTxt
354
            );
355
356
            $submitButton = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
357
            $form->addElement($formTitle, true);
358
            $form->addElement($formImage);
359
            $form->addElement($formUrl, true);
360
            $form->addElement($formWeight);
361
            $form->addElement($formDesc, true);
362
            $form->addElement($formHits);
363
            $form->addElement($formStat);
364
            $form->addElement(new XoopsFormHidden('id', $id));
365
            $form->addElement(new XoopsFormHidden('op', 'updatePartner'));
366
            $form->addElement($submitButton);
367
            $form->display();
368
            include __DIR__ . '/admin_footer.php';
369
        } else {
370
            $xpHelper->redirect('admin/main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XOOPSPARTNERS_INVALIDID);
371
        }
372
        break;
373
374
    case 'updatePartner':
375
        $title       = trim($title);
376
        $image       = trim($image);
377
        $image       = $myts->addSlashes(formatURL($image));
378
        $url         = trim($url);
379
        $description = trim($description);
380
        $id          = ($id > XoopspartnersConstants::DEFAULT_PID) ? $id : XoopspartnersConstants::DEFAULT_PID;
381
        $status      = (!empty($status) && ($status > XoopspartnersConstants::STATUS_INACTIVE))
382
                        ? (int)$status
383
                        : XoopspartnersConstants::STATUS_INACTIVE;
384
        $weight      = Request::getInt('weight', XoopspartnersConstants::DEFAULT_WEIGHT, 'POST');
385
        $weight      = $weight > XoopspartnersConstants::DEFAULT_WEIGHT
386
                       ? $weight
387
                       : XoopspartnersConstants::DEFAULT_WEIGHT;
388
        $hits        = $hits > 0 ? $hits : 0;
389 View Code Duplication
        if (empty($title) || empty($url) || empty($id) || empty($description)) {
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...
390
            $xpHelper->redirect("admin/main.php?op=edit_partner&amp;id={$id}",
391
                            XoopspartnersConstants::REDIRECT_DELAY_SHORT,
392
                            _AM_XOOPSPARTNERS_BESURE
393
            );
394
                }
395
396
        $xpPartnersHandler = $xpHelper->getHandler('partners');
397
        $partnerObj        = $xpPartnersHandler->get($id);
398
        if ($GLOBALS['xoopsSecurity']->check() && ($partnerObj instanceof XoopspartnersPartners)) {
399
            $partnerObj->setVar('url', $myts->addSlashes(formatURL($url)));
400
            $partnerObj->setVar('title', $myts->addSlashes($title));
401
            $partnerObj->setVar('description', $myts->addSlashes($description));
402
            $partnerObj->setVar('hits', $hits);
403
            $partnerObj->setVar('weight', $weight);
404
            $partnerObj->setVar('status', $status);
405
            $partnerObj->setVar('image', $image);
406
            $success = $xpPartnersHandler->insert($partnerObj);
407
            if ($success) {
408
                $xpHelper->redirect('admin/main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XOOPSPARTNERS_UPDATED);
409
            }
410
        }
411
        $xpHelper->redirect('admin/main.php',
412
                        XoopspartnersConstants::REDIRECT_DELAY_MEDIUM,
413
                        _AM_XOOPSPARTNERS_NOTUPDATED . '<br>' . implode('<br>',
414
                        $GLOBALS['xoopsSecurity']->getErrors())
415
        );
416
        break;
417
418
    case 'delPartner':
419
        if ((XoopspartnersConstants::CONFIRM_OK === $del) && ($id > XoopspartnersConstants::DEFAULT_PID)) {
420
            $xpPartnersHandler = $xpHelper->getHandler('partners');
421
            $partnerObj        = $xpPartnersHandler->get($id);
422
            if ($partnerObj instanceof XoopspartnersPartners) {
423
                if ($xpPartnersHandler->delete($partnerObj)) {
424
                    $xpHelper->redirect('admin/main.php', XoopspartnersConstants::REDIRECT_DELAY_SHORT, _AM_XOOPSPARTNERS_UPDATED);
425
                }
426
            }
427
            $xpHelper->redirect('admin/main.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _AM_XOOPSPARTNERS_NOTUPDATED);
428
        } else {
429
            $moduleAdmin->displayNavigation('main.php');
430
            xoops_confirm(array('op'  => 'delPartner',
431
                                'id'  => (int)$id,
432
                                'del' => XoopspartnersConstants::CONFIRM_OK),
433
                          'main.php',
434
                          _AM_XOOPSPARTNERS_SUREDELETE
435
            );
436
            include __DIR__ . '/admin_footer.php';
437
        }
438
        break;
439
}
440