Controller_Admin_Users::action_delete PHP Method

action_delete() public method

Delete a user
public action_delete ( )
    public function action_delete()
    {
        Kohana::$log->add(Kohana::DEBUG, 'Executing Controller_Users::action_delete');
        // If deletion is not desired, redirect to list
        if (isset($_POST['no'])) {
            $this->request->redirect($this->request->uri(array('action' => 'list')));
        }
        $this->template->content = View::factory('admin/users/delete')->bind('user', $this->_resource);
        // Bind locally
        $user =& $this->_resource;
        $name = $user->username;
        // If deletion is confirmed
        if (isset($_POST['yes'])) {
            try {
                $user->delete();
                Message::instance()->info('The user, :name, has been deleted.', array(':name' => $name));
                if (!$this->_internal) {
                    $this->request->redirect($this->request->uri(array('action' => 'list')));
                }
            } catch (Exception $e) {
                Kohana::$log->add(Kohana::ERROR, 'Error occured deleting user, id=' . $user->id . ', ' . $e->getMessage());
                Message::instance()->error('An error occured deleting user, :name.', array(':name' => $name));
                if (!$this->_internal) {
                    $this->request->redirect($this->request->uri(array('action' => 'list')));
                }
            }
        }
    }