function CatDown() { global $smcFunc, $txt; checkSession('get'); // Check if they are allowed to manage cats isAllowedTo('links_manage_cat'); // Get the cat id if (!empty($_REQUEST['cat'])) { $cat = (int) $_REQUEST['cat']; } if (empty($cat)) { fatal_error($txt['smflinks_nocatselected']); } $dbresult = $smcFunc['db_query']('', "\n\tSELECT \n\t\tID_CAT, title, description, image, ID_PARENT \n\tFROM {db_prefix}links_cat \n\tWHERE ID_CAT = {$cat}"); $row = $smcFunc['db_fetch_assoc']($dbresult); if (empty($row['ID_CAT'])) { fatal_error($txt['smflinks_nocatselected'], false); } ReOrderCats($cat); // Check if there is a category below it // First get our row order $dbresult1 = $smcFunc['db_query']('', ' SELECT roworder, ID_PARENT FROM {db_prefix}links_cat WHERE ID_CAT = {int:this_cat}', array('this_cat' => $cat)); $row = $smcFunc['db_fetch_assoc']($dbresult1); $ID_PARENT = $row['ID_PARENT']; $oldrow = $row['roworder']; $o = $row['roworder']; $o++; $smcFunc['db_free_result']($dbresult1); $dbresult = $smcFunc['db_query']('', ' SELECT ID_CAT, roworder FROM {db_prefix}links_cat WHERE ID_PARENT = {int:this_parent} AND roworder = {int:row_order}', array('this_parent' => $ID_PARENT, 'row_order' => $o)); if ($smcFunc['db_affected_rows']() == 0) { fatal_error($txt['smflinks_nocatbelow'], false); } $row2 = $smcFunc['db_fetch_assoc']($dbresult); // Swap the order Id's $smcFunc['db_query']('', ' UPDATE {db_prefix}links_cat SET roworder = {int:row_order} WHERE ID_CAT = {int:id_cat}', array('row_order' => $oldrow, 'id_cat' => $row2['ID_CAT'])); $smcFunc['db_query']('', ' UPDATE {db_prefix}links_cat SET roworder = {int:row_order} WHERE ID_CAT = {int:id_cat}', array('row_order' => $o, 'id_cat' => $cat)); $smcFunc['db_free_result']($dbresult); // Redirect to index to view cats if ($ID_PARENT == 0) { redirectexit('action=links'); } else { redirectexit('action=links;cat=' . $ID_PARENT); } }
function CatDown() { global $db_prefix, $txt; checkSession('get'); // Check if they are allowed to manage cats isAllowedTo('links_manage_cat'); // Get the cat id if (!empty($_REQUEST['cat'])) { $cat = (int) $_REQUEST['cat']; } if (empty($cat)) { fatal_error($txt['smflinks_nocatselected'], false); } $dbresult = db_query("\n\t\tSELECT \n\t\t\ttitle, ID_CAT \n\t\tFROM {$db_prefix}links_cat \n\t\tWHERE ID_CAT = {$cat} LIMIT 1", __FILE__, __LINE__); $row = mysql_fetch_assoc($dbresult); if (empty($row['ID_CAT'])) { fatal_error($txt['smflinks_nocatselected'], false); } ReOrderCats($cat); // Check if there is a category below it // First get our row order $dbresult1 = db_query("\n\tSELECT \n\t\troworder, ID_PARENT \n\tFROM {$db_prefix}links_cat \n\tWHERE ID_CAT = {$cat}", __FILE__, __LINE__); $row = mysql_fetch_assoc($dbresult1); $ID_PARENT = $row['ID_PARENT']; $oldrow = $row['roworder']; $o = $row['roworder']; $o++; mysql_free_result($dbresult1); $dbresult = db_query("\n\tSELECT \n\t\tID_CAT, roworder \n\tFROM {$db_prefix}links_cat \n\tWHERE ID_PARENT = {$ID_PARENT} AND roworder = {$o}", __FILE__, __LINE__); if (db_affected_rows() == 0) { fatal_error($txt['smflinks_nocatbelow'], false); } $row2 = mysql_fetch_assoc($dbresult); // Swap the order Id's db_query("UPDATE {$db_prefix}links_cat\n\t\tSET roworder = {$oldrow} WHERE ID_CAT = " . $row2['ID_CAT'], __FILE__, __LINE__); db_query("UPDATE {$db_prefix}links_cat\n\t\tSET roworder = {$o} WHERE ID_CAT = {$cat}", __FILE__, __LINE__); mysql_free_result($dbresult); // Redirect to index to view cats if ($ID_PARENT == 0) { redirectexit('action=links'); } else { redirectexit('action=links;cat=' . $ID_PARENT); } }
function CatDown() { global $db, $lang; // Get the cat id @($cat = intval($_REQUEST['cat'])); ReOrderCats($cat); // Check if there is a category below it // First get our row order $dbresult1 = $db->query("\n\tSELECT\n\t\troworder\n\tFROM " . TABLE_PREFIX . "gallery_cat\n\tWHERE ID_CAT = {$cat} LIMIT 1"); $row = $db->fetch_array($dbresult1); $oldrow = $row['roworder']; $o = $row['roworder']; $o++; $dbresult = $db->query("\n\tSELECT\n\t\tID_CAT, roworder\n\tFROM " . TABLE_PREFIX . "gallery_cat\n\tWHERE roworder = {$o}"); if ($db->num_rows($dbresult) == 0) { fatal_error($lang->gallery_nocatbelow, false); } $row2 = $db->fetch_array($dbresult); //Swap the order Id's $db->query("UPDATE " . TABLE_PREFIX . "gallery_cat\n\t\tSET roworder = {$oldrow} WHERE ID_CAT = " . $row2['ID_CAT']); $db->query("UPDATE " . TABLE_PREFIX . "gallery_cat\n\t\tSET roworder = {$o} WHERE ID_CAT = {$cat}"); //Redirect to index to view cats admin_redirect('index.php?module=config/ezgallery&action=admincat'); }