<?php require "../php/init.php"; $actId = Input::get('id'); if (is_numeric($actId)) { $outArray = array(); $act = new Activity(); $activityInfo = $act->getAllActivities($actId); $activityInfo->roles = $act->showRoles($actId); header("Content-type: application/json"); print json_encode($activityInfo); }
<?php require "../php/init.php"; $mainUser = new User(); if (!$mainUser->inRole(1)) { die('nope. not allowed!'); } $actId = Input::get('id'); $act = new Activity(); $oldRoles = $act->showRoles($actId); if ($userData = Input::get('info')) { $newRoles = $userData['roles']; unset($userData['roles']); if (Input::get('add')) { Activity::addActivity($userData, $newRoles); } else { try { Activity::updateActivity($actId, $userData); } catch (Exception $e) { echo $e; $error = true; } if (!$error) { foreach ($oldRoles as $key => $oldRole) { if (!in_array($key, $newRoles)) { Activity::removeRole($actId, $key); } } foreach ($newRoles as $key => $newRole) { if (!array_key_exists($newRole, $oldRoles)) { Activity::addRole($actId, $newRole);