// An exception ocurred. Return an error message. ApiUtils::handleException($app, $e); } }); // Service for update the values of an assistance list. $app->put('/assistanceList', function () use($app) { try { // Verify that the user is logged. if (ApiUtils::isLogged()) { // Get input. $request = $app->request(); $input = json_decode($request->getBody()); $rows = is_object($input) ? get_object_vars($input) : $input; // Update all rows. for ($i = 0; $i < count($rows); $i++) { $entry = Assistance::find($rows[$i]->id); $attributes = is_object($rows[$i]) ? get_object_vars($rows[$i]) : $rows[$i]; $creation = is_object($rows[$i]->creation) ? get_object_vars($rows[$i]->creation) : $rows[$i]->creation; $attributes['creation'] = $creation['date']; if ($entry != null) { $entry->update_attributes($attributes); } } // Return result. echo json_encode(array("error" => null)); } else { // Return error message. ApiUtils::returnError($app, 'UserNotAdmin'); } } catch (Exception $e) { // An exception ocurred. Return an error message.
// Get list. $rows = array(); if ($type == "event") { $rows = ApiUtils::rowToMap(Event::find($id)); } if ($type == "group") { $rows = ApiUtils::rowToMap(Group::find($id)); } if ($type == "user") { $rows = ApiUtils::rowToMap(User::find($id)); } if ($type == "person") { $rows = ApiUtils::rowToMap(Person::find($id)); } if ($type == "assistance") { $rows = ApiUtils::rowToMap(Assistance::find($id)); } // Return result. echo json_encode(array("row" => $rows, "error" => null)); } else { // Return error message. ApiUtils::returnError($app, 'UserNotLogged'); } } catch (Exception $e) { // An exception ocurred. Return an error message. ApiUtils::handleException($app, $e); } }); // Service for get all persons from a group. $app->get('/findByGroup/:id', function ($id) use($app) { try {