ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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(ilDBConstants::FETCHMODE_OBJECT)) {
39  return new self($row->eru_id);
40  }
41  return null;
42  }
43 
47  public function exists()
48  {
49  global $ilDB;
50 
51  $query = 'SELECT eru_id FROM ecs_remote_user ' .
52  'WHERE sid = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
53  'AND mid = ' . $ilDB->quote($this->getMid(), 'integer') . ' ' .
54  'AND usr_id = ' . $ilDB->quote($this->getUserId(), 'integer');
55  $res = $ilDB->query($query);
56  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
57  return (bool) $row->eru_id;
58  }
59  return false;
60  }
61 
62 
63  public function getId()
64  {
65  return $this->eru_id;
66  }
67 
68  public function setServerId($a_sid)
69  {
70  $this->sid = $a_sid;
71  }
72 
73  public function getServerId()
74  {
75  return $this->sid;
76  }
77 
78  public function setMid($a_mid)
79  {
80  $this->mid = $a_mid;
81  }
82 
83  public function getMid()
84  {
85  return $this->mid;
86  }
87 
88 
89  public function setUserId($a_usr_id)
90  {
91  $this->usr_id = $a_usr_id;
92  }
93 
94  public function getUserId()
95  {
96  return $this->usr_id;
97  }
98 
99  public function setRemoteUserId($a_remote_id)
100  {
101  $this->remote_usr_id = $a_remote_id;
102  }
103 
104  public function getRemoteUserId()
105  {
106  return $this->remote_usr_id;
107  }
108 
113  public function update()
114  {
115  $query = 'UPDATE ecs_remote_user SET ' .
116  'sid = ' . $GLOBALS['ilDB']->quote($this->getServerId(), 'integer') . ', ' .
117  'mid = ' . $GLOBALS['ilDB']->quote($this->getMid(), 'integer') . ', ' .
118  'usr_id = ' . $GLOBALS['ilDB']->quote($this->getUserId(), 'text') . ', ' .
119  'remote_usr_id = ' . $GLOBALS['ilDB']->quote($this->getRemoteUserId(), 'text') . ' ' .
120  'WHERE eru_id = ' . $GLOBALS['ilDB']->quote($this->getId());
121  $GLOBALS['ilDB']->manipulate($query);
122  return true;
123  }
124 
128  public function create()
129  {
130  $next_id = $GLOBALS['ilDB']->nextId('ecs_remote_user');
131  $query = 'INSERT INTO ecs_remote_user (eru_id, sid, mid, usr_id, remote_usr_id) ' .
132  'VALUES( ' .
133  $GLOBALS['ilDB']->quote($next_id) . ', ' .
134  $GLOBALS['ilDB']->quote($this->getServerId(), 'integer') . ', ' .
135  $GLOBALS['ilDB']->quote($this->getMid(), 'integer') . ', ' .
136  $GLOBALS['ilDB']->quote($this->getUserId(), 'text') . ', ' .
137  $GLOBALS['ilDB']->quote($this->getRemoteUserId(), 'text') . ' ' .
138  ')';
139  $GLOBALS['ilDB']->manipulate($query);
140  }
141 
146  protected function read()
147  {
148  if (!$this->getId()) {
149  return false;
150  }
151 
152  $query = 'SELECT * FROM ecs_remote_user ' .
153  'WHERE eru_id = ' . $GLOBALS['ilDB']->quote($this->getId(), 'integer');
154  $res = $GLOBALS['ilDB']->query($query);
155  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
156  $this->setServerId($row->sid);
157  $this->setMid($row->mid);
158  $this->setUserId($row->usr_id);
159  $this->setRemoteUserId($row->remote_usr_id);
160  }
161  }
162 }
setRemoteUserId($a_remote_id)
read()
Read data set.
Storage of ecs remote user.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
update()
Update remote user entry.
exists()
Check if entry exists for user.
foreach($_POST as $key=> $value) $res
$query
global $ilDB
static factory($a_usr_id)
Get instance for usr_id.
create()
Create nerw remote user entry.
__construct($a_eru_id=0)
Constructor.