mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
Fix #1061 : Stories are not detached from WZ when databox are unmounted
This commit is contained in:
@@ -65,6 +65,25 @@ class BasketElementRepository extends EntityRepository
|
|||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findElementsByDatabox(\databox $databox)
|
||||||
|
{
|
||||||
|
$dql = 'SELECT e
|
||||||
|
FROM Entities\BasketElement e
|
||||||
|
JOIN e.basket b
|
||||||
|
LEFT JOIN b.validation s
|
||||||
|
LEFT JOIN s.participants p
|
||||||
|
WHERE e.sbas_id = :sbas_id';
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'sbas_id' => $databox->get_sbas_id(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
$query->setParameters($params);
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param \record_adapter $record
|
* @param \record_adapter $record
|
||||||
|
@@ -29,7 +29,7 @@ class StoryWZRepository extends EntityRepository
|
|||||||
foreach ($stories as $key => $story) {
|
foreach ($stories as $key => $story) {
|
||||||
try {
|
try {
|
||||||
$story->getRecord()->get_title();
|
$story->getRecord()->get_title();
|
||||||
} catch (\Exception_Record_AdapterNotFound $e) {
|
} catch (\Exception_NotFound $e) {
|
||||||
$this->getEntityManager()->remove($story);
|
$this->getEntityManager()->remove($story);
|
||||||
unset($stories[$key]);
|
unset($stories[$key]);
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ class StoryWZRepository extends EntityRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($story->getUser()->get_id() !== $user->get_id()) {
|
if ($story->getUser()->get_id() !== $user->get_id()) {
|
||||||
throw new \Exception_Forbidden('You have not access to ths story');
|
throw new \Exception_Forbidden('You have not access to this story');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception_NotFound('Story not found');
|
throw new \Exception_NotFound('Story not found');
|
||||||
@@ -94,7 +94,7 @@ class StoryWZRepository extends EntityRepository
|
|||||||
if ($story) {
|
if ($story) {
|
||||||
try {
|
try {
|
||||||
$record = $story->getRecord();
|
$record = $story->getRecord();
|
||||||
} catch (\Exception_Record_AdapterNotFound $e) {
|
} catch (\Exception_NotFound $e) {
|
||||||
$this->getEntityManager()->remove($story);
|
$this->getEntityManager()->remove($story);
|
||||||
$this->getEntityManager()->flush();
|
$this->getEntityManager()->flush();
|
||||||
$story = null;
|
$story = null;
|
||||||
@@ -120,7 +120,31 @@ class StoryWZRepository extends EntityRepository
|
|||||||
foreach ($stories as $key => $story) {
|
foreach ($stories as $key => $story) {
|
||||||
try {
|
try {
|
||||||
$record = $story->getRecord();
|
$record = $story->getRecord();
|
||||||
} catch (\Exception_Record_AdapterNotFound $e) {
|
} catch (\Exception_NotFound $e) {
|
||||||
|
$this->getEntityManager()->remove($story);
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
unset($stories[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $stories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findByDatabox(\databox $databox)
|
||||||
|
{
|
||||||
|
$dql = 'SELECT s FROM Entities\StoryWZ s WHERE s.sbas_id = :sbas_id';
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
$query->setParameters(array(
|
||||||
|
'sbas_id' => $databox->get_sbas_id(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$stories = $query->getResult();
|
||||||
|
|
||||||
|
foreach ($stories as $key => $story) {
|
||||||
|
try {
|
||||||
|
$record = $story->getRecord();
|
||||||
|
} catch (\Exception_NotFound $e) {
|
||||||
$this->getEntityManager()->remove($story);
|
$this->getEntityManager()->remove($story);
|
||||||
$this->getEntityManager()->flush();
|
$this->getEntityManager()->flush();
|
||||||
unset($stories[$key]);
|
unset($stories[$key]);
|
||||||
|
@@ -341,6 +341,8 @@ class databox extends base
|
|||||||
|
|
||||||
public function unmount_databox(appbox $appbox)
|
public function unmount_databox(appbox $appbox)
|
||||||
{
|
{
|
||||||
|
$core = \bootstrap::getCore();
|
||||||
|
|
||||||
foreach ($this->get_collections() as $collection) {
|
foreach ($this->get_collections() as $collection) {
|
||||||
$collection->unmount_collection($appbox);
|
$collection->unmount_collection($appbox);
|
||||||
}
|
}
|
||||||
@@ -363,6 +365,16 @@ class databox extends base
|
|||||||
$n+=50;
|
$n+=50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($core['EM']->getRepository('\Entities\StoryWZ')->findByDatabox($this) as $story) {
|
||||||
|
$core['EM']->remove($story);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($core['EM']->getRepository('\Entities\BasketElement')->findElementsByDatabox($this) as $element) {
|
||||||
|
$core['EM']->remove($element);
|
||||||
|
}
|
||||||
|
|
||||||
|
$core['EM']->flush();
|
||||||
|
|
||||||
$params = array(':site_id' => $this->get_registry()->get('GV_sit'));
|
$params = array(':site_id' => $this->get_registry()->get('GV_sit'));
|
||||||
|
|
||||||
$sql = 'DELETE FROM clients WHERE site_id = :site_id';
|
$sql = 'DELETE FROM clients WHERE site_id = :site_id';
|
||||||
|
Reference in New Issue
Block a user