2008-11-11 07:39:20 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
|
|
|
|
* Copyright (C) 2000-2008 Bharat Mediratta
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
|
* your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
2008-11-18 08:10:14 +00:00
|
|
|
class Users_Controller extends REST_Controller {
|
2008-11-12 03:40:49 +00:00
|
|
|
protected $resource_type = "user";
|
|
|
|
|
|
2008-11-15 06:23:09 +00:00
|
|
|
/**
|
2008-11-18 08:28:32 +00:00
|
|
|
* Display comments based on criteria.
|
2008-11-18 15:48:08 +00:00
|
|
|
* @see Rest_Controller::_index()
|
2008-11-15 06:23:09 +00:00
|
|
|
*/
|
2008-11-18 15:48:08 +00:00
|
|
|
public function _index() {
|
2008-11-18 08:28:32 +00:00
|
|
|
throw new Exception("@todo Comment_Controller::_index NOT IMPLEMENTED");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see Rest_Controller::_create($resource)
|
|
|
|
|
*/
|
|
|
|
|
public function _create($user) {
|
|
|
|
|
throw new Exception("@todo User_Controller::_create NOT IMPLEMENTED");
|
2008-11-15 06:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-12 03:40:49 +00:00
|
|
|
/**
|
2008-11-19 04:20:35 +00:00
|
|
|
* @see Rest_Controller::_show($resource)
|
2008-11-12 03:40:49 +00:00
|
|
|
*/
|
2008-11-19 04:20:35 +00:00
|
|
|
public function _show($user) {
|
2008-11-18 08:28:32 +00:00
|
|
|
throw new Exception("@todo User_Controller::_show NOT IMPLEMENTED");
|
2008-11-12 03:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-11-18 08:28:32 +00:00
|
|
|
* @see Rest_Controller::_update($resource)
|
2008-11-12 03:40:49 +00:00
|
|
|
*/
|
2008-11-18 08:28:32 +00:00
|
|
|
public function _update($user) {
|
2008-12-19 22:16:10 +00:00
|
|
|
if ($user->guest || $user->id != user::active()->id) {
|
|
|
|
|
access::forbidden();
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-16 07:51:42 +00:00
|
|
|
$form = user::get_edit_form($user);
|
2008-11-15 06:23:09 +00:00
|
|
|
if ($form->validate()) {
|
2008-12-19 22:16:10 +00:00
|
|
|
$user->full_name = $form->edit_user->full_name->value;
|
|
|
|
|
$user->password = $form->edit_user->password->value;
|
|
|
|
|
$user->email = $form->edit_user->email->value;
|
2008-11-15 08:15:00 +00:00
|
|
|
$user->save();
|
|
|
|
|
if ($continue = $this->input->get("continue")) {
|
|
|
|
|
url::redirect($continue);
|
|
|
|
|
}
|
2008-11-15 06:23:09 +00:00
|
|
|
}
|
2008-11-16 19:12:01 +00:00
|
|
|
print $form;
|
2008-11-16 19:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-11-18 08:28:32 +00:00
|
|
|
* @see Rest_Controller::_delete($resource)
|
2008-11-16 19:26:44 +00:00
|
|
|
*/
|
2008-11-18 08:28:32 +00:00
|
|
|
public function _delete($user) {
|
|
|
|
|
throw new Exception("@todo User_Controller::_delete NOT IMPLEMENTED");
|
2008-11-11 07:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-12 03:40:49 +00:00
|
|
|
/**
|
2008-11-18 08:28:32 +00:00
|
|
|
* Present a form for editing a user
|
|
|
|
|
* @see Rest_Controller::form($resource)
|
2008-11-12 03:40:49 +00:00
|
|
|
*/
|
2008-11-18 23:40:47 +00:00
|
|
|
public function _form_edit($user) {
|
2008-12-19 22:16:10 +00:00
|
|
|
if ($user->guest || user::active()->id != $user->id) {
|
|
|
|
|
access::forbidden();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print user::get_edit_form(
|
|
|
|
|
$user,
|
|
|
|
|
"users/{$user->id}?_method=put&continue=" . $this->input->get("continue"));
|
2008-11-18 23:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Present a form for adding a user
|
|
|
|
|
* @see Rest_Controller::form($resource)
|
|
|
|
|
*/
|
|
|
|
|
public function _form_add($parameters) {
|
|
|
|
|
throw new Exception("@todo User_Controller::_form_add NOT IMPLEMENTED");
|
2008-11-11 07:39:20 +00:00
|
|
|
}
|
2008-11-18 08:28:32 +00:00
|
|
|
}
|