has('action')) { $groups_table = []; foreach ($groups as $group) { $privileges = DB::select(' SELECT `name` FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`=? ', [$group['UID']]); $privileges_html = []; foreach ($privileges as $privilege) { $privileges_html[] = $privilege['name']; } $groups_table[] = [ 'name' => $group['Name'], 'privileges' => join(', ', $privileges_html), 'actions' => button( page_link_to('admin_groups', ['action' => 'edit', 'id' => $group['UID']]), _('edit'), 'btn-xs' ) ]; } return page_with_title(admin_groups_title(), [ table([ 'name' => _('Name'), 'privileges' => _('Privileges'), 'actions' => '' ], $groups_table) ]); } else { switch ($request->input('action')) { case 'edit': if ($request->has('id') && preg_match('/^-\d{1,11}$/', $request->input('id'))) { $group_id = $request->input('id'); } else { return error('Incomplete call, missing Groups ID.', true); } $group = DB::select('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]); if (!empty($group)) { $privileges = DB::select(' SELECT `Privileges`.*, `GroupPrivileges`.`group_id` FROM `Privileges` LEFT OUTER JOIN `GroupPrivileges` ON ( `Privileges`.`id` = `GroupPrivileges`.`privilege_id` AND `GroupPrivileges`.`group_id`=? ) ORDER BY `Privileges`.`name` ', [$group_id]); $privileges_html = ''; $privileges_form = []; foreach ($privileges as $privilege) { $privileges_form[] = form_checkbox( 'privileges[]', $privilege['desc'] . ' (' . $privilege['name'] . ')', $privilege['group_id'] != '', $privilege['id'], 'privilege-' . $privilege['name'] ); $privileges_html .= sprintf( '