Exemplo n.º 1
0
 public function getFormChoices()
 {
     $this->transaction->requestTransaction();
     $stmt = $this->conn->prepare('SELECT `id`, `name` FROM `' . CoreTables::AREA_TBL . '` WHERE `projectId` = :projectId AND `statusId` = :statusId ORDER BY `name`');
     $stmt->bindValue(':projectId', $this->project->getId());
     $stmt->bindValue(':statusId', $this->publishedStatusId);
     $stmt->execute();
     $result = array();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $result[$row['id']] = $row['name'];
     }
     $stmt->closeCursor();
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Make sure that the transaction is always SOMEHOW closed at the end of the request.
  * 
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     if ($event->isMasterRequest()) {
         $this->transaction->closeTransaction();
     }
     if ($event->getRequest()->getSession()->has('_locale')) {
         $event->getResponse()->headers->setCookie(new Cookie(self::LAST_LANG_COOKIE, $event->getRequest()->getSession()->get('_locale'), time() + self::DEF_LAST_LANG_TIME));
     }
 }
Exemplo n.º 3
0
 public function remove(DataExport $item)
 {
     $this->transaction->requestTransaction();
     try {
         return $item->remove($this->conn);
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }
 /**
  * @return Course
  */
 public function getCourse($id)
 {
     $this->transaction->requestTransaction();
     $item = Course::fetchByProject($this->conn, $id, $this->project);
     if (false === $item) {
         $this->transaction->requestRollback();
         throw new ItemNotFoundException('The specified item has not been found.', $id);
     }
     return $item;
 }
 public function countParticipants()
 {
     $this->transaction->requestTransaction();
     try {
         return $this->conn->fetchColumn('SELECT SUM(s.`participantNum`) + SUM(s.`externalParticipantNum`) ' . 'FROM `' . EdkTables::REGISTRATION_SETTINGS_TBL . '` s ' . 'INNER JOIN `' . EdkTables::ROUTE_TBL . '` r ON r.`id` = s.`routeId` ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON r.`areaId` = a.`id` ' . $this->createWhereClause(), [':itemId' => $this->root->getId()]);
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }
Exemplo n.º 6
0
 public function getFormChoices()
 {
     $this->transaction->requestTransaction();
     $stmt = $this->conn->query('SELECT `id`, `name` FROM `' . CoreTables::PROJECT_TBL . '` WHERE `archived` = 1 ORDER BY `name`');
     $result = array();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $result[$row['id']] = $row['name'];
     }
     $stmt->closeCursor();
     return $result;
 }
Exemplo n.º 7
0
 public function confirmGoodFaithCompletion(Area $area, User $user, Course $course)
 {
     $this->transaction->requestTransaction();
     try {
         $output = $course->confirmGoodFaithCompletion($this->conn, $area, $user);
         $this->spawnActivationEvent($area, $output);
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }
Exemplo n.º 8
0
 public function removeMember(MembershipEntityInterface $item, User $user)
 {
     $this->transaction->requestTransaction();
     try {
         if ($item->removeMember($this->conn, $user)) {
             return ['status' => 1, 'data' => $item->findMembers($this->conn, $this->roleResolver)];
         }
         return ['status' => 0, 'data' => $item->findMembers($this->conn, $this->roleResolver)];
     } catch (Exception $exception) {
         $this->transaction->requestRollback();
         throw $exception;
     }
 }
 public function revoke(AreaRequest $item)
 {
     $this->transaction->requestTransaction();
     try {
         if (!$item->revoke($this->conn)) {
             throw new ModelException('Cannot revoke this this request.');
         }
         $this->eventDispatcher->dispatch(CantigaEvents::AREA_REQUEST_REVOKED, new AreaRequestEvent($item));
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }
Exemplo n.º 10
0
 public function revoke(EdkRoute $item)
 {
     $this->transaction->requestTransaction();
     try {
         if (!$item->revoke($this->conn)) {
             throw new ModelException('Cannot revoke this this route.');
         }
         $this->eventDispatcher->dispatch(MilestoneEvents::ACTIVATION_EVENT, new ActivationEvent($item->getArea()->getProject(), $item->getArea()->getEntity(), 'route.approved', $this->getActivationFunc($item)));
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }
Exemplo n.º 11
0
 /**
  * @param $membershipEntity Entity whose members we want to view
  * @param $id User ID
  * @return User
  */
 public function getItem(MembershipEntityInterface $membershipEntity, $id)
 {
     $this->transaction->requestTransaction();
     try {
         $user = User::fetchLinkedProfile($this->conn, $this->roleResolver, $membershipEntity, Join::create($this->membershipTable(), 'm', QueryClause::clause('m.userId = u.id')), QueryOperator::op('AND')->expr(QueryClause::clause('m.' . $this->entityColumn() . ' = :entityId', ':entityId', $membershipEntity->getId()))->expr(QueryClause::clause('u.`id` = :userId', ':userId', $id)));
         if (false === $user) {
             throw new ItemNotFoundException('The specified user has not been found.');
         }
         return $user;
     } catch (Exception $exception) {
         $this->transaction->requestRollback();
         throw $exception;
     }
 }
Exemplo n.º 12
0
 public function getFormChoices($entityType)
 {
     $this->transaction->requestTransaction();
     $stmt = $this->conn->prepare('SELECT `id`, `name` FROM `' . MilestoneTables::MILESTONE_TBL . '` WHERE `projectId` = :projectId AND `entityType` = :entityType ORDER BY `displayOrder`');
     $stmt->bindValue(':projectId', $this->project->getId());
     $stmt->bindValue(':entityType', $entityType);
     $stmt->execute();
     $result = array();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $result[$row['name']] = $row['id'];
     }
     $stmt->closeCursor();
     return $result;
 }
Exemplo n.º 13
0
 public function revoke($id, User $user)
 {
     $this->transaction->requestTransaction();
     try {
         $item = Invitation::fetchByUser($this->conn, $id, $user);
         if (empty($item)) {
             throw new ItemNotFoundException('The specified invitation cannot be found.');
         }
         $item->remove($this->conn);
     } catch (Exception $exception) {
         $this->transaction->requestRollback();
         throw $exception;
     }
 }
Exemplo n.º 14
0
 public function changeDuplicateFlag(EdkMessage $item)
 {
     $this->transaction->requestTransaction();
     try {
         if ($item->getDuplicate()) {
             $item->setDuplicate(false);
         } else {
             $item->setDuplicate(true);
         }
         $item->changeState($this->conn);
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }
Exemplo n.º 15
0
 public function isAllowed(Entity $entity, MembershipEntityInterface $who, $editable = false)
 {
     $this->transaction->requestTransaction();
     try {
         if ($who instanceof Project) {
             return $this->isAllowedForProject($entity, $who, $editable);
         } elseif ($who instanceof Group) {
             return $this->isAllowedForGroup($entity, $who, $editable);
         } elseif ($who instanceof Area) {
             return $this->isAllowedForArea($entity, $who, $editable);
         }
         throw new LogicException('Unsupported type of entity!');
     } catch (Exception $exception) {
         $this->transaction->requestRollback();
         throw $exception;
     }
 }
Exemplo n.º 16
0
 public function updateSettings(User $user)
 {
     $this->transaction->requestTransaction();
     $user->updateSettings($this->conn);
 }