XoopsModules25x /
xoopstube
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Module: XoopsTube |
||
| 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 | * |
||
| 9 | * PHP version 5 |
||
| 10 | * |
||
| 11 | * @category Module |
||
| 12 | * @package Xoopstube |
||
| 13 | * @author XOOPS Development Team |
||
| 14 | * @copyright 2001-2016 XOOPS Project (https://xoops.org) |
||
| 15 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 16 | * @link https://xoops.org/ |
||
| 17 | * @since 1.0.6 |
||
| 18 | */ |
||
| 19 | |||
| 20 | use Xmf\Request; |
||
| 21 | use XoopsModules\Xoopstube; |
||
| 22 | |||
| 23 | require_once __DIR__ . '/admin_header.php'; |
||
| 24 | |||
| 25 | $op = Request::getCmd('op', Request::getCmd('op', '', 'POST'), 'GET'); //cleanRequestVars($_REQUEST, 'op', ''); |
||
| 26 | $lid = Request::getInt('lid', Request::getInt('lid', 0, 'POST'), 'GET'); //cleanRequestVars($_REQUEST, 'lid', 0); |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param \XoopsModules\Xoopstube\Tree $xt |
||
| 30 | * @param int $itemid |
||
| 31 | * @param $title |
||
| 32 | * @param $checks |
||
| 33 | * @param string $order |
||
| 34 | */ |
||
| 35 | function makeTreeCheckTable(Xoopstube\Tree $xt, $itemid, $title, $checks, $order = '') |
||
| 36 | { |
||
| 37 | global $myts; |
||
| 38 | |||
| 39 | echo '<div style="text-align: left;">'; |
||
| 40 | echo '<form name="altcat" method="post" action="' . xoops_getenv('SCRIPT_NAME') . '">'; |
||
| 41 | echo '<table width="100%" callspacing="1" class="outer">'; |
||
| 42 | $sql = 'SELECT ' . $xt->id . ', ' . $title . ' FROM ' . $xt->table . ' WHERE ' . $xt->pid . '=0' . ' ORDER BY ' . $title; |
||
| 43 | if ('' !== $order) { |
||
| 44 | $sql .= ' ORDER BY ' . $order; |
||
| 45 | } |
||
| 46 | $result = $xt->db->query($sql); |
||
| 47 | |||
| 48 | while (list($cid, $name) = $xt->db->fetchRow($result)) { |
||
| 49 | $checked = array_key_exists($cid, $checks) ? 'checked' : ''; |
||
| 50 | $disabled = ($cid === Request::getInt('cid', 0, 'GET')) ? "disabled='yes'" : ''; |
||
| 51 | $level = 1; |
||
| 52 | echo ' |
||
| 53 | <tr style="text-align: left;"> |
||
| 54 | <td width="30%" class="head">' . $name . '</td> |
||
| 55 | <td class="head"> |
||
| 56 | <input type="checkbox" name="cid-' . $cid . '" value="0" ' . $checked . ' ' . $disabled . '> |
||
| 57 | </td> |
||
| 58 | </tr>'; |
||
| 59 | $arr = $xt->getChildTreeArray($cid, $order); |
||
| 60 | foreach ($arr as $cat) { |
||
| 61 | $cat['prefix'] = str_replace('.', '-', $cat['prefix']); |
||
| 62 | $catpath = ' ' . $cat['prefix'] . ' ' . htmlspecialchars($cat[$title]); |
||
| 63 | $checked = array_key_exists($cat['cid'], $checks) ? 'checked' : ''; |
||
| 64 | $disabled = ($cat['cid'] === Request::getInt('cid', 0, 'GET')) ? "disabled='yes'" : ''; |
||
| 65 | $level = mb_substr_count($cat['prefix'], '-') + 1; |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 66 | // echo "<tr><td>" . $catpath . "<input type='checkbox' name='cid-" . $cat['cid'] . "' value='0' " . $checked . " " . $disabled . "></td></tr>\n"; |
||
| 67 | echo ' |
||
| 68 | <tr style="text-align: left;"> |
||
| 69 | <td width="30%" class="even">' . $catpath . '</td> |
||
| 70 | <td class="even"> |
||
| 71 | <input type="checkbox" name="cid-' . $cat['cid'] . '" value="0" ' . $checked . ' ' . $disabled . '> |
||
| 72 | </td> |
||
| 73 | </tr>'; |
||
| 74 | } |
||
| 75 | } |
||
| 76 | echo '<tr> |
||
| 77 | <td width="30%"></td> |
||
| 78 | <td style="text-align: left;"> |
||
| 79 | <input type="submit" class="mainbutton" value="save"> |
||
| 80 | <input type="hidden" name="op" value="save"> |
||
| 81 | <input type="hidden" name="lid" value="' . $itemid . '"> |
||
| 82 | </td> |
||
| 83 | </tr>'; |
||
| 84 | echo '</table></form></div>'; |
||
| 85 | } |
||
| 86 | |||
| 87 | switch (mb_strtolower($op)) { |
||
| 88 | case 'save': |
||
| 89 | // first delete all alternate categories for this topic |
||
| 90 | $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_altcat') . ' WHERE lid=' . $lid; |
||
| 91 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||
| 92 | /** @var \XoopsLogger $logger */ |
||
| 93 | $logger = \XoopsLogger::getInstance(); |
||
| 94 | $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__); |
||
| 95 | |||
| 96 | return false; |
||
| 97 | } |
||
| 98 | |||
| 99 | $k = array_keys($_REQUEST); |
||
| 100 | foreach ($k as $sid) { |
||
| 101 | if (preg_match('/cid-(\d*)/', $sid, $cid)) { |
||
| 102 | $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('xoopstube_altcat') . '(cid, lid) VALUES("' . $cid[1] . '","' . $lid . '")'; |
||
| 103 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||
| 104 | $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__); |
||
| 105 | |||
| 106 | return false; |
||
| 107 | } |
||
| 108 | } |
||
| 109 | } |
||
| 110 | redirect_header('index.php', 1, _AM_XOOPSTUBE_ALTCAT_CREATED); |
||
| 111 | break; |
||
| 112 | case 'main': |
||
| 113 | default: |
||
| 114 | xoops_cp_header(); |
||
| 115 | //renderAdminMenu(_AM_XOOPSTUBE_MALTCAT); |
||
| 116 | echo '<fieldset><legend style="font-weight: bold; color: #0A3760;">' . _AM_XOOPSTUBE_ALTCAT_MODIFYF . '</legend> |
||
| 117 | <div style="padding: 8px;">' . _AM_XOOPSTUBE_ALTCAT_INFOTEXT . '</div> |
||
| 118 | </fieldset>'; |
||
| 119 | |||
| 120 | echo '<div style="text-align: left;"><h3> ' . $_REQUEST['title'] . ' </h3></div>'; |
||
| 121 | // Get an array of all alternate categories for this topic |
||
| 122 | $sql = $GLOBALS['xoopsDB']->query('SELECT cid FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_altcat') . ' WHERE lid="' . $lid . '" ORDER BY lid'); |
||
| 123 | $altcats = []; |
||
| 124 | while (false !== ($altcat = $GLOBALS['xoopsDB']->fetchArray($sql))) { |
||
| 125 | $altcats[$altcat['cid']] = true; |
||
| 126 | } |
||
| 127 | $mytree = new Xoopstube\Tree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
| 128 | makeTreeCheckTable($mytree, $lid, 'title', $altcats); |
||
| 129 | xoops_cp_footer(); |
||
| 130 | } |
||
| 131 |