50 return [self::COLLECTION_TABLE_NAME, self::COLLECTION_ASSIGNMENT_TABLE_NAME];
55 ?
int $owner_id =
null,
67 $q =
"SELECT owner_id, title FROM " . self::COLLECTION_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s";
68 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
69 $d = $this->db->fetchObject(
$r);
71 $title = (string) (
$d->title ??
'');
73 return $this->
blank($identification, $owner_id, $title);
79 SELECT 1 FROM " . self::COLLECTION_TABLE_NAME .
" 80 WHERE " . self::C_IDENTIFICATION .
" = %s 83 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
84 $d = $this->db->fetchAssoc(
$r);
86 return (
bool) (
$d[
'found'] ??
false);
94 $q =
"SELECT " . self::R_IDENTIFICATION .
" FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s ORDER BY position ASC";
95 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
96 while (
$d = $this->db->fetchAssoc(
$r)) {
97 yield (
string)
$d[self::R_IDENTIFICATION];
103 $q =
"DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s";
104 $r = $this->db->manipulateF(
$q, [
'text'], [$identification->
serialize()]);
111 $owner_id = $collection->
getOwner();
114 $resource_identification_strings =
array_map(
116 $resource_identifications
119 $q =
"DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s AND " 120 . $this->db->in(self::R_IDENTIFICATION, $resource_identification_strings,
true,
'text');
121 $r = $this->db->manipulateF($q, [
'text'], [$identification->serialize()]);
123 $missing_resource_identification_string = array_diff(
124 $resource_identification_strings,
127 foreach ($missing_resource_identification_string as $position => $resource_identification_string) {
128 $this->db->insert(self::COLLECTION_ASSIGNMENT_TABLE_NAME, [
129 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
130 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
131 'position' => [
'integer', (
int) $position + 1],
133 $event_data_container->
append(
134 new CollectionData([
'rid' => $resource_identification_string,
'rcid' => $identification->serialize()])
137 foreach ($resource_identification_strings as $position => $resource_identification_string) {
139 self::COLLECTION_ASSIGNMENT_TABLE_NAME,
141 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
142 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
143 'position' => [
'integer', (
int) $position + 1],
146 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
147 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
151 if ($this->
has($identification)) {
153 self::COLLECTION_TABLE_NAME,
155 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
156 'title' => [
'text', $title ??
''],
157 'owner_id' => [
'integer', $owner_id],
160 self::C_IDENTIFICATION => [
'text', $identification->serialize()]
165 self::COLLECTION_TABLE_NAME,
167 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
168 'title' => [
'text', $title ??
''],
169 'owner_id' => [
'integer', $owner_id],
177 $this->db->manipulateF(
178 "DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::R_IDENTIFICATION .
" = %s",
186 $this->db->manipulateF(
187 "DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s",
189 [$identification->serialize()]
191 $this->db->manipulateF(
192 "DELETE FROM " . self::COLLECTION_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s",
194 [$identification->serialize()]
198 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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ResourceIdentification.
getResourceIdentifications()
__construct(protected \ilDBInterface $db)
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)