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'); }
echo Html::anchor('groups/view/' . $group['id'], $group['name']); ?> </td> <?php } else { ?> <td><?php echo $group['name']; ?> </td> <?php } ?> <?php $right = Model_Group::access($group['id']); ?> <td><?php echo count(Sentry::group($group['id'])->users()); ?> </td> <td><?php echo round(count(isset(json_decode($right[0]['permissions'])->superuser) ? new SplFixedArray($total) : (array) json_decode($right[0]['permissions'])) * 100 / $total, 0, PHP_ROUND_HALF_EVEN); ?> /100</td> <?php if (Sentry::user()->has_access('groups_edit') || Sentry::user()->has_access('groups_delete')) { ?> <td><?php