} } $error = true; } } else { if (isset($_POST['set_main_image_nonce']) && wp_verify_nonce($_POST['set_main_image_nonce'], 'set_main_image')) { $result = Idp_Main::setMainImage($_POST['building_id'], $_POST['image_id'], $user_id); if ($result === false) { $error = true; } else { $updated = true; $message = __('Main image changed.', 'idp-theme'); } } else { if (isset($_POST['delete_image_nonce']) && wp_verify_nonce($_POST['delete_image_nonce'], 'delete_image')) { $result = Idp_Main::deleteBuildingImage($_POST['building_id'], $_POST['image_id'], $user_id); if ($result === false) { $error = true; } else { $updated = true; $message = __('Image deleted.', 'idp-theme'); } } else { if (isset($_POST['image_category_nonce']) && wp_verify_nonce($_POST['image_category_nonce'], 'image_category')) { Idp_Main::setImageCategory($_POST['building_id'], $_POST['image_id'], $_POST['image_category'], $user_id); } else { if (isset($_POST['crop_nonce']) && wp_verify_nonce($_POST['crop_nonce'], 'crop')) { if (!empty($_POST['cropPoints']) && !empty($_POST['cropImage'])) { $crop_points = array_map('intval', explode(',', $_POST['cropPoints'])); $crop_image_path = str_replace("http://haeuserbuch.de/", "", $_POST['cropImage']); $result = idp_crop_image($crop_points, $crop_image_path);
/** * Delete Building and all its data from the database * * @author Christopher Siewert * @return success */ public static function deleteBuilding($building_id) { global $wpdb; $errors = 0; $images = Idp_Main::getBuildingImages($building_id); foreach ($images as $image) { $result = Idp_Main::deleteBuildingImage($building_id, $image); if ($result === false) { $errors++; } } $building = Idp_Main::getBuildingBasicInfos($building_id); $result = $wpdb->delete($wpdb->prefix . 'building_attribute', array('building' => $building_id), array('%d')); if ($result === false) { $errors++; } $result = $wpdb->delete($wpdb->prefix . 'bounds', array('coordinates' => $building['bounds']), array('%s')); if ($result === false) { $errors++; } $result = $wpdb->delete($wpdb->prefix . 'building', array('id' => $building_id), array('%d')); if ($result === false) { $errors++; } if ($errors > 0) { return false; } else { return true; } }