From 481352c382d769d9074223ae9c7b6d969f0f6e58 Mon Sep 17 00:00:00 2001 From: Felix Rabinovich Date: Thu, 25 Dec 2008 02:16:41 +0000 Subject: User administration: 1. Add users; 2. Group administration; 3. General cleanup --- modules/user/controllers/groups.php | 106 ++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 modules/user/controllers/groups.php (limited to 'modules/user/controllers/groups.php') diff --git a/modules/user/controllers/groups.php b/modules/user/controllers/groups.php new file mode 100644 index 00000000..96084fe2 --- /dev/null +++ b/modules/user/controllers/groups.php @@ -0,0 +1,106 @@ +validate()) { + group::create($form->add_group->gname->value); + if ($continue = $this->input->get("continue")) { + url::redirect($continue); + } + } + print $form; + } + + /** + * @see Rest_Controller::_show($resource) + */ + public function _show($user) { + throw new Exception("@todo Group_Controller::_show NOT IMPLEMENTED"); + } + + /** + * @see Rest_Controller::_update($resource) + */ + public function _update($group) { + $form = group::get_edit_form($group); + if ($form->validate()) { + $group->name = $form->edit_group->gname->value; + $group->save(); + if ($continue = $this->input->get("continue")) { + url::redirect($continue); + } + } + print $form; + } + + /** + * @see Rest_Controller::_delete($resource) + */ + public function _delete($group) { + if (!(user::active()->admin) || $group->special) { + access::forbidden(); + } + // Prevent CSRF + $form = group::get_delete_form($group); + if ($form->validate()) { + $group->delete(); + if ($continue = $this->input->get("continue")) { + url::redirect($continue); + } + } + print $form; + } + + /** + * Present a form for editing a user + * @see Rest_Controller::form($resource) + */ + public function _form_edit($group) { + if ($group->guest || group::active()->id != $group->id) { + access::forbidden(); + } + + print group::get_edit_form( + $group, + "users/{$group->id}?_method=put&continue=" . $this->input->get("continue")); + } + + /** + * Present a form for adding a user + * @see Rest_Controller::form($resource) + */ + public function _form_add($parameters) { + throw new Exception("@todo Group_Controller::_form_add NOT IMPLEMENTED"); + } +} -- cgit v1.2.3