public function action_edit($id = null) { if (!Sentry::user()->has_access('groups_edit')) { self::no_access(); } $groups = Model_Group::access(intval($id)); $group['permissions'] = json_decode($groups[0]['permissions'], true); $group['groupName'] = $groups[0]['name']; if (Input::method() == 'POST') { if (!Input::post('groupName')) { Session::set_flash('error', 'Please choose a name for the group'); } else { $post = Input::post(); $groupName = $post['groupName']; unset($post['groupName']); // JSON_NUMERIC_CHECK to keep the int $permissions = json_encode($post, JSON_NUMERIC_CHECK); $updated = Model_Group::editGroup(intval($id), $groupName, $permissions); if ($updated) { Session::set_flash('success', 'The group ' . $groupName . ' has been successfully edited'); Response::redirect('groups'); } } } $var = self::access(); // all the access View::set_global('var', $var); // all the needed informations about the current group View::set_global('group', $group); $this->template->h2 = 'Edit Group'; $this->template->title = 'Groups » Edit'; $this->template->js .= Asset::js(array('mylibs/jquery.validate.js', 'script.js')); $this->template->content = View::forge('groups/edit'); }