예제 #1
0
<?php

/**
 * @Project NUKEVIET 4.x
 * @Author VINADES.,JSC (contact@vinades.vn)
 * @Copyright (C) 2014 VINADES.,JSC. All rights reserved
 * @License GNU/GPL version 2 or any later version
 * @Createdate 2-10-2010 18:49
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
$locationid = $nv_Request->get_int('locationid', 'post, get', 0);
$contents = "NO_" . $locationid;
list($locationid, $parentid, $title) = $db->query("SELECT id, parentid FROM " . $db_config['prefix'] . "_" . $module_data . "_location WHERE id=" . $locationid)->fetch(3);
if ($locationid > 0) {
    $result = $db->query("DELETE FROM " . $db_config['prefix'] . "_" . $module_data . "_location WHERE parentid=" . $locationid);
    $result = $db->query("DELETE FROM " . $db_config['prefix'] . "_" . $module_data . "_location WHERE id=" . $locationid);
    if ($result) {
        $contents = 'OK';
        nv_fix_location_order();
        nv_del_moduleCache($module_name);
    }
}
include NV_ROOTDIR . '/includes/header.php';
echo $contents;
include NV_ROOTDIR . '/includes/footer.php';
예제 #2
0
/**
 * nv_fix_location_order()
 *
 * @param integer $parentid
 * @param integer $order
 * @param integer $lev
 * @return
 */
function nv_fix_location_order($parentid = 0, $sort = 0, $lev = 0)
{
    global $db, $db_config, $module_data;
    $sql = 'SELECT id, parentid FROM ' . $db_config['prefix'] . '_' . $module_data . '_location WHERE parentid=' . $parentid . ' ORDER BY weight ASC';
    $result = $db->query($sql);
    $array_location_order = array();
    while ($row = $result->fetch()) {
        $array_location_order[] = $row['id'];
    }
    $result->closeCursor();
    $weight = 0;
    if ($parentid > 0) {
        ++$lev;
    } else {
        $lev = 0;
    }
    foreach ($array_location_order as $locationid_i) {
        ++$sort;
        ++$weight;
        $sql = 'UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_location SET weight=' . $weight . ', sort=' . $sort . ', lev=' . $lev . ' WHERE id=' . $locationid_i;
        $db->query($sql);
        $sort = nv_fix_location_order($locationid_i, $sort, $lev);
    }
    $numsub = $weight;
    if ($parentid > 0) {
        $sql = "UPDATE " . $db_config['prefix'] . "_" . $module_data . "_location SET numsub=" . $numsub;
        if ($numsub == 0) {
            $sql .= ",subid=''";
        } else {
            $sql .= ",subid='" . implode(",", $array_location_order) . "'";
        }
        $sql .= " WHERE id=" . intval($parentid);
        $db->query($sql);
    }
    return $sort;
}