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