Ejemplo n.º 1
0
/**
* Processes a reservation request (add/del/edit)
* @param string $fn function to perform
*/
function process_blackout($fn)
{
    $success = false;
    if (isset($_POST['resid'])) {
        $res = new Blackout($_POST['resid']);
    } else {
        if (isset($_GET['resid'])) {
            $res = new Blackout($_GET['resid']);
        } else {
            $res = new Blackout();
            if (isset($_POST['repeat_day'])) {
                // Check for reservation repeation
                $res->is_repeat = true;
                $repeat = get_repeat_dates($_POST['ts'], $_POST['repeat_day'], $_POST['duration']);
            } else {
                $repeat = array($_POST['ts']);
            }
        }
    }
    if ($fn == 'create') {
        $res->add_blackout($_POST['machid'], $_POST['starttime'], $_POST['endtime'], $repeat, $_POST['summary']);
    } else {
        if ($fn == 'modify') {
            $res->mod_blackout($_POST['starttime'], $_POST['endtime'], isset($_POST['del']), isset($_POST['mod_recur']), $_POST['summary']);
        } else {
            if ($fn == 'delete') {
                $res->del_blackout(isset($_POST['mod_recur']));
            }
        }
    }
}