XoopsModules25x /
tdmdownloads
| 1 | <?php |
||
| 2 | // |
||
| 3 | // ------------------------------------------------------------------------ // |
||
| 4 | // XOOPS - PHP Content Management System // |
||
| 5 | // Copyright (c) 2000-2019 XOOPS.org // |
||
| 6 | // <https://xoops.org> // |
||
| 7 | // ------------------------------------------------------------------------ // |
||
| 8 | // This program is free software; you can redistribute it and/or modify // |
||
| 9 | // it under the terms of the GNU General Public License as published by // |
||
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
||
| 11 | // (at your option) any later version. // |
||
| 12 | // // |
||
| 13 | // You may not change or alter any portion of this comment or credits // |
||
| 14 | // of supporting developers from this source code or any supporting // |
||
| 15 | // source code which is considered copyrighted (c) material of the // |
||
| 16 | // original comment or credit authors. // |
||
| 17 | // // |
||
| 18 | // This program is distributed in the hope that it will be useful, // |
||
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
| 21 | // GNU General Public License for more details. // |
||
| 22 | // // |
||
| 23 | // You should have received a copy of the GNU General Public License // |
||
| 24 | // along with this program; if not, write to the Free Software // |
||
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
| 26 | // ------------------------------------------------------------------------ // |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param $category |
||
| 30 | * @param $item_id |
||
| 31 | * @return mixed |
||
| 32 | */ |
||
| 33 | function tdmdownloads_notify_iteminfo($category, $item_id) |
||
| 34 | { |
||
| 35 | global $xoopsModule, $xoopsModuleConfig, $xoopsConfig; |
||
| 36 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 37 | $item_id = (int)$item_id; |
||
| 38 | if (empty($xoopsModule) || $xoopsModule->getVar('dirname') !== $moduleDirName) { |
||
| 39 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 40 | $moduleHandler = xoops_getHandler('module'); |
||
| 41 | $module = $moduleHandler->getByDirname($moduleDirName); |
||
| 42 | /** @var \XoopsConfigHandler $configHandler */ |
||
| 43 | $configHandler = xoops_getHandler('config'); |
||
| 44 | $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
| 45 | } else { |
||
| 46 | $module = $xoopsModule; |
||
| 47 | $config = $xoopsModuleConfig; |
||
| 48 | } |
||
| 49 | |||
| 50 | if ('global' === $category) { |
||
| 51 | $item['name'] = ''; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 52 | $item['url'] = ''; |
||
| 53 | |||
| 54 | return $item; |
||
| 55 | } |
||
| 56 | |||
| 57 | global $xoopsDB; |
||
| 58 | if ('category' === $category) { |
||
| 59 | // Assume we have a valid category id |
||
| 60 | $sql = 'SELECT title FROM ' . $xoopsDB->prefix('tdmdownloads_cat') . ' WHERE cid = ' . $item_id; |
||
| 61 | $result = $xoopsDB->query($sql); // TODO: error check |
||
| 62 | $result_array = $xoopsDB->fetchArray($result); |
||
| 63 | $item['name'] = $result_array['title']; |
||
| 64 | $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewcat.php?cid=' . $item_id; |
||
| 65 | |||
| 66 | return $item; |
||
| 67 | } |
||
| 68 | |||
| 69 | if ('file' === $category) { |
||
| 70 | // Assume we have a valid file id |
||
| 71 | $sql = 'SELECT cid,title FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE lid = ' . $item_id; |
||
| 72 | $result = $xoopsDB->query($sql); // TODO: error check |
||
| 73 | $result_array = $xoopsDB->fetchArray($result); |
||
| 74 | $item['name'] = $result_array['title']; |
||
| 75 | $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/singlefile.php?cid=' . $result_array['cid'] . '&lid=' . $item_id; |
||
| 76 | |||
| 77 | return $item; |
||
| 78 | } |
||
| 79 | |||
| 80 | return null; |
||
| 81 | } |
||
| 82 |