Ejemplo n.º 1
0
 /**
  * onCreate event handler
  * @param SeasonApplication $app
  */
 public function onCreate(SeasonApplication $app)
 {
     $id = $this->defaultRoleName;
     try {
         if (!is_string($id)) {
             $role = $this->roleService->getRole($id);
         } else {
             $role = $this->roleService->getRoleName($id);
         }
     } catch (Exceptions\DataErrorException $ex) {
         $this->logger->addError("Application listener - onCreate -  role load failed with - " . $ex->getMessage());
         return;
     }
     $pos = new Position();
     $pos->setGroup($app->getSportGroup());
     $pos->setRole($role);
     $pos->setOwner($app->getOwner());
     $pos->setPublishContact(false);
     $pos->setComment($this->defaultComment);
     try {
         $this->positionService->createPosition($pos);
         if ($this->deleteOldPosition) {
             $this->positionService->deletePositionsWithRole($pos->getOwner(), $pos->getRole());
         }
     } catch (Exceptions\DataErrorException $ex) {
         $this->logger->addError("Application listener - onCreate - savingData failed with - " . $ex->getMessage());
         return;
     }
 }
Ejemplo n.º 2
0
 public function positionsInit()
 {
     $pos = null;
     try {
         $user = $this->userService->getUserEmail($this->getDefaultUserEmail());
         $role = $this->roleService->getRoleName("admin");
         $group = $this->groupService->getSportGroupAbbr("root");
     } catch (Exceptions\NoResultException $ex) {
         return null;
     }
     try {
         $pos = $this->positionService->getUniquePosition($user, $group, $role);
     } catch (Exceptions\NoResultException $ex) {
         $this->logger->addDebug($ex->getMessage());
     }
     if ($pos === null) {
         $this->logger->addInfo("Security module initializer - Position - no position with user {$user}, role {$role} and group {$group} found. New one is gonna be created.");
         $pos = new Position();
         $pos->setGroup($group);
         $pos->setOwner($user);
         $pos->setRole($role);
         $pos->setName("Webmaster");
         $pos->setComment("System created");
         $this->positionService->createPosition($pos);
     }
 }
Ejemplo n.º 3
0
 private function posOwnerTypeHandle(Position $p)
 {
     if ($p === null) {
         throw new Exceptions\NullPointerException("Argument Position cannot be null");
     }
     try {
         $owner = null;
         $id = $this->getMixId($p->getOwner());
         if ($id !== null) {
             $owner = $this->userService->getUser($id, false);
         }
         $p->setOwner($owner);
     } catch (\Exception $e) {
         $this->logError($e);
         throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
     return $p;
 }