Пример #1
0
function newgrant($msg, $params = null)
{
    global $grantRestParams;
    // handle the request
    $DATA = false;
    if ($validated = validateParams($grantRestParams, $msg)) {
        $DATA = handleGrant($msg);
    }
    if ($DATA === false) {
        // grant creation unsucessfull
        if ($validated) {
            logError('invalid grant parameters');
            return array('httpInternalError', 'internal error');
        } else {
            // errors already generated in handleGrant
            return array('httpBadRequest', 'bad parameters');
        }
    }
    // return grant instance
    return array(false, array("id" => $DATA['id'], "url" => grantUrl($DATA)));
}
Пример #2
0
<?php

// process a grant request
require_once "grantfuncs.php";
// handle the request
$DATA = false;
if (validateParams($grantNewParams, $_POST)) {
    // uniform the request parameters to the REST api
    if (isset($_POST['grant_totaldays'])) {
        $_POST['grant_total'] = (int) ($_POST['grant_totaldays'] * 3600 * 24);
    }
    if (isset($_POST['ticket_totaldays'])) {
        $_POST['ticket_total'] = (int) ($_POST['ticket_totaldays'] * 3600 * 24);
    }
    if (isset($_POST['ticket_lastdldays'])) {
        $_POST['ticket_lastdl'] = (int) ($_POST['ticket_lastdldays'] * 3600 * 24);
    }
    $DATA = handleGrant($_POST);
}
// resulting page
if ($DATA !== false) {
    include "newgrantr.php";
} else {
    include "newgrants.php";
}