ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilECSRemoteUser.php
Go to the documentation of this file.
1<?php
2
9{
10 private $eru_id = 0;
11 private $sid = 0;
12 private $mid = 0;
13 private $usr_id = 0;
14 private $remote_usr_id = '';
15
16
20 public function __construct($a_eru_id = 0)
21 {
22 $this->eru_id = $a_eru_id;
23 $this->read();
24 }
25
31 public static function factory($a_usr_id)
32 {
33 global $ilDB;
34
35 $query = 'SELECT eru_id FROM ecs_remote_user '.
36 'WHERE usr_id = '.$ilDB->quote($a_usr_id,'integer');
37 $res = $ilDB->query($query);
38 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
39 {
40 return new self($row->eru_id);
41 }
42 return null;
43 }
44
48 public function exists()
49 {
50 global $ilDB;
51
52 $query = 'SELECT eru_id FROM ecs_remote_user '.
53 'WHERE sid = '.$ilDB->quote($this->getServerId(),'integer').' '.
54 'AND mid = '.$ilDB->quote($this->getMid(),'integer').' '.
55 'AND usr_id = '.$ilDB->quote($this->getUserId(),'integer');
56 $res = $ilDB->query($query);
57 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
58 {
59 return (bool) $row->eru_id;
60 }
61 return false;
62 }
63
64
65 public function getId()
66 {
67 return $this->eru_id;
68 }
69
70 public function setServerId($a_sid)
71 {
72 $this->sid = $a_sid;
73 }
74
75 public function getServerId()
76 {
77 return $this->sid;
78 }
79
80 public function setMid($a_mid)
81 {
82 $this->mid = $a_mid;
83 }
84
85 public function getMid()
86 {
87 return $this->mid;
88 }
89
90
91 public function setUserId($a_usr_id)
92 {
93 $this->usr_id = $a_usr_id;
94 }
95
96 public function getUserId()
97 {
98 return $this->usr_id;
99 }
100
101 public function setRemoteUserId($a_remote_id)
102 {
103 $this->remote_usr_id = $a_remote_id;
104 }
105
106 public function getRemoteUserId()
107 {
109 }
110
115 public function update()
116 {
117 $query = 'UPDATE ecs_remote_user SET '.
118 'sid = '.$GLOBALS['ilDB']->quote($this->getServerId(),'integer').', '.
119 'mid = '.$GLOBALS['ilDB']->quote($this->getMid(),'integer').', '.
120 'usr_id = '.$GLOBALS['ilDB']->quote($this->getUserId(),'text').', '.
121 'remote_usr_id = '.$GLOBALS['ilDB']->quote($this->getRemoteUserId(),'text').' '.
122 'WHERE eru_id = '.$GLOBALS['ilDB']->quote($this->getId());
123 $GLOBALS['ilDB']->manipulate($query);
124 return true;
125 }
126
130 public function create()
131 {
132
133 $next_id = $GLOBALS['ilDB']->nextId('ecs_remote_user');
134 $query = 'INSERT INTO ecs_remote_user (eru_id, sid, mid, usr_id, remote_usr_id) '.
135 'VALUES( '.
136 $GLOBALS['ilDB']->quote($next_id).', '.
137 $GLOBALS['ilDB']->quote($this->getServerId(),'integer').', '.
138 $GLOBALS['ilDB']->quote($this->getMid(),'integer').', '.
139 $GLOBALS['ilDB']->quote($this->getUserId(),'text').', '.
140 $GLOBALS['ilDB']->quote($this->getRemoteUserId(),'text').' '.
141 ')';
142 $GLOBALS['ilDB']->manipulate($query);
143 }
144
149 protected function read()
150 {
151 if(!$this->getId())
152 {
153 return false;
154 }
155
156 $query = 'SELECT * FROM ecs_remote_user '.
157 'WHERE eru_id = '.$GLOBALS['ilDB']->quote($this->getId(),'integer');
158 $res = $GLOBALS['ilDB']->query($query);
159 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
160 {
161 $this->setServerId($row->sid);
162 $this->setMid($row->mid);
163 $this->setUserId($row->usr_id);
164 $this->setRemoteUserId($row->remote_usr_id);
165 }
166 }
167
168}
169?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
Storage of ecs remote user.
exists()
Check if entry exists for user.
__construct($a_eru_id=0)
Constructor.
create()
Create nerw remote user entry.
update()
Update remote user entry.
static factory($a_usr_id)
Get instance for usr_id.
setRemoteUserId($a_remote_id)
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilDB