ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilECSCourseMemberAssignment Class Reference

Storage of ecs course assignments. More...

+ Collaboration diagram for ilECSCourseMemberAssignment:

Public Member Functions

 __construct (int $a_id=0)
 Constructor. More...
 
 getId ()
 
 setServer (int $a_server)
 Set server. More...
 
 getServer ()
 Get server. More...
 
 setMid (int $a_mid)
 
 getMid ()
 
 setCmsId (int $a_id)
 
 getCmsId ()
 
 setCmsSubId (int $a_id)
 
 getCmsSubId ()
 
 setObjId (int $a_id)
 
 getObjId ()
 
 setUid (string $a_id)
 
 getUid ()
 
 setStatus (bool $a_status)
 
 getStatus ()
 
 save ()
 Save new entry. More...
 
 update ()
 Update assignment. More...
 
 delete ()
 Delete entry. More...
 

Static Public Member Functions

static lookupMissingAssignmentsOfUser (string $a_usr_id)
 Lookup missing assignments;. More...
 
static deleteByObjId (int $a_obj_id)
 Delete by obj_id. More...
 
static deleteByServerId (int $a_server_id)
 Delete by server id. More...
 
static lookupUserIds (int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id)
 Lookup user ids. More...
 
static lookupAssignment (int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id, string $a_usr_id)
 Lookup assignment of user. More...
 

Data Fields

const STATUS_ASSIGNED = 0
 
const STATUS_LOCAL_DELETED = 1
 

Protected Member Functions

 read ()
 Read from db. More...
 

Private Attributes

ilDBInterface $db
 
int $id
 
int $server
 
int $mid
 
int $cms_id
 
int $cms_sub_id = 0
 
int $obj_id
 
string $uid
 
bool $status = false
 

Detailed Description

Storage of ecs course assignments.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 23 of file class.ilECSCourseMemberAssignment.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCourseMemberAssignment::__construct ( int  $a_id = 0)

Constructor.

Definition at line 43 of file class.ilECSCourseMemberAssignment.php.

44 {
45 global $DIC;
46
47 $this->db = $DIC->database();
48
49 $this->id = $a_id;
50
51 $this->read();
52 }
global $DIC
Definition: feed.php:28

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilECSCourseMemberAssignment::delete ( )

Delete entry.

Definition at line 299 of file class.ilECSCourseMemberAssignment.php.

299 : bool
300 {
301 $query = 'DELETE FROM ecs_course_assignments ' .
302 'WHERE id = ' . $this->db->quote($this->getId(), 'integer');
303 $this->db->manipulate($query);
304 return true;
305 }
$query

References $query, and getId().

+ Here is the call graph for this function:

◆ deleteByObjId()

static ilECSCourseMemberAssignment::deleteByObjId ( int  $a_obj_id)
static

Delete by obj_id.

Definition at line 79 of file class.ilECSCourseMemberAssignment.php.

79 : bool
80 {
81 global $DIC;
82
83 $ilDB = $DIC['ilDB'];
84
85 $query = 'DELETE FROM ecs_course_assignments ' .
86 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
87 $ilDB->manipulate($query);
88 return true;
89 }

References $DIC, $ilDB, and $query.

◆ deleteByServerId()

static ilECSCourseMemberAssignment::deleteByServerId ( int  $a_server_id)
static

Delete by server id.

Definition at line 94 of file class.ilECSCourseMemberAssignment.php.

94 : bool
95 {
96 global $DIC;
97
98 $ilDB = $DIC['ilDB'];
99
100 $query = 'DELETE FROM ecs_course_assignments ' .
101 'WHERE sid = ' . $ilDB->quote($a_server_id, 'integer');
102 $ilDB->manipulate($query);
103 return true;
104 }

References $DIC, $ilDB, and $query.

◆ getCmsId()

ilECSCourseMemberAssignment::getCmsId ( )

Definition at line 198 of file class.ilECSCourseMemberAssignment.php.

198 : int
199 {
200 return $this->cms_id;
201 }

References $cms_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getCmsSubId()

ilECSCourseMemberAssignment::getCmsSubId ( )

Definition at line 208 of file class.ilECSCourseMemberAssignment.php.

208 : ?int
209 {
210 return $this->cms_sub_id;
211 }

