3 namespace CoreFramework\Helper;
5 // Import framework stuff
6 use CoreFramework\Factory\ObjectFactory;
7 use CoreFramework\Generic\NullPointerException;
8 use CoreFramework\Registry\Generic\Registry;
9 use CoreFramework\Template\CompileableTemplate;
12 * A helper for constructing web forms
14 * @author Roland Haeder <webmaster@shipsimu.org>
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
17 * @license GNU GPL 3.0 or any newer version
18 * @link http://www.shipsimu.org
20 * This program is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
35 * Whether the form tag is opened (keep at FALSE or else your forms will
38 private $formOpened = FALSE;
43 private $formName = '';
46 * Whether form tag is enabled (default: TRUE)
48 private $formEnabled = TRUE;
51 const EXCEPTION_FORM_NAME_INVALID = 0x120;
52 const EXCEPTION_CLOSED_FORM = 0x121;
53 const EXCEPTION_OPENED_FORM = 0x122;
54 const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123;
57 * Protected constructor
61 protected function __construct () {
62 // Call parent constructor
63 parent::__construct(__CLASS__);
67 * Creates the helper class with the given template engine instance and form name
69 * @param $templateInstance An instance of a valid template engine
70 * @param $formName Name of the form
71 * @param $formId Value for 'id' attribute (default: $formName)
72 * @param $withForm Whether include the form tag
73 * @return $helperInstance A preparedf instance of this helper
75 public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = FALSE, $withForm = TRUE) {
77 $helperInstance = new HtmlFormHelper();
79 // Set template instance
80 $helperInstance->setTemplateInstance($templateInstance);
82 // Is the form id not set?
83 if ($formId === FALSE) {
84 // Use form id from form name
89 $helperInstance->setFormName($formName);
91 // A form-less field may say 'FALSE' here...
92 if ($withForm === TRUE) {
94 $helperInstance->addFormTag($formName, $formId);
97 $helperInstance->enableForm(FALSE);
100 // Return the prepared instance
101 return $helperInstance;
105 * Add the form tag or close it an already opened form tag
107 * @param $formName Name of the form (default: FALSE)
108 * @param $formId Id of the form (attribute 'id'; default: FALSE)
110 * @throws InvalidFormNameException If the form name is invalid ( = FALSE)
111 * @todo Add some unique PIN here to bypass problems with some browser and/or extensions
113 public function addFormTag ($formName = FALSE, $formId = FALSE) {
114 // When the form is not yet opened at least form name must be valid
115 if (($this->formOpened === FALSE) && ($formName === FALSE)) {
116 // Thrown an exception
117 throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
120 // Close the form is default
121 $formContent = '</form>';
123 // Check whether we shall open or close the form
124 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
126 $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s/%s\" method=\"%s\" target=\"%s\"",
128 $this->getConfigInstance()->getConfigEntry('base_url'),
129 $this->getConfigInstance()->getConfigEntry('form_action'),
130 $this->getConfigInstance()->getConfigEntry('form_method'),
131 $this->getConfigInstance()->getConfigEntry('form_target')
134 // Add form id as well
135 $formContent .= sprintf(" id=\"%s_form\"",
142 // Open the form and remeber the form name
143 $this->formOpened = TRUE;
145 // Add it to the content
146 $this->addHeaderContent($formContent);
148 // Add the hidden field required to identify safely this form
149 $this->addInputHiddenField('form', $this->getFormName());
152 if ($this->ifGroupOpenedPreviously()) {
153 // Then automatically close it here
154 $this->addFormGroup();
158 $this->formOpened = FALSE;
160 // Add it to the content
161 $this->addFooterContent($formContent);
166 * Add a text input tag to the form or throw an exception if it is not yet
167 * opened. The field's name will be set as id.
169 * @param $fieldName Input field name
170 * @param $fieldValue Input default value (default: empty)
172 * @throws FormClosedException If the form is not yet opened
174 public function addInputTextField ($fieldName, $fieldValue = '') {
175 // Is the form opened?
176 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
177 // Throw an exception
178 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
181 // Generate the content
182 $inputContent = sprintf("<input type=\"text\" class=\"textfield %s_field\" name=\"%s\" value=\"%s\" />",
188 // And add it maybe with a 'li' tag
189 $this->addContentToPreviousGroup($inputContent);
193 * Add a text input tag to the form with pre-loaded default value
195 * @param $fieldName Input field name
198 public function addInputTextFieldWithDefault ($fieldName) {
199 // Get the value from instance
200 $fieldValue = $this->getValueField($fieldName);
201 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
203 // Add the text field
204 $this->addInputTextField($fieldName, $fieldValue);
208 * Add a password input tag to the form or throw an exception if it is not
209 * yet opened. The field's name will be set as id.
211 * @param $fieldName Input field name
212 * @param $fieldValue Input default value (default: empty)
214 * @throws FormClosedException If the form is not yet opened
216 public function addInputPasswordField ($fieldName, $fieldValue = '') {
217 // Is the form opened?
218 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
219 // Throw an exception
220 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
223 // Generate the content
224 $inputContent = sprintf("<input type=\"password\" class=\"password %s_field\" name=\"%s\" value=\"%s\" />",
231 $this->addContentToPreviousGroup($inputContent);
235 * Add a hidden input tag to the form or throw an exception if it is not
236 * yet opened. The field's name will be set as id.
238 * @param $fieldName Input field name
239 * @param $fieldValue Input default value (default: empty)
241 * @throws FormClosedException If the form is not yet opened
243 public function addInputHiddenField ($fieldName, $fieldValue = '') {
244 // Is the form opened?
245 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
246 // Throw an exception
247 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
250 // Generate the content
251 $inputContent = sprintf("<input type=\"hidden\" name=\"%s\" value=\"%s\" />",
257 $this->addContentToPreviousGroup($inputContent);
261 * Add a hidden input tag to the form with pre-loaded default value
263 * @param $fieldName Input field name
266 public function addInputHiddenFieldWithDefault ($fieldName) {
267 // Get the value from instance
268 $fieldValue = $this->getValueField($fieldName);
269 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
271 // Add the text field
272 $this->addInputHiddenField($fieldName, $fieldValue);
276 * Add a hidden input tag to the form with configuration value
278 * @param $fieldName Input field name
279 * @param $prefix Prefix for configuration without trailing _
282 public function addInputHiddenConfiguredField ($fieldName, $prefix) {
283 // Get the value from instance
284 $fieldValue = $this->getConfigInstance()->getConfigEntry("{$prefix}_{$fieldName}");
285 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
287 // Add the text field
288 $this->addInputHiddenField($fieldName, $fieldValue);
292 * Add a checkbox input tag to the form or throw an exception if it is not
293 * yet opened. The field's name will be set as id.
295 * @param $fieldName Input field name
296 * @param $fieldChecked Whether the field is checked (defaut: checked)
298 * @throws FormClosedException If the form is not yet opened
300 public function addInputCheckboxField ($fieldName, $fieldChecked = TRUE) {
301 // Is the form opened?
302 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
303 // Throw an exception
304 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
307 // Set whether the check box is checked...
308 $checked = " checked=\"checked\"";
309 if ($fieldChecked === FALSE) $checked = ' ';
311 // Generate the content
312 $inputContent = sprintf("<input type=\"checkbox\" name=\"%s\" class=\"checkbox %s_field\" value=\"1\"%s/>",
319 $this->addContentToPreviousGroup($inputContent);
323 * Add a reset input tag to the form or throw an exception if it is not
324 * yet opened. The field's name will be set as id.
326 * @param $buttonText Text displayed on the button
328 * @throws FormClosedException If the form is not yet opened
330 public function addInputResetButton ($buttonText) {
331 // Is the form opened?
332 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
333 // Throw an exception
334 throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM);
337 // Generate the content
338 $inputContent = sprintf("<input type=\"reset\" class=\"reset_button\" id=\"%s_reset\" value=\"%s\" />",
339 $this->getFormName(),
344 $this->addContentToPreviousGroup($inputContent);
348 * Add a reset input tag to the form or throw an exception if it is not
349 * yet opened. The field's name will be set as id.
351 * @param $buttonText Text displayed on the button
353 * @throws FormClosedException If the form is not yet opened
355 public function addInputSubmitButton ($buttonText) {
356 // Is the form opened?
357 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
358 // Throw an exception
359 throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM);
362 // Generate the content
363 $inputContent = sprintf("<input type=\"submit\" class=\"submit_button\" id=\"%s_submit\" name=\"%s_button\" value=\"%s\" />",
364 $this->getFormName(),
365 $this->getFormName(),
370 $this->addContentToPreviousGroup($inputContent);
374 * Add a form group or close an already opened and open a new one
376 * @param $groupId Name of the group or last opened if empty
377 * @param $groupText Text including HTML to show above this group
379 * @throws FormClosedException If no form has been opened before
380 * @throws EmptyVariableException If $groupId is not set
382 public function addFormGroup ($groupId = '', $groupText = '') {
384 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
385 // Throw exception here
386 throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM);
389 // At least the group name should be set
390 if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === FALSE)) {
391 // Throw exception here
392 throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
393 } elseif (empty($groupId)) {
394 // Close the last opened
395 $groupId = $this->getPreviousGroupId();
398 // Same group to open?
399 if (($this->ifGroupOpenedPreviously() === FALSE) && ($groupId === $this->getPreviousGroupId())) {
400 // Abort here silently
404 // Initialize content with closing div by default
405 $content = " </div>\n</div><!-- Group - CLOSE //-->";
407 // Is this group opened?
408 if ($this->ifGroupOpenedPreviously() === FALSE) {
409 // Begin the div/span blocks
410 $content = sprintf("<!-- Group %s - OPEN //-->
411 <div class=\"group_box\" id=\"%s_group_box\">
412 <span class=\"group_text\" id=\"%s_group_text\">
415 <div class=\"group_field\" id=\"%s_group_field\">",
424 $this->openGroupByIdContent($groupId, $content, "div");
426 // Is a sub group opened?
427 if ($this->ifSubGroupOpenedPreviously()) {
429 $this->addFormSubGroup();
432 // Get previous group id
433 $prevGroupId = $this->getPreviousGroupId();
436 $this->closePreviousGroupByContent($content);
438 // All call it again if group name is not empty
439 if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
440 //* DEBUG: */ echo $groupId.'/'.$prevGroupId."<br />\n";
441 $this->addFormGroup($groupId, $groupText);
447 * Add a form sub group or close an already opened and open a new one or
448 * throws an exception if no group has been opened before or if sub group
451 * @param $subGroupId Name of the group or last opened if empty
452 * @param $subGroupText Text including HTML to show above this group
454 * @throws FormFormClosedException If no group has been opened before
455 * @throws EmptyVariableException If $subGroupId is not set
457 public function addFormSubGroup ($subGroupId = '', $subGroupText = '') {
458 // Is a group opened?
459 if ($this->ifGroupOpenedPreviously() === FALSE) {
460 // Throw exception here
461 throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
464 // At least the sub group name should be set
465 if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === FALSE)) {
466 // Throw exception here
467 throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
468 } elseif (empty($subGroupId)) {
469 // Close the last opened
470 $subGroupId = $this->getPreviousSubGroupId();
473 // Same sub group to open?
474 if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($subGroupId == $this->getPreviousSubGroupId())) {
475 // Abort here silently
479 // Initialize content with closing div by default
480 $content = " </div>\n</div><!-- Sub group- CLOSE //-->";
482 // Is this group opened?
483 if ($this->ifSubGroupOpenedPreviously() === FALSE) {
484 // Begin the span block
485 $content = sprintf("<!-- Sub group %s - OPEN //-->
486 <div class=\"subgroup_box\" id=\"%s_subgroup_box\">
487 <span class=\"subgroup_text\" id=\"%s_subgroup_text\">
490 <div class=\"subgroup_field\" id=\"%s_subgroup_field\">",
498 // Switch the state and remeber the name
499 $this->openSubGroupByIdContent($subGroupId, $content, "div");
501 // Get previous sub group id
502 $prevSubGroupId = $this->getPreviousSubGroupId();
505 $this->closePreviousSubGroupByContent($content);
507 // All call it again if sub group name is not empty
508 if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) {
509 $this->addFormSubGroup($subGroupId, $subGroupText);
515 * Add text surrounded by a span block when there is a group opened before
516 * or else by a div block.
518 * @param $fieldName Field name
519 * @param $fieldText Text for the field
521 * @throws FormClosedException If the form is not yet opened
523 public function addFieldText ($fieldName, $fieldText) {
524 // Is the form opened?
525 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
526 // Throw an exception
527 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
530 // Set the block type
532 if ($this->ifGroupOpenedPreviously()) $block = 'span';
534 // Generate the content
535 $inputContent = sprintf(" <%s id=\"%s_text\">
545 $this->addContentToPreviousGroup($inputContent);
549 * Add text (notes) surrounded by a div block. Still opened groups or sub
550 * groups will be automatically closed.
552 * @param $noteId Id for this note
553 * @param $formNotes The form notes we shell addd
555 * @throws FormClosedException If the form is not yet opened
557 public function addFormNote ($noteId, $formNotes) {
558 // Is the form opened?
559 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
560 // Throw an exception
561 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
564 // Generate the content
565 $inputContent = sprintf(" <div id=\"form_note_%s\">
573 $this->addContentToPreviousGroup($inputContent);
577 * Adds a selection box as a sub group to the form. Do not box this into
578 * another sub group. Sub-sub groups are not (yet) supported.
580 * @param $selectId Id of the selection box
581 * @param $firstEntry Content to be added as first non-selectable entry
583 * @throws FormClosedException If the form is not yet opened
585 public function addInputSelectField ($selectId, $firstEntry) {
586 // Is the form group opened?
587 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
588 // Throw an exception
589 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
592 // Shall we close or open the sub group?
593 if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($this->getPreviousSubGroupId() !== $selectId)) {
594 // Initialize first entry (which might be non-selectable if content is provided
595 if (!empty($firstEntry)) {
596 // Add selection around it
597 $firstEntry = sprintf("<option value=\"invalid\" disabled=\"disabled\">%s</option>\n",
602 // Construct the opening select tag
603 $content = sprintf("<select class=\"select_box\" id=\"%s_%s\" name=\"%s\">\n%s",
604 $this->getFormName(),
610 // Open the sub group
611 $this->openSubGroupByIdContent($selectId, $content, "select");
612 } elseif ($this->getPreviousSubGroupId() != $selectId) {
613 // Something went wrong!
614 $this->debugInstance(__METHOD__."(): Previous sub group id {$this->getPreviousSubGroupId()} does not match current id {$selectId}.");
616 // Close the sub group
617 $this->closePreviousSubGroupByContent("</select>");
622 * Adds a non-selectable sub option to a previously added selection box.
623 * This method does *not* validate if there is already a sub option added
624 * with the same name. We need to finish this here!
626 * @param $subName Name of the sub action
627 * @param $subValue Value of the sub action
629 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
630 * @todo Add checking if sub option is already added
632 public function addSelectSubOption ($subName, $subValue) {
633 // Is there a sub group (shall be a selection box!)
634 if ($this->ifSubGroupOpenedPreviously() === FALSE) {
635 // Then throw an exception here
636 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
639 // Render the content
640 $content = sprintf("<option value=\"invalid\" class=\"suboption suboption_%s\" disabled=\"disabled\">%s</option>\n",
645 // Add the content to the previously opened sub group
646 $this->addContentToPreviousGroup($content);
650 * Adds a selectable option to a previously added selection box. This method
651 * does *not* validate if there is already a sub option added with the same
652 * name. We need to finish this here!
654 * @param $optionName Name of the sub action
655 * @param $optionValue Value of the sub action
657 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
658 * @todo Add checking if sub option is already added
660 public function addSelectOption ($optionName, $optionValue) {
661 // Is there a sub group (shall be a selection box!)
662 if ($this->ifSubGroupOpenedPreviously() === FALSE) {
663 // Then throw an exception here
664 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
667 // Render the content
668 $content = sprintf("<option value=\"%s\" class=\"option option_%s\">%s</option>\n",
674 // Add the content to the previously opened sub group
675 $this->addContentToPreviousGroup($content);
679 * Adds a pre-configured CAPTCHA
683 public function addCaptcha () {
685 $extraInstance = NULL;
688 // Get last executed pre filter
689 $extraInstance = Registry::getRegistry()->getInstance('extra');
690 } catch (NullPointerException $e) {
691 // Instance in registry is not set (NULL)
692 // @TODO We need to log this later
695 // Get a configured instance
696 $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha_class', array($this, $extraInstance));
698 // Initiate the CAPTCHA
699 $captchaInstance->initiateCaptcha();
701 // Render the CAPTCHA code
702 $captchaInstance->renderCode();
704 // Get the content and add it to the helper
705 $this->addContentToPreviousGroup($captchaInstance->renderContent());
709 * Enables/disables the form tag usage
711 * @param $formEnabled Whether form is enabled or disabled
714 public final function enableForm ($formEnabled = TRUE) {
715 $this->formEnabled = (bool) $formEnabled;
719 * Setter for form name
721 * @param $formName Name of this form
724 public final function setFormName ($formName) {
725 $this->formName = (string) $formName;
729 * Getter for form name
731 * @return $formName Name of this form
733 public final function getFormName () {
734 return $this->formName;
738 * Checks whether the registration requires a valid email address
740 * @return $required Whether the email address is required
742 public function ifRegisterRequiresEmailVerification () {
743 $required = ($this->getConfigInstance()->getConfigEntry('register_requires_email') == 'Y');
748 * Checks whether profile data shall be asked
750 * @return $required Whether profile data shall be asked
752 public function ifRegisterIncludesProfile () {
753 $required = ($this->getConfigInstance()->getConfigEntry('register_includes_profile') == 'Y');
758 * Checks whether this form is secured by a CAPTCHA
760 * @return $isSecured Whether this form is secured by a CAPTCHA
762 public function ifFormSecuredWithCaptcha () {
763 $isSecured = ($this->getConfigInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y');
768 * Checks whether personal data shall be asked
770 * @return $required Whether personal data shall be asked
772 public function ifRegisterIncludesPersonaData () {
773 $required = ($this->getConfigInstance()->getConfigEntry('register_personal_data') == 'Y');
778 * Checks whether for birthday shall be asked
780 * @return $required Whether birthday shall be asked
782 public function ifProfileIncludesBirthDay () {
783 $required = ($this->getConfigInstance()->getConfigEntry('profile_includes_birthday') == 'Y');
788 * Checks whether email addresses can only be once used
792 public function ifEmailMustBeUnique () {
793 $isUnique = ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y');
798 * Checks whether the specified chat protocol is enabled in this form
800 * @return $required Whether the specified chat protocol is enabled
802 public function ifChatEnabled ($chatProtocol) {
803 $required = ($this->getConfigInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y');
808 * Checks whether login is enabled or disabled
810 * @return $isEnabled Whether the login is enabled or disabled
812 public function ifLoginIsEnabled () {
813 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_enabled') == 'Y');
818 * Checks whether login shall be done by username
820 * @return $isEnabled Whether the login shall be done by username
822 public function ifLoginWithUsername () {
823 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "username");
828 * Checks whether login shall be done by email
830 * @return $isEnabled Whether the login shall be done by email
832 public function ifLoginWithEmail () {
833 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "email");
838 * Checks whether guest login is allowed
840 * @return $isAllowed Whether guest login is allowed
842 public function ifGuestLoginAllowed () {
843 $isAllowed = ($this->getConfigInstance()->getConfigEntry('guest_login_allowed') == 'Y');
848 * Checks whether the email address change must be confirmed
850 * @return $requireConfirm Whether email change must be confirmed
852 public function ifEmailChangeRequireConfirmation () {
853 $requireConfirm = ($this->getConfigInstance()->getConfigEntry('email_change_confirmation') == 'Y');
854 return $requireConfirm;
858 * Checks whether the rules has been updated
860 * @return $rulesUpdated Whether rules has been updated
861 * @todo Implement check if rules have been changed
863 public function ifRulesHaveChanged () {
868 * Checks whether email change is allowed
870 * @return $emailChange Whether changing email address is allowed
872 public function ifEmailChangeAllowed () {
873 $emailChange = ($this->getConfigInstance()->getConfigEntry('email_change_allowed') == 'Y');
878 * Checks whether the user account is unconfirmed
880 * @return $isUnconfirmed Whether the user account is unconfirmed
882 public function ifUserAccountUnconfirmed () {
883 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed'));
884 return $isUnconfirmed;
888 * Checks whether the user account is locked
890 * @return $isUnconfirmed Whether the user account is locked
892 public function ifUserAccountLocked () {
893 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_locked'));
894 return $isUnconfirmed;
898 * Checks whether the user account is a guest
900 * @return $isUnconfirmed Whether the user account is a guest
902 public function ifUserAccountGuest () {
903 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_guest'));
904 return $isUnconfirmed;
908 * Checks whether the refill page is active which should be not the default
909 * on non-web applications.
911 * @return $refillActive Whether the refill page is active
913 public function ifRefillPageActive () {
914 $refillActive = ($this->getConfigInstance()->getConfigEntry('refill_page_active') == 'Y');
915 return $refillActive;
919 * Flushs the content out (not yet secured against open forms, etc.!) or
920 * close the form automatically
923 * @throws FormOpenedException If the form is still open
925 public function flushContent () {
926 // Is the form still open?
927 if (($this->formOpened === TRUE) && ($this->formEnabled === TRUE)) {
928 // Close the form automatically
930 } elseif ($this->formEnabled === FALSE) {
931 if ($this->ifSubGroupOpenedPreviously()) {
933 $this->addFormSubGroup();
934 } elseif ($this->ifGroupOpenedPreviously()) {
936 $this->addFormGroup();
940 // Send content to template engine
941 //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."<br />\n";
942 $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent());