mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
PHRAS-1863 PORT PHRAS-60 Add applicative trash (#2492)
This commit is contained in:
@@ -189,6 +189,9 @@ class RecordController extends Controller
|
|||||||
|
|
||||||
$deleted = [];
|
$deleted = [];
|
||||||
|
|
||||||
|
/** @var \collection[] $trashCollectionsBySbasId */
|
||||||
|
$trashCollectionsBySbasId = [];
|
||||||
|
|
||||||
$manager = $this->getEntityManager();
|
$manager = $this->getEntityManager();
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
try {
|
try {
|
||||||
@@ -205,10 +208,30 @@ class RecordController extends Controller
|
|||||||
$manager->remove($attachedStory);
|
$manager->remove($attachedStory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sbasId = $record->getDatabox()->get_sbas_id();
|
||||||
|
if(!array_key_exists($sbasId, $trashCollectionsBySbasId)) {
|
||||||
|
$trashCollectionsBySbasId[$sbasId] = $record->getDatabox()->getTrashCollection();
|
||||||
|
}
|
||||||
$deleted[] = $record->getId();
|
$deleted[] = $record->getId();
|
||||||
$record->delete();
|
if($trashCollectionsBySbasId[$sbasId] !== null) {
|
||||||
|
if($record->getCollection()->get_coll_id() == $trashCollectionsBySbasId[$sbasId]->get_coll_id()) {
|
||||||
|
// record is already in trash so delete it
|
||||||
|
$record->delete();
|
||||||
|
} else {
|
||||||
|
// move to trash collection
|
||||||
|
$record->move_to_collection($trashCollectionsBySbasId[$sbasId], $this->getApplicationBox());
|
||||||
|
// disable permalinks
|
||||||
|
foreach($record->get_subdefs() as $subdef) {
|
||||||
|
if( ($pl = $subdef->get_permalink()) ) {
|
||||||
|
$pl->set_is_activated(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// no trash collection, delete
|
||||||
|
$record->delete();
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -601,6 +601,19 @@ class databox extends base implements ThumbnailedElement
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return collection|null
|
||||||
|
*/
|
||||||
|
public function getTrashCollection()
|
||||||
|
{
|
||||||
|
foreach($this->get_collections() as $collection) {
|
||||||
|
if($collection->get_name() === '_TRASH_') {
|
||||||
|
return $collection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param int $record_id
|
* @param int $record_id
|
||||||
|
Reference in New Issue
Block a user