function test1() { \TimeSource::mock(2014, 1, 1, 0, 0, 0); $user1 = new UserAccountModel(); $user1->setEmail("*****@*****.**"); $user1->setUsername("test"); $user1->setPassword("password"); $user2 = new UserAccountModel(); $user2->setEmail("*****@*****.**"); $user2->setUsername("test2"); $user2->setPassword("password"); $userRepo = new UserAccountRepository(); $userRepo->create($user1); $userRepo->create($user2); $site = new SiteModel(); $site->setTitle("Test"); $site->setSlug("test"); $siteRepo = new SiteRepository(); $siteRepo->create($site, $user1, array(), $this->getSiteQuotaUsedForTesting()); $group1 = new GroupModel(); $group1->setTitle("test1"); $group1->setDescription("test test"); $group1->setUrl("http://www.group.com"); $group2 = new GroupModel(); $group2->setTitle("test this looks similar"); $group2->setDescription("test test"); $group2->setUrl("http://www.group.com"); $groupRepo = new GroupRepository(); \TimeSource::mock(2014, 1, 1, 1, 0, 0); $groupRepo->create($group1, $site, $user1); $groupRepo->create($group2, $site, $user2); $event = new EventModel(); $event->setSummary("test"); $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0)); $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0)); $eventRepository = new EventRepository(); $eventRepository->create($event, $site, $user1, $group2); $uwgr = new UserWatchesGroupRepository(); // Test before $erb = new \repositories\builders\EventRepositoryBuilder(); $erb->setGroup($group1); $this->assertEquals(0, count($erb->fetchAll())); $this->assertNull($uwgr->loadByUserAndGroup($user2, $group1)); $group2 = $groupRepo->loadById($group2->getId()); $this->assertFalse($group2->getIsDeleted()); $this->assertNull($group2->getIsDuplicateOfId()); // Mark \TimeSource::mock(2014, 1, 1, 2, 0, 0); $groupRepo->markDuplicate($group2, $group1, $user1); // Test Duplicate $erb = new \repositories\builders\EventRepositoryBuilder(); $erb->setGroup($group1); $this->assertEquals(1, count($erb->fetchAll())); $uwg = $uwgr->loadByUserAndGroup($user2, $group1); $this->assertNotNull($uwg); $group2 = $groupRepo->loadById($group2->getId()); $this->assertTrue($group2->getIsDeleted()); $this->assertEquals($group1->getId(), $group2->getIsDuplicateOfId()); }
function testMultiple() { TimeSource::mock(2013, 7, 1, 7, 0, 0); $user = new UserAccountModel(); $user->setEmail("*****@*****.**"); $user->setUsername("test"); $user->setPassword("password"); $userRepo = new UserAccountRepository(); $userRepo->create($user); $site = new SiteModel(); $site->setTitle("Test"); $site->setSlug("test"); $siteRepo = new SiteRepository(); $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting()); $group = new GroupModel(); $group->setTitle("test"); $group->setDescription("test test"); $group->setUrl("http://www.group.com"); $groupDupe = new GroupModel(); $groupDupe->setTitle("test DUPE"); $groupRepo = new GroupRepository(); $groupRepo->create($group, $site, $user); $groupRepo->create($groupDupe, $site, $user); TimeSource::mock(2013, 7, 1, 7, 1, 0); $groupRepo->markDuplicate($groupDupe, $group); $ufgr = new UserWatchesGroupRepository(); $ufgr->startUserWatchingGroupIdIfNotWatchedBefore($user, $group->getId()); $event = new EventModel(); $event->setSummary("test"); $event->setDescription("test test"); $event->setStartAt(getUTCDateTime(2013, 8, 1, 19, 0, 0)); $event->setEndAt(getUTCDateTime(2013, 8, 1, 21, 0, 0)); $eventRepository = new EventRepository(); $eventRepository->create($event, $site, $user, $group); ## TEST $this->assertNotNull($groupRepo->loadById($group->getId())); $groupRB = new GroupRepositoryBuilder(); $groupRB->setEvent($event); $groups = $groupRB->fetchAll(); $this->assertEquals(1, count($groups)); ## PURGE! $groupRepo->purge($group); ## TEST $this->assertNull($groupRepo->loadById($group->getId())); $groupRB = new GroupRepositoryBuilder(); $groupRB->setEvent($event); $groups = $groupRB->fetchAll(); $this->assertEquals(0, count($groups)); }
public static function run(Application $app, $verbose = false) { global $CONFIG; if ($verbose) { print "Starting " . date("c") . "\n"; } $userRepo = new UserAccountRepository(); $siteRepo = new SiteRepository(); $groupRepo = new GroupRepository(); $eventRepo = new EventRepository(); $userWatchesGroupRepository = new UserWatchesGroupRepository(); $userWatchesGroupStopRepository = new UserWatchesGroupStopRepository(); $userAccountGeneralSecurityKeyRepository = new UserAccountGeneralSecurityKeyRepository(); $userNotificationRepo = new UserNotificationRepository(); $userHasNoEditorPermissionsInSiteRepo = new UserHasNoEditorPermissionsInSiteRepository(); $userPermissionsRepo = new UserPermissionsRepository($app['extensions']); /** @var usernotifications/UserWatchesGroupPromptNotificationType **/ $userNotificationType = $app['extensions']->getCoreExtension()->getUserNotificationType('UserWatchesGroupPrompt'); $b = new UserWatchesGroupRepositoryBuilder(); foreach ($b->fetchAll() as $userWatchesGroup) { $user = $userRepo->loadByID($userWatchesGroup->getUserAccountId()); $group = $groupRepo->loadById($userWatchesGroup->getGroupId()); $site = $siteRepo->loadById($group->getSiteID()); // This is not the most efficient as it involves DB access and the results might not be used. But it'll do for now. $userPermissions = $userPermissionsRepo->getPermissionsForUserInSite($user, $site, false, true); if ($verbose) { print date("c") . " User " . $user->getEmail() . " Site " . $site->getTitle() . " Group " . $group->getTitle() . "\n"; } // UserWatchesGroupRepositoryBuilder() should only return instances where site is not also watched if ($site->getIsClosedBySysAdmin()) { if ($verbose) { print " ... site is closed\n"; } } else { if ($group->getIsDeleted()) { if ($verbose) { print " ... group is deleted\n"; } } else { if ($userHasNoEditorPermissionsInSiteRepo->isUserInSite($user, $site)) { if ($verbose) { print " ... user does not have edit permissions allowed in site\n"; } } else { if (!$userPermissions->hasPermission("org.openacalendar", "CALENDAR_CHANGE")) { if ($verbose) { print " ... user does not have org.openacalendar/CALENDAR_CHANGE permission in site\n"; } // Technically UserWatchesSiteRepositoryBuilder() should only return getIsWatching() == true but lets double check } else { if ($userWatchesGroup->getIsWatching()) { if ($verbose) { print " ... searching for data\n"; } $lastEvent = $eventRepo->loadLastNonDeletedNonImportedByStartTimeInGroupId($group->getId()); $data = $userWatchesGroup->getPromptEmailData($site, $lastEvent); if ($data['moreEventsNeeded']) { if ($verbose) { print " ... found data\n"; } ///// Notification Class $userNotification = $userNotificationType->getNewNotification($user, $site); $userNotification->setGroup($group); ////// Save Notification Class $userNotificationRepo->create($userNotification); ////// Send Email if ($userNotification->getIsEmail()) { $userWatchesGroupStop = $userWatchesGroupStopRepository->getForUserAndGroup($user, $group); configureAppForSite($site); configureAppForUser($user); $userAccountGeneralSecurityKey = $userAccountGeneralSecurityKeyRepository->getForUser($user); $unsubscribeURL = $CONFIG->getWebIndexDomainSecure() . '/you/emails/' . $user->getId() . '/' . $userAccountGeneralSecurityKey->getAccessKey(); $lastEventsBuilder = new EventRepositoryBuilder(); $lastEventsBuilder->setSite($site); $lastEventsBuilder->setGroup($group); $lastEventsBuilder->setOrderByStartAt(true); $lastEventsBuilder->setIncludeDeleted(false); $lastEventsBuilder->setIncludeImported(false); $lastEventsBuilder->setLimit($CONFIG->userWatchesGroupPromptEmailShowEvents); $lastEvents = $lastEventsBuilder->fetchAll(); $message = \Swift_Message::newInstance(); $message->setSubject("Any news about " . $group->getTitle() . "?"); $message->setFrom(array($CONFIG->emailFrom => $CONFIG->emailFromName)); $message->setTo($user->getEmail()); $messageText = $app['twig']->render('email/userWatchesGroupPromptEmail.txt.twig', array('group' => $group, 'user' => $user, 'lastEvents' => $lastEvents, 'stopCode' => $userWatchesGroupStop->getAccessKey(), 'generalSecurityCode' => $userAccountGeneralSecurityKey->getAccessKey(), 'unsubscribeURL' => $unsubscribeURL)); if ($CONFIG->isDebug) { file_put_contents('/tmp/userWatchesGroupPromptEmail.txt', $messageText); } $message->setBody($messageText); $messageHTML = $app['twig']->render('email/userWatchesGroupPromptEmail.html.twig', array('group' => $group, 'user' => $user, 'lastEvents' => $lastEvents, 'stopCode' => $userWatchesGroupStop->getAccessKey(), 'generalSecurityCode' => $userAccountGeneralSecurityKey->getAccessKey(), 'unsubscribeURL' => $unsubscribeURL)); if ($CONFIG->isDebug) { file_put_contents('/tmp/userWatchesGroupPromptEmail.html', $messageHTML); } $message->addPart($messageHTML, 'text/html'); $headers = $message->getHeaders(); $headers->addTextHeader('List-Unsubscribe', $unsubscribeURL); if ($verbose) { print " ... sending\n"; } if (!$CONFIG->isDebug) { $app['mailer']->send($message); } $userNotificationRepo->markEmailed($userNotification); } $userWatchesGroupRepository->markPromptEmailSent($userWatchesGroup, $data['checkTime']); } } } } } } } if ($verbose) { print "Finished " . date("c") . "\n"; } }
public function markNotificationSent(\DateTime $checkTime) { $userWatchesGroupRepository = new UserWatchesGroupRepository(); $userWatchesGroup = $userWatchesGroupRepository->loadByUserAndGroup($this->userAccount, $this->group); $userWatchesGroupRepository->markNotifyEmailSent($userWatchesGroup, $checkTime); }
function recur($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Event does not exist."); } if ($this->parameters['event']->getIsDeleted()) { die("No"); // TODO } if ($this->parameters['event']->getIsImported()) { die("No"); // TODO } if (!$this->parameters['group']) { // Existing Group // TODO csfr if ($request->request->get('intoGroupSlug')) { $groupRepo = new GroupRepository(); $group = $groupRepo->loadBySlug($app['currentSite'], $request->request->get('intoGroupSlug')); if ($group) { $groupRepo->addEventToGroup($this->parameters['event'], $group); $repo = new UserWatchesGroupRepository(); $repo->startUserWatchingGroupIfNotWatchedBefore($app['currentUser'], $group); return $app->redirect("/event/" . $this->parameters['event']->getSlugForURL() . "/recur/"); } } // New group if ($request->request->get('NewGroupTitle') && $request->request->get('CSFRToken') == $app['websession']->getCSFRToken()) { $group = new GroupModel(); $group->setTitle($request->request->get('NewGroupTitle')); $groupRepo = new GroupRepository(); $groupRepo->create($group, $app['currentSite'], $app['currentUser']); $groupRepo->addEventToGroup($this->parameters['event'], $group); return $app->redirect("/event/" . $this->parameters['event']->getSlugForURL() . "/recur/"); } return $app['twig']->render('site/event/recur.groupneeded.html.twig', $this->parameters); } else { $eventRecurSet = new EventRecurSetModel(); $eventRecurSet->setTimeZoneName($this->parameters['event']->getTimezone()); $data = $eventRecurSet->getEventPatternData($this->parameters['event']); if ($data['weekInMonth'] < 5) { $this->parameters['recurMonthlyOnWeekNumber'] = $data['weekInMonth']; $ordinal = array(1 => 'st', 2 => 'nd', 3 => 'rd', 4 => 'th'); $this->parameters['recurMonthlyOnWeekNumberOrdinal'] = $ordinal[$data['weekInMonth']]; } else { $this->parameters['recurMonthlyOnWeekNumber'] = null; $this->parameters['recurMonthlyOnWeekNumberOrdinal'] = null; } $this->parameters['recurMonthlyOnLastWeek'] = $data['isLastWeekInMonth']; return $app['twig']->render('site/event/recur.html.twig', $this->parameters); } }
/** * One event, 31 days from now, then 30 days, then 29 days, etc, only 1 email sent * @global type $CONFIG */ function test6() { global $CONFIG; $CONFIG->userWatchesPromptEmailSafeGapDays = 30; \TimeSource::mock(2013, 1, 1, 0, 0, 0); $user = new UserAccountModel(); $user->setEmail("*****@*****.**"); $user->setUsername("test"); $user->setPassword("password"); $userRepo = new UserAccountRepository(); $userRepo->create($user); $site = new SiteModel(); $site->setTitle("Test"); $site->setSlug("test"); $siteRepo = new SiteRepository(); $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting()); $group = new GroupModel(); $group->setTitle("Group"); $groupRepo = new GroupRepository(); $groupRepo->create($group, $site, $user); $event = new EventModel(); $start = \TimeSource::getDateTime(); $start->setDate(2013, 30, 9); $start->setTime(9, 0, 0); $event->setStartAt($start); $end = \TimeSource::getDateTime(); $end->setDate(2013, 30, 9); $end->setTime(12, 0, 0); $event->setEndAt($end); $eventRepo = new EventRepository(); $eventRepo->create($event, $site, $user, $group); // User will watch site automatically in site->create() // We don't want that, we want the group instead $userWatchesSiteRepo = new UserWatchesSiteRepository(); $userWatchesSiteRepo->stopUserWatchingSite($user, $site); $userWatchesGroupRepo = new UserWatchesGroupRepository(); $userWatchesGroupRepo->startUserWatchingGroup($user, $group); #Before email sent! for ($day = 1; $day <= 29; $day++) { \TimeSource::mock(2013, $day, 8, 1, 0, 0); $userWatchesGroup = $userWatchesGroupRepo->loadByUserAndGroup($user, $group); $data = $userWatchesGroup->getPromptEmailData($site, $eventRepo->loadLastNonDeletedNonImportedByStartTimeInGroupId($group->getId())); $this->assertFalse($data['moreEventsNeeded']); } #Email sent! \TimeSource::mock(2013, 30, 8, 1, 0, 0); $userWatchesGroup = $userWatchesGroupRepo->loadByUserAndGroup($user, $group); $data = $userWatchesGroup->getPromptEmailData($site, $eventRepo->loadLastNonDeletedNonImportedByStartTimeInGroupId($group->getId())); $this->assertTrue($data['moreEventsNeeded']); $userWatchesGroupRepo->markPromptEmailSent($userWatchesGroup, \TimeSource::getDateTime()); #After email sent \TimeSource::mock(2013, 31, 8, 1, 0, 0); $userWatchesGroup = $userWatchesGroupRepo->loadByUserAndGroup($user, $group); $data = $userWatchesGroup->getPromptEmailData($site, $eventRepo->loadLastNonDeletedNonImportedByStartTimeInGroupId($group->getId())); $this->assertFalse($data['moreEventsNeeded']); for ($day = 1; $day <= 30; $day++) { \TimeSource::mock(2013, $day, 9, 1, 0, 0); $userWatchesGroup = $userWatchesGroupRepo->loadByUserAndGroup($user, $group); $data = $userWatchesGroup->getPromptEmailData($site, $eventRepo->loadLastNonDeletedNonImportedByStartTimeInGroupId($group->getId())); $this->assertFalse($data['moreEventsNeeded']); } for ($day = 1; $day <= 31; $day++) { \TimeSource::mock(2013, $day, 10, 1, 0, 0); $userWatchesGroup = $userWatchesGroupRepo->loadByUserAndGroup($user, $group); $data = $userWatchesGroup->getPromptEmailData($site, $eventRepo->loadLastNonDeletedNonImportedByStartTimeInGroupId($group->getId())); $this->assertFalse($data['moreEventsNeeded']); } for ($day = 1; $day <= 30; $day++) { \TimeSource::mock(2013, $day, 11, 1, 0, 0); $userWatchesGroup = $userWatchesGroupRepo->loadByUserAndGroup($user, $group); $data = $userWatchesGroup->getPromptEmailData($site, $eventRepo->loadLastNonDeletedNonImportedByStartTimeInGroupId($group->getId())); $this->assertFalse($data['moreEventsNeeded']); } for ($day = 1; $day <= 31; $day++) { \TimeSource::mock(2013, $day, 12, 1, 0, 0); $userWatchesGroup = $userWatchesGroupRepo->loadByUserAndGroup($user, $group); $data = $userWatchesGroup->getPromptEmailData($site, $eventRepo->loadLastNonDeletedNonImportedByStartTimeInGroupId($group->getId())); $this->assertFalse($data['moreEventsNeeded']); } }
public function editWithMetaData(EventModel $event, EventEditMetaDataModel $eventEditMetaDataModel) { if ($event->getIsDeleted()) { throw new \Exception("Can't edit deleted events!"); } global $DB; try { $DB->beginTransaction(); $fields = array('summary', 'description', 'start_at', 'end_at', 'venue_id', 'area_id', 'country_id', 'timezone', 'url', 'ticket_url', 'is_physical', 'is_virtual', 'is_deleted', 'is_cancelled', 'custom'); $this->eventDBAccess->update($event, $fields, $eventEditMetaDataModel); if ($eventEditMetaDataModel->getUserAccount()) { if ($event->getGroupId()) { $ufgr = new UserWatchesGroupRepository(); $ufgr->startUserWatchingGroupIdIfNotWatchedBefore($eventEditMetaDataModel->getUserAccount(), $event->getGroupId()); } else { // TODO watch site? } } $DB->commit(); } catch (Exception $e) { $DB->rollBack(); } }
function test3() { $user = new UserAccountModel(); $user->setEmail("*****@*****.**"); $user->setUsername("test"); $user->setPassword("password"); $userOwner = new UserAccountModel(); $userOwner->setEmail("*****@*****.**"); $userOwner->setUsername("test2"); $userOwner->setPassword("password"); $userRepo = new UserAccountRepository(); $userRepo->create($user); $userRepo->create($userOwner); $site = new SiteModel(); $site->setTitle("Test"); $site->setSlug("test"); $siteRepo = new SiteRepository(); $siteRepo->create($site, $userOwner, array(), $this->getSiteQuotaUsedForTesting()); $group = new GroupModel(); $group->setTitle("test"); $group->setDescription("test test"); $group->setUrl("http://www.group.com"); $groupRepo = new GroupRepository(); $groupRepo->create($group, $site, $userOwner); $userWatchesgroupRepo = new UserWatchesGroupRepository(); # Part 1: User does not watch group $t = $userWatchesgroupRepo->loadByUserAndGroup($user, $group); $this->assertNull($t); $b = new UserWatchesGroupRepositoryBuilder(); $b->setGroup($group); $b->setUser($user); $t = $b->fetchAll(); $this->assertEquals(0, count($t)); # Part 2: Watches if not watched before! $userWatchesgroupRepo->startUserWatchingGroupIfNotWatchedBefore($user, $group); $t = $userWatchesgroupRepo->loadByUserAndGroup($user, $group); $this->assertEquals($user->getId(), $t->getUserAccountId()); $this->assertEquals(true, $t->getIsWatching()); $this->assertEquals(true, $t->getIsWasOnceWatching()); $b = new UserWatchesGroupRepositoryBuilder(); $b->setGroup($group); $b->setUser($user); $t = $b->fetchAll(); $this->assertEquals(1, count($t)); # Part 3: Stops Watching! $userWatchesgroupRepo->stopUserWatchingGroup($user, $group); $t = $userWatchesgroupRepo->loadByUserAndGroup($user, $group); $this->assertEquals(false, $t->getIsWatching()); $this->assertEquals(true, $t->getIsWasOnceWatching()); $b = new UserWatchesGroupRepositoryBuilder(); $b->setGroup($group); $b->setUser($user); $t = $b->fetchAll(); $this->assertEquals(0, count($t)); # Part 4: Watches if not watched before! As they have watched before, nothing happens $userWatchesgroupRepo->startUserWatchingGroupIfNotWatchedBefore($user, $group); $t = $userWatchesgroupRepo->loadByUserAndGroup($user, $group); $this->assertEquals(false, $t->getIsWatching()); $this->assertEquals(true, $t->getIsWasOnceWatching()); $b = new UserWatchesGroupRepositoryBuilder(); $b->setGroup($group); $b->setUser($user); $t = $b->fetchAll(); $this->assertEquals(0, count($t)); }
function stopWatchingFromEmail($slug, $userid, $code, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Group does not exist."); } $userRepo = new UserAccountRepository(); $user = $userRepo->loadByID($userid); if (!$user) { $app['monolog']->addError("Failed stop watching group from email - no user "); die("NO"); // TODO } $userWatchesGroupStopRepo = new UserWatchesGroupStopRepository(); $userWatchesGroupStop = $userWatchesGroupStopRepo->loadByUserAccountIDAndGroupIDAndAccessKey($user->getId(), $this->parameters['group']->getId(), $code); if (!$userWatchesGroupStop) { $app['monolog']->addError("Failed stop watching group from email - user " . $user->getId() . " - code wrong"); die("NO"); // TODO } $userWatchesGroupRepo = new UserWatchesGroupRepository(); $userWatchesGroup = $userWatchesGroupRepo->loadByUserAndGroup($user, $this->parameters['group']); if (!$userWatchesGroup || !$userWatchesGroup->getIsWatching()) { $app['monolog']->addError("Failed stop watching group from email - user " . $user->getId() . " - not watching"); die("You don't watch this group"); // TODO } if ($request->request->get('action') == 'unwatch' && $request->request->get('CSFRToken') == $app['websession']->getCSFRToken()) { $userWatchesGroupRepo->stopUserWatchingGroup($user, $this->parameters['group']); // redirect here because if we didn't the twig global and $app vars would be wrong (the old state) // this is an easy way to get round that. $app['flashmessages']->addMessage("You have stopped watching this group."); return $app->redirect('/group/' . $this->parameters['group']->getSlugForURL()); } $this->parameters['user'] = $user; return $app['twig']->render('site/group/stopWatchingFromEmail.html.twig', $this->parameters); }
public function markDuplicateWithMetaData(GroupModel $duplicateGroup, GroupModel $originalGroup, GroupEditMetaDataModel $groupEditMetaDataModel) { global $DB; if ($duplicateGroup->getId() == $originalGroup->getId()) { return; } try { $DB->beginTransaction(); $duplicateGroup->setIsDeleted(true); $duplicateGroup->setIsDuplicateOfId($originalGroup->getId()); $this->groupDBAccess->update($duplicateGroup, array('is_deleted', 'is_duplicate_of_id'), $groupEditMetaDataModel); // Users Watching Group $ufgr = new UserWatchesGroupRepository(); $usersRepo = new UserAccountRepositoryBuilder(); $usersRepo->setWatchesGroup($duplicateGroup); foreach ($usersRepo->fetchAll() as $user) { $ufgr->startUserWatchingGroupIfNotWatchedBefore($user, $originalGroup); } // Events in Group $statCheck = $DB->prepare("SELECT * FROM event_in_group WHERE group_id=:group_id AND " . " event_id=:event_id AND removed_at IS NULL "); $statAdd = $DB->prepare("INSERT INTO event_in_group (group_id,event_id,added_by_user_account_id,added_at,addition_approved_at,is_main_group) " . "VALUES (:group_id,:event_id,:added_by_user_account_id,:added_at,:addition_approved_at,:is_main_group)"); $erb = new EventRepositoryBuilder(); $erb->setGroup($duplicateGroup); foreach ($erb->fetchAll() as $event) { // check event not already in list $statCheck->execute(array('group_id' => $originalGroup->getId(), 'event_id' => $event->getId())); if ($statCheck->rowCount() == 0) { // TODO is_main_group ?????????????????? $statAdd->execute(array('group_id' => $originalGroup->getId(), 'event_id' => $event->getId(), 'is_main_group' => 0, 'added_by_user_account_id' => $user ? $user->getId() : null, 'added_at' => \TimeSource::getFormattedForDataBase(), 'addition_approved_at' => \TimeSource::getFormattedForDataBase())); } } $DB->commit(); } catch (Exception $e) { $DB->rollBack(); } }