ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $DIC;
34
35 $ilDB = $DIC['ilDB'];
36
37 $query = 'SELECT eru_id FROM ecs_remote_user ' .
38 'WHERE usr_id = ' . $ilDB->quote($a_usr_id, 'integer');
39 $res = $ilDB->query($query);
40 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
41 return new self($row->eru_id);
42 }
43 return null;
44 }
45
49 public function exists()
50 {
51 global $DIC;
52
53 $ilDB = $DIC['ilDB'];
54
55 $query = 'SELECT eru_id FROM ecs_remote_user ' .
56 'WHERE sid = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ' .
57 'AND mid = ' . $ilDB->quote($this->getMid(), 'integer') . ' ' .
58 'AND usr_id = ' . $ilDB->quote($this->getUserId(), 'integer');
59 $res = $ilDB->query($query);
60 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
61 return (bool) $row->eru_id;
62 }
63 return false;
64 }
65
66
67 public function getId()
68 {
69 return $this->eru_id;
70 }
71
72 public function setServerId($a_sid)
73 {
74 $this->sid = $a_sid;
75 }
76
77 public function getServerId()
78 {
79 return $this->sid;
80 }
81
82 public function setMid($a_mid)
83 {
84 $this->mid = $a_mid;
85 }
86
87 public function getMid()
88 {
89 return $this->mid;
90 }
91
92
93 public function setUserId($a_usr_id)
94 {
95 $this->usr_id = $a_usr_id;
96 }
97
98 public function getUserId()
99 {
100 return $this->usr_id;
101 }
102
103 public function setRemoteUserId($a_remote_id)
104 {
105 $this->remote_usr_id = $a_remote_id;
106 }
107
108 public function getRemoteUserId()
109 {
111 }
112
117 public function update()
118 {
119 $query = 'UPDATE ecs_remote_user SET ' .
120 'sid = ' . $GLOBALS['DIC']['ilDB']->quote($this->getServerId(), 'integer') . ', ' .
121 'mid = ' . $GLOBALS['DIC']['ilDB']->quote($this->getMid(), 'integer') . ', ' .
122 'usr_id = ' . $GLOBALS['DIC']['ilDB']->quote($this->getUserId(), 'text') . ', ' .
123 'remote_usr_id = ' . $GLOBALS['DIC']['ilDB']->quote($this->getRemoteUserId(), 'text') . ' ' .
124 'WHERE eru_id = ' . $GLOBALS['DIC']['ilDB']->quote($this->getId());
125 $GLOBALS['DIC']['ilDB']->manipulate($query);
126 return true;
127 }
128
132 public function create()
133 {
134 $next_id = $GLOBALS['DIC']['ilDB']->nextId('ecs_remote_user');
135 $query = 'INSERT INTO ecs_remote_user (eru_id, sid, mid, usr_id, remote_usr_id) ' .
136 'VALUES( ' .
137 $GLOBALS['DIC']['ilDB']->quote($next_id) . ', ' .
138 $GLOBALS['DIC']['ilDB']->quote($this->getServerId(), 'integer') . ', ' .
139 $GLOBALS['DIC']['ilDB']->quote($this->getMid(), 'integer') . ', ' .
140 $GLOBALS['DIC']['ilDB']->quote($this->getUserId(), 'text') . ', ' .
141 $GLOBALS['DIC']['ilDB']->quote($this->getRemoteUserId(), 'text') . ' ' .
142 ')';
143 $GLOBALS['DIC']['ilDB']->manipulate($query);
144 }
145
150 protected function read()
151 {
152 if (!$this->getId()) {
153 return false;
154 }
155
156 $query = 'SELECT * FROM ecs_remote_user ' .
157 'WHERE eru_id = ' . $GLOBALS['DIC']['ilDB']->quote($this->getId(), 'integer');
158 $res = $GLOBALS['DIC']['ilDB']->query($query);
159 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
160 $this->setServerId($row->sid);
161 $this->setMid($row->mid);
162 $this->setUserId($row->usr_id);
163 $this->setRemoteUserId($row->remote_usr_id);
164 }
165 }
166}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
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)
global $DIC
Definition: goto.php:24
$query
foreach($_POST as $key=> $value) $res
global $ilDB