<?php

require '../header.php';

requireLogin();

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

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

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

$data["success"] = true;
$data["loggedin"] = $currentuser->isLoggedIn();
$data["album"] = $album;

sendResponse($data);

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

exit();

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