43 protected \ilDBInterface
$db;
55 return [self::COLLECTION_TABLE_NAME, self::COLLECTION_ASSIGNMENT_TABLE_NAME];
60 ?
int $owner_id = null,
72 $q =
"SELECT owner_id, title FROM " . self::COLLECTION_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s";
73 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
74 $d = $this->db->fetchObject(
$r);
76 $title = (string) (
$d->title ??
'');
78 return $this->
blank($identification, $owner_id, $title);
84 SELECT 1 FROM " . self::COLLECTION_TABLE_NAME .
" 85 WHERE " . self::C_IDENTIFICATION .
" = %s 88 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
89 $d = $this->db->fetchAssoc(
$r);
91 return (
bool) (
$d[
'found'] ??
false);
99 $q =
"SELECT " . self::R_IDENTIFICATION .
" FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s ORDER BY position ASC";
100 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
101 while (
$d = $this->db->fetchAssoc(
$r)) {
102 yield (
string)
$d[self::R_IDENTIFICATION];
108 $q =
"DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s";
109 $r = $this->db->manipulateF(
$q, [
'text'], [$identification->
serialize()]);
116 $owner_id = $collection->
getOwner();
119 $resource_identification_strings =
array_map(
121 $resource_identifications
124 $q =
"DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s AND " 125 . $this->db->in(self::R_IDENTIFICATION, $resource_identification_strings,
true,
'text');
126 $r = $this->db->manipulateF($q, [
'text'], [$identification->serialize()]);
128 $missing_resource_identification_string = array_diff(
129 $resource_identification_strings,
132 foreach ($missing_resource_identification_string as $position => $resource_identification_string) {
133 $this->db->insert(self::COLLECTION_ASSIGNMENT_TABLE_NAME, [
134 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
135 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
136 'position' => [
'integer', (
int) $position + 1],
138 $event_data_container->
append(
139 new CollectionData([
'rid' => $resource_identification_string,
'rcid' => $identification->serialize()])
142 foreach ($resource_identification_strings as $position => $resource_identification_string) {
144 self::COLLECTION_ASSIGNMENT_TABLE_NAME,
146 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
147 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
148 'position' => [
'integer', (
int) $position + 1],
151 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
152 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
156 if ($this->
has($identification)) {
158 self::COLLECTION_TABLE_NAME,
160 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
161 'title' => [
'text', $title ??
''],
162 'owner_id' => [
'integer', $owner_id],
165 self::C_IDENTIFICATION => [
'text', $identification->serialize()]
170 self::COLLECTION_TABLE_NAME,
172 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
173 'title' => [
'text', $title ??
''],
174 'owner_id' => [
'integer', $owner_id],
182 $this->db->manipulateF(
183 "DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::R_IDENTIFICATION .
" = %s",
191 $this->db->manipulateF(
192 "DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s",
194 [$identification->serialize()]
196 $this->db->manipulateF(
197 "DELETE FROM " . self::COLLECTION_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s",
199 [$identification->serialize()]
203 public function preload(array $identification_strings): void
removeResourceFromAllCollections(ResourceIdentification $resource_identification)
update(ResourceCollection $collection, DataContainer $event_data_container)
const COLLECTION_ASSIGNMENT_TABLE_NAME
Class ResourceCollectionIdentification.
Interface CollectionRepository.
Class ResourceCollection.
Class CollectionDBRepository.
clear(ResourceCollectionIdentification $identification)
Class ResourceIdentification.
__construct(\ilDBInterface $db)
getResourceIdentifications()
preload(array $identification_strings)
getResourceIdStrings(ResourceCollectionIdentification $identification)
existing(ResourceCollectionIdentification $identification)
has(ResourceCollectionIdentification $identification)
const COLLECTION_TABLE_NAME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
blank(ResourceCollectionIdentification $identification, ?int $owner_id=null, ?string $title=null)
populateFromArray(array $data)