Beispiel #1
0
function saveTmpData()
{
    $query = 'BEGIN; LOCK "MapSettings";';
    $tables = getTables();
    $tbl_del = "";
    $ins = "";
    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $tmpT = tmpTable($table, TRUE);
        if (strlen($tbl_del) > 0) {
            $tbl_del .= ', ';
        }
        $tbl_del .= '"' . $table . '"';
        $ins .= ' INSERT INTO "' . $table . '" SELECT * FROM "' . $tmpT . '";';
    }
    $query .= ' TRUNCATE ' . $tbl_del . ' CASCADE;' . $ins;
    $query .= ' COMMIT;';
    $res = PQuery($query);
    if (!isset($res['error'])) {
        $res = setMapLastEdit();
    }
    if (!isset($res['error'])) {
        $res = CheckData();
    }
    return $res;
}
Beispiel #2
0
        } else {
            setTmpMapLastEdit();
            print json_encode(array("error" => false));
        }
    } elseif ($_POST['mode'] == "addNetworkBox") {
        $networkBoxType = $obj->{'networkBoxType'};
        $invNum = $obj->{'invNum'};
        $boxId = addNetworkBox($networkBoxType, $invNum, TRUE);
        if (isset($boxId['id'])) {
            $result = array("NetworkBoxId" => $boxId['id']);
        } else {
            $result = array("error" => isset($boxId['error']) ? $boxId['error'] : NULL);
        }
        setTmpMapLastEdit();
        setMapUserActivity($uId);
        print json_encode($result);
        die;
    } elseif ($_POST['mode'] == "save") {
        $result = saveTmpData();
        if (defined($result['error'])) {
            print json_encode(array("error" => $result['error']));
        } else {
            print json_encode(array("error" => false));
        }
    } elseif ($_POST['mode'] == "cancel") {
        setMapLastEdit();
        $result = checkData();
        print json_encode($result);
    }
    setMapUserActivity($uId);
}