Esempio n. 1
0
})->via('DELETE', 'GET', 'PUT', 'PATCH');
/**
 * ACTIVITY COLLECTION
 */
// @todo: create different activity endpoints
// ex: /activity/:table, /activity/recents/:days
$app->get("/{$v}/activity/?", function () use($params, $ZendDb, $acl) {
    $Activity = new DirectusActivityTableGateway($acl, $ZendDb);
    $datetime = new DateTime('NOW', new DateTimeZone('GMT'));
    $datetime->modify('-30 days');
    // @todo move this to backbone collection
    if (!$params['adv_search']) {
        unset($params['perPage']);
        $params['adv_search'] = "datetime >= '" . $datetime->format('Y-m-d H:i:s') . "'";
    }
    $new_get = $Activity->fetchFeed($params);
    $new_get['active'] = $new_get['total'];
    JsonView::render($new_get);
});
/**
 * COLUMNS COLLECTION
 */
// GET all table columns, or POST one new table column
$app->map("/{$v}/tables/:table/columns/?", function ($table_name) use($ZendDb, $params, $requestPayload, $app, $acl) {
    $params['table_name'] = $table_name;
    if ($app->request()->isPost()) {
        /**
         * @todo  check if a column by this name already exists
         * @todo  build this into the method when we shift its location to the new layer
         */
        if (!$acl->hasTablePrivilege($table_name, 'alter')) {