Пример #1
0
<?php

require_once 'ApiResponses.php';
require_once '../config.php';
if (!array_key_exists('photo_id', $_POST)) {
    $response = new ApiResponseFailure('Missing photo_id');
    $response->render();
}
require_once '../connect.php';
require_once '../PhotoManager.php';
// get property id from photo
$photo_id = $_POST['photo_id'];
$pm = new PhotoManager($db_connection, $UPLOAD_DIRECTORY);
$photo = $pm->get_photo_by_id($photo_id);
$property_id = $photo->propertyid;
// set default to 0 for all photos for this property
$pm->reset_default_for_property($property_id);
// set photo to default
$pm->set_default($photo_id, 1);
// return successful
$response = new ApiResponseSuccess();
$response->render();