ILIAS  release_8 Revision v8.24
class.ilECSExportManager.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
27{
28 protected ilDBInterface $db;
29
31
32 private function __construct()
33 {
34 global $DIC;
35
36 $this->db = $DIC->database();
37 }
38
42 public static function getInstance(): ilECSExportManager
43 {
44 if (!isset(self::$instance)) {
45 self::$instance = new ilECSExportManager();
46 }
47 return self::$instance;
48 }
49
53 public function _isExported(int $a_obj_id): bool
54 {
55 $query = 'SELECT * FROM ecs_export ' .
56 'WHERE obj_id = ' . $this->db->quote($a_obj_id, 'integer');
57 $res = $this->db->query($query);
59 return true;
60 }
61 return false;
62 }
63
64
68 public function _getAllEContentIds(int $a_server_id): array
69 {
70 $econtent_ids = array();
71 $query = "SELECT econtent_id,obj_id FROM ecs_export " .
72 'WHERE server_id = ' . $this->db->quote($a_server_id, 'integer');
73
74 $res = $this->db->query($query);
75 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
76 $econtent_ids[$row->econtent_id] = $row->obj_id;
77 }
78 return $econtent_ids;
79 }
80
84 public function getExportedIds(): array
85 {
86 $query = "SELECT obj_id FROM ecs_export ";
87 $res = $this->db->query($query);
88 $obj_ids = array();
89 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
90 $obj_ids[] = (int) $row->obj_id;
91 }
92 return $obj_ids;
93 }
94
98 public function getExportedIdsByType(string $a_type): array
99 {
100 $obj_ids = array();
101 $query = "SELECT e.obj_id FROM ecs_export e" .
102 " JOIN object_data o ON (e.obj_id = o.obj_id)" .
103 " WHERE o.type = " . $this->db->quote($a_type, "text");
104 $res = $this->db->query($query);
105 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
106 $obj_ids[] = (int) $row->obj_id;
107 }
108 return $obj_ids;
109 }
110
114 public function getExportServerIds(int $a_obj_id): array
115 {
116 $query = 'SELECT * FROM ecs_export ' .
117 'WHERE obj_id = ' . $this->db->quote($a_obj_id, 'integer');
118 $res = $this->db->query($query);
119
120 $sids = array();
121 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
122 $sids[] = (int) $row->server_id;
123 }
124 return $sids;
125 }
126
130 public function _getExportedIDsByServer(int $a_server_id): array
131 {
132 $query = "SELECT obj_id FROM ecs_export " .
133 'WHERE server_id = ' . $this->db->quote($a_server_id, 'integer');
134 $res = $this->db->query($query);
135 $obj_ids = [];
136 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
137 $obj_ids[] = $row->obj_id;
138 }
139 return $obj_ids;
140 }
141
145 public function lookupServerIds(int $a_obj_id): array
146 {
147 $query = 'SELECT * FROM ecs_export ' .
148 'WHERE obj_id = ' . $this->db->quote($a_obj_id, 'integer') . ' ';
149 $res = $this->db->query($query);
150 $sids = array();
151 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
152 $sids[] = (int) $row->server_id;
153 }
154 return $sids;
155 }
156
163 public function _deleteEContentIds(int $a_server_id, array $a_ids): bool
164 {
165 if (!is_array($a_ids) || !count($a_ids)) {
166 return true;
167 }
168 $query = "DELETE FROM ecs_export WHERE " . $this->db->in('econtent_id', $a_ids, false, 'integer') . ' ' .
169 'AND server_id = ' . $this->db->quote($a_server_id, 'integer');
170 $this->db->manipulate($query);
171 return true;
172 }
173
177 public function deleteByServer(int $a_server_id): void
178 {
179 $query = 'DELETE FROM ecs_export ' .
180 'WHERE server_id = ' . $this->db->quote($a_server_id, 'integer');
181 $this->db->manipulate($query);
182 }
183
187 public function _isRemote(int $a_server_id, int $a_econtent_id): bool
188 {
189 $query = "SELECT obj_id FROM ecs_export " .
190 "WHERE econtent_id = " . $this->db->quote($a_econtent_id, 'integer') . " " .
191 'AND server_id = ' . $this->db->quote($a_server_id, 'integer');
192 $res = $this->db->query($query);
193 if ($res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
194 return false;
195 }
196 return true;
197 }
198}
Manage the ECS exported contents.
getExportedIds()
Get exported ids.
static ilECSExportManager $instance
getExportedIdsByType(string $a_type)
Get exported ids by type.
_isExported(int $a_obj_id)
Check if object is exported.
static getInstance()
Get the singelton instance of this ilECSExportManager.
_getAllEContentIds(int $a_server_id)
get all exported econtent ids per server
lookupServerIds(int $a_obj_id)
Lookup server ids of exported objects.
_getExportedIDsByServer(int $a_server_id)
get exported ids for server
_isRemote(int $a_server_id, int $a_econtent_id)
is remote object
_deleteEContentIds(int $a_server_id, array $a_ids)
Delete econtent ids for server.
getExportServerIds(int $a_obj_id)
lookup server ids of exported materials
deleteByServer(int $a_server_id)
Delete by server id.
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query