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 | * @Module XoopsTube |
||||||
| 12 | * @Release Date: 21 June 2005 |
||||||
| 13 | * @Developer John N |
||||||
| 14 | * @Team XOOPS Development Team |
||||||
| 15 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||||
| 16 | */ |
||||||
| 17 | |||||||
| 18 | use Xmf\Request; |
||||||
| 19 | use XoopsModules\Xoopstube\{ |
||||||
| 20 | Lists, |
||||||
| 21 | Utility, |
||||||
| 22 | Tree |
||||||
| 23 | }; |
||||||
| 24 | |||||||
| 25 | require_once __DIR__ . '/admin_header.php'; |
||||||
| 26 | require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
||||||
| 27 | |||||||
| 28 | $op = ''; |
||||||
| 29 | |||||||
| 30 | if (isset($_POST)) { |
||||||
| 31 | foreach ($_POST as $k => $v) { |
||||||
| 32 | ${$k} = $v; |
||||||
| 33 | } |
||||||
| 34 | } |
||||||
| 35 | |||||||
| 36 | if (isset($_GET)) { |
||||||
| 37 | foreach ($_GET as $k => $v) { |
||||||
| 38 | ${$k} = $v; |
||||||
| 39 | } |
||||||
| 40 | } |
||||||
| 41 | |||||||
| 42 | /** |
||||||
| 43 | * @param int $cid |
||||||
| 44 | */ |
||||||
| 45 | function createCategory($cid = 0) |
||||||
| 46 | { |
||||||
| 47 | // require_once dirname(__DIR__) . '/class/xoopstube_lists.php'; |
||||||
| 48 | // require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||||
| 49 | |||||||
| 50 | global $myts, $totalcats, $xoopsModule; |
||||||
| 51 | |||||||
| 52 | $lid = 0; |
||||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||||
| 53 | $title = ''; |
||||||
| 54 | $imgurl = ''; |
||||||
| 55 | $description = ''; |
||||||
| 56 | $pid = ''; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 57 | $weight = 0; |
||||||
| 58 | $nohtml = 0; |
||||||
| 59 | $nosmiley = 0; |
||||||
| 60 | $noxcodes = 0; |
||||||
| 61 | $noimages = 0; |
||||||
| 62 | $nobreak = 1; |
||||||
| 63 | $spotlighttop = 0; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 64 | $spotlighthis = 0; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 65 | $client_id = 0; |
||||||
| 66 | $banner_id = 0; |
||||||
| 67 | $heading = _AM_XOOPSTUBE_CCATEGORY_CREATENEW; |
||||||
| 68 | $totalcats = Utility::getTotalCategoryCount(); |
||||||
| 69 | |||||||
| 70 | if ($cid > 0) { |
||||||
| 71 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE cid=' . (int)$cid; |
||||||
| 72 | $cat_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql)); |
||||||
| 73 | $title = htmlspecialchars($cat_arr['title']); |
||||||
| 74 | $imgurl = htmlspecialchars($cat_arr['imgurl']); |
||||||
| 75 | $description = htmlspecialchars($cat_arr['description']); |
||||||
| 76 | $nohtml = (int)$cat_arr['nohtml']; |
||||||
| 77 | $nosmiley = (int)$cat_arr['nosmiley']; |
||||||
| 78 | $noxcodes = (int)$cat_arr['noxcodes']; |
||||||
| 79 | $noimages = (int)$cat_arr['noimages']; |
||||||
| 80 | $nobreak = (int)$cat_arr['nobreak']; |
||||||
| 81 | $spotlighthis = (int)$cat_arr['spotlighthis']; |
||||||
| 82 | $spotlighttop = (int)$cat_arr['spotlighttop']; |
||||||
| 83 | $weight = $cat_arr['weight']; |
||||||
| 84 | $client_id = $cat_arr['client_id']; |
||||||
| 85 | $banner_id = $cat_arr['banner_id']; |
||||||
| 86 | $heading = _AM_XOOPSTUBE_CCATEGORY_MODIFY; |
||||||
| 87 | |||||||
| 88 | /** @var \XoopsMemberHandler $memberHandler */ |
||||||
| 89 | $memberHandler = xoops_getHandler('member'); |
||||||
| 90 | $group_list = $memberHandler->getGroupList(); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 91 | /** @var \XoopsMemberHandler $memberHandler */ |
||||||
| 92 | $memberHandler = xoops_getHandler('member'); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 93 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||||||
| 94 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
| 95 | $groups = $grouppermHandler->getGroupIds('XTubeCatPerm', $cid, $xoopsModule->getVar('mid')); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 96 | } else { |
||||||
| 97 | $groups = true; |
||||||
| 98 | } |
||||||
| 99 | echo '<br><br>'; |
||||||
| 100 | $sform = new \XoopsThemeForm($heading, 'op', xoops_getenv('SCRIPT_NAME'), 'post', true); |
||||||
| 101 | $sform->setExtra('enctype="multipart/form-data"'); |
||||||
| 102 | |||||||
| 103 | $sform->addElement(new \XoopsFormText(_AM_XOOPSTUBE_FCATEGORY_TITLE, 'title', 50, 80, $title), true); |
||||||
| 104 | $sform->addElement(new \XoopsFormText(_AM_XOOPSTUBE_FCATEGORY_WEIGHT, 'weight', 10, 80, $weight), false); |
||||||
| 105 | |||||||
| 106 | if ($totalcats > 0 && $cid) { |
||||||
| 107 | $mytreechose = new Tree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
||||||
| 108 | ob_start(); |
||||||
| 109 | $mytreechose->makeMySelBox('title', 'title', $cat_arr['pid'], 1, 'pid'); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 110 | $sform->addElement(new \XoopsFormLabel(_AM_XOOPSTUBE_FCATEGORY_SUBCATEGORY, ob_get_clean())); |
||||||
| 111 | } else { |
||||||
| 112 | $mytreechose = new Tree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
||||||
| 113 | ob_start(); |
||||||
| 114 | $mytreechose->makeMySelBox('title', 'title', $cid, 1, 'pid'); |
||||||
| 115 | $sform->addElement(new \XoopsFormLabel(_AM_XOOPSTUBE_FCATEGORY_SUBCATEGORY, ob_get_clean())); |
||||||
| 116 | } |
||||||
| 117 | |||||||
| 118 | $graph_array = Lists::getListTypeAsArray(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['catimage'], $type = 'images'); |
||||||
| 119 | $indexImageSelect = new \XoopsFormSelect('', 'imgurl', $imgurl); |
||||||
| 120 | $indexImageSelect->addOptionArray($graph_array); |
||||||
| 121 | $indexImageSelect->setExtra("onchange='showImgSelected(\"image\", \"imgurl\", \"" . $GLOBALS['xoopsModuleConfig']['catimage'] . '", "", "' . XOOPS_URL . "\")'"); |
||||||
| 122 | $indeximage_tray = new \XoopsFormElementTray(_AM_XOOPSTUBE_FCATEGORY_CIMAGE, ' '); |
||||||
| 123 | $indeximage_tray->addElement($indexImageSelect); |
||||||
| 124 | if ('' !== $imgurl && 1 != $imgurl) { |
||||||
| 125 | $indeximage_tray->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['catimage'] . '/' . $imgurl . "' name='image' id='image' alt=''>")); |
||||||
| 126 | } else { |
||||||
| 127 | $indeximage_tray->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . "/uploads/blank.gif' name='image' id='image' alt=''>")); |
||||||
| 128 | } |
||||||
| 129 | $sform->addElement($indeximage_tray); |
||||||
| 130 | |||||||
| 131 | // $editor = xtube_getWysiwygForm(_AM_XOOPSTUBE_FCATEGORY_DESCRIPTION, 'description', $description, 15, 60, ''); |
||||||
| 132 | // $sform->addElement($editor, false); |
||||||
| 133 | |||||||
| 134 | $optionsTrayNote = new \XoopsFormElementTray(_AM_XOOPSTUBE_FCATEGORY_DESCRIPTION, '<br>'); |
||||||
| 135 | if (class_exists('XoopsFormEditor')) { |
||||||
| 136 | $options['name'] = 'description'; |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 137 | $options['value'] = $description; |
||||||
| 138 | $options['rows'] = 5; |
||||||
| 139 | $options['cols'] = '100%'; |
||||||
| 140 | $options['width'] = '100%'; |
||||||
| 141 | $options['height'] = '200px'; |
||||||
| 142 | $editor = new \XoopsFormEditor('', $GLOBALS['xoopsModuleConfig']['form_optionsuser'], $options, $nohtml = false, $onfailure = 'textarea'); |
||||||
| 143 | $optionsTrayNote->addElement($editor); |
||||||
| 144 | } else { |
||||||
| 145 | $editor = new \XoopsFormDhtmlTextArea('', 'description', $item->getVar('description', 'e'), '100%', '100%'); |
||||||
|
0 ignored issues
–
show
'100%' of type string is incompatible with the type integer expected by parameter $cols of XoopsFormDhtmlTextArea::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
Comprehensibility
Best Practice
introduced
by
'100%' of type string is incompatible with the type integer expected by parameter $rows of XoopsFormDhtmlTextArea::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 146 | $optionsTrayNote->addElement($editor); |
||||||
| 147 | } |
||||||
| 148 | |||||||
| 149 | $sform->addElement($optionsTrayNote, false); |
||||||
| 150 | |||||||
| 151 | // Select Client/Sponsor |
||||||
| 152 | $client_select = new \XoopsFormSelect(_AM_XOOPSTUBE_CATSPONSOR, 'client_id', $client_id, false); |
||||||
|
0 ignored issues
–
show
false of type false is incompatible with the type integer expected by parameter $size of XoopsFormSelect::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 153 | $sql = 'SELECT cid, name FROM ' . $GLOBALS['xoopsDB']->prefix('bannerclient') . ' ORDER BY name ASC'; |
||||||
| 154 | $result = $GLOBALS['xoopsDB']->query($sql); |
||||||
| 155 | $client_array = []; |
||||||
| 156 | $client_array[0] = ' '; |
||||||
| 157 | while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
| 158 | $client_array[$myrow['cid']] = $myrow['name']; |
||||||
| 159 | } |
||||||
| 160 | $client_select->addOptionArray($client_array); |
||||||
| 161 | |||||||
| 162 | $client_select->setDescription(_AM_XOOPSTUBE_CATSPONSORDSC); |
||||||
| 163 | $sform->addElement($client_select); |
||||||
| 164 | |||||||
| 165 | // Select Banner |
||||||
| 166 | $banner_select = new \XoopsFormSelect(_AM_XOOPSTUBE_BANNERID, 'banner_id', $banner_id, false); |
||||||
| 167 | $sql = 'SELECT bid, cid FROM ' . $GLOBALS['xoopsDB']->prefix('banner') . ' ORDER BY bid ASC'; |
||||||
| 168 | $result = $GLOBALS['xoopsDB']->query($sql); |
||||||
| 169 | $banner_array = []; |
||||||
| 170 | $banner_array[0] = ' '; |
||||||
| 171 | while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||||||
| 172 | $banner_array[$myrow['bid']] = $myrow['bid']; |
||||||
| 173 | } |
||||||
| 174 | $banner_select->addOptionArray($banner_array); |
||||||
| 175 | $banner_select->setDescription(_AM_XOOPSTUBE_BANNERIDDSC); |
||||||
| 176 | $sform->addElement($banner_select); |
||||||
| 177 | |||||||
| 178 | $options_tray = new \XoopsFormElementTray(_AM_XOOPSTUBE_TEXTOPTIONS, '<br>'); |
||||||
| 179 | |||||||
| 180 | $html_checkbox = new \XoopsFormCheckBox('', 'nohtml', $nohtml); |
||||||
| 181 | $html_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLEHTML); |
||||||
| 182 | $options_tray->addElement($html_checkbox); |
||||||
| 183 | |||||||
| 184 | $smiley_checkbox = new \XoopsFormCheckBox('', 'nosmiley', $nosmiley); |
||||||
| 185 | $smiley_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLESMILEY); |
||||||
| 186 | $options_tray->addElement($smiley_checkbox); |
||||||
| 187 | |||||||
| 188 | $xcodes_checkbox = new \XoopsFormCheckBox('', 'noxcodes', $noxcodes); |
||||||
| 189 | $xcodes_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLEXCODE); |
||||||
| 190 | $options_tray->addElement($xcodes_checkbox); |
||||||
| 191 | |||||||
| 192 | $noimages_checkbox = new \XoopsFormCheckBox('', 'noimages', $noimages); |
||||||
| 193 | $noimages_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLEIMAGES); |
||||||
| 194 | $options_tray->addElement($noimages_checkbox); |
||||||
| 195 | |||||||
| 196 | $breaks_checkbox = new \XoopsFormCheckBox('', 'nobreak', $nobreak); |
||||||
| 197 | $breaks_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLEBREAK); |
||||||
| 198 | $options_tray->addElement($breaks_checkbox); |
||||||
| 199 | $sform->addElement($options_tray); |
||||||
| 200 | |||||||
| 201 | // $sform -> addElement(new \XoopsFormSelectGroup(_AM_XOOPSTUBE_FCATEGORY_GROUPPROMPT, "groups", true, $groups, 5, true)); |
||||||
| 202 | |||||||
| 203 | $sform->addElement(new \XoopsFormHidden('cid', (int)$cid)); |
||||||
| 204 | |||||||
| 205 | $sform->addElement(new \XoopsFormHidden('spotlighttop', (int)$cid)); |
||||||
| 206 | |||||||
| 207 | $buttonTray = new \XoopsFormElementTray('', ''); |
||||||
| 208 | $hidden = new \XoopsFormHidden('op', 'save'); |
||||||
| 209 | $buttonTray->addElement($hidden); |
||||||
| 210 | |||||||
| 211 | if (!$cid) { |
||||||
| 212 | $butt_create = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BSAVE, 'submit'); |
||||||
| 213 | $butt_create->setExtra('onclick="this.form.elements.op.value=\'addCat\'"'); |
||||||
| 214 | $buttonTray->addElement($butt_create); |
||||||
| 215 | |||||||
| 216 | $butt_clear = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BRESET, 'reset'); |
||||||
| 217 | $buttonTray->addElement($butt_clear); |
||||||
| 218 | |||||||
| 219 | $butt_cancel = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BCANCEL, 'button'); |
||||||
| 220 | $butt_cancel->setExtra('onclick="history.go(-1)"'); |
||||||
| 221 | $buttonTray->addElement($butt_cancel); |
||||||
| 222 | } else { |
||||||
| 223 | $butt_create = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BMODIFY, 'submit'); |
||||||
| 224 | $butt_create->setExtra('onclick="this.form.elements.op.value=\'addCat\'"'); |
||||||
| 225 | $buttonTray->addElement($butt_create); |
||||||
| 226 | |||||||
| 227 | $butt_delete = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETE, 'submit'); |
||||||
| 228 | $butt_delete->setExtra('onclick="this.form.elements.op.value=\'del\'"'); |
||||||
| 229 | $buttonTray->addElement($butt_delete); |
||||||
| 230 | |||||||
| 231 | $butt_cancel = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BCANCEL, 'button'); |
||||||
| 232 | $butt_cancel->setExtra('onclick="history.go(-1)"'); |
||||||
| 233 | $buttonTray->addElement($butt_cancel); |
||||||
| 234 | } |
||||||
| 235 | $sform->addElement($buttonTray); |
||||||
| 236 | $sform->display(); |
||||||
| 237 | |||||||
| 238 | $result2 = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat')); |
||||||
| 239 | [$numrows] = $GLOBALS['xoopsDB']->fetchRow($result2); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 240 | } |
||||||
| 241 | |||||||
| 242 | /* |
||||||
| 243 | if (!isset($_POST['op'])) { |
||||||
| 244 | $op = isset($_GET['op']) ? $_GET['op'] : 'main'; |
||||||
| 245 | } else { |
||||||
| 246 | $op = isset($_POST['op']) ? $_POST['op'] : 'main'; |
||||||
| 247 | } |
||||||
| 248 | */ |
||||||
| 249 | |||||||
| 250 | $op = Request::getString('op', Request::getString('op', 'main', 'POST'), 'GET'); |
||||||
| 251 | |||||||
| 252 | switch ($op) { |
||||||
| 253 | case 'move': |
||||||
| 254 | if (!Request::hasVar('ok', 'POST')) { |
||||||
| 255 | $cid = Request::getInt('cid', Request::getInt('cid', 0, 'GET'), 'POST'); //(isset($_POST['cid'])) ? $_POST['cid'] : $_GET['cid']; |
||||||
| 256 | |||||||
| 257 | xoops_cp_header(); |
||||||
| 258 | //renderAdminMenu(_AM_XOOPSTUBE_MCATEGORY); |
||||||
| 259 | |||||||
| 260 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||||
| 261 | $xoopstubetree = new Tree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
||||||
| 262 | $sform = new \XoopsThemeForm(_AM_XOOPSTUBE_CCATEGORY_MOVE, 'move', xoops_getenv('SCRIPT_NAME'), 'post', true); |
||||||
| 263 | ob_start(); |
||||||
| 264 | $xoopstubetree->makeMySelBox('title', 'title', 0, 0, 'target'); |
||||||
| 265 | $sform->addElement(new \XoopsFormLabel(_AM_XOOPSTUBE_BMODIFY, ob_get_clean())); |
||||||
| 266 | $create_tray = new \XoopsFormElementTray('', ''); |
||||||
| 267 | $create_tray->addElement(new \XoopsFormHidden('source', $cid)); |
||||||
| 268 | $create_tray->addElement(new \XoopsFormHidden('ok', 1)); |
||||||
| 269 | $create_tray->addElement(new \XoopsFormHidden('op', 'move')); |
||||||
| 270 | $butt_save = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BMOVE, 'submit'); |
||||||
| 271 | $butt_save->setExtra('onclick="this.form.elements.op.value=\'move\'"'); |
||||||
| 272 | $create_tray->addElement($butt_save); |
||||||
| 273 | $butt_cancel = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BCANCEL, 'submit'); |
||||||
| 274 | $butt_cancel->setExtra('onclick="this.form.elements.op.value=\'cancel\'"'); |
||||||
| 275 | $create_tray->addElement($butt_cancel); |
||||||
| 276 | $sform->addElement($create_tray); |
||||||
| 277 | $sform->display(); |
||||||
| 278 | xoops_cp_footer(); |
||||||
| 279 | } else { |
||||||
| 280 | $source = Request::getString('source', '', 'POST'); //$_POST['source']; |
||||||
| 281 | $target = Request::getString('target', '', 'POST'); //$_POST['target']; |
||||||
| 282 | if ($target === $source) { |
||||||
| 283 | redirect_header("category.php?op=move&ok=0&cid=$source", 5, _AM_XOOPSTUBE_CCATEGORY_MODIFY_FAILED); |
||||||
| 284 | } |
||||||
| 285 | if (!$target) { |
||||||
| 286 | redirect_header("category.php?op=move&ok=0&cid=$source", 5, _AM_XOOPSTUBE_CCATEGORY_MODIFY_FAILEDT); |
||||||
| 287 | } |
||||||
| 288 | $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' set cid = ' . $target . ' WHERE cid =' . $source; |
||||||
| 289 | $result = $GLOBALS['xoopsDB']->queryF($sql); |
||||||
| 290 | $error = _AM_XOOPSTUBE_DBERROR . ': <br><br>' . $sql; |
||||||
| 291 | if (!$result) { |
||||||
| 292 | trigger_error($error, E_USER_ERROR); |
||||||
| 293 | } |
||||||
| 294 | redirect_header('category.php?op=default', 1, _AM_XOOPSTUBE_CCATEGORY_MODIFY_MOVED); |
||||||
| 295 | } |
||||||
| 296 | break; |
||||||
| 297 | case 'addCat': |
||||||
| 298 | |||||||
| 299 | $groups = Request::getArray('groups', [], 'POST'); //isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(); |
||||||
| 300 | $cid = Request::getInt('cid', 0, 'POST'); //(isset($_REQUEST['cid'])) ? $_REQUEST['cid'] : 0; |
||||||
| 301 | $pid = Request::getInt('pid', 0, 'POST'); //(isset($_REQUEST['pid'])) ? $_REQUEST['pid'] : 0; |
||||||
| 302 | $weight = (Request::getInt('weight', 0, 'POST') > 0) ? Request::getInt('weight', 0, 'POST') : 0; //(isset($_REQUEST['weight']) && $_REQUEST['weight'] > 0) ? $_REQUEST['weight'] : 0; |
||||||
| 303 | $spotlighthis = Request::getInt('lid', 0, 'POST'); //(isset($_REQUEST['lid'])) ? $_REQUEST['lid'] : 0; |
||||||
| 304 | $spotlighttop = (1 == Request::getInt('spotlighttop', 0, 'POST')) ? 1 : 0; //($_REQUEST['spotlighttop'] == 1) ? 1 : 0; |
||||||
| 305 | $title = Request::getString('title', '', 'POST'); //$myts->addslashes($_REQUEST['title']); |
||||||
| 306 | $descriptionb = Request::getString('description', '', 'POST'); //$myts->addslashes($_REQUEST['description']); |
||||||
| 307 | $imgurl = Request::getString('imgurl', '', 'POST'); // $_REQUEST['imgurl'] && $_REQUEST['imgurl'] != 'blank.gif') ? $myts->addslashes($_REQUEST['imgurl']) : ''; |
||||||
| 308 | $client_id = Request::getInt('client_id', 0, 'POST'); //(isset($_REQUEST['client_id'])) ? $_REQUEST['client_id'] : 0; |
||||||
| 309 | if ($client_id > 0) { |
||||||
| 310 | $banner_id = 0; |
||||||
| 311 | } else { |
||||||
| 312 | $banner_id = Request::getInt('banner_id', 0, 'POST'); //(isset($_REQUEST['banner_id'])) ? $_REQUEST['banner_id'] : 0; |
||||||
| 313 | } |
||||||
| 314 | $nohtml = Request::getInt('nohtml', 0, 'POST'); //isset($_REQUEST['nohtml']) ? $_REQUEST['nohtml'] : 0; |
||||||
| 315 | $nosmiley = Request::getInt('nosmiley', 0, 'POST'); //isset($_REQUEST['nosmiley']) ? $_REQUEST['nosmiley'] : 0; |
||||||
| 316 | $noxcodes = Request::getInt('noxcodes', 0, 'POST'); //isset($_REQUEST['noxcodes']) ? $_REQUEST['noxcodes'] : 0; |
||||||
| 317 | $noimages = Request::getInt('noimages', 0, 'POST'); //isset($_REQUEST['noimages']) ? $_REQUEST['noimages'] : 0; |
||||||
| 318 | $nobreak = Request::getInt('nobreak', 0, 'POST'); //isset($_REQUEST['nobreak']) ? $_REQUEST['nobreak'] : 0; |
||||||
| 319 | |||||||
| 320 | if (!$cid) { |
||||||
| 321 | $cid = 0; |
||||||
| 322 | $sql = 'INSERT INTO ' |
||||||
| 323 | . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') |
||||||
| 324 | . " (cid, pid, title, imgurl, description, nohtml, nosmiley, noxcodes, noimages, nobreak, weight, spotlighttop, spotlighthis, client_id, banner_id ) VALUES ($cid, $pid, '$title', '$imgurl', '$descriptionb', '$nohtml', '$nosmiley', '$noxcodes', '$noimages', '$nobreak', '$weight', $spotlighttop, $spotlighthis, $client_id, $banner_id )"; |
||||||
| 325 | if (0 == $cid) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 326 | $newid = $GLOBALS['xoopsDB']->getInsertId(); |
||||||
| 327 | } |
||||||
| 328 | |||||||
| 329 | // Notify of new category |
||||||
| 330 | |||||||
| 331 | global $xoopsModule; |
||||||
| 332 | $tags = []; |
||||||
| 333 | $tags['CATEGORY_NAME'] = $title; |
||||||
| 334 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $newid; |
||||||
| 335 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||||||
| 336 | $notificationHandler = xoops_getHandler('notification'); |
||||||
| 337 | $notificationHandler->triggerEvent('global', 0, 'new_category', $tags); |
||||||
| 338 | $database_mess = _AM_XOOPSTUBE_CCATEGORY_CREATED; |
||||||
| 339 | } else { |
||||||
| 340 | if ($cid == $pid) { |
||||||
| 341 | redirect_header('category.php', 1, _AM_XOOPSTUBE_ERROR_CATISCAT); |
||||||
| 342 | } |
||||||
| 343 | $sql = 'UPDATE ' |
||||||
| 344 | . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') |
||||||
| 345 | . " SET title ='$title', imgurl='$imgurl', pid =$pid, description='$descriptionb', spotlighthis='$spotlighthis' , spotlighttop='$spotlighttop', nohtml='$nohtml', nosmiley='$nosmiley', noxcodes='$noxcodes', noimages='$noimages', nobreak='$nobreak', weight='$weight', client_id='$client_id', banner_id='$banner_id' WHERE cid=" |
||||||
| 346 | . $cid; |
||||||
| 347 | $database_mess = _AM_XOOPSTUBE_CCATEGORY_MODIFIED; |
||||||
| 348 | } |
||||||
| 349 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||||||
| 350 | /** @var \XoopsLogger $logger */ |
||||||
| 351 | $logger = \XoopsLogger::getInstance(); |
||||||
| 352 | $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__); |
||||||
| 353 | |||||||
| 354 | return false; |
||||||
| 355 | } |
||||||
| 356 | redirect_header('category.php', 1, $database_mess); |
||||||
| 357 | break; |
||||||
| 358 | case 'del': |
||||||
| 359 | |||||||
| 360 | global $xoopsModule; |
||||||
| 361 | |||||||
| 362 | // $cid = (isset($_POST['cid']) && is_numeric($_POST['cid'])) ? (int) $_POST['cid'] : (int) $_GET['cid']; |
||||||
| 363 | $cid = Request::getInt('cid', Request::getInt('cid', 0, 'GET'), 'POST'); |
||||||
| 364 | // $ok = (isset($_POST['ok']) && $_POST['ok'] == 1) ? (int) $_POST['ok'] : 0; |
||||||
| 365 | $ok = (1 == Request::getInt('ok', 0, 'POST')) ? 1 : 0; |
||||||
| 366 | $xoopstubetree = new Tree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
||||||
| 367 | |||||||
| 368 | if (1 == $ok) { |
||||||
| 369 | // get all subcategories under the specified category |
||||||
| 370 | $arr = $xoopstubetree->getAllChildId($cid); |
||||||
| 371 | $lcount = count($arr); |
||||||
| 372 | |||||||
| 373 | for ($i = 0; $i < $lcount; ++$i) { |
||||||
| 374 | // get all links in each subcategory |
||||||
| 375 | $result = $GLOBALS['xoopsDB']->query('SELECT lid FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE cid=' . (int)$arr[$i]); |
||||||
| 376 | // now for each linkload, delete the text data and vote ata associated with the linkload |
||||||
| 377 | while (list($lid) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
||||||
| 378 | $sql = sprintf('DELETE FROM `%s` WHERE lid = %u', $GLOBALS['xoopsDB']->prefix('xoopstube_votedata'), (int)$lid); |
||||||
| 379 | $GLOBALS['xoopsDB']->query($sql); |
||||||
| 380 | $sql = sprintf('DELETE FROM `%s` WHERE lid = %u', $GLOBALS['xoopsDB']->prefix('xoopstube_videos'), (int)$lid); |
||||||
| 381 | $GLOBALS['xoopsDB']->query($sql); |
||||||
| 382 | |||||||
| 383 | // delete comments |
||||||
| 384 | xoops_comment_delete($xoopsModule->getVar('mid'), $lid); |
||||||
| 385 | } |
||||||
| 386 | // all links for each subcategory is deleted, now delete the subcategory data |
||||||
| 387 | $sql = sprintf('DELETE FROM `%s` WHERE cid = %u', $GLOBALS['xoopsDB']->prefix('xoopstube_cat'), (int)$arr[$i]); |
||||||
| 388 | $GLOBALS['xoopsDB']->query($sql); |
||||||
| 389 | // delete altcat entries |
||||||
| 390 | $sql = sprintf('DELETE FROM `%s` WHERE cid = %u', $GLOBALS['xoopsDB']->prefix('xoopstube_altcat'), $arr[$i]); |
||||||
| 391 | $GLOBALS['xoopsDB']->query($sql); |
||||||
| 392 | } |
||||||
| 393 | // all subcategory and associated data are deleted, now delete category data and its associated data |
||||||
| 394 | $result = $GLOBALS['xoopsDB']->query('SELECT lid FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE cid=' . $cid); |
||||||
| 395 | while (list($lid) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
||||||
| 396 | $sql = sprintf('DELETE FROM `%s` WHERE lid = %u', $GLOBALS['xoopsDB']->prefix('xoopstube_videos'), (int)$lid); |
||||||
| 397 | $GLOBALS['xoopsDB']->query($sql); |
||||||
| 398 | // delete comments |
||||||
| 399 | xoops_comment_delete($xoopsModule->getVar('mid'), (int)$lid); |
||||||
| 400 | $sql = sprintf('DELETE FROM `%s` WHERE lid = %u', $GLOBALS['xoopsDB']->prefix('xoopstube_votedata'), (int)$lid); |
||||||
| 401 | $GLOBALS['xoopsDB']->query($sql); |
||||||
| 402 | } |
||||||
| 403 | |||||||
| 404 | // delete altcat entries |
||||||
| 405 | $sql = sprintf('DELETE FROM `%s` WHERE cid = %u', $GLOBALS['xoopsDB']->prefix('xoopstube_altcat'), $cid); |
||||||
| 406 | $GLOBALS['xoopsDB']->query($sql); |
||||||
| 407 | |||||||
| 408 | // delete category |
||||||
| 409 | $sql = sprintf('DELETE FROM `%s` WHERE cid = %u', $GLOBALS['xoopsDB']->prefix('xoopstube_cat'), $cid); |
||||||
| 410 | $error = _AM_XOOPSTUBE_DBERROR . ': <br><br>' . $sql; |
||||||
| 411 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeCatPerm', $cid); |
||||||
| 412 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||||||
| 413 | trigger_error($error, E_USER_ERROR); |
||||||
| 414 | } |
||||||
| 415 | |||||||
| 416 | // delete group permissions |
||||||
| 417 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeCatPerm', $cid); |
||||||
| 418 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||||||
| 419 | trigger_error($error, E_USER_ERROR); |
||||||
| 420 | } |
||||||
| 421 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeSubPerm', $cid); |
||||||
| 422 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||||||
| 423 | trigger_error($error, E_USER_ERROR); |
||||||
| 424 | } |
||||||
| 425 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeAppPerm', $cid); |
||||||
| 426 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||||||
| 427 | trigger_error($error, E_USER_ERROR); |
||||||
| 428 | } |
||||||
| 429 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeAutoApp', $cid); |
||||||
| 430 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||||||
| 431 | trigger_error($error, E_USER_ERROR); |
||||||
| 432 | } |
||||||
| 433 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeRatePerms', $cid); |
||||||
| 434 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||||||
| 435 | trigger_error($error, E_USER_ERROR); |
||||||
| 436 | } |
||||||
| 437 | |||||||
| 438 | redirect_header('category.php', 1, _AM_XOOPSTUBE_CCATEGORY_DELETED); |
||||||
| 439 | } else { |
||||||
| 440 | xoops_cp_header(); |
||||||
| 441 | xoops_confirm( |
||||||
| 442 | [ |
||||||
| 443 | 'op' => 'del', |
||||||
| 444 | 'cid' => $cid, |
||||||
| 445 | 'ok' => 1, |
||||||
| 446 | ], |
||||||
| 447 | 'category.php', |
||||||
| 448 | _AM_XOOPSTUBE_CCATEGORY_AREUSURE |
||||||
| 449 | ); |
||||||
| 450 | xoops_cp_footer(); |
||||||
| 451 | } |
||||||
| 452 | break; |
||||||
| 453 | case 'modCat': |
||||||
| 454 | $cid = Request::getInt('cid', 0, 'POST'); //(isset($_POST['cid'])) ? $_POST['cid'] : 0; |
||||||
| 455 | xoops_cp_header(); |
||||||
| 456 | //renderAdminMenu(_AM_XOOPSTUBE_MCATEGORY); |
||||||
| 457 | createCategory($cid); |
||||||
| 458 | require_once __DIR__ . '/admin_footer.php'; |
||||||
| 459 | break; |
||||||
| 460 | case 'main': |
||||||
| 461 | default: |
||||||
| 462 | xoops_cp_header(); |
||||||
| 463 | //renderAdminMenu(_AM_XOOPSTUBE_MCATEGORY); |
||||||
| 464 | |||||||
| 465 | // require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||||
| 466 | $xoopstubetree = new Tree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
||||||
| 467 | $sform = new \XoopsThemeForm(_AM_XOOPSTUBE_CCATEGORY_MODIFY, 'category', xoops_getenv('SCRIPT_NAME'), 'post', true); |
||||||
| 468 | $totalcats = Utility::getTotalCategoryCount(); |
||||||
| 469 | |||||||
| 470 | if ($totalcats > 0) { |
||||||
| 471 | ob_start(); |
||||||
| 472 | $xoopstubetree->makeMySelBox('title', 'title'); |
||||||
| 473 | $sform->addElement(new \XoopsFormLabel(_AM_XOOPSTUBE_CCATEGORY_MODIFY_TITLE, ob_get_clean())); |
||||||
| 474 | $dup_tray = new \XoopsFormElementTray('', ''); |
||||||
| 475 | $dup_tray->addElement(new \XoopsFormHidden('op', 'modCat')); |
||||||
| 476 | $butt_dup = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BMODIFY, 'submit'); |
||||||
| 477 | $butt_dup->setExtra('onclick="this.form.elements.op.value=\'modCat\'"'); |
||||||
| 478 | $dup_tray->addElement($butt_dup); |
||||||
| 479 | $butt_move = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BMOVE, 'submit'); |
||||||
| 480 | $butt_move->setExtra('onclick="this.form.elements.op.value=\'move\'"'); |
||||||
| 481 | $dup_tray->addElement($butt_move); |
||||||
| 482 | $butt_dupct = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETE, 'submit'); |
||||||
| 483 | $butt_dupct->setExtra('onclick="this.form.elements.op.value=\'del\'"'); |
||||||
| 484 | $dup_tray->addElement($butt_dupct); |
||||||
| 485 | $sform->addElement($dup_tray); |
||||||
| 486 | $sform->display(); |
||||||
| 487 | } |
||||||
| 488 | createCategory(0); |
||||||
| 489 | require_once __DIR__ . '/admin_footer.php'; |
||||||
| 490 | break; |
||||||
| 491 | } |
||||||
| 492 |