ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSExportManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 protected ilDBInterface $db;
30
32
33 private function __construct()
34 {
35 global $DIC;
36
37 $this->db = $DIC->database();
38 }
39
43 public static function getInstance(): ilECSExportManager
44 {
45 if (!isset(self::$instance)) {
46 self::$instance = new ilECSExportManager();
47 }
48 return self::$instance;
49 }
50
54 public function _isExported(int $a_obj_id): bool
55 {
56 $query = 'SELECT * FROM ecs_export ' .
57 'WHERE obj_id = ' . $this->db->quote($a_obj_id, 'integer');
58 $res = $this->db->query($query);
60 return true;
61 }
62 return false;
63 }
64
65
69 public function _getAllEContentIds(int $a_server_id): array
70 {
71 $econtent_ids = array();
72 $query = "SELECT econtent_id,obj_id FROM ecs_export " .
73 'WHERE server_id = ' . $this->db->quote($a_server_id, 'integer');
74
75 $res = $this->db->query($query);
76 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
77 $econtent_ids[$row->econtent_id] = $row->obj_id;
78 }
79 return $econtent_ids;
80 }
81
85 public function getExportedIds(): array
86 {
87 $query = "SELECT obj_id FROM ecs_export ";
88 $res = $this->db->query($query);
89 $obj_ids = array();
90 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
91 $obj_ids[] = (int) $row->obj_id;
92 }
93 return $obj_ids;
94 }
95
99 public function getExportedIdsByType(string $a_type): array
100 {
101 $obj_ids = array();
102 $query = "SELECT e.obj_id FROM ecs_export e" .
103 " JOIN object_data o ON (e.obj_id = o.obj_id)" .
104 " WHERE o.type = " . $this->db->quote($a_type, "text");
105 $res = $this->db->query($query);
106 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
107 $obj_ids[] = (int) $row->obj_id;
108 }
109 return $obj_ids;
110 }
111
115 public function getExportServerIds(int $a_obj_id): array
116 {
117 $query = 'SELECT * FROM ecs_export ' .
118 'WHERE obj_id = ' . $this->db->quote($a_obj_id, 'integer');
119 $res = $this->db->query($query);
120
121 $sids = array();
122 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
123 $sids[] = (int) $row->server_id;
124 }
125 return $sids;
126 }
127
131 public function _getExportedIDsByServer(int $a_server_id): array
132 {
133 $query = "SELECT obj_id FROM ecs_export " .
134 'WHERE server_id = ' . $this->db->quote($a_server_id, 'integer');
135 $res = $this->db->query($query);
136 $obj_ids = [];
137 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
138 $obj_ids[] = $row->obj_id;
139 }
140 return $obj_ids;
141 }
142
146 public function lookupServerIds(int $a_obj_id): array
147 {
148 $query = 'SELECT * FROM ecs_export ' .
149 'WHERE obj_id = ' . $this->db->quote($a_obj_id, 'integer') . ' ';
150 $res = $this->db->query($query);
151 $sids = array();
152 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
153 $sids[] = (int) $row->server_id;
154 }
155 return $sids;
156 }
157
164 public function _deleteEContentIds(int $a_server_id, array $a_ids): bool
165 {
166 if (!is_array($a_ids) || !count($a_ids)) {
167 return true;
168 }
169 $query = "DELETE FROM ecs_export WHERE " . $this->db->in('econtent_id', $a_ids, false, 'integer') . ' ' .
170 'AND server_id = ' . $this->db->quote($a_server_id, 'integer');
171 $this->db->manipulate($query);
172 return true;
173 }
174
178 public function deleteByServer(int $a_server_id): void
179 {
180 $query = 'DELETE FROM ecs_export ' .
181 'WHERE server_id = ' . $this->db->quote($a_server_id, 'integer');
182 $this->db->manipulate($query);
183 }
184
188 public function _isRemote(int $a_server_id, int $a_econtent_id): bool
189 {
190 $query = "SELECT obj_id FROM ecs_export " .
191 "WHERE econtent_id = " . $this->db->quote($a_econtent_id, 'integer') . " " .
192 'AND server_id = ' . $this->db->quote($a_server_id, 'integer');
193 $res = $this->db->query($query);
194 if ($res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
195 return false;
196 }
197 return true;
198 }
199}
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.
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26