Ejemplo n.º 1
0
<?php

namespace SP\App\Api\Activity\Calendar;

require_once 'CalEvent.php';
require_once __DIR__ . '/../../crud/ActivityCrudManager.php';
use SP\App\Api\CRUD\ActivityCrudManager;
/**
* @var mixed[] $request Array with event bindings to create event.
*/
$request = json_decode(file_get_contents('php://input'), true);
$manager = new ActivityCrudManager($_SERVER['REQUEST_METHOD'], new CalEvent(), $request, isset($_GET['id']) ? $_GET['id'] : null, isset($_GET['byUser']) ? $_GET['byUser'] : null, isset($_GET['where']) ? $_GET['where'] : null, isset($_GET['bindings']) ? $_GET['bindings'] : null);
echo json_encode($manager->getResponse());
Ejemplo n.º 2
0
<?php

namespace SP\App\Api\Activity\Task;

/**
* TODO: move logic to own file.
*/
require_once 'Task.php';
require_once __DIR__ . '/../../crud/ActivityCrudManager.php';
use SP\App\Api\CRUD\ActivityCrudManager;
/**
* @var mixed[] $request Array with task bindings to create task.
*/
$request = json_decode(file_get_contents('php://input'), true);
if (isset($request['subtasks'])) {
    $request['subtasks'] = base64_encode(serialize($request['subtasks']));
}
$manager = new ActivityCrudManager($_SERVER['REQUEST_METHOD'], new Task(), $request, isset($_GET['id']) ? $_GET['id'] : null, isset($_GET['byUser']) ? $_GET['byUser'] : null, isset($_GET['where']) ? $_GET['where'] : null, isset($_GET['bindings']) ? $_GET['bindings'] : null);
$response = $manager->getResponse();
if (is_array($response['data'])) {
    foreach ($response['data'] as &$task) {
        if (!empty($task['subtasks'])) {
            $task['subtasks'] = unserialize(base64_decode($task['subtasks']));
        }
    }
}
echo json_encode($response);