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 $q =
"SELECT " . self::C_IDENTIFICATION .
" FROM " . self::COLLECTION_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s";
85 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
87 return (
$r->numRows() === 1);
95 $q =
"SELECT " . self::R_IDENTIFICATION .
" FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s ORDER BY position ASC";
96 $r = $this->db->queryF(
$q, [
'text'], [$identification->
serialize()]);
97 while (
$d = $this->db->fetchAssoc(
$r)) {
98 yield (
string)
$d[self::R_IDENTIFICATION];
104 $q =
"DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s";
105 $r = $this->db->manipulateF(
$q, [
'text'], [$identification->
serialize()]);
112 $owner_id = $collection->
getOwner();
115 $resource_identification_strings = array_map(
117 $resource_identifications
120 $q =
"DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s AND " 121 . $this->db->in(self::R_IDENTIFICATION, $resource_identification_strings,
true,
'text');
122 $r = $this->db->manipulateF($q, [
'text'], [$identification->serialize()]);
124 $missing_resource_identification_string = array_diff(
125 $resource_identification_strings,
128 foreach ($missing_resource_identification_string as $position => $resource_identification_string) {
129 $this->db->insert(self::COLLECTION_ASSIGNMENT_TABLE_NAME, [
130 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
131 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
132 'position' => [
'integer', (
int)$position + 1],
134 $event_data_container->
append(
135 new CollectionData([
'rid' => $resource_identification_string,
'rcid' => $identification->serialize()])
138 foreach ($resource_identification_strings as $position => $resource_identification_string) {
140 self::COLLECTION_ASSIGNMENT_TABLE_NAME,
142 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
143 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
144 'position' => [
'integer', (
int)$position + 1],
147 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
148 self::R_IDENTIFICATION => [
'text', $resource_identification_string],
152 if ($this->
has($identification)) {
154 self::COLLECTION_TABLE_NAME,
156 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
157 'title' => [
'text', $title ??
''],
158 'owner_id' => [
'integer', $owner_id],
161 self::C_IDENTIFICATION => [
'text', $identification->serialize()]
166 self::COLLECTION_TABLE_NAME,
168 self::C_IDENTIFICATION => [
'text', $identification->serialize()],
169 'title' => [
'text', $title ??
''],
170 'owner_id' => [
'integer', $owner_id],
178 $this->db->manipulateF(
179 "DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::R_IDENTIFICATION .
" = %s",
187 $this->db->manipulateF(
188 "DELETE FROM " . self::COLLECTION_ASSIGNMENT_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s",
190 [$identification->serialize()]
192 $this->db->manipulateF(
193 "DELETE FROM " . self::COLLECTION_TABLE_NAME .
" WHERE " . self::C_IDENTIFICATION .
" = %s",
195 [$identification->serialize()]
200 public function preload(array $identification_strings): void
getResourceIdentifications()
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)
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)