3 namespace CoreFramework\Helper;
5 // Import framework stuff
6 use CoreFramework\Template\CompileableTemplate;
9 * A helper for constructing web forms
11 * @author Roland Haeder <webmaster@shipsimu.org>
13 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
14 * @license GNU GPL 3.0 or any newer version
15 * @link http://www.shipsimu.org
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
32 * Whether the form tag is opened (keep at FALSE or else your forms will
35 private $formOpened = FALSE;
40 private $formName = '';
43 * Whether form tag is enabled (default: TRUE)
45 private $formEnabled = TRUE;
48 const EXCEPTION_FORM_NAME_INVALID = 0x120;
49 const EXCEPTION_CLOSED_FORM = 0x121;
50 const EXCEPTION_OPENED_FORM = 0x122;
51 const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123;
54 * Protected constructor
58 protected function __construct () {
59 // Call parent constructor
60 parent::__construct(__CLASS__);
64 * Creates the helper class with the given template engine instance and form name
66 * @param $templateInstance An instance of a valid template engine
67 * @param $formName Name of the form
68 * @param $formId Value for 'id' attribute (default: $formName)
69 * @param $withForm Whether include the form tag
70 * @return $helperInstance A preparedf instance of this helper
72 public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = FALSE, $withForm = TRUE) {
74 $helperInstance = new HtmlFormHelper();
76 // Set template instance
77 $helperInstance->setTemplateInstance($templateInstance);
79 // Is the form id not set?
80 if ($formId === FALSE) {
81 // Use form id from form name
86 $helperInstance->setFormName($formName);
88 // A form-less field may say 'FALSE' here...
89 if ($withForm === TRUE) {
91 $helperInstance->addFormTag($formName, $formId);
94 $helperInstance->enableForm(FALSE);
97 // Return the prepared instance
98 return $helperInstance;
102 * Add the form tag or close it an already opened form tag
104 * @param $formName Name of the form (default: FALSE)
105 * @param $formId Id of the form (attribute 'id'; default: FALSE)
107 * @throws InvalidFormNameException If the form name is invalid ( = FALSE)
108 * @todo Add some unique PIN here to bypass problems with some browser and/or extensions
110 public function addFormTag ($formName = FALSE, $formId = FALSE) {
111 // When the form is not yet opened at least form name must be valid
112 if (($this->formOpened === FALSE) && ($formName === FALSE)) {
113 // Thrown an exception
114 throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
117 // Close the form is default
118 $formContent = '</form>';
120 // Check whether we shall open or close the form
121 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
123 $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s/%s\" method=\"%s\" target=\"%s\"",
125 $this->getConfigInstance()->getConfigEntry('base_url'),
126 $this->getConfigInstance()->getConfigEntry('form_action'),
127 $this->getConfigInstance()->getConfigEntry('form_method'),
128 $this->getConfigInstance()->getConfigEntry('form_target')
131 // Add form id as well
132 $formContent .= sprintf(" id=\"%s_form\"",
139 // Open the form and remeber the form name
140 $this->formOpened = TRUE;
142 // Add it to the content
143 $this->addHeaderContent($formContent);
145 // Add the hidden field required to identify safely this form
146 $this->addInputHiddenField('form', $this->getFormName());
149 if ($this->ifGroupOpenedPreviously()) {
150 // Then automatically close it here
151 $this->addFormGroup();
155 $this->formOpened = FALSE;
157 // Add it to the content
158 $this->addFooterContent($formContent);
163 * Add a text input tag to the form or throw an exception if it is not yet
164 * opened. The field's name will be set as id.
166 * @param $fieldName Input field name
167 * @param $fieldValue Input default value (default: empty)
169 * @throws FormClosedException If the form is not yet opened
171 public function addInputTextField ($fieldName, $fieldValue = '') {
172 // Is the form opened?
173 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
174 // Throw an exception
175 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
178 // Generate the content
179 $inputContent = sprintf("<input type=\"text\" class=\"textfield %s_field\" name=\"%s\" value=\"%s\" />",
185 // And add it maybe with a 'li' tag
186 $this->addContentToPreviousGroup($inputContent);
190 * Add a text input tag to the form with pre-loaded default value
192 * @param $fieldName Input field name
195 public function addInputTextFieldWithDefault ($fieldName) {
196 // Get the value from instance
197 $fieldValue = $this->getValueField($fieldName);
198 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
200 // Add the text field
201 $this->addInputTextField($fieldName, $fieldValue);
205 * Add a password input tag to the form or throw an exception if it is not
206 * yet opened. The field's name will be set as id.
208 * @param $fieldName Input field name
209 * @param $fieldValue Input default value (default: empty)
211 * @throws FormClosedException If the form is not yet opened
213 public function addInputPasswordField ($fieldName, $fieldValue = '') {
214 // Is the form opened?
215 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
216 // Throw an exception
217 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
220 // Generate the content
221 $inputContent = sprintf("<input type=\"password\" class=\"password %s_field\" name=\"%s\" value=\"%s\" />",
228 $this->addContentToPreviousGroup($inputContent);
232 * Add a hidden input tag to the form or throw an exception if it is not
233 * yet opened. The field's name will be set as id.
235 * @param $fieldName Input field name
236 * @param $fieldValue Input default value (default: empty)
238 * @throws FormClosedException If the form is not yet opened
240 public function addInputHiddenField ($fieldName, $fieldValue = '') {
241 // Is the form opened?
242 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
243 // Throw an exception
244 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
247 // Generate the content
248 $inputContent = sprintf("<input type=\"hidden\" name=\"%s\" value=\"%s\" />",
254 $this->addContentToPreviousGroup($inputContent);
258 * Add a hidden input tag to the form with pre-loaded default value
260 * @param $fieldName Input field name
263 public function addInputHiddenFieldWithDefault ($fieldName) {
264 // Get the value from instance
265 $fieldValue = $this->getValueField($fieldName);
266 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
268 // Add the text field
269 $this->addInputHiddenField($fieldName, $fieldValue);
273 * Add a hidden input tag to the form with configuration value
275 * @param $fieldName Input field name
276 * @param $prefix Prefix for configuration without trailing _
279 public function addInputHiddenConfiguredField ($fieldName, $prefix) {
280 // Get the value from instance
281 $fieldValue = $this->getConfigInstance()->getConfigEntry("{$prefix}_{$fieldName}");
282 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
284 // Add the text field
285 $this->addInputHiddenField($fieldName, $fieldValue);
289 * Add a checkbox input tag to the form or throw an exception if it is not
290 * yet opened. The field's name will be set as id.
292 * @param $fieldName Input field name
293 * @param $fieldChecked Whether the field is checked (defaut: checked)
295 * @throws FormClosedException If the form is not yet opened
297 public function addInputCheckboxField ($fieldName, $fieldChecked = TRUE) {
298 // Is the form opened?
299 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
300 // Throw an exception
301 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
304 // Set whether the check box is checked...
305 $checked = " checked=\"checked\"";
306 if ($fieldChecked === FALSE) $checked = ' ';
308 // Generate the content
309 $inputContent = sprintf("<input type=\"checkbox\" name=\"%s\" class=\"checkbox %s_field\" value=\"1\"%s/>",
316 $this->addContentToPreviousGroup($inputContent);
320 * Add a reset input tag to the form or throw an exception if it is not
321 * yet opened. The field's name will be set as id.
323 * @param $buttonText Text displayed on the button
325 * @throws FormClosedException If the form is not yet opened
327 public function addInputResetButton ($buttonText) {
328 // Is the form opened?
329 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
330 // Throw an exception
331 throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM);
334 // Generate the content
335 $inputContent = sprintf("<input type=\"reset\" class=\"reset_button\" id=\"%s_reset\" value=\"%s\" />",
336 $this->getFormName(),
341 $this->addContentToPreviousGroup($inputContent);
345 * Add a reset input tag to the form or throw an exception if it is not
346 * yet opened. The field's name will be set as id.
348 * @param $buttonText Text displayed on the button
350 * @throws FormClosedException If the form is not yet opened
352 public function addInputSubmitButton ($buttonText) {
353 // Is the form opened?
354 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
355 // Throw an exception
356 throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM);
359 // Generate the content
360 $inputContent = sprintf("<input type=\"submit\" class=\"submit_button\" id=\"%s_submit\" name=\"%s_button\" value=\"%s\" />",
361 $this->getFormName(),
362 $this->getFormName(),
367 $this->addContentToPreviousGroup($inputContent);
371 * Add a form group or close an already opened and open a new one
373 * @param $groupId Name of the group or last opened if empty
374 * @param $groupText Text including HTML to show above this group
376 * @throws FormClosedException If no form has been opened before
377 * @throws EmptyVariableException If $groupId is not set
379 public function addFormGroup ($groupId = '', $groupText = '') {
381 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
382 // Throw exception here
383 throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM);
386 // At least the group name should be set
387 if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === FALSE)) {
388 // Throw exception here
389 throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
390 } elseif (empty($groupId)) {
391 // Close the last opened
392 $groupId = $this->getPreviousGroupId();
395 // Same group to open?
396 if (($this->ifGroupOpenedPreviously() === FALSE) && ($groupId === $this->getPreviousGroupId())) {
397 // Abort here silently
401 // Initialize content with closing div by default
402 $content = " </div>\n</div><!-- Group - CLOSE //-->";
404 // Is this group opened?
405 if ($this->ifGroupOpenedPreviously() === FALSE) {
406 // Begin the div/span blocks
407 $content = sprintf("<!-- Group %s - OPEN //-->
408 <div class=\"group_box\" id=\"%s_group_box\">
409 <span class=\"group_text\" id=\"%s_group_text\">
412 <div class=\"group_field\" id=\"%s_group_field\">",
421 $this->openGroupByIdContent($groupId, $content, "div");
423 // Is a sub group opened?
424 if ($this->ifSubGroupOpenedPreviously()) {
426 $this->addFormSubGroup();
429 // Get previous group id
430 $prevGroupId = $this->getPreviousGroupId();
433 $this->closePreviousGroupByContent($content);
435 // All call it again if group name is not empty
436 if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
437 //* DEBUG: */ echo $groupId.'/'.$prevGroupId."<br />\n";
438 $this->addFormGroup($groupId, $groupText);
444 * Add a form sub group or close an already opened and open a new one or
445 * throws an exception if no group has been opened before or if sub group
448 * @param $subGroupId Name of the group or last opened if empty
449 * @param $subGroupText Text including HTML to show above this group
451 * @throws FormFormClosedException If no group has been opened before
452 * @throws EmptyVariableException If $subGroupId is not set
454 public function addFormSubGroup ($subGroupId = '', $subGroupText = '') {
455 // Is a group opened?
456 if ($this->ifGroupOpenedPreviously() === FALSE) {
457 // Throw exception here
458 throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
461 // At least the sub group name should be set
462 if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === FALSE)) {
463 // Throw exception here
464 throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
465 } elseif (empty($subGroupId)) {
466 // Close the last opened
467 $subGroupId = $this->getPreviousSubGroupId();
470 // Same sub group to open?
471 if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($subGroupId == $this->getPreviousSubGroupId())) {
472 // Abort here silently
476 // Initialize content with closing div by default
477 $content = " </div>\n</div><!-- Sub group- CLOSE //-->";
479 // Is this group opened?
480 if ($this->ifSubGroupOpenedPreviously() === FALSE) {
481 // Begin the span block
482 $content = sprintf("<!-- Sub group %s - OPEN //-->
483 <div class=\"subgroup_box\" id=\"%s_subgroup_box\">
484 <span class=\"subgroup_text\" id=\"%s_subgroup_text\">
487 <div class=\"subgroup_field\" id=\"%s_subgroup_field\">",
495 // Switch the state and remeber the name
496 $this->openSubGroupByIdContent($subGroupId, $content, "div");
498 // Get previous sub group id
499 $prevSubGroupId = $this->getPreviousSubGroupId();
502 $this->closePreviousSubGroupByContent($content);
504 // All call it again if sub group name is not empty
505 if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) {
506 $this->addFormSubGroup($subGroupId, $subGroupText);
512 * Add text surrounded by a span block when there is a group opened before
513 * or else by a div block.
515 * @param $fieldName Field name
516 * @param $fieldText Text for the field
518 * @throws FormClosedException If the form is not yet opened
520 public function addFieldText ($fieldName, $fieldText) {
521 // Is the form opened?
522 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
523 // Throw an exception
524 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
527 // Set the block type
529 if ($this->ifGroupOpenedPreviously()) $block = 'span';
531 // Generate the content
532 $inputContent = sprintf(" <%s id=\"%s_text\">
542 $this->addContentToPreviousGroup($inputContent);
546 * Add text (notes) surrounded by a div block. Still opened groups or sub
547 * groups will be automatically closed.
549 * @param $noteId Id for this note
550 * @param $formNotes The form notes we shell addd
552 * @throws FormClosedException If the form is not yet opened
554 public function addFormNote ($noteId, $formNotes) {
555 // Is the form opened?
556 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
557 // Throw an exception
558 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
561 // Generate the content
562 $inputContent = sprintf(" <div id=\"form_note_%s\">
570 $this->addContentToPreviousGroup($inputContent);
574 * Adds a selection box as a sub group to the form. Do not box this into
575 * another sub group. Sub-sub groups are not (yet) supported.
577 * @param $selectId Id of the selection box
578 * @param $firstEntry Content to be added as first non-selectable entry
580 * @throws FormClosedException If the form is not yet opened
582 public function addInputSelectField ($selectId, $firstEntry) {
583 // Is the form group opened?
584 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
585 // Throw an exception
586 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
589 // Shall we close or open the sub group?
590 if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($this->getPreviousSubGroupId() !== $selectId)) {
591 // Initialize first entry (which might be non-selectable if content is provided
592 if (!empty($firstEntry)) {
593 // Add selection around it
594 $firstEntry = sprintf("<option value=\"invalid\" disabled=\"disabled\">%s</option>\n",
599 // Construct the opening select tag
600 $content = sprintf("<select class=\"select_box\" id=\"%s_%s\" name=\"%s\">\n%s",
601 $this->getFormName(),
607 // Open the sub group
608 $this->openSubGroupByIdContent($selectId, $content, "select");
609 } elseif ($this->getPreviousSubGroupId() != $selectId) {
610 // Something went wrong!
611 $this->debugInstance(__METHOD__."(): Previous sub group id {$this->getPreviousSubGroupId()} does not match current id {$selectId}.");
613 // Close the sub group
614 $this->closePreviousSubGroupByContent("</select>");
619 * Adds a non-selectable sub option to a previously added selection box.
620 * This method does *not* validate if there is already a sub option added
621 * with the same name. We need to finish this here!
623 * @param $subName Name of the sub action
624 * @param $subValue Value of the sub action
626 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
627 * @todo Add checking if sub option is already added
629 public function addSelectSubOption ($subName, $subValue) {
630 // Is there a sub group (shall be a selection box!)
631 if ($this->ifSubGroupOpenedPreviously() === FALSE) {
632 // Then throw an exception here
633 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
636 // Render the content
637 $content = sprintf("<option value=\"invalid\" class=\"suboption suboption_%s\" disabled=\"disabled\">%s</option>\n",
642 // Add the content to the previously opened sub group
643 $this->addContentToPreviousGroup($content);
647 * Adds a selectable option to a previously added selection box. This method
648 * does *not* validate if there is already a sub option added with the same
649 * name. We need to finish this here!
651 * @param $optionName Name of the sub action
652 * @param $optionValue Value of the sub action
654 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
655 * @todo Add checking if sub option is already added
657 public function addSelectOption ($optionName, $optionValue) {
658 // Is there a sub group (shall be a selection box!)
659 if ($this->ifSubGroupOpenedPreviously() === FALSE) {
660 // Then throw an exception here
661 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
664 // Render the content
665 $content = sprintf("<option value=\"%s\" class=\"option option_%s\">%s</option>\n",
671 // Add the content to the previously opened sub group
672 $this->addContentToPreviousGroup($content);
676 * Adds a pre-configured CAPTCHA
680 public function addCaptcha () {
682 $extraInstance = NULL;
685 // Get last executed pre filter
686 $extraInstance = Registry::getRegistry()->getInstance('extra');
687 } catch (NullPointerException $e) {
688 // Instance in registry is not set (NULL)
689 // @TODO We need to log this later
692 // Get a configured instance
693 $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha_class', array($this, $extraInstance));
695 // Initiate the CAPTCHA
696 $captchaInstance->initiateCaptcha();
698 // Render the CAPTCHA code
699 $captchaInstance->renderCode();
701 // Get the content and add it to the helper
702 $this->addContentToPreviousGroup($captchaInstance->renderContent());
706 * Enables/disables the form tag usage
708 * @param $formEnabled Whether form is enabled or disabled
711 public final function enableForm ($formEnabled = TRUE) {
712 $this->formEnabled = (bool) $formEnabled;
716 * Setter for form name
718 * @param $formName Name of this form
721 public final function setFormName ($formName) {
722 $this->formName = (string) $formName;
726 * Getter for form name
728 * @return $formName Name of this form
730 public final function getFormName () {
731 return $this->formName;
735 * Checks whether the registration requires a valid email address
737 * @return $required Whether the email address is required
739 public function ifRegisterRequiresEmailVerification () {
740 $required = ($this->getConfigInstance()->getConfigEntry('register_requires_email') == 'Y');
745 * Checks whether profile data shall be asked
747 * @return $required Whether profile data shall be asked
749 public function ifRegisterIncludesProfile () {
750 $required = ($this->getConfigInstance()->getConfigEntry('register_includes_profile') == 'Y');
755 * Checks whether this form is secured by a CAPTCHA
757 * @return $isSecured Whether this form is secured by a CAPTCHA
759 public function ifFormSecuredWithCaptcha () {
760 $isSecured = ($this->getConfigInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y');
765 * Checks whether personal data shall be asked
767 * @return $required Whether personal data shall be asked
769 public function ifRegisterIncludesPersonaData () {
770 $required = ($this->getConfigInstance()->getConfigEntry('register_personal_data') == 'Y');
775 * Checks whether for birthday shall be asked
777 * @return $required Whether birthday shall be asked
779 public function ifProfileIncludesBirthDay () {
780 $required = ($this->getConfigInstance()->getConfigEntry('profile_includes_birthday') == 'Y');
785 * Checks whether email addresses can only be once used
789 public function ifEmailMustBeUnique () {
790 $isUnique = ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y');
795 * Checks whether the specified chat protocol is enabled in this form
797 * @return $required Whether the specified chat protocol is enabled
799 public function ifChatEnabled ($chatProtocol) {
800 $required = ($this->getConfigInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y');
805 * Checks whether login is enabled or disabled
807 * @return $isEnabled Whether the login is enabled or disabled
809 public function ifLoginIsEnabled () {
810 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_enabled') == 'Y');
815 * Checks whether login shall be done by username
817 * @return $isEnabled Whether the login shall be done by username
819 public function ifLoginWithUsername () {
820 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "username");
825 * Checks whether login shall be done by email
827 * @return $isEnabled Whether the login shall be done by email
829 public function ifLoginWithEmail () {
830 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "email");
835 * Checks whether guest login is allowed
837 * @return $isAllowed Whether guest login is allowed
839 public function ifGuestLoginAllowed () {
840 $isAllowed = ($this->getConfigInstance()->getConfigEntry('guest_login_allowed') == 'Y');
845 * Checks whether the email address change must be confirmed
847 * @return $requireConfirm Whether email change must be confirmed
849 public function ifEmailChangeRequireConfirmation () {
850 $requireConfirm = ($this->getConfigInstance()->getConfigEntry('email_change_confirmation') == 'Y');
851 return $requireConfirm;
855 * Checks whether the rules has been updated
857 * @return $rulesUpdated Whether rules has been updated
858 * @todo Implement check if rules have been changed
860 public function ifRulesHaveChanged () {
865 * Checks whether email change is allowed
867 * @return $emailChange Whether changing email address is allowed
869 public function ifEmailChangeAllowed () {
870 $emailChange = ($this->getConfigInstance()->getConfigEntry('email_change_allowed') == 'Y');
875 * Checks whether the user account is unconfirmed
877 * @return $isUnconfirmed Whether the user account is unconfirmed
879 public function ifUserAccountUnconfirmed () {
880 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed'));
881 return $isUnconfirmed;
885 * Checks whether the user account is locked
887 * @return $isUnconfirmed Whether the user account is locked
889 public function ifUserAccountLocked () {
890 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_locked'));
891 return $isUnconfirmed;
895 * Checks whether the user account is a guest
897 * @return $isUnconfirmed Whether the user account is a guest
899 public function ifUserAccountGuest () {
900 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_guest'));
901 return $isUnconfirmed;
905 * Checks whether the refill page is active which should be not the default
906 * on non-web applications.
908 * @return $refillActive Whether the refill page is active
910 public function ifRefillPageActive () {
911 $refillActive = ($this->getConfigInstance()->getConfigEntry('refill_page_active') == 'Y');
912 return $refillActive;
916 * Flushs the content out (not yet secured against open forms, etc.!) or
917 * close the form automatically
920 * @throws FormOpenedException If the form is still open
922 public function flushContent () {
923 // Is the form still open?
924 if (($this->formOpened === TRUE) && ($this->formEnabled === TRUE)) {
925 // Close the form automatically
927 } elseif ($this->formEnabled === FALSE) {
928 if ($this->ifSubGroupOpenedPreviously()) {
930 $this->addFormSubGroup();
931 } elseif ($this->ifGroupOpenedPreviously()) {
933 $this->addFormGroup();
937 // Send content to template engine
938 //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."<br />\n";
939 $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent());