Made Offers a bit more robust and operation atomic

This commit is contained in:
Christian Wolf 2019-06-27 12:03:36 +02:00
parent af506435ac
commit 2da8da6b37
2 changed files with 36 additions and 15 deletions

View File

@ -1,5 +1,7 @@
<?php
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
@ -162,6 +164,11 @@ class CommonClubsModelClub extends AbstractCommonClubsModel
$offerAssocFactory = new CommonClubsModelFactoryOfferassoc();
$offerFactory = new CommonClubsModelFactoryOffer();
$db = Factory::getDbo();
$db->transactionStart(true);
try
{
foreach($delIds as $id)
{
$delId = (int) $id;
@ -179,6 +186,14 @@ class CommonClubsModelClub extends AbstractCommonClubsModel
$o->save();
}
}
catch (Exception $ex)
{
$db->transactionRollback(true);
throw $ex;
}
$db->transactionCommit(true);
}
public function getUsers()
{

View File

@ -349,8 +349,14 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
// TODO ACL needed
try
{
$this->club->setOfferIds($ids);
$this->club->save();
}
catch(ElementNotFoundException $ex)
{
throw new InvalidUserDataException('Es gab ein Problem mit der Eingabe. Bitte Seite neu laden und Daten erneut eintragen.');
}
}
}