ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSExport.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 protected ilDBInterface $db;
30
31 protected int $server_id = 0;
32 protected int $obj_id = 0;
33 protected int $econtent_id = 0;
34 protected bool $exported = false;
35
36 public function __construct(int $a_server_id, int $a_obj_id)
37 {
38 global $DIC;
39
40 $this->server_id = $a_server_id;
41 $this->obj_id = $a_obj_id;
42
43 $this->db = $DIC->database();
44 $this->read();
45 }
46
50 public function getServerId(): int
51 {
52 return $this->server_id;
53 }
54
58 public function setServerId(int $a_server_id): void
59 {
60 $this->server_id = $a_server_id;
61 }
62
69 public function setExported(bool $a_status): void
70 {
71 $this->exported = $a_status;
72 }
73
77 public function isExported(): bool
78 {
79 return $this->exported;
80 }
81
87 public function setEContentId(int $a_id): void
88 {
89 $this->econtent_id = $a_id;
90 }
91
97 public function getEContentId(): int
98 {
99 return $this->econtent_id;
100 }
101
105 public function save(): bool
106 {
107 $query = "DELETE FROM ecs_export " .
108 "WHERE obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " .
109 'AND server_id = ' . $this->db->quote($this->getServerId());
110 $this->db->manipulate($query);
111
112 if ($this->isExported()) {
113 $query = "INSERT INTO ecs_export (server_id,obj_id,econtent_id) " .
114 "VALUES ( " .
115 $this->db->quote($this->server_id, 'integer') . ', ' .
116 $this->db->quote($this->obj_id, 'integer') . ", " .
117 $this->db->quote($this->getEContentId(), 'integer') . " " .
118 ")";
119 $this->db->manipulate($query);
120 }
121
122 return true;
123 }
124
128 private function read(): void
129 {
130 $query = "SELECT * FROM ecs_export WHERE " .
131 "obj_id = " . $this->db->quote($this->obj_id, 'integer') . " AND " .
132 'server_id = ' . $this->db->quote($this->getServerId(), 'integer');
133 $res = $this->db->query($query);
134 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
135 $this->econtent_id = (int) $row->econtent_id;
136 $this->exported = true;
137 }
138 }
139}
Storage of an ECS exported object.
__construct(int $a_server_id, int $a_obj_id)
getEContentId()
get econtent id
getServerId()
Get server id.
setEContentId(int $a_id)
set econtent id
isExported()
check if an object is exported or not
ilDBInterface $db
setExported(bool $a_status)
Set exported.
setServerId(int $a_server_id)
Set server id.
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26