Exemplo n.º 1
0
function MG_staticSortAlbumsSave()
{
    global $_TABLES, $_MG_CONF;
    $startaid = !empty($_POST['startaid']) ? COM_applyFilter($_POST['startaid'], true) : 0;
    $sortfield = !empty($_POST['sortfield']) ? COM_applyFilter($_POST['sortfield'], true) : 0;
    $sortorder = !empty($_POST['sortorder']) ? COM_applyFilter($_POST['sortorder'], true) : 0;
    $process_subs = !empty($_POST['processsub']) ? COM_applyFilter($_POST['processsub'], true) : 0;
    switch ($sortfield) {
        case '0':
            // album title
            $sql_sort_by = " ORDER BY album_title ";
            break;
        case '1':
            // media_count
            $sql_sort_by = " ORDER BY media_count ";
            break;
        case '2':
            // last_update
            $sql_sort_by = " ORDER BY last_update ";
            break;
        default:
            $sql_sort_by = " ORDER BY album_title ";
            break;
    }
    switch ($sortorder) {
        case '0':
            // ascending
            $sql_order = " DESC";
            break;
        case '1':
            // descending
            $sql_order = " ASC";
            break;
    }
    if ($process_subs == 0) {
        $sql = "SELECT album_id FROM {$_TABLES['mg_albums']} " . "WHERE album_parent=" . $startaid . " " . $sql_sort_by . $sql_order;
        $result = DB_query($sql);
        $order = 10;
        while ($row = DB_fetchArray($result)) {
            DB_change($_TABLES['mg_albums'], 'album_order', $order, 'album_id', $row['album_id']);
            $order += 10;
        }
    } else {
        MG_staticSortAlbumChildren($startaid, $sql_order, $sql_sort_by);
    }
    header("Location: " . $_MG_CONF['admin_url'] . 'index.php?msg=1');
}
Exemplo n.º 2
0
function MG_staticSortAlbumsSave()
{
    global $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $_POST;
    $startaid = COM_applyFilter($_POST['startaid'], true);
    $sortfield = COM_applyFilter($_POST['sortfield'], true);
    $sortorder = COM_applyFilter($_POST['sortorder'], true);
    $process_subs = COM_applyFilter($_POST['processsub'], true);
    switch ($sortby) {
        case '0':
            // album title
            $sql_sort_by = " ORDER BY album_title ";
            break;
        case '1':
            // media_count
            $sql_sort_by = " ORDER BY media_count ";
            break;
        case '2':
            // last_update
            $sql_sort_by = " ORDER BY last_update ";
            break;
        default:
            $sql_sort_by = " ORDER BY album_title ";
            break;
    }
    switch ($sortorder) {
        case '0':
            // ascending
            $sql_order = " DESC";
            break;
        case '1':
            // descending
            $sql_order = " ASC";
            break;
    }
    if ($process_subs == 0) {
        $sql = "SELECT album_id,album_order FROM {$_TABLES['mg_albums']} WHERE album_parent=" . $startaid . " " . $sql_sort_by . $sql_order;
        $order = 10;
        $result = DB_query($sql);
        $numRows = DB_numRows($result);
        for ($x = 0; $x < $numRows; $x++) {
            $row = DB_fetchArray($result);
            $album_id[$x] = $row['album_id'];
            $album_order[$x] = $order;
            $order += 10;
        }
        $album_count = $numRows;
        $i = 0;
        for ($x = 0; $x < $album_count; $x++) {
            $sql = "UPDATE " . $_TABLES['mg_albums'] . " SET album_order=" . $album_order[$x] . " WHERE album_id=" . $album_id[$x];
            $res = DB_query($sql);
        }
    } else {
        MG_staticSortAlbumChildren($startaid, $sql_order, $sql_sort_by);
    }
    header("Location: " . $_MG_CONF['admin_url'] . 'index.php?msg=1');
}