00001 <?php
00002 class HijackaccountController extends ControllerBase {
00003
00004
00005
00006
00007
00008 public function get_routes() {
00009 return array(
00010 new CommandsRoute('https://process_commands/users/{id:ui>}/hijack', $this, 'users_hijack', new UsersAccessControl())
00011 );
00012 }
00013
00014
00015
00016
00017 public function action_users_hijack(PageData $page_data, $id) {
00018 $user = Users::get($id);
00019 if ($user === false) {
00020 return self::NOT_FOUND;
00021 }
00022
00023 $cmd = CommandsFactory::create_command($user, 'hijack', false);
00024 $ok = $cmd->can_execute(false);
00025 if (!$ok) {
00026 return self::ACCESS_DENIED;
00027 }
00028
00029 $err = $cmd->execute();
00030 if ($err->is_ok()) {
00031 $err = new Message(tr(
00032 'You now have been logged in as %name. If you log out, you will return to you old session',
00033 'hijackaccount',
00034 array('%name' => $user->get_title())
00035 ));
00036 }
00037 History::go_to(0, $err);
00038 }
00039 }