Subversion Repositories bysoftdeveloper

[/] [classes/] [switchuser.php] - Blame information for rev 31

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 alvawu
<?php
2
class SwitchUser
3
{
4
        private $original;
5
        private $target;
6
 
7
        public function __construct($original, $target)
8
        {
9
                $this->original = $original;
10
                $this->target = $target;
11
        }
12
 
13
        public function change()
14
        {
15
                self::switchTo($this->target);
16
        }
17
 
18
        public function changeBack()
19
        {
20
                self::switchTo($this->original);
21
        }
22
 
23
        public static function switchTo($userobject)
24
        {
25
                if($userobject instanceof eZUser)
26
                {
27
                        eZUser::logoutCurrent();
28
                        $userobject->loginCurrent();
29
                }
30
        }
31
 
32
}