ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 assignemt. 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 Member Functions

 getArrayForDatabase ()
 

Private Attributes

ilDBInterface $db
 
int $id
 
int $server
 
int $mid
 
int $cms_id
 
int $cms_sub_id = null
 
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 24 of file class.ilECSCourseMemberAssignment.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCourseMemberAssignment::__construct ( int  $a_id = 0)

Constructor.

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

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

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilECSCourseMemberAssignment::delete ( )

Delete entry.

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

295 : bool
296 {
297 $query = 'DELETE FROM ecs_course_assignments ' .
298 'WHERE id = ' . $this->db->quote($this->getId(), 'integer');
299 $this->db->manipulate($query);
300 return true;
301 }

References 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 80 of file class.ilECSCourseMemberAssignment.php.

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

References $DIC, and $ilDB.

◆ deleteByServerId()

static ilECSCourseMemberAssignment::deleteByServerId ( int  $a_server_id)
static

Delete by server id.

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

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

References $DIC, and $ilDB.

◆ getArrayForDatabase()

ilECSCourseMemberAssignment::getArrayForDatabase ( )
private

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

244 : array
245 {
246 return [
247 'id' => ['integer', $this->getId()],
248 'sid' => ['integer', $this->getServer()],
249 'mid' => ['integer', $this->getMid()],
250 'cms_id' => ['integer', $this->getCmsId()],
251 'cms_sub_id' => ['integer', $this->getCmsSubId()],
252 'obj_id' => ['integer', $this->getObjId()],
253 'usr_id' => ['text', $this->getUid()],
254 'status' => ['integer', $this->getStatus()],
255 ];
256 }

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

Referenced by save(), and update().

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

◆ getCmsId()

ilECSCourseMemberAssignment::getCmsId ( )

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

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

References $cms_id.

Referenced by getArrayForDatabase(), and save().

+ Here is the caller graph for this function:

◆ getCmsSubId()

ilECSCourseMemberAssignment::getCmsSubId ( )

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

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

References $cms_sub_id.

Referenced by getArrayForDatabase(), and save().

+ Here is the caller graph for this function:

◆ getId()

ilECSCourseMemberAssignment::getId ( )

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

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

References $id.

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

+ Here is the caller graph for this function:

◆ getMid()

ilECSCourseMemberAssignment::getMid ( )

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

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

References $mid.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getObjId()

ilECSCourseMemberAssignment::getObjId ( )

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

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

References $obj_id.

Referenced by getArrayForDatabase(), and save().

+ Here is the caller graph for this function:

◆ getServer()

ilECSCourseMemberAssignment::getServer ( )

Get server.

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

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

References $server.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getStatus()

ilECSCourseMemberAssignment::getStatus ( )

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

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

References $status.

Referenced by getArrayForDatabase().

+ Here is the caller graph for this function:

◆ getUid()

ilECSCourseMemberAssignment::getUid ( )

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

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

References $uid.

Referenced by getArrayForDatabase(), and save().

+ 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 138 of file class.ilECSCourseMemberAssignment.php.

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

References $DIC, $ilDB, $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 60 of file class.ilECSCourseMemberAssignment.php.

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

References $DIC, $ilDB, $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 110 of file class.ilECSCourseMemberAssignment.php.

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

References $DIC, $ilDB, $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 308 of file class.ilECSCourseMemberAssignment.php.

308 : bool
309 {
310 if (!$this->getId()) {
311 return false;
312 }
313 $r = $this->db->queryF(
314 "SELECT sid,mid,cms_id,cms_sub_id,obj_id,usr_id,status FROM ecs_course_assignments WHERE id = %d",
315 ['integer'],
316 [$this->getId()]
317 );
318 $row = $this->db->fetchObject($r);
319 $this->setServer((int) $row->sid);
320 $this->setMid((int) $row->mid);
321 $this->setCmsId((int) $row->cms_id);
322 $this->setCmsSubId((int) $row->cms_sub_id);
323 $this->setObjId((int) $row->obj_id);
324 $this->setUid($row->usr_id);
325 $this->setStatus((bool) $row->status);
326 return true;
327 }

References 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 260 of file class.ilECSCourseMemberAssignment.php.

260 : bool
261 {
262 $this->id = $this->db->nextId('ecs_course_assignments');
263
264 $assignment = self::lookupAssignment(
265 $this->getCmsId(),
266 $this->getCmsSubId(),
267 $this->getObjId(),
268 $this->getUid()
269 );
270 if ($assignment instanceof self) {
271 $assignment->update();
272 return true;
273 }
274 $this->db->insert('ecs_course_assignments', $this->getArrayForDatabase());
275 return true;
276 }
static lookupAssignment(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id, string $a_usr_id)
Lookup assignment of user.

References getArrayForDatabase(), getCmsId(), getCmsSubId(), getObjId(), getUid(), and lookupAssignment().

+ Here is the call graph for this function:

◆ setCmsId()

ilECSCourseMemberAssignment::setCmsId ( int  $a_id)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setCmsSubId()

ilECSCourseMemberAssignment::setCmsSubId ( ?int  $a_id)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setMid()

ilECSCourseMemberAssignment::setMid ( int  $a_mid)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjId()

ilECSCourseMemberAssignment::setObjId ( int  $a_id)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setServer()

ilECSCourseMemberAssignment::setServer ( int  $a_server)

Set server.

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

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

References ILIAS\UI\examples\Progress\Bar\server().

Referenced by read().

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

◆ setStatus()

ilECSCourseMemberAssignment::setStatus ( bool  $a_status)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setUid()

ilECSCourseMemberAssignment::setUid ( string  $a_id)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilECSCourseMemberAssignment::update ( )

Update assignemt.

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

281 : bool
282 {
283 $this->db->update('ecs_course_assignments', $this->getArrayForDatabase(), [
284 'id' => [
285 'integer',
286 $this->getId(),
287 ],
288 ]);
289 return true;
290 }

References getArrayForDatabase(), and getId().

+ Here is the call graph for this function:

Field Documentation

◆ $cms_id

int ilECSCourseMemberAssignment::$cms_id
private

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

Referenced by getCmsId().

◆ $cms_sub_id

int ilECSCourseMemberAssignment::$cms_sub_id = null
private

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

Referenced by getCmsSubId().

◆ $db

ilDBInterface ilECSCourseMemberAssignment::$db
private

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

◆ $id

int ilECSCourseMemberAssignment::$id
private

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

Referenced by getId().

◆ $mid

int ilECSCourseMemberAssignment::$mid
private

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

Referenced by getMid().

◆ $obj_id

int ilECSCourseMemberAssignment::$obj_id
private

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

Referenced by getObjId().

◆ $server

int ilECSCourseMemberAssignment::$server
private

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

Referenced by getServer().

◆ $status

bool ilECSCourseMemberAssignment::$status = false
private

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

Referenced by getStatus().

◆ $uid

string ilECSCourseMemberAssignment::$uid
private

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

Referenced by getUid().

◆ STATUS_ASSIGNED

const ilECSCourseMemberAssignment::STATUS_ASSIGNED = 0

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

◆ STATUS_LOCAL_DELETED

const ilECSCourseMemberAssignment::STATUS_LOCAL_DELETED = 1

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


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