3 namespace Org\Mxchange\CoreFramework\Helper;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
7 use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
8 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
9 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
10 use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
11 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
12 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
15 use \InvalidArgumentException;
18 * A helper for constructing web forms
20 * @author Roland Haeder <webmaster@shipsimu.org>
22 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
23 * @license GNU GPL 3.0 or any newer version
24 * @link http://www.shipsimu.org
26 * This program is free software: you can redistribute it and/or modify
27 * it under the terms of the GNU General Public License as published by
28 * the Free Software Foundation, either version 3 of the License, or
29 * (at your option) any later version.
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public License
37 * along with this program. If not, see <http://www.gnu.org/licenses/>.
39 class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
41 * Whether the form tag is opened (keep at false or else your forms will
44 private $formOpened = false;
47 * Name of current form
49 private $formName = '';
57 * Whether form tag is enabled (default: true)
59 private $formEnabled = true;
62 const EXCEPTION_FORM_NAME_INVALID = 0x120;
63 const EXCEPTION_CLOSED_FORM = 0x121;
64 const EXCEPTION_OPENED_FORM = 0x122;
65 const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123;
68 * Protected constructor
72 private function __construct () {
73 // Call parent constructor
74 parent::__construct(__CLASS__);
78 * Creates the helper class with the given template engine instance and form name
80 * @param $templateInstance An instance of a valid template engine
81 * @param $formName Name of the form
82 * @param $formId Value for 'id' attribute (default: $formName)
83 * @param $withForm Whether include the form tag
84 * @return $helperInstance A preparedf instance of this helper
86 public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, string $formName, string $formId = NULL, bool $withForm = true) {
88 $helperInstance = new HtmlFormHelper();
90 // Set template instance
91 $helperInstance->setTemplateInstance($templateInstance);
93 // Is the form id not set?
94 if (is_null($formId)) {
95 // Use form id from form name
100 $helperInstance->setFormName($formName);
102 // A form-less field may say 'false' here...
103 if ($withForm === true) {
105 $helperInstance->addFormTag($formName, $formId);
108 $helperInstance->enableForm(false);
111 // Return the prepared instance
112 return $helperInstance;
116 * Add the form tag or close it an already opened form tag
118 * @param $formName Name of the form (default: false)
119 * @param $formId Id of the form (attribute 'id'; default: false)
121 * @throws InvalidFormNameException If the form name is invalid ( = false)
122 * @todo Add some unique PIN here to bypass problems with some browser and/or extensions
124 public function addFormTag (string $formName = NULL, string $formId = NULL) {
125 // When the form is not yet opened at least form name must be valid
126 if (($this->formOpened === false) && (is_null($formName))) {
127 // Thrown an exception
128 throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
131 // Close the form is default
132 $formContent = '</form>';
134 // Check whether we shall open or close the form
135 if (($this->formOpened === false) && ($this->formEnabled === true)) {
137 $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s/%s\" method=\"%s\" target=\"%s\" id=\"%s_form\">",
139 FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('base_url'),
140 FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('form_action'),
141 FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('form_method'),
142 FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('form_target'),
146 // Open the form and remeber the form name and id
147 $this->formName = $formName;
148 $this->formId = $formId;
149 $this->formOpened = true;
151 // Add it to the content
152 $this->addHeaderContent($formContent);
154 // Add the hidden field required to identify safely this form
155 $this->addInputHiddenField('form', $this->getFormName());
158 if ($this->ifGroupOpenedPreviously()) {
159 // Then automatically close it here
160 $this->addFormGroup();
164 $this->formOpened = false;
166 // Add it to the content
167 $this->addFooterContent($formContent);
172 * Add a text input tag to the form or throw an exception if it is not yet
173 * opened. The field's name will be set as id.
175 * @param $fieldName Input field name
176 * @param $fieldValue Input default value (default: empty)
178 * @throws FormClosedException If the form is not yet opened
180 public function addInputTextField (string $fieldName, string $fieldValue = '') {
181 // Is the form opened?
182 if (($this->formOpened === false) && ($this->formEnabled === true)) {
183 // Throw an exception
184 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
187 // Generate the content
188 $inputContent = sprintf('<input type="text" class="form-control" id="%s_%s_field" name="%s" value="%s" />',
195 // And add it maybe with a 'li' tag
196 $this->addContentToPreviousGroup($inputContent);
200 * Add a text input tag to the form with pre-loaded default value
202 * @param $fieldName Input field name
205 public function addInputTextFieldWithDefault (string $fieldName) {
206 // Get the value from instance
207 $fieldValue = $this->getValueField($fieldName);
208 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
210 // Add the text field
211 $this->addInputTextField($fieldName, $fieldValue);
215 * Add a password input tag to the form or throw an exception if it is not
216 * yet opened. The field's name will be set as id.
218 * @param $fieldName Input field name
219 * @param $fieldValue Input default value (default: empty)
221 * @throws FormClosedException If the form is not yet opened
223 public function addInputPasswordField (string $fieldName, string $fieldValue = '') {
224 // Is the form opened?
225 if (($this->formOpened === false) && ($this->formEnabled === true)) {
226 // Throw an exception
227 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
230 // Generate the content
231 $inputContent = sprintf('<input type="password" class="form-control" id="%s_%s_field" name="%s" value="%s" />',
239 $this->addContentToPreviousGroup($inputContent);
243 * Add a hidden input tag to the form or throw an exception if it is not
244 * yet opened. The field's name will be set as id.
246 * @param $fieldName Input field name
247 * @param $fieldValue Input default value (default: empty)
249 * @throws FormClosedException If the form is not yet opened
251 public function addInputHiddenField (string $fieldName, string $fieldValue = '') {
252 // Is the form opened?
253 if (($this->formOpened === false) && ($this->formEnabled === true)) {
254 // Throw an exception
255 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
258 // Generate the content
259 $inputContent = sprintf('<input type="hidden" name="%s" value="%s" />',
265 $this->addContentToPreviousGroup($inputContent);
269 * Add a hidden input tag to the form with pre-loaded default value
271 * @param $fieldName Input field name
274 public function addInputHiddenFieldWithDefault (string $fieldName) {
275 // Get the value from instance
276 $fieldValue = $this->getValueField($fieldName);
277 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
279 // Add the text field
280 $this->addInputHiddenField($fieldName, $fieldValue);
284 * Add a hidden input tag to the form with configuration value
286 * @param $fieldName Input field name
287 * @param $prefix Prefix for configuration without trailing _
290 public function addInputHiddenConfiguredField (string $fieldName, string $prefix) {
291 // Get the value from instance
292 $fieldValue = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry("{$prefix}_{$fieldName}");
293 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
295 // Add the text field
296 $this->addInputHiddenField($fieldName, $fieldValue);
300 * Add a checkbox input tag to the form or throw an exception if it is not
301 * yet opened. The field's name will be set as id.
303 * @param $fieldName Input field name
304 * @param $fieldChecked Whether the field is checked (defaut: checked)
306 * @throws FormClosedException If the form is not yet opened
308 public function addInputCheckboxField (string $fieldName, bool $fieldChecked = true) {
309 // Is the form opened?
310 if (($this->formOpened === false) && ($this->formEnabled === true)) {
311 // Throw an exception
312 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
315 // Set whether the check box is checked...
316 $checked = ($fieldChecked ? ' checked="checked"' : ' ');
318 // Generate the content
319 $inputContent = sprintf('<input type="checkbox" name="%s" class="checkbox" id="%s_%s_field" value="1"%s />',
327 $this->addContentToPreviousGroup($inputContent);
331 * Add a reset input tag to the form or throw an exception if it is not
332 * yet opened. The field's name will be set as id.
334 * @param $buttonText Text displayed on the button
336 * @throws FormClosedException If the form is not yet opened
338 public function addInputResetButton (string $buttonText) {
339 // Is the form opened?
340 if (($this->formOpened === false) && ($this->formEnabled === true)) {
341 // Throw an exception
342 throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM);
345 // Generate the content
346 $inputContent = sprintf('<input type="reset" class="reset_button" id="%s_reset" value="%s" />',
352 $this->addContentToPreviousGroup($inputContent);
356 * Add a reset input tag to the form or throw an exception if it is not
357 * yet opened. The field's name will be set as id.
359 * @param $buttonText Text displayed on the button
361 * @throws FormClosedException If the form is not yet opened
363 public function addInputSubmitButton (string $buttonText) {
364 // Is the form opened?
365 if (($this->formOpened === false) && ($this->formEnabled === true)) {
366 // Throw an exception
367 throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM);
370 // Generate the content
371 $inputContent = sprintf('<input type="submit" class="submit_button" id="%s_submit" name="%s_submit" value="%s" />',
378 $this->addContentToPreviousGroup($inputContent);
382 * Add a form group or close an already opened and open a new one
384 * @param $groupId Name of the group or last opened if empty
385 * @param $groupText Text including HTML to show above this group
387 * @throws FormClosedException If no form has been opened before
388 * @throws InvalidArgumentException If $groupId is not set
390 public function addFormGroup (string $groupId = '', string $groupText = '') {
392 if (($this->formOpened === false) && ($this->formEnabled === true)) {
393 // Throw exception here
394 throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM);
395 } elseif ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === false)) {
396 // Throw exception here
397 throw new InvalidArgumentException('Parameter "groupId" is empty but group is not closed');
398 } elseif (empty($groupId)) {
399 // Close the last opened
400 $groupId = $this->getPreviousGroupId();
403 // Same group to open?
404 if (($this->ifGroupOpenedPreviously() === false) && ($groupId === $this->getPreviousGroupId())) {
405 // Abort here silently
409 // Initialize content with closing div by default
410 $content = " </div>\n</div><!-- Group - CLOSE //-->";
412 // Is this group opened?
413 if ($this->ifGroupOpenedPreviously() === false) {
414 // Begin the div/span blocks
415 $content = sprintf("<!-- Group %s - OPEN //-->
416 <div class=\"group_box\" id=\"%s_group_box\">
417 <span class=\"group_text\" id=\"%s_group_text\">
420 <div class=\"group_field\" id=\"%s_group_field\">",
429 $this->openGroupByIdContent($groupId, $content, "div");
431 // Is a sub group opened?
432 if ($this->ifSubGroupOpenedPreviously()) {
434 $this->addFormSubGroup();
437 // Get previous group id
438 $prevGroupId = $this->getPreviousGroupId();
441 $this->closePreviousGroupByContent($content);
443 // All call it again if group name is not empty
444 if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
445 //* DEBUG: */ echo $groupId.'/'.$prevGroupId."<br />\n";
446 $this->addFormGroup($groupId, $groupText);
452 * Add a form sub group or close an already opened and open a new one or
453 * throws an exception if no group has been opened before or if sub group
456 * @param $subGroupId Name of the group or last opened if empty
457 * @param $subGroupText Text including HTML to show above this group
459 * @throws FormFormClosedException If no group has been opened before
460 * @throws InvalidArgumentException If $subGroupId is not set
462 public function addFormSubGroup (string $subGroupId = '', string $subGroupText = '') {
463 // Is a group opened?
464 if ($this->ifGroupOpenedPreviously() === false) {
465 // Throw exception here
466 throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
467 } elseif ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === false)) {
468 // Throw exception here
469 throw new InvalidArgumentException('Parameter "subGroupId" is empty but sub-group is not closed');
470 } elseif (empty($subGroupId)) {
471 // Close the last opened
472 $subGroupId = $this->getPreviousSubGroupId();
475 // Same sub group to open?
476 if (($this->ifSubGroupOpenedPreviously() === false) && ($subGroupId == $this->getPreviousSubGroupId())) {
477 // Abort here silently
481 // Initialize content with closing div by default
482 $content = " </div>\n</div><!-- Sub group- CLOSE //-->";
484 // Is this group opened?
485 if ($this->ifSubGroupOpenedPreviously() === false) {
486 // Begin the span block
487 $content = sprintf("<!-- Sub group %s - OPEN //-->
488 <div class=\"subgroup_box\" id=\"%s_subgroup_box\">
489 <span class=\"subgroup_text\" id=\"%s_subgroup_text\">
492 <div class=\"subgroup_field\" id=\"%s_subgroup_field\">",
500 // Switch the state and remeber the name
501 $this->openSubGroupByIdContent($subGroupId, $content, "div");
503 // Get previous sub group id
504 $prevSubGroupId = $this->getPreviousSubGroupId();
507 $this->closePreviousSubGroupByContent($content);
509 // All call it again if sub group name is not empty
510 if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) {
511 $this->addFormSubGroup($subGroupId, $subGroupText);
517 * Adds text surrounded by a label tag for given form field
519 * @param $fieldName Field name
520 * @param $fieldText Text for the field
521 * @param $fieldTitle Optional title for label tag
523 * @throws FormClosedException If the form is not yet opened
525 public function addFieldLabel (string $fieldName, string $fieldText, string $fieldTitle = '') {
526 // Is the form opened?
527 if (($this->formOpened === false) && ($this->formEnabled === true)) {
528 // Throw an exception
529 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
532 // Default is no title attribute
533 $titleAttribute = '';
536 if (!empty($fieldTitle)) {
537 // Create title attribute
538 $titleAttribute = sprintf(' title="%s" data-toggle="tooltip"', $fieldTitle);
541 // Generate the content
542 $inputContent = sprintf('<label class="col-form-label" for="%s_%s_field"%s>
552 $this->addContentToPreviousGroup($inputContent);
556 * Add text (notes) surrounded by a div block. Still opened groups or sub
557 * groups will be automatically closed.
559 * @param $noteId Id for this note
560 * @param $formNotes The form notes we shell addd
562 * @throws FormClosedException If the form is not yet opened
564 public function addFormNote (string $noteId, string $formNotes) {
565 // Is the form opened?
566 if (($this->formOpened === false) && ($this->formEnabled === true)) {
567 // Throw an exception
568 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
571 // Generate the content
572 $inputContent = sprintf(" <div id=\"form_note_%s\">
580 $this->addContentToPreviousGroup($inputContent);
584 * Adds a selection box as a sub group to the form. Do not box this into
585 * another sub group. Sub-sub groups are not (yet) supported.
587 * @param $selectId Id of the selection box
588 * @param $firstEntry Content to be added as first non-selectable entry
590 * @throws FormClosedException If the form is not yet opened
592 public function addInputSelectField (string $selectId, string $firstEntry) {
593 // Is the form group opened?
594 if (($this->formOpened === false) && ($this->formEnabled === true)) {
595 // Throw an exception
596 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
599 // Shall we close or open the sub group?
600 if (($this->ifSubGroupOpenedPreviously() === false) && ($this->getPreviousSubGroupId() !== $selectId)) {
601 // Initialize first entry (which might be non-selectable if content is provided
602 if (!empty($firstEntry)) {
603 // Add selection around it
604 $firstEntry = sprintf("<option value=\"invalid\" disabled=\"disabled\">%s</option>\n",
609 // Construct the opening select tag
610 $content = sprintf("<select class=\"select_box\" id=\"%s_%s\" name=\"%s\">\n%s",
611 $this->getFormName(),
617 // Open the sub group
618 $this->openSubGroupByIdContent($selectId, $content, "select");
619 } elseif ($this->getPreviousSubGroupId() != $selectId) {
620 // Something went wrong!
621 $this->debugInstance(__METHOD__."(): Previous sub group id {$this->getPreviousSubGroupId()} does not match current id {$selectId}.");
623 // Close the sub group
624 $this->closePreviousSubGroupByContent("</select>");
629 * Adds a non-selectable sub option to a previously added selection box.
630 * This method does *not* validate if there is already a sub option added
631 * with the same name. We need to finish this here!
633 * @param $subName Name of the sub action
634 * @param $subValue Value of the sub action
636 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
637 * @todo Add checking if sub option is already added
639 public function addSelectSubOption (string $subName, string $subValue) {
640 // Is there a sub group (shall be a selection box!)
641 if ($this->ifSubGroupOpenedPreviously() === false) {
642 // Then throw an exception here
643 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
646 // Render the content
647 $content = sprintf("<option value=\"invalid\" class=\"suboption suboption_%s\" disabled=\"disabled\">%s</option>\n",
652 // Add the content to the previously opened sub group
653 $this->addContentToPreviousGroup($content);
657 * Adds a selectable option to a previously added selection box. This method
658 * does *not* validate if there is already a sub option added with the same
659 * name. We need to finish this here!
661 * @param $optionName Name of the sub action
662 * @param $optionValue Value of the sub action
664 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
665 * @todo Add checking if sub option is already added
667 public function addSelectOption (string $optionName, string $optionValue) {
668 // Is there a sub group (shall be a selection box!)
669 if ($this->ifSubGroupOpenedPreviously() === false) {
670 // Then throw an exception here
671 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
674 // Render the content
675 $content = sprintf("<option value=\"%s\" class=\"option option_%s\">%s</option>\n",
681 // Add the content to the previously opened sub group
682 $this->addContentToPreviousGroup($content);
686 * Adds a pre-configured CAPTCHA
690 public function addCaptcha () {
692 $extraInstance = NULL;
695 // Get last executed pre filter
696 $extraInstance = GenericRegistry::getRegistry()->getInstance('extra');
697 } catch (NullPointerException $e) {
698 // Instance in registry is not set (NULL)
699 // @TODO We need to log this later
702 // Get a configured instance
703 $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha_class', array($this, $extraInstance));
705 // Initiate the CAPTCHA
706 $captchaInstance->initiateCaptcha();
708 // Render the CAPTCHA code
709 $captchaInstance->renderCode();
711 // Get the content and add it to the helper
712 $this->addContentToPreviousGroup($captchaInstance->renderContent());
716 * Enables/disables the form tag usage
718 * @param $formEnabled Whether form is enabled or disabled
721 public final function enableForm (bool $formEnabled = true) {
722 $this->formEnabled = $formEnabled;
726 * Setter for form name
728 * @param $formName Name of this form
731 public final function setFormName (string $formName) {
732 $this->formName = $formName;
736 * Getter for form name
738 * @return $formName Name of this form
740 public final function getFormName () {
741 return $this->formName;
747 * @param $formId Id of this form
750 public final function setFormId (string $formId) {
751 $this->formId = $formId;
757 * @return $formId Id of this form
759 public final function getFormId () {
760 return $this->formId;
764 * Checks whether the registration requires a valid email address
766 * @return $required Whether the email address is required
768 public function ifRegisterRequiresEmailVerification () {
769 $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_requires_email');
774 * Checks whether profile data shall be asked
776 * @return $required Whether profile data shall be asked
778 public function ifRegisterIncludesProfile () {
779 $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_includes_profile');
784 * Checks whether this form is secured by a CAPTCHA
786 * @return $isSecured Whether this form is secured by a CAPTCHA
788 public function ifFormSecuredWithCaptcha () {
789 $isSecured = FrameworkBootstrap::getConfigurationInstance()->isEnabled($this->getFormName() . '_captcha_secured');
794 * Checks whether personal data shall be asked
796 * @return $required Whether personal data shall be asked
798 public function ifRegisterIncludesPersonaData () {
799 $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_personal_data');
804 * Checks whether for birthday shall be asked
806 * @return $required Whether birthday shall be asked
808 public function ifProfileIncludesBirthDay () {
809 $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('profile_includes_birthday');
814 * Checks whether email addresses can only be once used
818 public function ifEmailMustBeUnique () {
819 $isUnique = FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_email_unique');
824 * Checks whether the specified chat protocol is enabled in this form
826 * @return $required Whether the specified chat protocol is enabled
828 public function ifChatEnabled (string $chatProtocol) {
829 $required = FrameworkBootstrap::getConfigurationInstance()->isEnabled('chat_protocol_' . $chatProtocol);
834 * Checks whether login is enabled or disabled
836 * @return $isEnabled Whether the login is enabled or disabled
838 public function ifLoginIsEnabled () {
839 $isEnabled = FrameworkBootstrap::getConfigurationInstance()->isEnabled('user_login');
844 * Checks whether login shall be done by username
846 * @return $isEnabled Whether the login shall be done by username
848 public function ifLoginWithUsername () {
849 $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == 'username');
854 * Checks whether login shall be done by email
856 * @return $isEnabled Whether the login shall be done by email
858 public function ifLoginWithEmail () {
859 $isEnabled = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_type') == 'email');
864 * Checks whether guest login is allowed
866 * @return $isAllowed Whether guest login is allowed
868 public function ifGuestLoginAllowed () {
869 $isAllowed = FrameworkBootstrap::getConfigurationInstance()->isEnabled('guest_login');
874 * Checks whether the email address change must be confirmed
876 * @return $requireConfirm Whether email change must be confirmed
878 public function ifEmailChangeRequireConfirmation () {
879 $requireConfirm = FrameworkBootstrap::getConfigurationInstance()->isEnabled('email_change_confirmation');
880 return $requireConfirm;
884 * Checks whether the rules has been updated
886 * @return $rulesUpdated Whether rules has been updated
887 * @todo Implement check if rules have been changed
889 public function ifRulesHaveChanged () {
894 * Checks whether email change is allowed
896 * @return $emailChange Whether changing email address is allowed
898 public function ifEmailChangeAllowed () {
899 $emailChange = FrameworkBootstrap::getConfigurationInstance()->isEnabled('email_change');
904 * Checks whether the user account is unconfirmed
906 * @return $isUnconfirmed Whether the user account is unconfirmed
908 public function ifUserAccountUnconfirmed () {
909 $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_unconfirmed'));
910 return $isUnconfirmed;
914 * Checks whether the user account is locked
916 * @return $isUnconfirmed Whether the user account is locked
918 public function ifUserAccountLocked () {
919 $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_locked'));
920 return $isUnconfirmed;
924 * Checks whether the user account is a guest
926 * @return $isUnconfirmed Whether the user account is a guest
928 public function ifUserAccountGuest () {
929 $isUnconfirmed = ($this->getValueField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) === FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest'));
930 return $isUnconfirmed;
934 * Checks whether the refill page is active which should be not the default
935 * on non-web applications.
937 * @return $refillActive Whether the refill page is active
939 public function ifRefillPageActive () {
940 $refillActive = FrameworkBootstrap::getConfigurationInstance()->isEnabled('refill_page_active');
941 return $refillActive;
945 * Flushs the content out (not yet secured against open forms, etc.!) or
946 * close the form automatically
949 * @throws FormOpenedException If the form is still open
951 public function flushContent () {
952 // Is the form still open?
953 if (($this->formOpened === true) && ($this->formEnabled === true)) {
954 // Close the form automatically
956 } elseif ($this->formEnabled === false) {
957 if ($this->ifSubGroupOpenedPreviously()) {
959 $this->addFormSubGroup();
960 } elseif ($this->ifGroupOpenedPreviously()) {
962 $this->addFormGroup();
966 // Send content to template engine
967 //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."<br />\n";
968 $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent());