Port PHRAS-1381 to 4.1

This commit is contained in:
Mike Ng
2018-03-08 13:02:07 +04:00
parent 64d669bc5f
commit f95e40f0b8
3 changed files with 60 additions and 44 deletions

View File

@@ -110,6 +110,9 @@ class MoveCollectionController extends Controller
return $this->app->json($datas);
}
/** @var \collection[] $trashCollectionsBySbasId */
$trashCollectionsBySbasId = [];
foreach ($records as $record) {
$record->move_to_collection($collection, $this->getApplicationBox());
@@ -121,6 +124,33 @@ class MoveCollectionController extends Controller
}
}
}
$sbasId = $record->getDatabox()->get_sbas_id();
if (!array_key_exists($sbasId, $trashCollectionsBySbasId)) {
$trashCollectionsBySbasId[$sbasId] = $record->getDatabox()->getTrashCollection();
}
if ($trashCollectionsBySbasId[$sbasId] !== null) {
if ($record->getCollection()->get_coll_id() == $trashCollectionsBySbasId[$sbasId]->get_coll_id() && $collection->get_coll_id() !== $trashCollectionsBySbasId[$sbasId]->get_coll_id()) {
// record is already in trash so active it
foreach ($record->get_subdefs() as $subdef) {
if (($pl = $subdef->get_permalink())) {
$pl->set_is_activated(true);
}
}
if ($request->request->get("chg_coll_son") == "1") {
/** @var \record_adapter $child */
foreach ($record->getChildren() as $child) {
if ($this->getAclForUser()->has_right_on_base($child->getBaseId(), \ACL::CANDELETERECORD)) {
foreach ($child->get_subdefs() as $childSubdef) {
if (($childPl = $childSubdef->get_permalink())) {
$childPl->set_is_activated(true);
}
}
}
}
}
}
}
}
$ret = [