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