ILIAS  release_8 Revision v8.24
class.ilECSExport.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
27{
28 protected ilDBInterface $db;
29
30 protected int $server_id = 0;
31 protected int $obj_id = 0;
32 protected int $econtent_id = 0;
33 protected bool $exported = false;
34
35 public function __construct(int $a_server_id, int $a_obj_id)
36 {
37 global $DIC;
38
39 $this->server_id = $a_server_id;
40 $this->obj_id = $a_obj_id;
41
42 $this->db = $DIC->database();
43 $this->read();
44 }
45
49 public function getServerId(): int
50 {
51 return $this->server_id;
52 }
53
57 public function setServerId(int $a_server_id): void
58 {
59 $this->server_id = $a_server_id;
60 }
61
68 public function setExported(bool $a_status): void
69 {
70 $this->exported = $a_status;
71 }
72
76 public function isExported(): bool
77 {
78 return $this->exported;
79 }
80
86 public function setEContentId(int $a_id): void
87 {
88 $this->econtent_id = $a_id;
89 }
90
96 public function getEContentId(): int
97 {
98 return $this->econtent_id;
99 }
100
104 public function save(): bool
105 {
106 $query = "DELETE FROM ecs_export " .
107 "WHERE obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " .
108 'AND server_id = ' . $this->db->quote($this->getServerId());
109 $this->db->manipulate($query);
110
111 if ($this->isExported()) {
112 $query = "INSERT INTO ecs_export (server_id,obj_id,econtent_id) " .
113 "VALUES ( " .
114 $this->db->quote($this->server_id, 'integer') . ', ' .
115 $this->db->quote($this->obj_id, 'integer') . ", " .
116 $this->db->quote($this->getEContentId(), 'integer') . " " .
117 ")";
118 $this->db->manipulate($query);
119 }
120
121 return true;
122 }
123
127 private function read(): void
128 {
129 $query = "SELECT * FROM ecs_export WHERE " .
130 "obj_id = " . $this->db->quote($this->obj_id, 'integer') . " AND " .
131 'server_id = ' . $this->db->quote($this->getServerId(), 'integer');
132 $res = $this->db->query($query);
133 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
134 $this->econtent_id = (int) $row->econtent_id;
135 $this->exported = true;
136 }
137 }
138}
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.
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query