public function transformContent()
 {
     $form = $this->getForm('create_entry');
     if ($form->isSent() && $form->isValid()) {
         // Fill domain objects by extracting the values
         // from the form elements directly.
         $name = $form->getFormElementByName('name');
         $email = $form->getFormElementByName('email');
         $website = $form->getFormElementByName('website');
         $user = new User();
         $user->setName($name->getAttribute('value'));
         $user->setEmail($email->getAttribute('value'));
         $user->setWebsite($website->getAttribute('value'));
         $title = $form->getFormElementByName('title');
         $text = $form->getFormElementByName('text');
         $entry = new Entry();
         $entry->setTitle($title->getAttribute('value'));
         $entry->setText($text->getContent());
         $entry->setEditor($user);
         // Save the entry using the business component.
         $this->getGuestbookService()->saveEntry($entry);
     }
     // set language dependent button label by using the
     // language and context information of the current
     // DOM node.
     $config = $this->getConfiguration('APF\\modules\\guestbook2009\\pres', 'language.ini');
     $buttonLabel = $config->getSection($this->language)->getValue('form.label.button');
     $button = $form->getFormElementByName('send');
     $button->setAttribute('value', $buttonLabel);
     // Transform on definition place to render
     // the content within the surrounding div.
     $form->transformOnPlace();
     // add dynamic link
     $this->setPlaceHolder('overviewlink', LinkGenerator::generateUrl(Url::fromCurrent()->mergeQuery(['gbview' => 'list'])));
 }
 public function transformContent()
 {
     $form = $this->getForm('login');
     if ($form->isSent() && $form->isValid()) {
         $fieldUser = $form->getFormElementByName('username');
         $fieldPass = $form->getFormElementByName('password');
         $user = new User();
         $user->setUsername($fieldUser->getAttribute('value'));
         $user->setPassword($fieldPass->getAttribute('value'));
         if (!$this->getGuestbookService()->validateCredentials($user)) {
             $error = $this->getTemplate('error');
             $form->setPlaceHolder('error', $error->transformTemplate());
         }
     }
     $form->transformOnPlace();
 }
 public function transformContent()
 {
     $entryId = $this->getRequest()->getParameter('entryid');
     if ($entryId === null) {
         $this->displayEntrySelection('edit');
     } else {
         // pre-fill edit form by directly accessing the APF form objects
         $gS = $this->getGuestbookService();
         $form = $this->getForm('edit_entry');
         if ($form->isSent() === false) {
             $entry = $gS->loadEntry($entryId);
             $editor = $entry->getEditor();
             $name = $form->getFormElementByName('name');
             $name->setAttribute('value', $editor->getName());
             $email = $form->getFormElementByName('email');
             $email->setAttribute('value', $editor->getEmail());
             $website = $form->getFormElementByName('website');
             $website->setAttribute('value', $editor->getWebsite());
             $title = $form->getFormElementByName('title');
             $title->setAttribute('value', $entry->getTitle());
             $text = $form->getFormElementByName('text');
             $text->setContent($entry->getText());
             $hiddenEntryId = $form->getFormElementByName('entryid');
             $hiddenEntryId->setAttribute('value', $entry->getId());
             $hiddenEditorId = $form->getFormElementByName('editorid');
             $hiddenEditorId->setAttribute('value', $editor->getId());
         } else {
             // save entry
             if ($form->isValid() === true) {
                 $entry = new Entry();
                 $editor = new User();
                 $name = $form->getFormElementByName('name');
                 $editor->setName($name->getAttribute('value'));
                 $email = $form->getFormElementByName('email');
                 $editor->setEmail($email->getAttribute('value'));
                 $website = $form->getFormElementByName('website');
                 $editor->setWebsite($website->getAttribute('value'));
                 $title = $form->getFormElementByName('title');
                 $entry->setTitle($title->getAttribute('value'));
                 $text = $form->getFormElementByName('text');
                 $entry->setText($text->getContent());
                 // retrieve the entry id from the hidden field
                 $hiddenEntryId = $form->getFormElementByName('entryid');
                 $entry->setId($hiddenEntryId->getAttribute('value'));
                 // retrieve the editor id from the hidden field
                 $hiddenEditorId = $form->getFormElementByName('editorid');
                 $editor->setId($hiddenEditorId->getAttribute('value'));
                 $entry->setEditor($editor);
                 $gS->saveEntry($entry);
             }
         }
         $form->transformOnPlace();
     }
 }
Example #4
0
 /**
  * Checks the user's credentials.
  *
  * @param User $user The user to authenticate.
  *
  * @return boolean True in case, the user is allowed to login, false otherwise.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 17.05.2009<br />
  */
 public function validateCredentials(User $user)
 {
     $authCrit = new GenericCriterionObject();
     $authCrit->addPropertyIndicator('Username', $user->getUsername());
     $authCrit->addPropertyIndicator('Password', md5($user->getPassword()));
     $gbUser = $this->orm->loadObjectByCriterion('User', $authCrit);
     return $gbUser !== null;
 }