コード例 #1
0
function moveLink($lid, $direction)
{
    global $db, $cfg;
    if (!isset($lid) && !isset($direction) && $direction !== "up" && $direction !== "down") {
        header("location: admin.php?op=editLinks");
    }
    $idx = getLinkSortOrder($lid);
    $position = array("up" => -1, "down" => 1);
    $new_idx = $idx + $position[$direction];
    $sql = "UPDATE tf_links SET sort_order={$idx} WHERE sort_order={$new_idx}";
    $db->Execute($sql);
    showError($db, $sql);
    $sql = "UPDATE tf_links SET sort_order={$new_idx} WHERE lid={$lid}";
    $db->Execute($sql);
    showError($db, $sql);
    header("Location: admin.php?op=editLinks");
}
コード例 #2
0
function deleteOldLink($lid)
{
    global $db;
    // Get Current sort order index of link with this link id:
    $idx = getLinkSortOrder($lid);
    // Fetch all link ids and their sort orders where the sort order is greater
    // than the one we're removing - we need to shuffle each sort order down
    // one:
    $sql = "SELECT sort_order, lid FROM tf_links ";
    $sql .= "WHERE sort_order > {$idx} ORDER BY sort_order ASC";
    $result = $db->Execute($sql);
    showError($db, $sql);
    $arLinks = $result->GetAssoc();
    // Decrement the sort order of each link:
    foreach ($arLinks as $sid => $this_lid) {
        $sql = "UPDATE tf_links SET sort_order=sort_order-1 WHERE lid={$this_lid}";
        $db->Execute($sql);
        showError($db, $sql);
    }
    // Finally delete the link:
    $sql = "DELETE FROM tf_links WHERE lid=" . $lid;
    $result = $db->Execute($sql);
    showError($db, $sql);
}
コード例 #3
0
/**
 * Delete Link
 *
 * @param $lid
 */
function deleteOldLink($lid)
{
    global $db;
    // Link Mod
    //$sql = "delete from tf_links where lid=".$lid;
    // Get Current sort order index of link with this link id:
    $idx = getLinkSortOrder($lid);
    // Fetch all link ids and their sort orders where the sort order is greater
    // than the one we're removing - we need to shuffle each sort order down
    // one:
    $sql = "SELECT sort_order, lid FROM tf_links ";
    $sql .= "WHERE sort_order > " . $db->qstr($idx) . " ORDER BY sort_order ASC";
    $result = $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        dbError($sql);
    }
    $arLinks = $result->GetAssoc();
    // Decrement the sort order of each link:
    foreach ($arLinks as $sid => $this_lid) {
        $sql = "UPDATE tf_links SET sort_order=sort_order-1 WHERE lid=" . $db->qstr($this_lid);
        $db->Execute($sql);
        if ($db->ErrorNo() != 0) {
            dbError($sql);
        }
    }
    // Finally delete the link:
    $sql = "DELETE FROM tf_links WHERE lid=" . $db->qstr($lid);
    $result = $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        dbError($sql);
    }
    // flush session-cache
    cacheFlush();
}