function RemovePersonStatusgruppeComplete ($username, $range_id) { $result = getAllStatusgruppenIDS($range_id); $user = User::findByUsername($username); $query = "SELECT DISTINCT statusgruppe_id FROM statusgruppe_user LEFT JOIN statusgruppen USING (statusgruppe_id) WHERE range_id = ? AND user_id = ?"; $statement = DBManager::get()->prepare($query); foreach ($result as $range_id) { $statement->execute(array($range_id, $user->user_id)); $statusgruppen = $statement->fetchAll(PDO::FETCH_COLUMN); $statement->closeCursor(); foreach ($statusgruppen as $id) { RemovePersonStatusgruppe($username, $id); } } }
public function routes(&$router) { // Get all contact groups $router->get('/contacts/groups', function () use($router) { $groups = ContactsGroups::load($GLOBALS['user']->id); $users = array(); foreach ($groups as $index => $group) { $members = ContactsGroups::loadMembers($GLOBALS['user']->id, $group['group_id']); if (!$router->compact()) { foreach ($members as $user_id) { if (!isset($users[$user_id])) { $user = $router->dispatch('get', '/user(/:user_id)', $user_id); $users[$user_id] = $user['user']; } } } $groups[$index]['members'] = $members; } $router->render($router->compact() ? compact('groups') : compact('groups', 'users')); }); // Create new contact group $router->post('/contacts/groups', function () use($router) { $name = trim(Request::get('name')); if (!$name) { $router->halt(406, 'No name provided'); } AddNewStatusgruppe($name, $GLOBALS['user']->id, 0); $router->render($router->dispatch('get', '/contacts/groups')); }); // Get members of contact group $router->get('/contacts/groups/:group_id', function ($group_id) use($router) { if (!ContactsGroups::exists($group_id)) { $router->halt(404, 'Contact group "%s" not found', $group_id); } $members = ContactsGroups::loadMembers($GLOBALS['user']->id, $group_id); if ($router->compact()) { $router->render(compact('members')); } $users = array(); foreach ($members as $user_id) { $user = $router->dispatch('get', '/user(/:user_id)', $user_id); $users[] = $user['user']; } $router->render(compact('members', 'users')); }); // Remove contact group $router->delete('/contacts/groups/:group_id', function ($group_id) use($router) { if (!ContactsGroups::exists($group_id)) { $router->halt(404, 'Contact group "%s" not found', $group_id); } DeleteStatusgruppe($group_id); $router->halt(200, 'Contact group "%s" has been deleted', $group_id); }); // Put a user into contact group $router->put('/contacts/groups/:group_id/:user_id', function ($group_id, $user_id) use($router) { if (!ContactsGroups::exists($group_id)) { $router->halt(404, 'Contact group "%s" not found', $group_id); } $user = \User::find($user_id); if (!$user) { $router->halt(404, 'User "%s" not found', $user_id); } if (!InsertPersonStatusgruppe($user_id, $group_id)) { $router->halt(500); } $router->render($router->dispatch('get', '/contacts/groups/:group_id', $group_id)); }); // Remove user from contact group $router->delete('/contacts/groups/:group_id/:user_id', function ($group_id, $user_id) use($router) { if (!ContactsGroups::exists($group_id)) { $router->halt(404, 'Contact group "%s" not found', $group_id); } $user = \User::find($user_id); if (!$user) { $router->halt(404, 'User "%s" not found', $user_id); } $username = $user->username; RemovePersonStatusgruppe($username, $group_id); $router->halt(200); }); }
MovePersonPosition (Request::quoted('username'), Request::option('role_id'), "down"); } // sort the persons of a statusgroup by their family name if (Request::option('cmd') == 'sortByName') { sortStatusgruppeByName(Request::option('role_id')); } // add persons to a statusgroup foreach ((array) GetAllStatusgruppen($range_id) as $id => $role) { addToStatusgroup($range_id, $id, $workgroup_mode); } // delete a person from a statusgroup if (Request::option('cmd') == 'removePerson') { RemovePersonStatusgruppe (Request::quoted('username'), Request::option('role_id')); $message = _('Die Person wurde aus der Gruppe entfernt!'); PageLayout::postMessage(MessageBox::success($message)); } // edit the data of a role if (Request::option('cmd') == 'doEditRole') { $statusgruppe = new Statusgruppe(Request::option('role_id')); $name = htmlReady($statusgruppe->getName()); if ($statusgruppe->checkData()) { $message = sprintf(_('Die Daten der Gruppe %s wurden geändert!'), '<b>'. htmlReady($name) .'</b>'); PageLayout::postMessage(MessageBox::info($message)); } $statusgruppe->store();