<?php

require '../header.php';

$data = array();
$data["success"] = false;

if ( !isset($_REQUEST['imageid']) || !isset($_REQUEST['title']) || ($_REQUEST['title'] == "") ) {
    sendResponse($data);
}

$image = new Image($_REQUEST['imageid']);
if ( $image->getID() == 0 ) {
    sendResponse($data);
}
$album = new Album($image->getAlbumID());

$image->setTitle($_REQUEST['title']);
$image->setDescription($_REQUEST['description']);
$image->save();
$data["success"] = true;
$data["image"] = $image;

sendResponse($data);

function sendResponse($data) {
    header('Content-Type: application/json');
    echo json_encode($data);
    exit();
}

exit();

// vim: set ts=4:sw=4