References $cms_sub_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getId()

ilECSCourseMemberAssignment::getId ( )

Definition at line 162 of file class.ilECSCourseMemberAssignment.php.

162 : int
163 {
164 return $this->id;
165 }

References $id.

Referenced by delete(), read(), save(), and update().

+ Here is the caller graph for this function:

◆ getMid()

ilECSCourseMemberAssignment::getMid ( )

Definition at line 188 of file class.ilECSCourseMemberAssignment.php.

188 : int
189 {
190 return $this->mid;
191 }

References $mid.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getObjId()

ilECSCourseMemberAssignment::getObjId ( )

Definition at line 218 of file class.ilECSCourseMemberAssignment.php.

218 : int
219 {
220 return $this->obj_id;
221 }

References $obj_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getServer()

ilECSCourseMemberAssignment::getServer ( )

Get server.

Definition at line 178 of file class.ilECSCourseMemberAssignment.php.

178 : int
179 {
180 return $this->server;
181 }

References $server.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getStatus()

ilECSCourseMemberAssignment::getStatus ( )

Definition at line 238 of file class.ilECSCourseMemberAssignment.php.

238 : bool
239 {
240 return $this->status;
241 }

References $status.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getUid()

ilECSCourseMemberAssignment::getUid ( )

Definition at line 228 of file class.ilECSCourseMemberAssignment.php.

228 : ?string
229 {
230 return $this->uid;
231 }

References $uid.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ lookupAssignment()

static ilECSCourseMemberAssignment::lookupAssignment ( int  $a_cms_id,
?int  $a_cms_sub_id,
int  $a_obj_id,
string  $a_usr_id 
)
static

Lookup assignment of user.

Definition at line 137 of file class.ilECSCourseMemberAssignment.php.

138 {
139 global $DIC;
140
141 $ilDB = $DIC['ilDB'];
142
143 if (is_null($a_cms_sub_id)) {
144 $cms_sub_id_query = 'AND (cms_sub_id IS NULL or cms_sub_id = 0) ';
145 } else {
146 $cms_sub_id_query = 'AND cms_sub_id = ' . $ilDB->quote($a_cms_sub_id, 'integer') . ' ';
147 }
148
149 $query = 'SELECT id FROM ecs_course_assignments ' .
150 'WHERE cms_id = ' . $ilDB->quote($a_cms_id, 'integer') . ' ' .
151 $cms_sub_id_query .
152 'AND obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
153 'AND usr_id = ' . $ilDB->quote($a_usr_id, 'text');
154 $res = $ilDB->query($query);
155 if ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
156 return new ilECSCourseMemberAssignment((int) $row->id);
157 }
158 return null;
159 }
Storage of ecs course assignments.
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilECSCmsCourseMemberCommandQueueHandler\refreshAssignmentStatus(), and save().

+ Here is the caller graph for this function:

◆ lookupMissingAssignmentsOfUser()

static ilECSCourseMemberAssignment::lookupMissingAssignmentsOfUser ( string  $a_usr_id)
static

Lookup missing assignments;.

Parameters
string$a_usr_idaccount
Returns
ilECSCourseMemberAssignment[]

Definition at line 59 of file class.ilECSCourseMemberAssignment.php.

59 : array
60 {
61 global $DIC;
62
63 $ilDB = $DIC['ilDB'];
64
65 $query = 'SELECT id FROM ecs_course_assignments ' .
66 'WHERE usr_id = ' . $ilDB->quote($a_usr_id, 'text');
67 $res = $ilDB->query($query);
68
69 $assignments = array();
70 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
71 $assignments[] = new self((int) $row->id);
72 }
73 return $assignments;
74 }

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilECSAppEventListener\handleMembership().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupUserIds()

static ilECSCourseMemberAssignment::lookupUserIds ( int  $a_cms_id,
?int  $a_cms_sub_id,
int  $a_obj_id 
)
static

Lookup user ids.

Definition at line 109 of file class.ilECSCourseMemberAssignment.php.

