18 declare(strict_types=1);
47 $this->db = $DIC->database();
65 $query =
'SELECT id FROM ecs_course_assignments ' .
66 'WHERE usr_id = ' .
$ilDB->quote($a_usr_id,
'text');
69 $assignments = array();
71 $assignments[] =
new self((
int) $row->id);
85 $query =
'DELETE FROM ecs_course_assignments ' .
86 'WHERE obj_id = ' .
$ilDB->quote($a_obj_id,
'integer');
87 $ilDB->manipulate($query);
100 $query =
'DELETE FROM ecs_course_assignments ' .
101 'WHERE sid = ' .
$ilDB->quote($a_server_id,
'integer');
102 $ilDB->manipulate($query);
109 public static function lookupUserIds(
int $a_cms_id, ?
int $a_cms_sub_id,
int $a_obj_id): array
113 $ilDB = $DIC[
'ilDB'];
115 if (is_null($a_cms_sub_id)) {
116 $cms_sub_id_query =
'AND (cms_sub_id IS NULL OR cms_sub_id = 0) ';
118 $cms_sub_id_query =
'AND cms_sub_id = ' .
$ilDB->quote($a_cms_sub_id,
'integer') .
' ';
121 $query =
'SELECT usr_id FROM ecs_course_assignments ' .
122 'WHERE cms_id = ' .
$ilDB->quote($a_cms_id,
'integer') .
' ' .
124 'AND obj_id = ' .
$ilDB->quote($a_obj_id,
'integer');
129 $usr_ids[] = $row->usr_id;
141 $ilDB = $DIC[
'ilDB'];
143 if (is_null($a_cms_sub_id)) {
144 $cms_sub_id_query =
'AND (cms_sub_id IS NULL OR cms_sub_id = 0) ';
146 $cms_sub_id_query =
'AND cms_sub_id = ' .
$ilDB->quote($a_cms_sub_id,
'integer') .
' ';
149 $query =
'SELECT id FROM ecs_course_assignments ' .
150 'WHERE cms_id = ' .
$ilDB->quote($a_cms_id,
'integer') .
' ' .
152 'AND obj_id = ' .
$ilDB->quote($a_obj_id,
'integer') .
' ' .
153 'AND usr_id = ' .
$ilDB->quote($a_usr_id,
'text');
172 $this->server = $a_server;
195 $this->cms_id = $a_id;
205 $this->cms_sub_id = $a_id;
215 $this->obj_id = $a_id;
223 public function setUid(
string $a_id): void
235 $this->status = $a_status;
246 'id' => [
'integer', $this->
getId()],
247 'sid' => [
'integer', $this->
getServer()],
248 'mid' => [
'integer', $this->
getMid()],
249 'cms_id' => [
'integer', $this->
getCmsId()],
251 'obj_id' => [
'integer', $this->
getObjId()],
252 'usr_id' => [
'text', $this->
getUid()],
253 'status' => [
'integer', $this->
getStatus()],
261 $this->
id = $this->db->nextId(
'ecs_course_assignments');
263 $assignment = self::lookupAssignment(
269 if ($assignment instanceof
self) {
270 $assignment->update();
294 public function delete():
bool 296 $query =
'DELETE FROM ecs_course_assignments ' .
297 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
298 $this->db->manipulate($query);
307 protected function read(): bool
309 if (!$this->
getId()) {
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",
317 $row = $this->db->fetchObject(
$r);
319 $this->
setMid((
int) $row->mid);
320 $this->
setCmsId((
int) $row->cms_id);
322 $this->
setObjId((
int) $row->obj_id);
323 $this->
setUid($row->usr_id);
update()
Update assignemt.
setStatus(bool $a_status)
static lookupAssignment(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id, string $a_usr_id)
Lookup assignment of user.
static deleteByServerId(int $a_server_id)
Delete by server id.
static lookupUserIds(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id)
Lookup user ids.
static deleteByObjId(int $a_obj_id)
Delete by obj_id.
setServer(int $a_server)
Set server.
Storage of ecs course assignments.
static lookupMissingAssignmentsOfUser(string $a_usr_id)
Lookup missing assignments;.
__construct(int $a_id=0)
Constructor.
const STATUS_LOCAL_DELETED