This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | use Xmf\Module\Admin; |
||||
6 | use XoopsModules\Tag\{ |
||||
7 | Helper as TagHelper, |
||||
8 | LinkHandler, |
||||
9 | Tag, |
||||
10 | TagHandler |
||||
11 | }; |
||||
12 | use XoopsModules\Tdmdownloads\{ |
||||
13 | Helper, |
||||
14 | Tree |
||||
15 | }; |
||||
16 | |||||
17 | /** |
||||
18 | * TDMDownload |
||||
19 | * |
||||
20 | * You may not change or alter any portion of this comment or credits |
||||
21 | * of supporting developers from this source code or any supporting source code |
||||
22 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||
23 | * This program is distributed in the hope that it will be useful, |
||||
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
26 | * |
||||
27 | * @copyright Gregory Mage (Aka Mage) |
||||
28 | * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||
29 | * @author Gregory Mage (Aka Mage) |
||||
30 | */ |
||||
31 | require __DIR__ . '/admin_header.php'; |
||||
32 | // Template |
||||
33 | $templateMain = 'tdmdownloads_admin_downloads.tpl'; |
||||
34 | $helper = Helper::getInstance(); |
||||
35 | $myts = \MyTextSanitizer::getInstance(); |
||||
36 | //On recupere la valeur de l'argument op dans l'URL$ |
||||
37 | $op = \Xmf\Request::getCmd('op', 'list'); |
||||
38 | $catId = \Xmf\Request::getInt('cat_cid', 0); |
||||
39 | // compte le nombre de téléchargement non validé |
||||
40 | $criteria = new \CriteriaCompo(); |
||||
41 | $criteria->add(new \Criteria('status', 0)); |
||||
42 | $downloads_waiting = $downloadsHandler->getCount($criteria); |
||||
43 | $statusMenu = \Xmf\Request::getInt('statut_display', 1); |
||||
44 | //Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page |
||||
45 | switch ($op) { |
||||
46 | // Vue liste |
||||
47 | case 'list': |
||||
48 | //Affichage de la partie haute de l'administration de Xoops |
||||
49 | xoops_cp_header(); |
||||
50 | $adminObject = Admin::getInstance(); |
||||
51 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
52 | if (1 == $statusMenu) { |
||||
53 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); |
||||
54 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW_MULTIUPLOAD, '../upload.php?op=list&cat_cid=' . $catId, 'add'); |
||||
55 | if (0 == $downloads_waiting) { |
||||
56 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add'); |
||||
57 | } else { |
||||
58 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add', 'style="color : Red"'); |
||||
59 | } |
||||
60 | } else { |
||||
61 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); |
||||
62 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); |
||||
63 | } |
||||
64 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
65 | $limit = $helper->getConfig('perpageadmin'); |
||||
66 | $categoryArray = $categoryHandler->getAll(); |
||||
67 | $numrowscat = count($categoryArray); |
||||
68 | // redirection si il n'y a pas de catégories |
||||
69 | if (0 === $numrowscat) { |
||||
70 | redirect_header('category.php?op=new_cat', 2, _AM_TDMDOWNLOADS_REDIRECT_NOCAT); |
||||
71 | } |
||||
72 | $criteria = new \CriteriaCompo(); |
||||
73 | // affiche uniquement les téléchargements activés |
||||
74 | if (\Xmf\Request::hasVar('statut_display', 'GET')) { |
||||
75 | if (0 === \Xmf\Request::getInt('statut_display', 0, 'GET')) { |
||||
76 | $criteria->add(new \Criteria('status', 0)); |
||||
77 | $statusDisplay = 0; |
||||
78 | } else { |
||||
79 | $criteria->add(new \Criteria('status', 0, '!=')); |
||||
80 | $statusDisplay = 1; |
||||
81 | } |
||||
82 | } else { |
||||
83 | $criteria->add(new \Criteria('status', 0, '!=')); |
||||
84 | $statusDisplay = 1; |
||||
85 | } |
||||
86 | $documentSort = 1; |
||||
87 | $documentOrder = 1; |
||||
88 | if (\Xmf\Request::hasVar('document_tri')) { |
||||
89 | if (1 == \Xmf\Request::getInt('document_tri')) { |
||||
90 | $criteria->setSort('date'); |
||||
91 | $documentSort = 1; |
||||
92 | } |
||||
93 | if (2 == \Xmf\Request::getInt('document_tri')) { |
||||
94 | $criteria->setSort('title'); |
||||
95 | $documentSort = 2; |
||||
96 | } |
||||
97 | if (3 == \Xmf\Request::getInt('document_tri')) { |
||||
98 | $criteria->setSort('hits'); |
||||
99 | $documentSort = 3; |
||||
100 | } |
||||
101 | if (4 == \Xmf\Request::getInt('document_tri')) { |
||||
102 | $criteria->setSort('rating'); |
||||
103 | $documentSort = 4; |
||||
104 | } |
||||
105 | if (5 == \Xmf\Request::getInt('document_tri')) { |
||||
106 | $criteria->setSort('cid'); |
||||
107 | $documentSort = 5; |
||||
108 | } |
||||
109 | } else { |
||||
110 | $criteria->setSort('date'); |
||||
111 | } |
||||
112 | if (\Xmf\Request::hasVar('document_order')) { |
||||
113 | if (1 == \Xmf\Request::getInt('document_order')) { |
||||
114 | $criteria->setOrder('DESC'); |
||||
115 | $documentOrder = 1; |
||||
116 | } |
||||
117 | if (2 == \Xmf\Request::getInt('document_order')) { |
||||
118 | $criteria->setOrder('ASC'); |
||||
119 | $documentOrder = 2; |
||||
120 | } |
||||
121 | } else { |
||||
122 | $criteria->setOrder('DESC'); |
||||
123 | } |
||||
124 | $start = \Xmf\Request::getInt('start', 0); |
||||
125 | $criteria->setStart($start); |
||||
126 | $criteria->setLimit($limit); |
||||
127 | //pour faire une jointure de table |
||||
128 | $downloadsHandler->table_link = $downloadsHandler->db->prefix('tdmdownloads_cat'); // Nom de la table en jointure |
||||
129 | $downloadsHandler->field_link = 'cat_cid'; // champ de la table en jointure |
||||
130 | $downloadsHandler->field_object = 'cid'; // champ de la table courante |
||||
131 | $downloadsArray = $downloadsHandler->getByLink($criteria); |
||||
132 | $numrows = $downloadsHandler->getCount($criteria); |
||||
133 | $pagenav = ''; |
||||
134 | if ($numrows > $limit) { |
||||
135 | $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=list&document_tri=' . $documentSort . '&document_order=' . $documentOrder . '&statut_display=' . $statusDisplay); |
||||
136 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||||
137 | } |
||||
138 | //Affichage du tableau des téléchargements |
||||
139 | $GLOBALS['xoopsTpl']->append('downloads_count', $numrows); |
||||
140 | if ($numrows > 0) { |
||||
141 | $selectDocument = _AM_TDMDOWNLOADS_TRIPAR |
||||
142 | . "<select name=\"document_tri\" id=\"document_tri\" onchange=\"location='" |
||||
143 | . XOOPS_URL |
||||
144 | . '/modules/' |
||||
145 | . $xoopsModule->dirname() |
||||
146 | . "/admin/downloads.php?statut_display=$statusDisplay&document_order=$documentOrder&document_tri='+this.options[this.selectedIndex].value\">"; |
||||
147 | $selectDocument .= '<option value="1"' . (1 == $documentSort ? ' selected="selected"' : '') . '>' . _AM_TDMDOWNLOADS_FORMDATE . '</option>'; |
||||
148 | $selectDocument .= '<option value="2"' . (2 == $documentSort ? ' selected="selected"' : '') . '>' . _AM_TDMDOWNLOADS_FORMTITLE . '</option>'; |
||||
149 | $selectDocument .= '<option value="3"' . (3 == $documentSort ? ' selected="selected"' : '') . '>' . _AM_TDMDOWNLOADS_FORMHITS . '</option>'; |
||||
150 | $selectDocument .= '<option value="4"' . (4 == $documentSort ? ' selected="selected"' : '') . '>' . _AM_TDMDOWNLOADS_FORMRATING . '</option>'; |
||||
151 | $selectDocument .= '<option value="5"' . (5 == $documentSort ? ' selected="selected"' : '') . '>' . _AM_TDMDOWNLOADS_FORMCAT . '</option>'; |
||||
152 | $selectDocument .= '</select> '; |
||||
153 | $GLOBALS['xoopsTpl']->assign('selectDocument', $selectDocument); |
||||
154 | $selectOrder = _AM_TDMDOWNLOADS_ORDER |
||||
155 | . "<select name=\"order_tri\" id=\"order_tri\" onchange=\"location='" |
||||
156 | . XOOPS_URL |
||||
157 | . '/modules/' |
||||
158 | . $xoopsModule->dirname() |
||||
159 | . "/admin/downloads.php?statut_display=$statusDisplay&document_tri=$documentSort&document_order='+this.options[this.selectedIndex].value\">"; |
||||
160 | $selectOrder .= '<option value="1"' . (1 == $documentOrder ? ' selected="selected"' : '') . '>DESC</option>'; |
||||
161 | $selectOrder .= '<option value="2"' . (2 == $documentOrder ? ' selected="selected"' : '') . '>ASC</option>'; |
||||
162 | $selectOrder .= '</select> '; |
||||
163 | $GLOBALS['xoopsTpl']->assign('selectOrder', $selectOrder); |
||||
164 | $mytree = new Tree($categoryArray, 'cat_cid', 'cat_pid'); |
||||
165 | $class = 'odd'; |
||||
166 | $downloads = []; |
||||
167 | foreach (array_keys($downloadsArray) as $i) { |
||||
168 | /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ |
||||
169 | $download = [ |
||||
170 | 'category' => $utility::getPathTree($mytree, $downloadsArray[$i]->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' <img src="../assets/images/deco/arrow.gif"> '), |
||||
171 | 'cid' => $downloadsArray[$i]->getVar('cid'), |
||||
172 | 'lid' => $i, |
||||
173 | 'title' => $downloadsArray[$i]->getVar('title'), |
||||
174 | 'hits' => $downloadsArray[$i]->getVar('hits'), |
||||
175 | 'rating' => number_format((float)$downloadsArray[$i]->getVar('rating'), 1), |
||||
176 | 'statut_display' => $statusDisplay, |
||||
177 | ]; |
||||
178 | $GLOBALS['xoopsTpl']->append('downloads_list', $download); |
||||
179 | unset($download); |
||||
180 | } |
||||
181 | } else { |
||||
182 | $GLOBALS['xoopsTpl']->assign('message_erreur', _AM_TDMDOWNLOADS_ERREUR_NODOWNLOADSWAITING); |
||||
183 | } |
||||
184 | break; |
||||
185 | // vue création |
||||
186 | case 'new_downloads': |
||||
187 | //Affichage de la partie haute de l'administration de Xoops |
||||
188 | xoops_cp_header(); |
||||
189 | $adminObject = Admin::getInstance(); |
||||
190 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
191 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); |
||||
192 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); |
||||
193 | if (0 == $downloads_waiting) { |
||||
194 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add'); |
||||
195 | } else { |
||||
196 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add', 'style="color : Red"'); |
||||
197 | } |
||||
198 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
199 | //Affichage du formulaire de création des téléchargements |
||||
200 | /** @var \XoopsModules\Tdmdownloads\Downloads $obj */ |
||||
201 | $obj = $downloadsHandler->create(); |
||||
202 | $form = $obj->getForm($donnee = [], false); |
||||
203 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
204 | break; |
||||
205 | // Pour éditer un téléchargement |
||||
206 | case 'edit_downloads': |
||||
207 | //Affichage de la partie haute de l'administration de Xoops |
||||
208 | xoops_cp_header(); |
||||
209 | $adminObject = Admin::getInstance(); |
||||
210 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
211 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); |
||||
212 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); |
||||
213 | if (0 == $downloads_waiting) { |
||||
214 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add'); |
||||
215 | } else { |
||||
216 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add', 'style="color : Red"'); |
||||
217 | } |
||||
218 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
219 | //Affichage du formulaire de création des téléchargements |
||||
220 | $downloads_lid = \Xmf\Request::getInt('downloads_lid', 0, 'GET'); |
||||
221 | /** @var \XoopsModules\Tdmdownloads\Downloads $obj */ |
||||
222 | $obj = $downloadsHandler->get($downloads_lid); |
||||
223 | $form = $obj->getForm($donnee = [], false); |
||||
224 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
225 | break; |
||||
226 | // Pour supprimer un téléchargement |
||||
227 | case 'del_downloads': |
||||
228 | global $xoopsModule; |
||||
229 | $downloads_lid = \Xmf\Request::getInt('downloads_lid', 0, 'GET'); |
||||
230 | $obj = $downloadsHandler->get($downloads_lid); |
||||
231 | if (\Xmf\Request::hasVar('ok') && 1 == \Xmf\Request::getInt('ok')) { |
||||
232 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
233 | redirect_header('downloads.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
234 | } |
||||
235 | // permet d'extraire le nom du fichier |
||||
236 | $urlfile = substr_replace($obj->getVar('url'), '', 0, mb_strlen($uploadurl_downloads)); |
||||
237 | if ($downloadsHandler->delete($obj)) { |
||||
238 | // permet de donner le chemin du fichier |
||||
239 | $urlfile = $uploaddir_downloads . $urlfile; |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
240 | // si le fichier est sur le serveur il es détruit |
||||
241 | if (is_file($urlfile)) { |
||||
242 | chmod($urlfile, 0777); |
||||
243 | unlink($urlfile); |
||||
244 | } |
||||
245 | // supression des votes |
||||
246 | $criteria = new \CriteriaCompo(); |
||||
247 | $criteria->add(new \Criteria('lid', $downloads_lid)); |
||||
248 | $votedata = $ratingHandler->getAll($criteria); |
||||
249 | foreach (array_keys($votedata) as $i) { |
||||
250 | /** @var \XoopsModules\Tdmdownloads\Rating[] $votedata */ |
||||
251 | $objvotedata = $ratingHandler->get($votedata[$i]->getVar('ratingid')); |
||||
252 | $ratingHandler->delete($objvotedata) || $objvotedata->getHtmlErrors(); |
||||
253 | } |
||||
254 | // supression des rapports de fichier brisé |
||||
255 | $criteria = new \CriteriaCompo(); |
||||
256 | $criteria->add(new \Criteria('lid', $downloads_lid)); |
||||
257 | $downloads_broken = $brokenHandler->getAll($criteria); |
||||
258 | foreach (array_keys($downloads_broken) as $i) { |
||||
259 | /** @var \XoopsModules\Tdmdownloads\Broken[] $downloads_broken */ |
||||
260 | $objbroken = $brokenHandler->get($downloads_broken[$i]->getVar('reportid')); |
||||
261 | $brokenHandler->delete($objbroken) || $objbroken->getHtmlErrors(); |
||||
262 | } |
||||
263 | // supression des data des champs sup. |
||||
264 | $criteria = new \CriteriaCompo(); |
||||
265 | $criteria->add(new \Criteria('lid', $downloads_lid)); |
||||
266 | $downloads_fielddata = $fielddataHandler->getAll($criteria); |
||||
267 | foreach (array_keys($downloads_fielddata) as $i) { |
||||
268 | /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloads_fielddata */ |
||||
269 | $objfielddata = $fielddataHandler->get($downloads_fielddata[$i]->getVar('iddata')); |
||||
270 | $fielddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors(); |
||||
271 | } |
||||
272 | // supression des commentaires |
||||
273 | xoops_comment_delete($xoopsModule->getVar('mid'), $downloads_lid); |
||||
274 | //supression des tags |
||||
275 | if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { |
||||
276 | /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ |
||||
277 | $linkHandler = TagHelper::getInstance()->getHandler('Link'); |
||||
278 | $criteria = new \CriteriaCompo(); |
||||
279 | $criteria->add(new \Criteria('tag_itemid', $downloads_lid)); |
||||
280 | $downloadsTags = $linkHandler->getAll($criteria); |
||||
281 | foreach (array_keys($downloadsTags) as $i) { |
||||
282 | /** @var \XoopsModules\Tag\Link[] $downloadsTags */ |
||||
283 | $objtags = $linkHandler->get($downloadsTags[$i]->getVar('tl_id')); |
||||
284 | $linkHandler->delete($objtags) || $objtags->getHtmlErrors(); |
||||
0 ignored issues
–
show
It seems like
$objtags can also be of type null ; however, parameter $object of XoopsPersistableObjectHandler::delete() does only seem to accept XoopsObject , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
285 | } |
||||
286 | } |
||||
287 | redirect_header('downloads.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); |
||||
288 | } else { |
||||
289 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
290 | } |
||||
291 | } else { |
||||
292 | //Affichage de la partie haute de l'administration de Xoops |
||||
293 | xoops_cp_header(); |
||||
294 | $adminObject = Admin::getInstance(); |
||||
295 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
296 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); |
||||
297 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); |
||||
298 | if (0 == $downloads_waiting) { |
||||
299 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add'); |
||||
300 | } else { |
||||
301 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add', 'style="color : Red"'); |
||||
302 | } |
||||
303 | $adminObject->displayButton('left'); |
||||
304 | xoops_confirm( |
||||
305 | ['ok' => 1, 'downloads_lid' => $downloads_lid, 'op' => 'del_downloads'], |
||||
306 | $_SERVER['REQUEST_URI'], |
||||
307 | sprintf(_AM_TDMDOWNLOADS_FORMSUREDEL, $obj->getVar('title')) . '<br><br>' . _AM_TDMDOWNLOADS_FORMWITHFILE . ' <b><a href="' . $obj->getVar('url') . '">' . $obj->getVar('url') . '</a></b><br>' |
||||
308 | ); |
||||
309 | } |
||||
310 | break; |
||||
311 | // Pour voir les détails du téléchargement |
||||
312 | case 'view_downloads': |
||||
313 | //Affichage de la partie haute de l'administration de Xoops |
||||
314 | xoops_cp_header(); |
||||
315 | $adminObject = Admin::getInstance(); |
||||
316 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
317 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_LISTE, 'downloads.php?op=list', 'list'); |
||||
318 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_NEW, 'downloads.php?op=new_downloads', 'add'); |
||||
319 | if (0 == $downloads_waiting) { |
||||
320 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add'); |
||||
321 | } else { |
||||
322 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_DOWNLOADS_WAIT, 'downloads.php?op=list&statut_display=0', 'add', 'style="color : Red"'); |
||||
323 | } |
||||
324 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
325 | $GLOBALS['xoopsTpl']->assign('uploadurl_shots', $uploadurl_shots); |
||||
326 | $downloads_lid = \Xmf\Request::getInt('downloads_lid', 0, 'GET'); |
||||
327 | //information du téléchargement |
||||
328 | $viewDownloads = $downloadsHandler->get($downloads_lid); |
||||
329 | //catégorie |
||||
330 | //$view_category = $categoryHandler->get($viewDownloads->getVar('cid')); |
||||
331 | $categoryArray = $categoryHandler->getAll(); |
||||
332 | $mytree = new Tree($categoryArray, 'cat_cid', 'cat_pid'); |
||||
333 | // sortie des informations |
||||
334 | $downloads_title = $viewDownloads->getVar('title'); |
||||
335 | $downloads_description = $viewDownloads->getVar('description'); |
||||
336 | //permet d'enlever [pagebreak] du texte |
||||
337 | $downloads_description = str_replace('[pagebreak]', '', $downloads_description); |
||||
338 | $category = $utility::getPathTree($mytree, $viewDownloads->getVar('cid'), $categoryArray, 'cat_title', $prefix = ' <img src="../assets/images/deco/arrow.gif"> '); |
||||
339 | // affichages des informations du téléchargement |
||||
340 | $download = [ |
||||
341 | 'title' => $downloads_title, |
||||
342 | 'description' => $downloads_description, |
||||
343 | 'cid' => $viewDownloads->getVar('cid'), |
||||
344 | 'lid' => $downloads_lid, |
||||
345 | 'category' => $category, |
||||
346 | ]; |
||||
347 | $criteria = new \CriteriaCompo(); |
||||
348 | $criteria->setSort('weight ASC, title'); |
||||
349 | $criteria->setOrder('ASC'); |
||||
350 | $criteria->add(new \Criteria('status', 1)); |
||||
351 | $downloads_field = $fieldHandler->getAll($criteria); |
||||
352 | $fieldsList = []; |
||||
353 | foreach (array_keys($downloads_field) as $i) { |
||||
354 | /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ |
||||
355 | if (1 == $downloads_field[$i]->getVar('status_def')) { |
||||
356 | if (1 == $downloads_field[$i]->getVar('fid')) { |
||||
357 | //page d'accueil |
||||
358 | if ('' !== $viewDownloads->getVar('homepage')) { |
||||
359 | $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMHOMEPAGE, 'value' => '<a href="' . $viewDownloads->getVar('homepage') . '">' . $viewDownloads->getVar('homepage') . '</a>']; |
||||
360 | } |
||||
361 | } |
||||
362 | if (2 == $downloads_field[$i]->getVar('fid')) { |
||||
363 | //version |
||||
364 | if ('' !== $viewDownloads->getVar('version')) { |
||||
365 | $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMVERSION, 'value' => $viewDownloads->getVar('version')]; |
||||
366 | } |
||||
367 | } |
||||
368 | if (3 == $downloads_field[$i]->getVar('fid')) { |
||||
369 | //taille du fichier |
||||
370 | if ('' !== $viewDownloads->getVar('size')) { |
||||
371 | $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT, 'value' => $viewDownloads->getVar('size')]; |
||||
372 | } |
||||
373 | } |
||||
374 | if (4 == $downloads_field[$i]->getVar('fid')) { |
||||
375 | //plateforme |
||||
376 | if ('' !== $viewDownloads->getVar('platform')) { |
||||
377 | $fieldsList[] = ['name' => _AM_TDMDOWNLOADS_FORMPLATFORM, 'value' => $viewDownloads->getVar('platform')]; |
||||
378 | } |
||||
379 | } |
||||
380 | } else { |
||||
381 | $contenu = ''; |
||||
382 | $criteria = new \CriteriaCompo(); |
||||
383 | $criteria->add(new \Criteria('lid', $downloads_lid)); |
||||
384 | $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); |
||||
0 ignored issues
–
show
It seems like
$downloads_field[$i]->getVar('fid') can also be of type array and array ; however, parameter $value of Criteria::__construct() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
385 | $downloadsfielddata = $fielddataHandler->getAll($criteria); |
||||
386 | foreach (array_keys($downloadsfielddata) as $j) { |
||||
387 | /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */ |
||||
388 | $contenu = $downloadsfielddata[$j]->getVar('data'); |
||||
389 | } |
||||
390 | if ('' !== $contenu) { |
||||
391 | $fieldsList[] = ['name' => $downloads_field[$i]->getVar('title'), 'value' => $contenu]; |
||||
392 | } |
||||
393 | } |
||||
394 | } |
||||
395 | $download['fields_list'] = $fieldsList; |
||||
396 | // tags |
||||
397 | if (1 == $helper->getConfig('usetag') && class_exists(Tag::class)) { |
||||
398 | require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php'; |
||||
399 | $tags_array = tagBar($downloads_lid, 0); |
||||
400 | if (!empty($tags_array)) { |
||||
401 | $tags = ''; |
||||
402 | foreach (array_keys($tags_array['tags']) as $i) { |
||||
403 | $tags .= $tags_array['delimiter'] . ' ' . $tags_array['tags'][$i] . ' '; |
||||
404 | } |
||||
405 | $download['tags'] = ['title' => $tags_array['title'], 'value' => $tags]; |
||||
406 | } |
||||
407 | } |
||||
408 | if ($helper->getConfig('useshots')) { |
||||
409 | if ('blank.gif' !== $viewDownloads->getVar('logourl')) { |
||||
410 | $download['logourl'] = $viewDownloads->getVar('logourl'); |
||||
411 | } |
||||
412 | } |
||||
413 | $download['date'] = formatTimestamp($viewDownloads->getVar('date')); |
||||
414 | $download['submitter'] = XoopsUser::getUnameFromId($viewDownloads->getVar('submitter')); |
||||
415 | $download['hits'] = $viewDownloads->getVar('hits'); |
||||
416 | $download['rating'] = number_format((float)$viewDownloads->getVar('rating'), 1); |
||||
417 | $download['votes'] = $viewDownloads->getVar('votes'); |
||||
418 | if (true === $helper->getConfig('use_paypal') && '' !== $viewDownloads->getVar('paypal')) { |
||||
419 | $download['paypal'] = $viewDownloads->getVar('paypal'); |
||||
420 | } |
||||
421 | $download['comments'] = $viewDownloads->getVar('comments'); |
||||
422 | $GLOBALS['xoopsTpl']->assign('download', $download); |
||||
423 | // Utilisateur enregistré |
||||
424 | $ratings = []; |
||||
425 | $criteria = new \CriteriaCompo(); |
||||
426 | $criteria->add(new \Criteria('lid', $downloads_lid)); |
||||
427 | $criteria->add(new \Criteria('ratinguser', 0, '!=')); |
||||
428 | $votedataArray = $ratingHandler->getAll($criteria); |
||||
429 | $votesTotal = count($votedataArray); |
||||
430 | $ratings['user_total'] = $votesTotal; |
||||
431 | $userList = []; |
||||
432 | foreach (array_keys($votedataArray) as $i) { |
||||
433 | /** @var \XoopsModules\Tdmdownloads\Rating[] $votedataArray */ |
||||
434 | $userList[] = [ |
||||
435 | 'ratinguser' => \XoopsUser::getUnameFromId($votedataArray[$i]->getVar('ratinguser')), |
||||
436 | 'ratinghostname' => $votedataArray[$i]->getVar('ratinghostname'), |
||||
437 | 'rating' => $votedataArray[$i]->getVar('rating'), |
||||
438 | 'ratingtimestamp' => formatTimestamp($votedataArray[$i]->getVar('ratingtimestamp')), |
||||
439 | 'myTextForm' => myTextForm('downloads.php?op=del_vote&lid=' . $votedataArray[$i]->getVar('lid') . '&rid=' . $votedataArray[$i]->getVar('ratingid'), 'X'), |
||||
440 | ]; |
||||
441 | } |
||||
442 | $ratings['user_list'] = $userList; |
||||
443 | // Utilisateur anonyme |
||||
444 | $criteria = new \CriteriaCompo(); |
||||
445 | $criteria->add(new \Criteria('lid', $downloads_lid)); |
||||
446 | $criteria->add(new \Criteria('ratinguser', 0)); |
||||
447 | $votedataArray = $ratingHandler->getAll($criteria); |
||||
448 | $votesTotal = count($votedataArray); |
||||
449 | $ratings['anon_total'] = $votesTotal; |
||||
450 | $anon_list = []; |
||||
451 | foreach (array_keys($votedataArray) as $i) { |
||||
452 | $anon_list[] = [ |
||||
453 | 'ratinghostname' => $votedataArray[$i]->getVar('ratinghostname'), |
||||
454 | 'rating' => $votedataArray[$i]->getVar('rating'), |
||||
455 | 'ratingtimestamp' => formatTimestamp($votedataArray[$i]->getVar('ratingtimestamp')), |
||||
456 | 'myTextForm' => myTextForm('downloads.php?op=del_vote&lid=' . $votedataArray[$i]->getVar('lid') . '&rid=' . $votedataArray[$i]->getVar('ratingid'), 'X'), |
||||
457 | ]; |
||||
458 | } |
||||
459 | $ratings['anon_list'] = $anon_list; |
||||
460 | $ratings['votes_total'] = $ratings['user_total'] + $ratings['anon_total']; |
||||
461 | $GLOBALS['xoopsTpl']->assign('ratings', $ratings); |
||||
462 | $GLOBALS['xoopsTpl']->assign('download_detail', true); |
||||
463 | break; |
||||
464 | // permet de suprimmer un vote et de recalculer la note |
||||
465 | case 'del_vote': |
||||
466 | $objvotedata = $ratingHandler->get(\Xmf\Request::getInt('rid')); |
||||
467 | if ($ratingHandler->delete($objvotedata)) { |
||||
468 | $criteria = new \CriteriaCompo(); |
||||
469 | $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('lid'))); |
||||
470 | $votedataArray = $ratingHandler->getAll($criteria); |
||||
471 | $votesTotal = $ratingHandler->getCount($criteria); |
||||
472 | $obj = $downloadsHandler->get(\Xmf\Request::getInt('lid')); |
||||
473 | if (0 === $votesTotal) { |
||||
474 | $obj->setVar('rating', number_format(0, 1)); |
||||
475 | $obj->setVar('votes', 0); |
||||
476 | if ($downloadsHandler->insert($obj)) { |
||||
477 | redirect_header('downloads.php?op=view_downloads&downloads_lid=' . \Xmf\Request::getInt('lid'), 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); |
||||
478 | } |
||||
479 | } else { |
||||
480 | $ratingTotal = 0; |
||||
481 | foreach (array_keys($votedataArray) as $i) { |
||||
482 | /** @var \XoopsModules\Tdmdownloads\Rating[] $votedataArray */ |
||||
483 | $ratingTotal += $votedataArray[$i]->getVar('rating'); |
||||
484 | } |
||||
485 | $rating = $ratingTotal / $votesTotal; |
||||
486 | $obj->setVar('rating', number_format((float)$rating, 1)); |
||||
487 | $obj->setVar('votes', $votesTotal); |
||||
488 | if ($downloadsHandler->insert($obj)) { |
||||
489 | redirect_header('downloads.php?op=view_downloads&downloads_lid=' . \Xmf\Request::getInt('lid'), 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); |
||||
490 | } |
||||
491 | } |
||||
492 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
493 | } |
||||
494 | $GLOBALS['xoopsTpl']->assign('message_erreur', $objvotedata->getHtmlErrors()); |
||||
495 | break; |
||||
496 | // Pour sauver un téléchargement |
||||
497 | case 'save_downloads': |
||||
498 | global $xoopsDB; |
||||
499 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||||
500 | xoops_cp_header(); |
||||
501 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
502 | redirect_header('downloads.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
503 | } |
||||
504 | /** @var \XoopsModules\Tdmdownloads\Downloads $obj */ |
||||
505 | if (\Xmf\Request::hasVar('lid')) { |
||||
506 | $obj = $downloadsHandler->get(\Xmf\Request::getInt('lid')); |
||||
507 | } else { |
||||
508 | $obj = $downloadsHandler->create(); |
||||
509 | } |
||||
510 | $erreur = false; |
||||
511 | $errorMessage = ''; |
||||
512 | $donnee = []; |
||||
513 | $obj->setVar('title', \Xmf\Request::getString('title', '', 'POST')); |
||||
514 | $obj->setVar('cid', \Xmf\Request::getInt('cid', 0, 'POST')); |
||||
515 | $obj->setVar('homepage', formatURL(\Xmf\Request::getUrl('homepage', '', 'POST'))); |
||||
516 | $obj->setVar('version', \Xmf\Request::getString('version', '', 'POST')); |
||||
517 | $obj->setVar('paypal', \Xmf\Request::getString('paypal', '', 'POST')); |
||||
518 | if (\Xmf\Request::hasVar('platform', 'POST')) { |
||||
519 | $obj->setVar('platform', implode('|', \Xmf\Request::getArray('platform', [], 'POST'))); |
||||
520 | } |
||||
521 | $obj->setVar('description', \Xmf\Request::getString('description', '', 'POST')); |
||||
522 | if (\Xmf\Request::hasVar('submitter', 'POST')) { |
||||
523 | $obj->setVar('submitter', \Xmf\Request::getInt('submitter', 0, 'POST')); |
||||
524 | $donnee['submitter'] = \Xmf\Request::getInt('submitter', 0, 'POST'); |
||||
525 | } else { |
||||
526 | $obj->setVar('submitter', !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0); |
||||
527 | $donnee['submitter'] = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
||||
528 | } |
||||
529 | if (\Xmf\Request::hasVar('downloads_modified')) { |
||||
530 | $obj->setVar('date', time()); |
||||
531 | if (\Xmf\Request::hasVar('status', 'POST')) { |
||||
532 | $obj->setVar('status', 1); |
||||
533 | $donnee['status'] = 1; |
||||
534 | } else { |
||||
535 | $obj->setVar('status', 0); |
||||
536 | $donnee['status'] = 0; |
||||
537 | } |
||||
538 | } else { |
||||
539 | if (\Xmf\Request::hasVar('date_update', 'POST') && 'Y' === $_POST['date_update']) { |
||||
540 | $obj->setVar('date', strtotime($_POST['date'])); |
||||
541 | if (\Xmf\Request::hasVar('status', 'POST')) { |
||||
542 | $obj->setVar('status', 2); |
||||
543 | $donnee['status'] = 1; |
||||
544 | } else { |
||||
545 | $obj->setVar('status', 0); |
||||
546 | $donnee['status'] = 0; |
||||
547 | } |
||||
548 | } else { |
||||
549 | if (\Xmf\Request::hasVar('status', 'POST')) { |
||||
550 | $obj->setVar('status', 1); |
||||
551 | $donnee['status'] = 1; |
||||
552 | } else { |
||||
553 | $obj->setVar('status', 0); |
||||
554 | $donnee['status'] = 0; |
||||
555 | } |
||||
556 | if (\Xmf\Request::hasVar('date', 'POST')) { |
||||
557 | $obj->setVar('date', strtotime($_POST['date'])); |
||||
558 | } else { |
||||
559 | $obj->setVar('date', time()); |
||||
560 | } |
||||
561 | } |
||||
562 | //$donnee['date_update'] = $_POST['date_update']; //no more used later |
||||
563 | } |
||||
564 | // erreur si la description est vide |
||||
565 | if (\Xmf\Request::hasVar('description', 'POST')) { |
||||
566 | if ('' === \Xmf\Request::getString('description', '')) { |
||||
567 | $erreur = true; |
||||
568 | $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_NODESCRIPTION . '<br>'; |
||||
569 | } |
||||
570 | } |
||||
571 | // erreur si la catégorie est vide |
||||
572 | if (\Xmf\Request::hasVar('cid', 'POST')) { |
||||
573 | if (0 == \Xmf\Request::getInt('cid', 0, 'POST')) { |
||||
574 | $erreur = true; |
||||
575 | $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_NOCAT . '<br>'; |
||||
576 | } |
||||
577 | } |
||||
578 | // pour enregistrer temporairement les valeur des champs sup |
||||
579 | $criteria = new \CriteriaCompo(); |
||||
580 | $criteria->setSort('weight ASC, title'); |
||||
581 | $criteria->setOrder('ASC'); |
||||
582 | $downloads_field = $fieldHandler->getAll($criteria); |
||||
583 | foreach (array_keys($downloads_field) as $i) { |
||||
584 | /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ |
||||
585 | if (0 == $downloads_field[$i]->getVar('status_def')) { |
||||
586 | $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); |
||||
587 | $donnee[$fieldName] = \Xmf\Request::getString($fieldName, '', 'POST'); |
||||
588 | } |
||||
589 | } |
||||
590 | // enregistrement temporaire des tags |
||||
591 | if (1 == $helper->getConfig('usetag') && class_exists(Tag::class)) { |
||||
592 | $donnee['TAG'] = $_POST['tag']; |
||||
593 | } |
||||
594 | if (true === $erreur) { |
||||
595 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||
596 | /** @var \XoopsThemeForm $form */ |
||||
597 | $form = $obj->getForm($donnee, true); |
||||
598 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
599 | break; |
||||
600 | } |
||||
601 | // Pour le fichier |
||||
602 | $mediaSize = 0; |
||||
603 | if (isset($_POST['xoops_upload_file'][0])) { |
||||
604 | $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); |
||||
605 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
||||
606 | if ($helper->getConfig('newnamedownload')) { |
||||
607 | $uploader->setPrefix($helper->getConfig('prefixdownloads')); |
||||
608 | } |
||||
609 | $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
||||
610 | if (!$uploader->upload()) { |
||||
611 | $errorMessage .= $uploader->getErrors() . '<br>'; |
||||
612 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||
613 | $form = $obj->getForm($donnee, true); |
||||
614 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
615 | break; |
||||
616 | } |
||||
617 | $mediaSize = $uploader->getMediaSize(); |
||||
618 | $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); |
||||
619 | } else { |
||||
620 | if ($_FILES['attachedfile']['name'] > '') { |
||||
621 | // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize |
||||
622 | $errorMessage .= $uploader->getErrors() . '<br>'; |
||||
623 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||
624 | $form = $obj->getForm($donnee, true); |
||||
625 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
626 | break; |
||||
627 | } |
||||
628 | $obj->setVar('url', \Xmf\Request::getUrl('url', '', 'POST')); |
||||
629 | } |
||||
630 | } else { |
||||
631 | $obj->setVar('url', \Xmf\Request::getUrl('url', '', 'POST')); |
||||
632 | } |
||||
633 | // Pour l'image |
||||
634 | if (isset($_POST['xoops_upload_file'][1])) { |
||||
635 | $uploader_2 = new \XoopsMediaUploader( |
||||
636 | $uploaddir_shots, [ |
||||
637 | 'image/gif', |
||||
638 | 'image/jpeg', |
||||
639 | 'image/pjpeg', |
||||
640 | 'image/x-png', |
||||
641 | 'image/png', |
||||
642 | ], $helper->getConfig('maxuploadsize'), null, null |
||||
643 | ); |
||||
644 | if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { |
||||
645 | $uploader_2->setPrefix('downloads_'); |
||||
646 | $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); |
||||
647 | if (!$uploader_2->upload()) { |
||||
648 | $errorMessage .= $uploader_2->getErrors() . '<br>'; |
||||
649 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||
650 | $form = $obj->getForm($donnee, true); |
||||
651 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
652 | break; |
||||
653 | } |
||||
654 | $obj->setVar('logourl', $uploader_2->getSavedFileName()); |
||||
655 | } else { |
||||
656 | if ($_FILES['attachedimage']['name'] > '') { |
||||
657 | // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize |
||||
658 | $errorMessage .= $uploader_2->getErrors() . '<br>'; |
||||
659 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||
660 | $form = $obj->getForm($donnee, true); |
||||
661 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
662 | break; |
||||
663 | } |
||||
664 | $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'POST')); |
||||
665 | } |
||||
666 | } else { |
||||
667 | $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'POST')); |
||||
668 | } |
||||
669 | //Automatic file size |
||||
670 | if ('' == Xmf\Request::getString('sizeValue', '')) { |
||||
671 | if (0 == $mediaSize) { |
||||
672 | $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); |
||||
673 | } else { |
||||
674 | $obj->setVar('size', $utility::convertFileSize($mediaSize)); |
||||
675 | } |
||||
676 | } else { |
||||
677 | $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); |
||||
678 | } |
||||
679 | $timeToRedirect = 2; |
||||
680 | if (0 == $obj->getVar('size')) { |
||||
681 | $obj->setVar('size', ''); |
||||
682 | $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; |
||||
683 | $timeToRedirect = 10; |
||||
684 | } |
||||
685 | // enregistrement |
||||
686 | if ($downloadsHandler->insert($obj)) { |
||||
687 | if (!\Xmf\Request::hasVar('downloads_modified')) { |
||||
688 | $lidDownloads = $obj->getNewEnreg($db); |
||||
689 | } else { |
||||
690 | $lidDownloads = \Xmf\Request::getInt('lid'); |
||||
691 | } |
||||
692 | //tags |
||||
693 | if (1 == $helper->getConfig('usetag') && class_exists(TagHandler::class)) { |
||||
694 | /** @var \XoopsModules\Tag\TagHandler $tagHandler */ |
||||
695 | $tagHandler = TagHelper::getInstance()->getHandler('Tag'); |
||||
696 | $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0); |
||||
697 | } |
||||
698 | // Récupération des champs supplémentaires: |
||||
699 | $criteria = new \CriteriaCompo(); |
||||
700 | $criteria->setSort('weight ASC, title'); |
||||
701 | $criteria->setOrder('ASC'); |
||||
702 | $downloads_field = $fieldHandler->getAll($criteria); |
||||
703 | foreach (array_keys($downloads_field) as $i) { |
||||
704 | if (0 == $downloads_field[$i]->getVar('status_def')) { |
||||
705 | $iddata = 'iddata' . $downloads_field[$i]->getVar('fid'); |
||||
706 | if (\Xmf\Request::hasVar($iddata, 'POST')) { |
||||
707 | if ('' === \Xmf\Request::getString($iddata, '')) { |
||||
708 | $objdata = $fielddataHandler->create(); |
||||
709 | } else { |
||||
710 | $objdata = $fielddataHandler->get(\Xmf\Request::getString($iddata, '', 'POST')); |
||||
711 | } |
||||
712 | } else { |
||||
713 | $objdata = $fielddataHandler->create(); |
||||
714 | } |
||||
715 | $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); |
||||
716 | $objdata->setVar('data', \Xmf\Request::getString($fieldName, '', 'POST')); |
||||
717 | $objdata->setVar('lid', $lidDownloads); |
||||
718 | $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); |
||||
719 | $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); |
||||
720 | } |
||||
721 | } |
||||
722 | //permission pour télécharger |
||||
723 | if (2 == $helper->getConfig('permission_download')) { |
||||
724 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||||
725 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||
726 | $criteria = new \CriteriaCompo(); |
||||
727 | $criteria->add(new \Criteria('gperm_itemid', $lidDownloads, '=')); |
||||
728 | $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
||||
729 | $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download_item', '=')); |
||||
730 | $grouppermHandler->deleteAll($criteria); |
||||
731 | if (\Xmf\Request::hasVar('item_download', 'POST')) { |
||||
732 | foreach ($_POST['item_download'] as $onegroup_id) { |
||||
733 | $grouppermHandler->addRight('tdmdownloads_download_item', $lidDownloads, $onegroup_id, $xoopsModule->getVar('mid')); |
||||
734 | } |
||||
735 | } |
||||
736 | } |
||||
737 | // pour les notifications uniquement lors d'un nouveau téléchargement |
||||
738 | if (\Xmf\Request::hasVar('downloads_modified')) { |
||||
739 | $tags = []; |
||||
740 | $tags['FILE_NAME'] = \Xmf\Request::getString('title', '', 'POST'); |
||||
741 | $tags['FILE_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST') . '&lid=' . $lidDownloads; |
||||
742 | $downloadscat_cat = $categoryHandler->get(\Xmf\Request::getInt('cid', 0, 'POST')); |
||||
743 | $tags['CATEGORY_NAME'] = $downloadscat_cat->getVar('cat_title'); |
||||
744 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . \Xmf\Request::getInt('cid', 0, 'POST'); |
||||
745 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||||
746 | $notificationHandler = xoops_getHandler('notification'); |
||||
747 | $notificationHandler->triggerEvent('global', 0, 'new_file', $tags); |
||||
748 | $notificationHandler->triggerEvent('category', \Xmf\Request::getInt('cid', 0, 'POST'), 'new_file', $tags); |
||||
749 | } |
||||
750 | redirect_header('downloads.php', $timeToRedirect, _AM_TDMDOWNLOADS_REDIRECT_SAVE . '<br><br>' . $error_message); |
||||
751 | } |
||||
752 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
753 | $form = $obj->getForm($donnee, true); |
||||
754 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
755 | break; |
||||
756 | // permet de valider un téléchargement proposé |
||||
757 | case 'update_status': |
||||
758 | $obj = $downloadsHandler->get(\Xmf\Request::getInt('downloads_lid')); |
||||
759 | $obj->setVar('status', 1); |
||||
760 | if ($downloadsHandler->insert($obj)) { |
||||
761 | redirect_header('downloads.php', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE); |
||||
762 | } |
||||
763 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
764 | break; |
||||
765 | // permet de valider un téléchargement proposé |
||||
766 | case 'lock_status': |
||||
767 | $obj = $downloadsHandler->get(\Xmf\Request::getInt('downloads_lid')); |
||||
768 | $obj->setVar('status', 0); |
||||
769 | if ($downloadsHandler->insert($obj)) { |
||||
770 | redirect_header('downloads.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DEACTIVATED); |
||||
771 | } |
||||
772 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
773 | break; |
||||
774 | } |
||||
775 | // Local icons path |
||||
776 | if (is_object($helper->getModule())) { |
||||
777 | $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
||||
778 | $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
||||
779 | $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
![]() |
|||||
780 | $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
||||
781 | } |
||||
782 | //Affichage de la partie basse de l'administration de Xoops |
||||
783 | require_once __DIR__ . '/admin_footer.php'; |
||||
784 |