109 : array
110 {
111 global $DIC;
112
113 $ilDB = $DIC['ilDB'];
114
115 if (is_null($a_cms_sub_id)) {
116 $cms_sub_id_query = 'AND (cms_sub_id IS NULL or cms_sub_id = 0) ';
117 } else {
118 $cms_sub_id_query = 'AND cms_sub_id = ' . $ilDB->quote($a_cms_sub_id, 'integer') . ' ';
119 }
120
121 $query = 'SELECT usr_id FROM ecs_course_assignments ' .
122 'WHERE cms_id = ' . $ilDB->quote($a_cms_id, 'integer') . ' ' .
123 $cms_sub_id_query .
124 'AND obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
125 $res = $ilDB->query($query);
126
127 $usr_ids = [];
128 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
129 $usr_ids[] = $row->usr_id;
130 }
131 return $usr_ids;
132 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilECSCmsCourseMemberCommandQueueHandler\refreshAssignmentStatus().

+ Here is the caller graph for this function:

◆ read()

ilECSCourseMemberAssignment::read ( )
protected

Read from db.

Definition at line 312 of file class.ilECSCourseMemberAssignment.php.

312 : bool
313 {
314 if (!$this->getId()) {
315 return false;
316 }
317
318 $query = 'SELECT * FROM ecs_course_assignments ' .
319 'WHERE id = ' . $this->db->quote($this->getId(), 'integer');
320 $res = $this->db->query($query);
321 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
322 $this->setServer((int) $row->sid);
323 $this->setMid((int) $row->mid);
324 $this->setCmsId((int) $row->cms_id);
325 if (!is_null($row->cms_sub_id)) {
326 $this->setCmsSubId((int) $row->cms_sub_id);
327 }
328 $this->setObjId((int) $row->obj_id);
329 if (!is_null($row->usr_id)) {
330 $this->setUid($row->usr_id);
331 }
332 $this->setStatus((bool) $row->status);
333 }
334 return true;
335 }

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, getId(), setCmsId(), setCmsSubId(), setMid(), setObjId(), setServer(), setStatus(), and setUid().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilECSCourseMemberAssignment::save ( )

Save new entry.

Definition at line 246 of file class.ilECSCourseMemberAssignment.php.

246 : bool
247 {
248 $this->id = $this->db->nextId('ecs_course_assignments');
249
250 $assignment = self::lookupAssignment(
251 $this->getCmsId(),
252 $this->getCmsSubId(),
253 $this->getObjId(),
254 $this->getUid()
255 );
256 if ($assignment instanceof self) {
257 $assignment->update();
258 return true;
259 }
260
261 $query = 'INSERT INTO ecs_course_assignments ' .
262 '(id,sid,mid,cms_id,cms_sub_id,obj_id,usr_id,status) ' .
263 'VALUES( ' .
264 $this->db->quote($this->getId(), 'integer') . ', ' .
265 $this->db->quote($this->getServer(), 'integer') . ', ' .
266 $this->db->quote($this->getMid(), 'integer') . ', ' .
267 $this->db->quote($this->getCmsId(), 'integer') . ', ' .
268 $this->db->quote($this->getCmsSubId(), 'integer') . ', ' .
269 $this->db->quote($this->getObjId(), 'integer') . ', ' .
270 $this->db->quote($this->getUid(), 'text') . ', ' .
271 $this->db->quote($this->getStatus(), 'integer') . ' ' .
272 ')';
273 $this->db->manipulate($query);
274 return true;
275 }
static lookupAssignment(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id, string $a_usr_id)
Lookup assignment of user.

References $query, getCmsId(), getCmsSubId(), getId(), getMid(), getObjId(), getServer(), getStatus(), getUid(), and lookupAssignment().

+ Here is the call graph for this function:

◆ setCmsId()

ilECSCourseMemberAssignment::setCmsId ( int  $a_id)

Definition at line 193 of file class.ilECSCourseMemberAssignment.php.

