Passed
Push — master ( 0dbed9...b8aee2 )
by Goffy
45s queued 10s
created

admin/broken.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * TDMDownload
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
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
 * @copyright   Gregory Mage (Aka Mage)
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Gregory Mage (Aka Mage)
15
 */
16
require __DIR__ . '/admin_header.php';
17
18
// Template
19
$templateMain = 'tdmdownloads_admin_broken.tpl';
20
21
/** @var \XoopsModules\Tdmdownloads\Helper $helper */
22
$helper = \XoopsModules\Tdmdownloads\Helper::getInstance();
23
24
//On recupere la valeur de l'argument op dans l'URL$
25
$op = \Xmf\Request::getString('op', 'list');
26
27
//Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page
28
switch ($op) {
29
    // Vue liste
30
    case 'list':
31
        //Affichage de la partie haute de l'administration de Xoops
32
        xoops_cp_header();
33
        $adminObject = \Xmf\Module\Admin::getInstance();
34
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__)));
35
36
        $criteria = new \CriteriaCompo();
37
        if (\Xmf\Request::hasVar('limit', 'REQUEST')) {
38
            $criteria->setLimit(\Xmf\Request::getInt('limit', 0, 'REQUEST'));
39
            $limit = \Xmf\Request::getInt('limit', 0, 'REQUEST');
40
        } else {
41
            $criteria->setLimit($helper->getConfig('perpageadmin'));
42
            $limit = $helper->getConfig('perpageadmin');
43
        }
44
        if (\Xmf\Request::hasVar('start', 'REQUEST')) {
45
            $criteria->setStart(\Xmf\Request::getInt('start', 0, 'REQUEST'));
46
            $start = \Xmf\Request::getInt('start', 0, 'REQUEST');
47
        } else {
48
            $criteria->setStart(0);
49
            $start = 0;
50
        }
51
        $criteria->setSort('reportid');
52
        $criteria->setOrder('ASC');
53
        //pour faire une jointure de table
54
        $brokenHandler->table_link   = $brokenHandler->db->prefix('tdmdownloads_downloads'); // Nom de la table en jointure
55
        $brokenHandler->field_link   = 'lid'; // champ de la table en jointure
56
        $brokenHandler->field_object = 'lid'; // champ de la table courante
57
        $brokenArray         = $brokenHandler->getByLink($criteria);
58
        $numrows                     = $brokenHandler->getCount($criteria);
59
        $pagenav                     = '';
60
        if ($numrows > $limit) {
61
            $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=list&limit=' . $limit);
62
            $pagenav = $pagenav->renderNav(4);
63
        }
64
        //Affichage du tableau des téléchargements brisés
65
        if ($numrows > 0) {
66
            $GLOBALS['xoopsTpl']->assign('broken_count', $numrows);
67
            $broken = [];
68
            foreach (array_keys($brokenArray) as $i) {
69
                $broken = [
70
                    'lid'      => $brokenArray[$i]->getVar('lid'),
71
                    'reportid' => $brokenArray[$i]->getVar('reportid'),
72
                    'title'    => $brokenArray[$i]->getVar('title'),
73
                    'cid'      => $brokenArray[$i]->getVar('cid'),
74
                    'sender'   => XoopsUser::getUnameFromId($brokenArray[$i]->getVar('sender')),
75
                    'ip'       => $brokenArray[$i]->getVar('ip'),
76
                ];
77
                $GLOBALS['xoopsTpl']->append('broken_list', $broken);
78
                unset($broken);
79
            }
80
        } else {
81
            $GLOBALS['xoopsTpl']->assign('error', _AM_TDMDOWNLOADS_ERREUR_NOBROKENDOWNLOADS);
82
        }
83
        break;
84
    // permet de suprimmer le rapport de téléchargment brisé
85
    case 'del_brokendownloads':
86
        $obj = $brokenHandler->get(\Xmf\Request::getInt('broken_id', 0, 'REQUEST'));
87
        if (\Xmf\Request::hasVar('ok', 'REQUEST') && 1 == \Xmf\Request::getInt('ok', 0, 'REQUEST')) {
88
            if (!$GLOBALS['xoopsSecurity']->check()) {
89
                redirect_header('downloads.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
90
            }
91
            if ($brokenHandler->delete($obj)) {
92
                redirect_header('broken.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK);
93
            }
94
            $GLOBALS['xoopsTpl']->assign('error', $obj->getHtmlErrors());
95
        } else {
96
            //Affichage de la partie haute de l'administration de Xoops
97
            xoops_cp_header();
98
            $adminObject = \Xmf\Module\Admin::getInstance();
99
            $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('broken.php'));
100
            $adminObject->addItemButton(_MI_TDMDOWNLOADS_ADMENU4, 'broken.php?op=list', 'list');
101
            $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
102
            xoops_confirm(['ok' => 1, 'broken_id' => \Xmf\Request::getInt('broken_id', 0, 'REQUEST'), 'op' => 'del_brokendownloads'], $_SERVER['REQUEST_URI'], _AM_TDMDOWNLOADS_BROKEN_SURDEL . '<br>');
103
        }
104
        break;
105
}
106
// Local icons path
107
if (is_object($helper->getModule())) {
108
    $pathModIcon16 = $helper->getModule()->getInfo('modicons16');
109
    $pathModIcon32 = $helper->getModule()->getInfo('modicons32');
110
111
    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
0 ignored issues
show
Are you sure $pathModIcon16 of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

111
    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . /** @scrutinizer ignore-type */ $pathModIcon16);
Loading history...
112
    $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
113
}
114
//Affichage de la partie basse de l'administration de Xoops
115
require_once __DIR__ . '/admin_footer.php';
116