ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 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.

References $DIC, and read().

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
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilECSCourseMemberAssignment::delete ( )

Delete entry.

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

References getId().

294  : bool
295  {
296  $query = 'DELETE FROM ecs_course_assignments ' .
297  'WHERE id = ' . $this->db->quote($this->getId(), 'integer');
298  $this->db->manipulate($query);
299  return true;
300  }
+ 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.

References $DIC, and $ilDB.

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  }
global $DIC
Definition: feed.php:28

◆ deleteByServerId()

static ilECSCourseMemberAssignment::deleteByServerId ( int  $a_server_id)
static

Delete by server id.

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

References $DIC, and $ilDB.

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  }
global $DIC
Definition: feed.php:28

◆ getArrayForDatabase()

ilECSCourseMemberAssignment::getArrayForDatabase ( )
private

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

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

Referenced by save(), and update().

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

◆ getCmsId()

ilECSCourseMemberAssignment::getCmsId ( )

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

References $cms_id.

Referenced by getArrayForDatabase(), and save().

198  : int
199  {
200  return $this->cms_id;
201  }
+ Here is the caller graph for this function:

◆ getCmsSubId()

ilECSCourseMemberAssignment::getCmsSubId ( )

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

References $cms_sub_id.

Referenced by getArrayForDatabase(), and save().

208  : ?int
209  {
210  return $this->cms_sub_id;
211  }
+ Here is the caller graph for this function:

◆ getId()

ilECSCourseMemberAssignment::getId ( )

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

References $id.

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

162  : int
163  {
164  return $this->id;
165  }
+ Here is the caller graph for this function:

◆ getMid()

ilECSCourseMemberAssignment::getMid ( )

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

References $mid.

Referenced by getArrayForDatabase().

188  : int
189  {
190  return $this->mid;
191  }
+ Here is the caller graph for this function:

◆ getObjId()

ilECSCourseMemberAssignment::getObjId ( )

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

References $obj_id.

Referenced by getArrayForDatabase(), and save().

218  : int
219  {
220  return $this->obj_id;
221  }
+ Here is the caller graph for this function:

◆ getServer()

ilECSCourseMemberAssignment::getServer ( )

Get server.

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

References $server.

Referenced by getArrayForDatabase().

178  : int
179  {
180  return $this->server;
181  }
+ Here is the caller graph for this function:

◆ getStatus()

ilECSCourseMemberAssignment::getStatus ( )

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

References $status.

Referenced by getArrayForDatabase().

238  : bool
239  {
240  return $this->status;
241  }
+ Here is the caller graph for this function:

◆ getUid()

ilECSCourseMemberAssignment::getUid ( )

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

References $uid.

Referenced by getArrayForDatabase(), and save().

228  : string
229  {
230  return $this->uid;
231  }
+ 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.

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

Referenced by ilECSCmsCourseMemberCommandQueueHandler\refreshAssignmentStatus().

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
Storage of ecs course assignments.
+ 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.

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

Referenced by ilECSAppEventListener\handleMembership().

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ 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.

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

Referenced by ilECSCmsCourseMemberCommandQueueHandler\refreshAssignmentStatus().

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ read()

ilECSCourseMemberAssignment::read ( )
protected

Read from db.

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

References $r, getId(), setCmsId(), setCmsSubId(), setMid(), setObjId(), setServer(), setStatus(), and setUid().

Referenced by __construct().

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

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

259  : bool
260  {
261  $this->id = $this->db->nextId('ecs_course_assignments');
262 
263  $assignment = self::lookupAssignment(
264  $this->getCmsId(),
265  $this->getCmsSubId(),
266  $this->getObjId(),
267  $this->getUid()
268  );
269  if ($assignment instanceof self) {
270  $assignment->update();
271  return true;
272  }
273  $this->db->insert('ecs_course_assignments', $this->getArrayForDatabase());
274  return true;
275  }
+ Here is the call graph for this function:

◆ setCmsId()

ilECSCourseMemberAssignment::setCmsId ( int  $a_id)

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

Referenced by read().

193  : void
194  {
195  $this->cms_id = $a_id;
196  }
+ Here is the caller graph for this function:

◆ setCmsSubId()

ilECSCourseMemberAssignment::setCmsSubId ( ?int  $a_id)

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

Referenced by read().

203  : void
204  {
205  $this->cms_sub_id = $a_id;
206  }
+ Here is the caller graph for this function:

◆ setMid()

ilECSCourseMemberAssignment::setMid ( int  $a_mid)

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

Referenced by read().

183  : void
184  {
185  $this->mid = $a_mid;
186  }
+ Here is the caller graph for this function:

◆ setObjId()

ilECSCourseMemberAssignment::setObjId ( int  $a_id)

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

Referenced by read().

213  : void
214  {
215  $this->obj_id = $a_id;
216  }
+ 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.

Referenced by read().

170  : void
171  {
172  $this->server = $a_server;
173  }
+ Here is the caller graph for this function:

◆ setStatus()

ilECSCourseMemberAssignment::setStatus ( bool  $a_status)

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

Referenced by read().

233  : void
234  {
235  $this->status = $a_status;
236  }
+ Here is the caller graph for this function:

◆ setUid()

ilECSCourseMemberAssignment::setUid ( string  $a_id)

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

Referenced by read().

223  : void
224  {
225  $this->uid = $a_id;
226  }
+ Here is the caller graph for this function:

◆ update()

ilECSCourseMemberAssignment::update ( )

Update assignemt.

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

References getArrayForDatabase(), and getId().

280  : bool
281  {
282  $this->db->update('ecs_course_assignments', $this->getArrayForDatabase(), [
283  'id' => [
284  'integer',
285  $this->getId(),
286  ],
287  ]);
288  return true;
289  }
+ 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 = null
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: