$app->put('', $check_token_exists, $decode_body, function ($username) { change_pwd($username); }); $app->delete('', $check_token_exists, function ($username) { delete_user($username); }); }); }); $app->group('/calendars', function () use($app) { global $check_token_exists; global $decode_body; $app->get('', $check_token_exists, function () { get_calendars(); }); $app->post('', $check_token_exists, $decode_body, function () { create_calendar(); }); $app->group('/:calendar_id', function () use($app) { global $check_token_exists; global $decode_body; $app->get('', $check_token_exists, function ($calendar_id) { get_calendar($calendar_id); }); $app->put('', $check_token_exists, $decode_body, function ($calendar_id) { edit_calendar($calendar_id); }); $app->delete('', $check_token_exists, function ($calendar_id) { delete_calendar($calendar_id); }); $app->group('/members', function () use($app) { global $check_token_exists;
function create_calendars($user_name, $output_list) { $counter = 0; foreach ($output_list as $task) { $id = create_calendar($user_name, $task[start_date], $task[date_modified], $task[name], $task[description], $task[date_due], $task[contact_name], $task[location]); $output_list[$counter]['id'] = $id; $counter++; } return array_reverse($output_list); }