[PLUGIN][AttachmentCollections] Prevent user from appending stuff in a collection (s)he doesn't own

This commit is contained in:
Phablulo Joel 2021-12-25 11:27:00 -03:00
parent 1e965157de
commit af3d278fde

View File

@ -153,12 +153,16 @@ class AttachmentCollections extends Plugin
['aid' => $attachment_id, 'id' => $user->getId(), 'ids' => $removed]
);
}
$collection_ids = \array_map(fn ($x) => $x->getId(), $colls);
foreach ($added as $cid) {
// prevent user from putting something in a collection (s)he doesn't own:
if (\in_array($cid, $collection_ids)) {
DB::persist(CollectionEntry::create([
'attachment_id' => $attachment_id,
'collection_id' => $cid,
]));
}
}
DB::flush();
}
// add to new collection form