.

HijackUsersCommand Class Reference

Command to login as another user. More...

Inheritance diagram for HijackUsersCommand:
CommandComposite CommandBase ICommand IAction ISerializable

List of all members.

Public Member Functions

  get_description ()
  Returns a description of this command.
  get_name ()
  Returns title of command.

Protected Member Functions

  create_notification_command ($hijacker, $hijacked)
  do_execute ()
  Does executing.
  do_undo ()
  Does undo.

Protected Attributes

  $session_data

Detailed Description

Command to login as another user.

Definition at line 5 of file hijack.cmd.php.


Member Function Documentation

HijackUsersCommand::create_notification_command ( hijacker,
hijacked  
) [protected]

Definition at line 62 of file hijack.cmd.php.

00062                                                                              {
00063                 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'hijackaccount/notification', false);
00064                 $view->assign('hijacker', $hijacker);
00065                 $cmd = CommandsFactory::create_command(
00066                         $hijacked, 
00067                         'notify', 
00068                         array(
00069                                 'title' => tr('%name logged into your account', 'hijackaccount', array('%name' => $hijacker->name)),
00070                                 'message' => $view->render(),
00071                                 'source' => 'usermanagement.hijackaccount'
00072                         )
00073                 );
00074                 return $cmd;            
00075         }
HijackUsersCommand::do_execute (  )  [protected]

Does executing.

Returns:
Status

Reimplemented from CommandComposite.

Definition at line 31 of file hijack.cmd.php.

00031                                         {
00032                 $ret = new Status();
00033                 $this->session_data = array_merge(array(), $_SESSION);
00034                 
00035                 Load::commands('generics/massdelete', 'users/loginknown', 'generics/cookie.set');
00036                 // Store session data
00037                 $duration = GyroDate::ONE_DAY;
00038                 $cur_user = Users::get_current_user();
00039                 $saved_session_id = session::get_session_id();
00040                 $params = array('id' => $saved_session_id, 'id_user' => $cur_user->id, 'data' => $_SESSION, 'expirationdate' => time() + $duration);
00041                 $this->append(CommandsFactory::create_command('hijackaccountsavedsessions', 'create', $params));
00042                 // Clear session, but keep current user as fallback
00043                 Session::clear();
00044                 Session::push('current_user', clone($cur_user));
00045                 // Delete expired
00046                 $this->append(new MassDeleteCommand('hijackaccountsavedsessions', new DBCondition('expirationdate', '<', time())));
00047                 // Login as given user
00048                 $user = $this->get_instance();
00049                 $this->append(new LoginknownUsersCommand($user));
00050                 // Notify USer
00051                 if (Load::is_module_loaded('usermanagement.notifications')) {
00052                         $notify = $this->create_notification_command($cur_user, $user);
00053                         if ($notify->can_execute($user)) {
00054                                 $this->append($notify);
00055                         }
00056                 }
00057                 // Set a Cookie
00058                 $this->append(new CookieSetCommand(HijackAccount::COOKIE_NAME, $saved_session_id, 0));
00059                 return $ret;
00060         }
HijackUsersCommand::do_undo (  )  [protected]

Does undo.

Reimplemented from CommandComposite.

Definition at line 80 of file hijack.cmd.php.

00080                                      {
00081                 foreach($this->session_data as $key => $data) {
00082                         Session::push($key, $data);
00083                 }
00084                 Session::restart();
00085         }       
HijackUsersCommand::get_description (  ) 

Returns a description of this command.

Reimplemented from CommandBase.

Definition at line 18 of file hijack.cmd.php.

00018                                           {
00019                 $ret = tr(
00020                         'Hijack Account',
00021                         'hijack'
00022                 );
00023                 return $ret;
00024         }
HijackUsersCommand::get_name (  ) 

Returns title of command.

Reimplemented from CommandBase.

Definition at line 11 of file hijack.cmd.php.

00011                                    {
00012                 return 'hijack';
00013         }

Member Data Documentation

HijackUsersCommand::$session_data [protected]

Definition at line 6 of file hijack.cmd.php.


The documentation for this class was generated from the following file:
  • contributions/usermanagement.hijackaccount/behaviour/commands/users/hijack.cmd.php