193 : void
194 {
195 $this->cms_id = $a_id;
196 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setCmsSubId()

ilECSCourseMemberAssignment::setCmsSubId ( int  $a_id)

Definition at line 203 of file class.ilECSCourseMemberAssignment.php.

203 : void
204 {
205 $this->cms_sub_id = $a_id;
206 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMid()

ilECSCourseMemberAssignment::setMid ( int  $a_mid)

Definition at line 183 of file class.ilECSCourseMemberAssignment.php.

183 : void
184 {
185 $this->mid = $a_mid;
186 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjId()

ilECSCourseMemberAssignment::setObjId ( int  $a_id)

Definition at line 213 of file class.ilECSCourseMemberAssignment.php.

213 : void
214 {
215 $this->obj_id = $a_id;
216 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setServer()

ilECSCourseMemberAssignment::setServer ( int  $a_server)

Set server.

Definition at line 170 of file class.ilECSCourseMemberAssignment.php.

170 : void
171 {
172 $this->server = $a_server;
173 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setStatus()

ilECSCourseMemberAssignment::setStatus ( bool  $a_status)

Definition at line 233 of file class.ilECSCourseMemberAssignment.php.

233 : void
234 {
235 $this->status = $a_status;
236 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setUid()

ilECSCourseMemberAssignment::setUid ( string  $a_id)

Definition at line 223 of file class.ilECSCourseMemberAssignment.php.

223 : void
224 {
225 $this->uid = $a_id;
226 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilECSCourseMemberAssignment::update ( )

Update assignment.

Definition at line 280 of file class.ilECSCourseMemberAssignment.php.

280 : bool
281 {
282 $query = 'UPDATE ecs_course_assignments ' .
283 'SET ' .
284 'sid = ' . $this->db->quote($this->getServer(), 'integer') . ', ' .
285 'mid = ' . $this->db->quote($this->getMid(), 'integer') . ', ' .
286 'cms_id = ' . $this->db->quote($this->getCmsId(), 'integer') . ', ' .
287 'cms_sub_id = ' . $this->db->quote($this->getCmsSubId(), 'integer') . ', ' .
288 'obj_id = ' . $this->db->quote($this->getObjId(), 'integer') . ', ' .
289 'usr_id = ' . $this->db->quote($this->getUid(), 'text') . ', ' .
290 'status = ' . $this->db->quote($this->getStatus(), 'integer') . ' ' .
291 'WHERE id = ' . $this->db->quote($this->getId(), 'integer');
292 $this->db->manipulate($query);
293 return true;
294 }

References $query, getCmsId(), getCmsSubId(), getId(), getMid(), getObjId(), getServer(), getStatus(), and getUid().

+ Here is the call graph for this function:

Field Documentation

◆ $cms_id

int ilECSCourseMemberAssignment::$cms_id
private

Definition at line 33 of file class.ilECSCourseMemberAssignment.php.

Referenced by getCmsId().

◆ $cms_sub_id

int ilECSCourseMemberAssignment::$cms_sub_id = 0
private

Definition at line 34 of file class.ilECSCourseMemberAssignment.php.

Referenced by getCmsSubId().

◆ $db

ilDBInterface ilECSCourseMemberAssignment::$db
private

Definition at line 28 of file class.ilECSCourseMemberAssignment.php.

◆ $id

int ilECSCourseMemberAssignment::$id
private

Definition at line 30 of file class.ilECSCourseMemberAssignment.php.

Referenced by getId().

◆ $mid

int ilECSCourseMemberAssignment::$mid
private

Definition at line 32 of file class.ilECSCourseMemberAssignment.php.

Referenced by getMid().

◆ $obj_id

int ilECSCourseMemberAssignment::$obj_id
private

Definition at line 35 of file class.ilECSCourseMemberAssignment.php.

Referenced by getObjId().

◆ $server

int ilECSCourseMemberAssignment::$server
private

Definition at line 31 of file class.ilECSCourseMemberAssignment.php.

Referenced by getServer().

◆ $status

bool ilECSCourseMemberAssignment::$status = false
private

Definition at line 37 of file class.ilECSCourseMemberAssignment.php.

Referenced by getStatus().

◆ $uid

string ilECSCourseMemberAssignment::$uid
private

Definition at line 36 of file class.ilECSCourseMemberAssignment.php.

Referenced by getUid().

◆ STATUS_ASSIGNED

const ilECSCourseMemberAssignment::STATUS_ASSIGNED = 0

Definition at line 25 of file class.ilECSCourseMemberAssignment.php.

◆ STATUS_LOCAL_DELETED

const ilECSCourseMemberAssignment::STATUS_LOCAL_DELETED = 1

Definition at line 26 of file class.ilECSCourseMemberAssignment.php.


The documentation for this class was generated from the following file: