XoopsModules25x /
xoopstube
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 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 | * @Version $Id: category.php v 1.00 21 June 2005 John N Exp $ |
||
| 12 | * @Module WF-Links |
||
| 13 | * @Version v1.0.3 |
||
| 14 | * @Release Date: 21 June 2005 |
||
| 15 | * @Developer John N |
||
| 16 | * @Team WF-Projects |
||
| 17 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
| 18 | */ |
||
| 19 | |||
| 20 | include_once __DIR__ . '/admin_header.php'; |
||
| 21 | include_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
||
| 22 | |||
| 23 | $op = ''; |
||
| 24 | |||
| 25 | if (isset($_POST)) { |
||
| 26 | foreach ($_POST as $k => $v) { |
||
| 27 | ${$k} = $v; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | if (isset($_GET)) { |
||
| 32 | foreach ($_GET as $k => $v) { |
||
| 33 | ${$k} = $v; |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param int $cid |
||
| 39 | */ |
||
| 40 | function createCategory($cid = 0) |
||
| 41 | { |
||
| 42 | include_once dirname(__DIR__) . '/class/xoopstube_lists.php'; |
||
| 43 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 44 | |||
| 45 | global $xoopsDB, $xtubemyts, $xoopsModuleConfig, $totalcats, $xoopsModule; |
||
| 46 | |||
| 47 | $lid = 0; |
||
| 48 | $title = ''; |
||
| 49 | $imgurl = ''; |
||
| 50 | $description = ''; |
||
| 51 | $pid = ''; |
||
| 52 | $weight = 0; |
||
| 53 | $nohtml = 0; |
||
| 54 | $nosmiley = 0; |
||
| 55 | $noxcodes = 0; |
||
| 56 | $noimages = 0; |
||
| 57 | $nobreak = 1; |
||
| 58 | $spotlighttop = 0; |
||
| 59 | $spotlighthis = 0; |
||
| 60 | $client_id = 0; |
||
| 61 | $banner_id = 0; |
||
| 62 | $heading = _AM_XOOPSTUBE_CCATEGORY_CREATENEW; |
||
| 63 | $totalcats = xtubeGetTotalCategoryCount(); |
||
| 64 | |||
| 65 | if ($cid > 0) { |
||
| 66 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_cat') . ' WHERE cid=' . intval($cid); |
||
| 67 | $cat_arr = $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||
| 68 | $title = $xtubemyts->htmlSpecialChars($cat_arr['title']); |
||
| 69 | $imgurl = $xtubemyts->htmlSpecialChars($cat_arr['imgurl']); |
||
| 70 | $description = $xtubemyts->htmlSpecialChars($cat_arr['description']); |
||
| 71 | $nohtml = intval($cat_arr['nohtml']); |
||
| 72 | $nosmiley = intval($cat_arr['nosmiley']); |
||
| 73 | $noxcodes = intval($cat_arr['noxcodes']); |
||
| 74 | $noimages = intval($cat_arr['noimages']); |
||
| 75 | $nobreak = intval($cat_arr['nobreak']); |
||
| 76 | $spotlighthis = intval($cat_arr['spotlighthis']); |
||
| 77 | $spotlighttop = intval($cat_arr['spotlighttop']); |
||
| 78 | $weight = $cat_arr['weight']; |
||
| 79 | $client_id = $cat_arr['client_id']; |
||
| 80 | $banner_id = $cat_arr['banner_id']; |
||
| 81 | $heading = _AM_XOOPSTUBE_CCATEGORY_MODIFY; |
||
| 82 | |||
| 83 | $member_handler = & xoops_gethandler('member'); |
||
| 84 | $group_list = & $member_handler->getGroupList(); |
||
| 85 | |||
| 86 | $gperm_handler = & xoops_gethandler('groupperm'); |
||
| 87 | $groups = $gperm_handler->getGroupIds('XTubeCatPerm', $cid, $xoopsModule->getVar('mid')); |
||
| 88 | // $groups = $groups; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 89 | } else { |
||
| 90 | $groups = true; |
||
| 91 | } |
||
| 92 | echo '<br /><br />'; |
||
| 93 | $sform = new XoopsThemeForm($heading, 'op', xoops_getenv('PHP_SELF')); |
||
| 94 | $sform->setExtra('enctype="multipart/form-data"'); |
||
| 95 | |||
| 96 | $sform->addElement(new XoopsFormText(_AM_XOOPSTUBE_FCATEGORY_TITLE, 'title', 50, 80, $title), true); |
||
| 97 | $sform->addElement(new XoopsFormText(_AM_XOOPSTUBE_FCATEGORY_WEIGHT, 'weight', 10, 80, $weight), false); |
||
| 98 | |||
| 99 | if ($totalcats > 0 && $cid) { |
||
| 100 | $mytreechose = new XoopstubeTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
| 101 | ob_start(); |
||
| 102 | $mytreechose->makeMySelBox('title', 'title', $cat_arr['pid'], 1, 'pid'); |
||
| 103 | $sform->addElement(new XoopsFormLabel(_AM_XOOPSTUBE_FCATEGORY_SUBCATEGORY, ob_get_contents())); |
||
| 104 | ob_end_clean(); |
||
| 105 | } else { |
||
| 106 | $mytreechose = new XoopstubeTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
| 107 | ob_start(); |
||
| 108 | $mytreechose->makeMySelBox('title', 'title', $cid, 1, 'pid'); |
||
| 109 | $sform->addElement(new XoopsFormLabel(_AM_XOOPSTUBE_FCATEGORY_SUBCATEGORY, ob_get_contents())); |
||
| 110 | ob_end_clean(); |
||
| 111 | } |
||
| 112 | |||
| 113 | $graph_array = & XoopstubeLists::getListTypeAsArray( |
||
| 114 | XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['catimage'], |
||
| 115 | $type = 'images' |
||
| 116 | ); |
||
| 117 | $indeximage_select = new XoopsFormSelect('', 'imgurl', $imgurl); |
||
| 118 | $indeximage_select->addOptionArray($graph_array); |
||
| 119 | $indeximage_select->setExtra( |
||
| 120 | "onchange='showImgSelected(\"image\", \"imgurl\", \"" . $xoopsModuleConfig['catimage'] . "\", \"\", \"" . XOOPS_URL . "\")'" |
||
| 121 | ); |
||
| 122 | $indeximage_tray = new XoopsFormElementTray(_AM_XOOPSTUBE_FCATEGORY_CIMAGE, ' '); |
||
| 123 | $indeximage_tray->addElement($indeximage_select); |
||
| 124 | View Code Duplication | if (!empty($imgurl)) { |
|
| 125 | $indeximage_tray->addElement( |
||
| 126 | new XoopsFormLabel( |
||
| 127 | '', "<br /><br /><img src='" . XOOPS_URL . "/" . $xoopsModuleConfig['catimage'] . "/" . $imgurl . "' name='image' id='image' alt='' />" |
||
| 128 | ) |
||
| 129 | ); |
||
| 130 | } else { |
||
| 131 | $indeximage_tray->addElement( |
||
| 132 | new XoopsFormLabel( |
||
| 133 | '', "<br /><br /><img src='" . XOOPS_URL . "/uploads/blank.gif' name='image' id='image' alt='' />" |
||
| 134 | ) |
||
| 135 | ); |
||
| 136 | } |
||
| 137 | $sform->addElement($indeximage_tray); |
||
| 138 | |||
| 139 | // $editor = xtube_getWysiwygForm(_AM_XOOPSTUBE_FCATEGORY_DESCRIPTION, 'description', $description, 15, 60, ''); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 140 | // $sform->addElement($editor, false); |
||
| 141 | |||
| 142 | $optionsTrayNote = new XoopsFormElementTray(_AM_XOOPSTUBE_FCATEGORY_DESCRIPTION, '<br />'); |
||
| 143 | View Code Duplication | if (class_exists('XoopsFormEditor')) { |
|
| 144 | $options['name'] = 'description'; |
||
| 145 | $options['value'] = $description; |
||
| 146 | $options['rows'] = 5; |
||
| 147 | $options['cols'] = '100%'; |
||
| 148 | $options['width'] = '100%'; |
||
| 149 | $options['height'] = '200px'; |
||
| 150 | $editor = new XoopsFormEditor('', $xoopsModuleConfig['form_optionsuser'], $options, $nohtml = false, $onfailure = 'textarea'); |
||
| 151 | $optionsTrayNote->addElement($editor); |
||
| 152 | } else { |
||
| 153 | $editor = new XoopsFormDhtmlTextArea( |
||
| 154 | '', 'description', $item->getVar( |
||
| 155 | 'description', |
||
| 156 | 'e' |
||
| 157 | ), '100%', '100%' |
||
| 158 | ); |
||
| 159 | $optionsTrayNote->addElement($editor); |
||
| 160 | } |
||
| 161 | |||
| 162 | $sform->addElement($optionsTrayNote, false); |
||
| 163 | |||
| 164 | // Select Client/Sponsor |
||
| 165 | $client_select = new XoopsFormSelect(_AM_XOOPSTUBE_CATSPONSOR, 'client_id', $client_id, false); |
||
| 166 | $sql = 'SELECT cid, name FROM ' . $xoopsDB->prefix('bannerclient') . ' ORDER BY name ASC'; |
||
| 167 | $result = $xoopsDB->query($sql); |
||
| 168 | $client_array = array(); |
||
| 169 | $client_array[0] = ' '; |
||
| 170 | while ($myrow = $xoopsDB->fetchArray($result)) { |
||
| 171 | $client_array[$myrow['cid']] = $myrow['name']; |
||
| 172 | } |
||
| 173 | $client_select->addOptionArray($client_array); |
||
| 174 | |||
| 175 | $client_select->setDescription(_AM_XOOPSTUBE_CATSPONSORDSC); |
||
| 176 | $sform->addElement($client_select); |
||
| 177 | |||
| 178 | // Select Banner |
||
| 179 | $banner_select = new XoopsFormSelect(_AM_XOOPSTUBE_BANNERID, 'banner_id', $banner_id, false); |
||
| 180 | $sql = 'SELECT bid, cid FROM ' . $xoopsDB->prefix('banner') . ' ORDER BY bid ASC'; |
||
| 181 | $result = $xoopsDB->query($sql); |
||
| 182 | $banner_array = array(); |
||
| 183 | $banner_array[0] = ' '; |
||
| 184 | while ($myrow = $xoopsDB->fetchArray($result)) { |
||
| 185 | $banner_array[$myrow['bid']] = $myrow['bid']; |
||
| 186 | } |
||
| 187 | $banner_select->addOptionArray($banner_array); |
||
| 188 | $banner_select->setDescription(_AM_XOOPSTUBE_BANNERIDDSC); |
||
| 189 | $sform->addElement($banner_select); |
||
| 190 | |||
| 191 | $options_tray = new XoopsFormElementTray(_AM_XOOPSTUBE_TEXTOPTIONS, '<br />'); |
||
| 192 | |||
| 193 | $html_checkbox = new XoopsFormCheckBox('', 'nohtml', $nohtml); |
||
| 194 | $html_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLEHTML); |
||
| 195 | $options_tray->addElement($html_checkbox); |
||
| 196 | |||
| 197 | $smiley_checkbox = new XoopsFormCheckBox('', 'nosmiley', $nosmiley); |
||
| 198 | $smiley_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLESMILEY); |
||
| 199 | $options_tray->addElement($smiley_checkbox); |
||
| 200 | |||
| 201 | $xcodes_checkbox = new XoopsFormCheckBox('', 'noxcodes', $noxcodes); |
||
| 202 | $xcodes_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLEXCODE); |
||
| 203 | $options_tray->addElement($xcodes_checkbox); |
||
| 204 | |||
| 205 | $noimages_checkbox = new XoopsFormCheckBox('', 'noimages', $noimages); |
||
| 206 | $noimages_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLEIMAGES); |
||
| 207 | $options_tray->addElement($noimages_checkbox); |
||
| 208 | |||
| 209 | $breaks_checkbox = new XoopsFormCheckBox('', 'nobreak', $nobreak); |
||
| 210 | $breaks_checkbox->addOption(1, _AM_XOOPSTUBE_DISABLEBREAK); |
||
| 211 | $options_tray->addElement($breaks_checkbox); |
||
| 212 | $sform->addElement($options_tray); |
||
| 213 | |||
| 214 | // $sform -> addElement(new XoopsFormSelectGroup(_AM_XOOPSTUBE_FCATEGORY_GROUPPROMPT, "groups", true, $groups, 5, true)); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 215 | |||
| 216 | $sform->addElement(new XoopsFormHidden('cid', intval($cid))); |
||
| 217 | |||
| 218 | $sform->addElement(new XoopsFormHidden('spotlighttop', intval($cid))); |
||
| 219 | |||
| 220 | $button_tray = new XoopsFormElementTray('', ''); |
||
| 221 | $hidden = new XoopsFormHidden('op', 'save'); |
||
| 222 | $button_tray->addElement($hidden); |
||
| 223 | |||
| 224 | if (!$cid) { |
||
| 225 | $butt_create = new XoopsFormButton('', '', _AM_XOOPSTUBE_BSAVE, 'submit'); |
||
| 226 | $butt_create->setExtra('onclick="this.form.elements.op.value=\'addCat\'"'); |
||
| 227 | $button_tray->addElement($butt_create); |
||
| 228 | |||
| 229 | $butt_clear = new XoopsFormButton('', '', _AM_XOOPSTUBE_BRESET, 'reset'); |
||
| 230 | $button_tray->addElement($butt_clear); |
||
| 231 | |||
| 232 | $butt_cancel = new XoopsFormButton('', '', _AM_XOOPSTUBE_BCANCEL, 'button'); |
||
| 233 | $butt_cancel->setExtra('onclick="history.go(-1)"'); |
||
| 234 | $button_tray->addElement($butt_cancel); |
||
| 235 | } else { |
||
| 236 | $butt_create = new XoopsFormButton('', '', _AM_XOOPSTUBE_BMODIFY, 'submit'); |
||
| 237 | $butt_create->setExtra('onclick="this.form.elements.op.value=\'addCat\'"'); |
||
| 238 | $button_tray->addElement($butt_create); |
||
| 239 | |||
| 240 | $butt_delete = new XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETE, 'submit'); |
||
| 241 | $butt_delete->setExtra('onclick="this.form.elements.op.value=\'del\'"'); |
||
| 242 | $button_tray->addElement($butt_delete); |
||
| 243 | |||
| 244 | $butt_cancel = new XoopsFormButton('', '', _AM_XOOPSTUBE_BCANCEL, 'button'); |
||
| 245 | $butt_cancel->setExtra('onclick="history.go(-1)"'); |
||
| 246 | $button_tray->addElement($butt_cancel); |
||
| 247 | } |
||
| 248 | $sform->addElement($button_tray); |
||
| 249 | $sform->display(); |
||
| 250 | |||
| 251 | $result2 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopstube_cat')); |
||
| 252 | list($numrows) = $xoopsDB->fetchRow($result2); |
||
| 253 | } |
||
| 254 | |||
| 255 | if (!isset($_POST['op'])) { |
||
| 256 | $op = isset($_GET['op']) ? $_GET['op'] : 'main'; |
||
| 257 | } else { |
||
| 258 | $op = isset($_POST['op']) ? $_POST['op'] : 'main'; |
||
| 259 | } |
||
| 260 | |||
| 261 | switch ($op) { |
||
| 262 | case 'move': |
||
| 263 | if (!isset($_POST['ok'])) { |
||
| 264 | $cid = (isset($_POST['cid'])) ? $_POST['cid'] : $_GET['cid']; |
||
| 265 | |||
| 266 | xoops_cp_header(); |
||
| 267 | //xtubeRenderAdminMenu(_AM_XOOPSTUBE_MCATEGORY); |
||
| 268 | |||
| 269 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 270 | $xoopstubetree = new XoopstubeTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
| 271 | $sform = new XoopsThemeForm(_AM_XOOPSTUBE_CCATEGORY_MOVE, 'move', xoops_getenv('PHP_SELF')); |
||
| 272 | ob_start(); |
||
| 273 | $xoopstubetree->makeMySelBox('title', 'title', 0, 0, 'target'); |
||
| 274 | $sform->addElement(new XoopsFormLabel(_AM_XOOPSTUBE_BMODIFY, ob_get_contents())); |
||
| 275 | ob_end_clean(); |
||
| 276 | $create_tray = new XoopsFormElementTray('', ''); |
||
| 277 | $create_tray->addElement(new XoopsFormHidden('source', $cid)); |
||
| 278 | $create_tray->addElement(new XoopsFormHidden('ok', 1)); |
||
| 279 | $create_tray->addElement(new XoopsFormHidden('op', 'move')); |
||
| 280 | $butt_save = new XoopsFormButton('', '', _AM_XOOPSTUBE_BMOVE, 'submit'); |
||
| 281 | $butt_save->setExtra('onclick="this.form.elements.op.value=\'move\'"'); |
||
| 282 | $create_tray->addElement($butt_save); |
||
| 283 | $butt_cancel = new XoopsFormButton('', '', _AM_XOOPSTUBE_BCANCEL, 'submit'); |
||
| 284 | $butt_cancel->setExtra('onclick="this.form.elements.op.value=\'cancel\'"'); |
||
| 285 | $create_tray->addElement($butt_cancel); |
||
| 286 | $sform->addElement($create_tray); |
||
| 287 | $sform->display(); |
||
| 288 | xoops_cp_footer(); |
||
| 289 | } else { |
||
| 290 | global $xoopsDB; |
||
| 291 | |||
| 292 | $source = $_POST['source']; |
||
| 293 | $target = $_POST['target']; |
||
| 294 | if ($target == $source) { |
||
| 295 | redirect_header("category.php?op=move&ok=0&cid=$source", 5, _AM_XOOPSTUBE_CCATEGORY_MODIFY_FAILED); |
||
| 296 | } |
||
| 297 | if (!$target) { |
||
| 298 | redirect_header("category.php?op=move&ok=0&cid=$source", 5, _AM_XOOPSTUBE_CCATEGORY_MODIFY_FAILEDT); |
||
| 299 | } |
||
| 300 | $sql |
||
| 301 | = "UPDATE " . $xoopsDB->prefix('xoopstube_videos') . " set cid = " . $target . " WHERE cid =" . $source; |
||
| 302 | $result = $xoopsDB->queryF($sql); |
||
| 303 | $error = _AM_XOOPSTUBE_DBERROR . ": <br /><br />" . $sql; |
||
| 304 | if (!$result) { |
||
| 305 | trigger_error($error, E_USER_ERROR); |
||
| 306 | } |
||
| 307 | redirect_header('category.php?op=default', 1, _AM_XOOPSTUBE_CCATEGORY_MODIFY_MOVED); |
||
| 308 | exit(); |
||
| 309 | } |
||
| 310 | break; |
||
| 311 | |||
| 312 | case 'addCat': |
||
|
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. Loading history...
|
|||
| 313 | |||
| 314 | $groups = isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(); |
||
| 315 | $cid = (isset($_REQUEST['cid'])) ? $_REQUEST['cid'] : 0; |
||
| 316 | $pid = (isset($_REQUEST['pid'])) ? $_REQUEST['pid'] : 0; |
||
| 317 | $weight = (isset($_REQUEST['weight']) && $_REQUEST['weight'] > 0) ? $_REQUEST['weight'] : 0; |
||
| 318 | $spotlighthis = (isset($_REQUEST['lid'])) ? $_REQUEST['lid'] : 0; |
||
| 319 | $spotlighttop = ($_REQUEST['spotlighttop'] == 1) ? 1 : 0; |
||
| 320 | $title = $xtubemyts->addslashes($_REQUEST['title']); |
||
| 321 | $descriptionb = $xtubemyts->addslashes($_REQUEST['description']); |
||
| 322 | $imgurl = ($_REQUEST['imgurl'] && $_REQUEST['imgurl'] != 'blank.gif') ? $xtubemyts->addslashes( |
||
| 323 | $_REQUEST['imgurl'] |
||
| 324 | ) : ''; |
||
| 325 | $client_id = (isset($_REQUEST['client_id'])) ? $_REQUEST['client_id'] : 0; |
||
| 326 | if ($client_id > 0) { |
||
| 327 | $banner_id = 0; |
||
| 328 | } else { |
||
| 329 | $banner_id = (isset($_REQUEST['banner_id'])) ? $_REQUEST['banner_id'] : 0; |
||
| 330 | } |
||
| 331 | $nohtml = isset($_REQUEST['nohtml']) ? $_REQUEST['nohtml'] : 0; |
||
| 332 | $nosmiley = isset($_REQUEST['nosmiley']) ? $_REQUEST['nosmiley'] : 0; |
||
| 333 | $noxcodes = isset($_REQUEST['noxcodes']) ? $_REQUEST['noxcodes'] : 0; |
||
| 334 | $noimages = isset($_REQUEST['noimages']) ? $_REQUEST['noimages'] : 0; |
||
| 335 | $nobreak = isset($_REQUEST['nobreak']) ? $_REQUEST['nobreak'] : 0; |
||
| 336 | |||
| 337 | if (!$cid) { |
||
| 338 | $cid = 0; |
||
| 339 | $sql = "INSERT INTO " . $xoopsDB->prefix( |
||
| 340 | 'xoopstube_cat' |
||
| 341 | ) |
||
| 342 | . " (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 )"; |
||
| 343 | if ($cid == 0) { |
||
| 344 | $newid = $xoopsDB->getInsertId(); |
||
| 345 | } |
||
| 346 | |||
| 347 | // Notify of new category |
||
| 348 | |||
| 349 | global $xoopsModule; |
||
| 350 | $tags = array(); |
||
| 351 | $tags['CATEGORY_NAME'] = $title; |
||
| 352 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $newid; |
||
| 353 | $notification_handler = & xoops_gethandler('notification'); |
||
| 354 | $notification_handler->triggerEvent('global', 0, 'new_category', $tags); |
||
| 355 | $database_mess = _AM_XOOPSTUBE_CCATEGORY_CREATED; |
||
| 356 | } else { |
||
| 357 | if ($cid == $pid) { |
||
| 358 | redirect_header('category.php', 1, _AM_XOOPSTUBE_ERROR_CATISCAT); |
||
| 359 | exit(); |
||
| 360 | } |
||
| 361 | $sql = "UPDATE " . $xoopsDB->prefix('xoopstube_cat') . " 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=" |
||
| 362 | . intval( |
||
| 363 | $cid |
||
| 364 | ); |
||
| 365 | $database_mess = _AM_XOOPSTUBE_CCATEGORY_MODIFIED; |
||
| 366 | } |
||
| 367 | if (!$result = $xoopsDB->query($sql)) { |
||
| 368 | XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__); |
||
| 369 | |||
| 370 | return false; |
||
| 371 | } |
||
| 372 | redirect_header('category.php', 1, $database_mess); |
||
| 373 | break; |
||
| 374 | |||
| 375 | case 'del': |
||
|
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. Loading history...
|
|||
| 376 | |||
| 377 | global $xoopsDB, $xoopsModule; |
||
| 378 | |||
| 379 | $cid = (isset($_POST['cid']) && is_numeric($_POST['cid'])) |
||
| 380 | ? intval($_POST['cid']) |
||
| 381 | : intval( |
||
| 382 | $_GET['cid'] |
||
| 383 | ); |
||
| 384 | $ok = (isset($_POST['ok']) && $_POST['ok'] == 1) ? intval($_POST['ok']) : 0; |
||
| 385 | $xoopstubetree = new XoopstubeTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
| 386 | |||
| 387 | if ($ok == 1) { |
||
| 388 | // get all subcategories under the specified category |
||
| 389 | $arr = $xoopstubetree->getAllChildId($cid); |
||
| 390 | $lcount = count($arr); |
||
| 391 | |||
| 392 | for ($i = 0; $i < $lcount; ++$i) { |
||
| 393 | // get all links in each subcategory |
||
| 394 | $result = $xoopsDB->query( |
||
| 395 | 'SELECT lid FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE cid=' . intval($arr[$i]) |
||
| 396 | ); |
||
| 397 | // now for each linkload, delete the text data and vote ata associated with the linkload |
||
| 398 | View Code Duplication | while (list($lid) = $xoopsDB->fetchRow($result)) { |
|
| 399 | $sql = sprintf( |
||
| 400 | "DELETE FROM %s WHERE lid = %u", |
||
| 401 | $xoopsDB->prefix('xoopstube_votedata'), |
||
| 402 | intval($lid) |
||
| 403 | ); |
||
| 404 | $xoopsDB->query($sql); |
||
| 405 | $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix('xoopstube_videos'), intval($lid)); |
||
| 406 | $xoopsDB->query($sql); |
||
| 407 | |||
| 408 | // delete comments |
||
| 409 | xoops_comment_delete($xoopsModule->getVar('mid'), $lid); |
||
| 410 | } |
||
| 411 | // all links for each subcategory is deleted, now delete the subcategory data |
||
| 412 | $sql = sprintf("DELETE FROM %s WHERE cid = %u", $xoopsDB->prefix('xoopstube_cat'), intval($arr[$i])); |
||
| 413 | $xoopsDB->query($sql); |
||
| 414 | // delete altcat entries |
||
| 415 | $sql = sprintf("DELETE FROM %s WHERE cid = %u", $xoopsDB->prefix('xoopstube_altcat'), $arr[$i]); |
||
| 416 | $xoopsDB->query($sql); |
||
| 417 | } |
||
| 418 | // all subcategory and associated data are deleted, now delete category data and its associated data |
||
| 419 | $result = $xoopsDB->query( |
||
| 420 | 'SELECT lid FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE cid=' . intval($cid) |
||
| 421 | ); |
||
| 422 | View Code Duplication | while (list($lid) = $xoopsDB->fetchRow($result)) { |
|
| 423 | $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix('xoopstube_videos'), intval($lid)); |
||
| 424 | $xoopsDB->query($sql); |
||
| 425 | // delete comments |
||
| 426 | xoops_comment_delete($xoopsModule->getVar('mid'), intval($lid)); |
||
| 427 | $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB->prefix('xoopstube_votedata'), intval($lid)); |
||
| 428 | $xoopsDB->query($sql); |
||
| 429 | } |
||
| 430 | |||
| 431 | // delete altcat entries |
||
| 432 | $sql = sprintf("DELETE FROM %s WHERE cid = %u", $xoopsDB->prefix('xoopstube_altcat'), intval($cid)); |
||
| 433 | $xoopsDB->query($sql); |
||
| 434 | |||
| 435 | // delete category |
||
| 436 | $sql = sprintf("DELETE FROM %s WHERE cid = %u", $xoopsDB->prefix('xoopstube_cat'), intval($cid)); |
||
| 437 | $error = _AM_XOOPSTUBE_DBERROR . ": <br /><br />" . $sql; |
||
| 438 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeCatPerm', intval($cid)); |
||
| 439 | if (!$result = $xoopsDB->query($sql)) { |
||
| 440 | trigger_error($error, E_USER_ERROR); |
||
| 441 | } |
||
| 442 | |||
| 443 | // delete group permissions |
||
| 444 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeCatPerm', $cid); |
||
| 445 | if (!$result = $xoopsDB->query($sql)) { |
||
| 446 | trigger_error($error, E_USER_ERROR); |
||
| 447 | } |
||
| 448 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeSubPerm', $cid); |
||
| 449 | if (!$result = $xoopsDB->query($sql)) { |
||
| 450 | trigger_error($error, E_USER_ERROR); |
||
| 451 | } |
||
| 452 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeAppPerm', $cid); |
||
| 453 | if (!$result = $xoopsDB->query($sql)) { |
||
| 454 | trigger_error($error, E_USER_ERROR); |
||
| 455 | } |
||
| 456 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeAutoApp', $cid); |
||
| 457 | if (!$result = $xoopsDB->query($sql)) { |
||
| 458 | trigger_error($error, E_USER_ERROR); |
||
| 459 | } |
||
| 460 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'XTubeRatePerms', $cid); |
||
| 461 | if (!$result = $xoopsDB->query($sql)) { |
||
| 462 | trigger_error($error, E_USER_ERROR); |
||
| 463 | } |
||
| 464 | |||
| 465 | redirect_header('category.php', 1, _AM_XOOPSTUBE_CCATEGORY_DELETED); |
||
| 466 | exit(); |
||
| 467 | } else { |
||
| 468 | xoops_cp_header(); |
||
| 469 | xoops_confirm( |
||
| 470 | array( |
||
| 471 | 'op' => 'del', |
||
| 472 | 'cid' => intval($cid), |
||
| 473 | 'ok' => 1 |
||
| 474 | ), |
||
| 475 | 'category.php', |
||
| 476 | _AM_XOOPSTUBE_CCATEGORY_AREUSURE |
||
| 477 | ); |
||
| 478 | xoops_cp_footer(); |
||
| 479 | } |
||
| 480 | break; |
||
| 481 | |||
| 482 | case 'modCat': |
||
| 483 | $cid = (isset($_POST['cid'])) ? $_POST['cid'] : 0; |
||
| 484 | xoops_cp_header(); |
||
| 485 | //xtubeRenderAdminMenu(_AM_XOOPSTUBE_MCATEGORY); |
||
| 486 | createCategory($cid); |
||
| 487 | include_once __DIR__ . '/admin_footer.php'; |
||
| 488 | break; |
||
| 489 | |||
| 490 | case 'main': |
||
| 491 | default: |
||
| 492 | xoops_cp_header(); |
||
| 493 | //xtubeRenderAdminMenu(_AM_XOOPSTUBE_MCATEGORY); |
||
| 494 | |||
| 495 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 496 | $xoopstubetree = new XoopstubeTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
| 497 | $sform = new XoopsThemeForm(_AM_XOOPSTUBE_CCATEGORY_MODIFY, 'category', xoops_getenv('PHP_SELF')); |
||
| 498 | $totalcats = xtubeGetTotalCategoryCount(); |
||
| 499 | |||
| 500 | if ($totalcats > 0) { |
||
| 501 | ob_start(); |
||
| 502 | $xoopstubetree->makeMySelBox('title', 'title'); |
||
| 503 | $sform->addElement(new XoopsFormLabel(_AM_XOOPSTUBE_CCATEGORY_MODIFY_TITLE, ob_get_contents())); |
||
| 504 | ob_end_clean(); |
||
| 505 | $dup_tray = new XoopsFormElementTray('', ''); |
||
| 506 | $dup_tray->addElement(new XoopsFormHidden('op', 'modCat')); |
||
| 507 | $butt_dup = new XoopsFormButton('', '', _AM_XOOPSTUBE_BMODIFY, 'submit'); |
||
| 508 | $butt_dup->setExtra('onclick="this.form.elements.op.value=\'modCat\'"'); |
||
| 509 | $dup_tray->addElement($butt_dup); |
||
| 510 | $butt_move = new XoopsFormButton('', '', _AM_XOOPSTUBE_BMOVE, 'submit'); |
||
| 511 | $butt_move->setExtra('onclick="this.form.elements.op.value=\'move\'"'); |
||
| 512 | $dup_tray->addElement($butt_move); |
||
| 513 | $butt_dupct = new XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETE, 'submit'); |
||
| 514 | $butt_dupct->setExtra('onclick="this.form.elements.op.value=\'del\'"'); |
||
| 515 | $dup_tray->addElement($butt_dupct); |
||
| 516 | $sform->addElement($dup_tray); |
||
| 517 | $sform->display(); |
||
| 518 | } |
||
| 519 | createCategory(0); |
||
| 520 | include_once __DIR__ . '/admin_footer.php'; |
||
| 521 | break; |
||
| 522 | } |
||
| 523 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.