コード例 #1
0
 /**
  * @param PersonDto $person
  * @param string $dateOfBirth
  * @throws UpdateNodeException
  * @throws \Exception
  *
  * @return string
  */
 public function updateAction(PersonDto $person, $dateOfBirth = '')
 {
     $profile = $this->profileService->getCurrentPartyProfile();
     $referenceNode = $person->getReferenceNode();
     if ($profile->getIdentifier() !== $referenceNode->getIdentifier()) {
         throw new UpdateNodeException('You can only update your own node', 125172979);
     }
     foreach ($person->getObjectVars() as $propertyName => $propertyValue) {
         if ($propertyName !== NULL && $propertyName !== 'referenceNode' && $propertyName !== 'image') {
             $properties[$propertyName] = $propertyValue;
         }
     }
     if ($dateOfBirth !== '') {
         $timestamp = strtotime($dateOfBirth);
         $dateOfBirth = new \DateTime();
         $dateOfBirth->setTimestamp($timestamp);
         $properties['dateOfBirth'] = $dateOfBirth;
     }
     if (isset($properties)) {
         $this->nodeWriteRepository->updateNode($referenceNode, $properties);
     }
     $locale = new Locale('nl');
     $this->response->setHeader('Notification', $this->translator->translateById('profile.update.success', [], NULL, $locale, 'Main', 'BuJitsuDo.Authentication'));
     return '';
 }
コード例 #2
0
 /**
  * @param NodeInterface $event
  * @param NodeInterface $person
  */
 public function removeAttendeeFromEvent(NodeInterface $event, NodeInterface $person)
 {
     $personAndEventData = $this->getEventsAndPersonData($event, $person);
     $this->removeEventFromUser($person, $personAndEventData, 'attendeeIdentifiers', 'attendees', 'User is not set in attendees');
     $this->removeEventFromUser($event, $personAndEventData, 'personEventsIdentifiers', 'personEvents', 'Event is not registered for user');
     $this->nodeWriteRepository->updateNode($person, ['events' => $personAndEventData['personEvents']]);
     $this->nodeWriteRepository->updateNode($event, ['attendees' => $personAndEventData['attendees']]);
     $this->persistenceManager->persistAll();
     $this->emitAttendeeRemoved($event, $person);
 }
コード例 #3
0
 /**
  * @param Account $account
  * @param NodeInterface $userStorageNode
  * @param PersonDto $person
  * @return NodeInterface|string
  */
 protected function createProfileNode(Account $account, NodeInterface $userStorageNode, PersonDto $person)
 {
     try {
         $profileNode = $this->findProfileNode($person->getEmailAddress());
         if ($profileNode === NULL) {
             $properties = ['title' => $person->getFirstName() . ' ' . $person->getLastName(), 'firstName' => $person->getFirstName(), 'lastName' => $person->getLastName(), 'address' => $person->getAddress(), 'zipCode' => $person->getZipCode(), 'city' => $person->getCity(), 'emailAddress' => $person->getEmailAddress(), 'phone' => $person->getPhone(), 'dateOfBirth' => $person->getDateOfBirth(), 'jiuJitsu' => $person->getJiuJitsu(), 'buJitsuDo' => $person->getBuJitsuDo(), 'jiuJitsuDegree' => $person->getJiuJitsuDegree(), 'buJitsuDoDegree' => $person->getBuJitsuDoDegree(), 'gender' => $person->getGender()];
             if ($person->getFirstName() && $person->getLastName()) {
                 $nodeName = $person->getFirstName() . ' ' . $person->getLastName();
             }
             $idealNodeName = Utility::renderValidNodeName(isset($nodeName) ? $nodeName : uniqid('node'));
             $idealNodeName = htmlspecialchars($idealNodeName, ENT_NOQUOTES, 'UTF-8');
             $profileNode = $this->nodeWriteRepository->createChildNode($userStorageNode, $idealNodeName, 'BuJitsuDo.Authentication:Person', $properties);
             if ($person->getImage() instanceof Image) {
                 $profileNode = $this->profileService->setImageToNode($profileNode, $person->getImage(), $person->getFirstName(), 'Profile images');
             }
         }
         $account->getParty()->getPreferences()->set('profileNodeIdentifier', $profileNode->getIdentifier());
         $this->partyRepository->update($account->getParty());
         $this->persistenceManager->persistAll();
         $this->emitPersonCreated($profileNode);
         return $profileNode;
     } catch (\Exception $exception) {
         $this->systemLogger->log('Profile node could not be created because: ' . $exception->getMessage(), LOG_CRIT);
         return $exception->getMessage();
     }
 }