Пример #1
0
$updated = false;
$error = false;
//if we have a $building (id), we can update it
$building_id = intval(htmlspecialchars(get_query_var('buildingid', 0)));
$building_bounds = "";
$building_district = "";
$user_id = get_current_user_id();
$not_found = false;
//form data is present
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['building_nonce']) && wp_verify_nonce($_POST['building_nonce'], 'building')) {
        $formData = [];
        foreach ($_POST as $key => $value) {
            $formData[$key] = idp_test_input($value);
        }
        $building_id = Idp_Main::saveBuildingBounds($formData);
        if ($building_id != '0') {
            $updated = true;
        } else {
            $error = true;
        }
    }
}
//try to get building, if it exists
if ($building_id != '0') {
    $building = Idp_Main::getBuildingBasicInfos($building_id);
    if (!array_key_exists('id', $building)) {
        $not_found = true;
    } else {
        $building_bounds = $building['bounds'];
        $building_district = $building['district']['id'];