ILIAS  release_8 Revision v8.24
class.ilECSImport.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 string $econtent_id = '';
33 protected string $content_id = '';
34 protected ?string $sub_id = '';
35 protected int $mid = 0;
36 protected bool $imported = false;
37
38 public function __construct(int $a_server_id, int $a_obj_id)
39 {
40 global $DIC;
41 $this->db = $DIC->database();
42
43 $this->server_id = $a_server_id;
44 $this->obj_id = $a_obj_id;
45
46 $this->read();
47 }
48
49 public function setServerId($a_server_id): void
50 {
51 $this->server_id = $a_server_id;
52 }
53
54 public function getServerId(): int
55 {
56 return $this->server_id;
57 }
58
62 public function setImported(bool $a_status): void
63 {
64 $this->imported = $a_status;
65 }
66
67 public function setSubId(string $a_id): void
68 {
69 $this->sub_id = $a_id;
70 }
71
72 public function getSubId(): ?string
73 {
74 return (isset($this->sub_id) && $this->sub_id !== '') ? $this->sub_id : null;
75 }
76
80 public function setContentId($a_content_id): void
81 {
82 $this->content_id = $a_content_id;
83 }
84
88 public function getContentId(): string
89 {
90 return $this->content_id;
91 }
92
96 public function setMID($a_mid): void
97 {
98 $this->mid = $a_mid;
99 }
100
104 public function getMID(): int
105 {
106 return $this->mid;
107 }
108
115 public function setEContentId($a_id): void
116 {
117 $this->econtent_id = $a_id;
118 }
119
123 public function getEContentId(): string
124 {
125 return $this->econtent_id;
126 }
127
131 public function save(): bool
132 {
133 $query = "DELETE FROM ecs_import " .
134 "WHERE obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " .
135 'AND server_id = ' . $this->db->quote($this->getServerId(), 'integer');
136 $this->db->manipulate($query);
137
138 $query = "INSERT INTO ecs_import (obj_id,mid,econtent_id,sub_id,server_id,content_id) " .
139 "VALUES ( " .
140 $this->db->quote($this->obj_id, 'integer') . ", " .
141 $this->db->quote($this->mid, 'integer') . ", " .
142 $this->db->quote($this->econtent_id, 'text') . ", " .
143 $this->db->quote($this->getSubId(), 'text') . ', ' .
144 $this->db->quote($this->getServerId(), 'integer') . ', ' .
145 $this->db->quote($this->getContentId(), 'text') . ' ' .
146 ")";
147
148 $this->db->manipulate($query);
149
150 return true;
151 }
152
156 private function read(): void
157 {
158 $query = "SELECT * FROM ecs_import WHERE " .
159 "obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " .
160 'AND server_id = ' . $this->db->quote($this->getServerId(), 'integer');
161 $res = $this->db->query($query);
162 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
163 $this->econtent_id = $row->econtent_id;
164 $this->mid = (int) $row->mid;
165 $this->sub_id = $row->sub_id;
166 $this->content_id = $row->content_id;
167 }
168 }
169}
Storage of ECS imported objects.
setContentId($a_content_id)
Set content id.
setMID($a_mid)
set mid
getContentId()
get content id
setEContentId($a_id)
set econtent id
setServerId($a_server_id)
setImported(bool $a_status)
Set imported.
getEContentId()
get econtent id
__construct(int $a_server_id, int $a_obj_id)
setSubId(string $a_id)
ilDBInterface $db
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query