3 namespace Org\Mxchange\CoreFramework\Helper;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseWrapper;
7 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
8 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
9 use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
10 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
11 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
14 use \InvalidArgumentException;
17 * A helper for constructing web forms
19 * @author Roland Haeder <webmaster@shipsimu.org>
21 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
22 * @license GNU GPL 3.0 or any newer version
23 * @link http://www.shipsimu.org
25 * This program is free software: you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation, either version 3 of the License, or
28 * (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program. If not, see <http://www.gnu.org/licenses/>.
38 class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
40 * Whether the form tag is opened (keep at false or else your forms will
43 private $formOpened = false;
46 * Name of current form
48 private $formName = '';
56 * Whether form tag is enabled (default: true)
58 private $formEnabled = true;
61 const EXCEPTION_FORM_NAME_INVALID = 0x120;
62 const EXCEPTION_CLOSED_FORM = 0x121;
63 const EXCEPTION_OPENED_FORM = 0x122;
64 const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123;
67 * Protected constructor
71 protected function __construct () {
72 // Call parent constructor
73 parent::__construct(__CLASS__);
77 * Creates the helper class with the given template engine instance and form name
79 * @param $templateInstance An instance of a valid template engine
80 * @param $formName Name of the form
81 * @param $formId Value for 'id' attribute (default: $formName)
82 * @param $withForm Whether include the form tag
83 * @return $helperInstance A preparedf instance of this helper
85 public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false, $withForm = true) {
87 $helperInstance = new HtmlFormHelper();
89 // Set template instance
90 $helperInstance->setTemplateInstance($templateInstance);
92 // Is the form id not set?
93 if ($formId === false) {
94 // Use form id from form name
99 $helperInstance->setFormName($formName);
101 // A form-less field may say 'false' here...
102 if ($withForm === true) {
104 $helperInstance->addFormTag($formName, $formId);
107 $helperInstance->enableForm(false);
110 // Return the prepared instance
111 return $helperInstance;
115 * Add the form tag or close it an already opened form tag
117 * @param $formName Name of the form (default: false)
118 * @param $formId Id of the form (attribute 'id'; default: false)
120 * @throws InvalidFormNameException If the form name is invalid ( = false)
121 * @todo Add some unique PIN here to bypass problems with some browser and/or extensions
123 public function addFormTag ($formName = false, $formId = false) {
124 // When the form is not yet opened at least form name must be valid
125 if (($this->formOpened === false) && ($formName === false)) {
126 // Thrown an exception
127 throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
130 // Close the form is default
131 $formContent = '</form>';
133 // Check whether we shall open or close the form
134 if (($this->formOpened === false) && ($this->formEnabled === true)) {
136 $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s/%s\" method=\"%s\" target=\"%s\" id=\"%s_form\">",
138 $this->getConfigInstance()->getConfigEntry('base_url'),
139 $this->getConfigInstance()->getConfigEntry('form_action'),
140 $this->getConfigInstance()->getConfigEntry('form_method'),
141 $this->getConfigInstance()->getConfigEntry('form_target'),
145 // Open the form and remeber the form name and id
146 $this->formName = $formName;
147 $this->formId = $formId;
148 $this->formOpened = true;
150 // Add it to the content
151 $this->addHeaderContent($formContent);
153 // Add the hidden field required to identify safely this form
154 $this->addInputHiddenField('form', $this->getFormName());
157 if ($this->ifGroupOpenedPreviously()) {
158 // Then automatically close it here
159 $this->addFormGroup();
163 $this->formOpened = false;
164 $this->formName = '';
167 // Add it to the content
168 $this->addFooterContent($formContent);
173 * Add a text input tag to the form or throw an exception if it is not yet
174 * opened. The field's name will be set as id.
176 * @param $fieldName Input field name
177 * @param $fieldValue Input default value (default: empty)
179 * @throws FormClosedException If the form is not yet opened
181 public function addInputTextField ($fieldName, $fieldValue = '') {
182 // Is the form opened?
183 if (($this->formOpened === false) && ($this->formEnabled === true)) {
184 // Throw an exception
185 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
188 // Generate the content
189 $inputContent = sprintf('<input type="text" class="form-control" id="%s_%s_field" name="%s" value="%s" />',
196 // And add it maybe with a 'li' tag
197 $this->addContentToPreviousGroup($inputContent);
201 * Add a text input tag to the form with pre-loaded default value
203 * @param $fieldName Input field name
206 public function addInputTextFieldWithDefault ($fieldName) {
207 // Get the value from instance
208 $fieldValue = $this->getValueField($fieldName);
209 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
211 // Add the text field
212 $this->addInputTextField($fieldName, $fieldValue);
216 * Add a password input tag to the form or throw an exception if it is not
217 * yet opened. The field's name will be set as id.
219 * @param $fieldName Input field name
220 * @param $fieldValue Input default value (default: empty)
222 * @throws FormClosedException If the form is not yet opened
224 public function addInputPasswordField ($fieldName, $fieldValue = '') {
225 // Is the form opened?
226 if (($this->formOpened === false) && ($this->formEnabled === true)) {
227 // Throw an exception
228 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
231 // Generate the content
232 $inputContent = sprintf('<input type="password" class="form-control" id="%s_%s_field" name="%s" value="%s" />',
240 $this->addContentToPreviousGroup($inputContent);
244 * Add a hidden input tag to the form or throw an exception if it is not
245 * yet opened. The field's name will be set as id.
247 * @param $fieldName Input field name
248 * @param $fieldValue Input default value (default: empty)
250 * @throws FormClosedException If the form is not yet opened
252 public function addInputHiddenField ($fieldName, $fieldValue = '') {
253 // Is the form opened?
254 if (($this->formOpened === false) && ($this->formEnabled === true)) {
255 // Throw an exception
256 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
259 // Generate the content
260 $inputContent = sprintf('<input type="hidden" name="%s" value="%s" />',
266 $this->addContentToPreviousGroup($inputContent);
270 * Add a hidden input tag to the form with pre-loaded default value
272 * @param $fieldName Input field name
275 public function addInputHiddenFieldWithDefault ($fieldName) {
276 // Get the value from instance
277 $fieldValue = $this->getValueField($fieldName);
278 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
280 // Add the text field
281 $this->addInputHiddenField($fieldName, $fieldValue);
285 * Add a hidden input tag to the form with configuration value
287 * @param $fieldName Input field name
288 * @param $prefix Prefix for configuration without trailing _
291 public function addInputHiddenConfiguredField ($fieldName, $prefix) {
292 // Get the value from instance
293 $fieldValue = $this->getConfigInstance()->getConfigEntry("{$prefix}_{$fieldName}");
294 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
296 // Add the text field
297 $this->addInputHiddenField($fieldName, $fieldValue);
301 * Add a checkbox input tag to the form or throw an exception if it is not
302 * yet opened. The field's name will be set as id.
304 * @param $fieldName Input field name
305 * @param $fieldChecked Whether the field is checked (defaut: checked)
307 * @throws FormClosedException If the form is not yet opened
309 public function addInputCheckboxField ($fieldName, $fieldChecked = true) {
310 // Is the form opened?
311 if (($this->formOpened === false) && ($this->formEnabled === true)) {
312 // Throw an exception
313 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
316 // Set whether the check box is checked...
317 $checked = ' checked="checked"';
318 if ($fieldChecked === false) $checked = ' ';
320 // Generate the content
321 $inputContent = sprintf('<input type="checkbox" name="%s" class="checkbox" id="%s_%s_field" value="1"%s />',
329 $this->addContentToPreviousGroup($inputContent);
333 * Add a reset input tag to the form or throw an exception if it is not
334 * yet opened. The field's name will be set as id.
336 * @param $buttonText Text displayed on the button
338 * @throws FormClosedException If the form is not yet opened
340 public function addInputResetButton ($buttonText) {
341 // Is the form opened?
342 if (($this->formOpened === false) && ($this->formEnabled === true)) {
343 // Throw an exception
344 throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM);
347 // Generate the content
348 $inputContent = sprintf('<input type="reset" class="reset_button" id="%s_reset" value="%s" />',
354 $this->addContentToPreviousGroup($inputContent);
358 * Add a reset input tag to the form or throw an exception if it is not
359 * yet opened. The field's name will be set as id.
361 * @param $buttonText Text displayed on the button
363 * @throws FormClosedException If the form is not yet opened
365 public function addInputSubmitButton ($buttonText) {
366 // Is the form opened?
367 if (($this->formOpened === false) && ($this->formEnabled === true)) {
368 // Throw an exception
369 throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM);
372 // Generate the content
373 $inputContent = sprintf('<input type="submit" class="submit_button" id="%s_submit" name="%s_submit" value="%s" />',
380 $this->addContentToPreviousGroup($inputContent);
384 * Add a form group or close an already opened and open a new one
386 * @param $groupId Name of the group or last opened if empty
387 * @param $groupText Text including HTML to show above this group
389 * @throws FormClosedException If no form has been opened before
390 * @throws InvalidArgumentException If $groupId is not set
392 public function addFormGroup ($groupId = '', $groupText = '') {
394 if (($this->formOpened === false) && ($this->formEnabled === true)) {
395 // Throw exception here
396 throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM);
397 } elseif ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === false)) {
398 // Throw exception here
399 throw new InvalidArgumentException('Parameter "groupId" is empty but group is not closed');
400 } elseif (empty($groupId)) {
401 // Close the last opened
402 $groupId = $this->getPreviousGroupId();
405 // Same group to open?
406 if (($this->ifGroupOpenedPreviously() === false) && ($groupId === $this->getPreviousGroupId())) {
407 // Abort here silently
411 // Initialize content with closing div by default
412 $content = " </div>\n</div><!-- Group - CLOSE //-->";
414 // Is this group opened?
415 if ($this->ifGroupOpenedPreviously() === false) {
416 // Begin the div/span blocks
417 $content = sprintf("<!-- Group %s - OPEN //-->
418 <div class=\"group_box\" id=\"%s_group_box\">
419 <span class=\"group_text\" id=\"%s_group_text\">
422 <div class=\"group_field\" id=\"%s_group_field\">",
431 $this->openGroupByIdContent($groupId, $content, "div");
433 // Is a sub group opened?
434 if ($this->ifSubGroupOpenedPreviously()) {
436 $this->addFormSubGroup();
439 // Get previous group id
440 $prevGroupId = $this->getPreviousGroupId();
443 $this->closePreviousGroupByContent($content);
445 // All call it again if group name is not empty
446 if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
447 //* DEBUG: */ echo $groupId.'/'.$prevGroupId."<br />\n";
448 $this->addFormGroup($groupId, $groupText);
454 * Add a form sub group or close an already opened and open a new one or
455 * throws an exception if no group has been opened before or if sub group
458 * @param $subGroupId Name of the group or last opened if empty
459 * @param $subGroupText Text including HTML to show above this group
461 * @throws FormFormClosedException If no group has been opened before
462 * @throws InvalidArgumentException If $subGroupId is not set
464 public function addFormSubGroup ($subGroupId = '', $subGroupText = '') {
465 // Is a group opened?
466 if ($this->ifGroupOpenedPreviously() === false) {
467 // Throw exception here
468 throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
469 } elseif ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === false)) {
470 // Throw exception here
471 throw new InvalidArgumentException('Parameter "subGroupId" is empty but sub-group is not closed');
472 } elseif (empty($subGroupId)) {
473 // Close the last opened
474 $subGroupId = $this->getPreviousSubGroupId();
477 // Same sub group to open?
478 if (($this->ifSubGroupOpenedPreviously() === false) && ($subGroupId == $this->getPreviousSubGroupId())) {
479 // Abort here silently
483 // Initialize content with closing div by default
484 $content = " </div>\n</div><!-- Sub group- CLOSE //-->";
486 // Is this group opened?
487 if ($this->ifSubGroupOpenedPreviously() === false) {
488 // Begin the span block
489 $content = sprintf("<!-- Sub group %s - OPEN //-->
490 <div class=\"subgroup_box\" id=\"%s_subgroup_box\">
491 <span class=\"subgroup_text\" id=\"%s_subgroup_text\">
494 <div class=\"subgroup_field\" id=\"%s_subgroup_field\">",
502 // Switch the state and remeber the name
503 $this->openSubGroupByIdContent($subGroupId, $content, "div");
505 // Get previous sub group id
506 $prevSubGroupId = $this->getPreviousSubGroupId();
509 $this->closePreviousSubGroupByContent($content);
511 // All call it again if sub group name is not empty
512 if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) {
513 $this->addFormSubGroup($subGroupId, $subGroupText);
519 * Adds text surrounded by a label tag for given form field
521 * @param $fieldName Field name
522 * @param $fieldText Text for the field
523 * @param $fieldTitle Optional title for label tag
525 * @throws FormClosedException If the form is not yet opened
527 public function addFieldLabel ($fieldName, $fieldText, $fieldTitle = '') {
528 // Is the form opened?
529 if (($this->formOpened === false) && ($this->formEnabled === true)) {
530 // Throw an exception
531 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
534 // Default is no title attribute
535 $titleAttribute = '';
538 if (!empty($fieldTitle)) {
539 // Create title attribute
540 $titleAttribute = sprintf(' title="%s" data-toggle="tooltip"', $fieldTitle);
543 // Generate the content
544 $inputContent = sprintf('<label class="control-label" for="%s_%s_field"%s>
554 $this->addContentToPreviousGroup($inputContent);
558 * Add text (notes) surrounded by a div block. Still opened groups or sub
559 * groups will be automatically closed.
561 * @param $noteId Id for this note
562 * @param $formNotes The form notes we shell addd
564 * @throws FormClosedException If the form is not yet opened
566 public function addFormNote ($noteId, $formNotes) {
567 // Is the form opened?
568 if (($this->formOpened === false) && ($this->formEnabled === true)) {
569 // Throw an exception
570 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
573 // Generate the content
574 $inputContent = sprintf(" <div id=\"form_note_%s\">
582 $this->addContentToPreviousGroup($inputContent);
586 * Adds a selection box as a sub group to the form. Do not box this into
587 * another sub group. Sub-sub groups are not (yet) supported.
589 * @param $selectId Id of the selection box
590 * @param $firstEntry Content to be added as first non-selectable entry
592 * @throws FormClosedException If the form is not yet opened
594 public function addInputSelectField ($selectId, $firstEntry) {
595 // Is the form group opened?
596 if (($this->formOpened === false) && ($this->formEnabled === true)) {
597 // Throw an exception
598 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
601 // Shall we close or open the sub group?
602 if (($this->ifSubGroupOpenedPreviously() === false) && ($this->getPreviousSubGroupId() !== $selectId)) {
603 // Initialize first entry (which might be non-selectable if content is provided
604 if (!empty($firstEntry)) {
605 // Add selection around it
606 $firstEntry = sprintf("<option value=\"invalid\" disabled=\"disabled\">%s</option>\n",
611 // Construct the opening select tag
612 $content = sprintf("<select class=\"select_box\" id=\"%s_%s\" name=\"%s\">\n%s",
613 $this->getFormName(),
619 // Open the sub group
620 $this->openSubGroupByIdContent($selectId, $content, "select");
621 } elseif ($this->getPreviousSubGroupId() != $selectId) {
622 // Something went wrong!
623 $this->debugInstance(__METHOD__."(): Previous sub group id {$this->getPreviousSubGroupId()} does not match current id {$selectId}.");
625 // Close the sub group
626 $this->closePreviousSubGroupByContent("</select>");
631 * Adds a non-selectable sub option to a previously added selection box.
632 * This method does *not* validate if there is already a sub option added
633 * with the same name. We need to finish this here!
635 * @param $subName Name of the sub action
636 * @param $subValue Value of the sub action
638 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
639 * @todo Add checking if sub option is already added
641 public function addSelectSubOption ($subName, $subValue) {
642 // Is there a sub group (shall be a selection box!)
643 if ($this->ifSubGroupOpenedPreviously() === false) {
644 // Then throw an exception here
645 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
648 // Render the content
649 $content = sprintf("<option value=\"invalid\" class=\"suboption suboption_%s\" disabled=\"disabled\">%s</option>\n",
654 // Add the content to the previously opened sub group
655 $this->addContentToPreviousGroup($content);
659 * Adds a selectable option to a previously added selection box. This method
660 * does *not* validate if there is already a sub option added with the same
661 * name. We need to finish this here!
663 * @param $optionName Name of the sub action
664 * @param $optionValue Value of the sub action
666 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
667 * @todo Add checking if sub option is already added
669 public function addSelectOption ($optionName, $optionValue) {
670 // Is there a sub group (shall be a selection box!)
671 if ($this->ifSubGroupOpenedPreviously() === false) {
672 // Then throw an exception here
673 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
676 // Render the content
677 $content = sprintf("<option value=\"%s\" class=\"option option_%s\">%s</option>\n",
683 // Add the content to the previously opened sub group
684 $this->addContentToPreviousGroup($content);
688 * Adds a pre-configured CAPTCHA
692 public function addCaptcha () {
694 $extraInstance = NULL;
697 // Get last executed pre filter
698 $extraInstance = GenericRegistry::getRegistry()->getInstance('extra');
699 } catch (NullPointerException $e) {
700 // Instance in registry is not set (NULL)
701 // @TODO We need to log this later
704 // Get a configured instance
705 $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha_class', array($this, $extraInstance));
707 // Initiate the CAPTCHA
708 $captchaInstance->initiateCaptcha();
710 // Render the CAPTCHA code
711 $captchaInstance->renderCode();
713 // Get the content and add it to the helper
714 $this->addContentToPreviousGroup($captchaInstance->renderContent());
718 * Enables/disables the form tag usage
720 * @param $formEnabled Whether form is enabled or disabled
723 public final function enableForm ($formEnabled = true) {
724 $this->formEnabled = (bool) $formEnabled;
728 * Setter for form name
730 * @param $formName Name of this form
733 public final function setFormName ($formName) {
734 $this->formName = (string) $formName;
738 * Getter for form name
740 * @return $formName Name of this form
742 public final function getFormName () {
743 return $this->formName;
749 * @param $formId Id of this form
752 public final function setFormId ($formId) {
753 $this->formId = (string) $formId;
759 * @return $formId Id of this form
761 public final function getFormId () {
762 return $this->formId;
766 * Checks whether the registration requires a valid email address
768 * @return $required Whether the email address is required
770 public function ifRegisterRequiresEmailVerification () {
771 $required = ($this->getConfigInstance()->getConfigEntry('register_requires_email') == 'Y');
776 * Checks whether profile data shall be asked
778 * @return $required Whether profile data shall be asked
780 public function ifRegisterIncludesProfile () {
781 $required = ($this->getConfigInstance()->getConfigEntry('register_includes_profile') == 'Y');
786 * Checks whether this form is secured by a CAPTCHA
788 * @return $isSecured Whether this form is secured by a CAPTCHA
790 public function ifFormSecuredWithCaptcha () {
791 $isSecured = ($this->getConfigInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y');
796 * Checks whether personal data shall be asked
798 * @return $required Whether personal data shall be asked
800 public function ifRegisterIncludesPersonaData () {
801 $required = ($this->getConfigInstance()->getConfigEntry('register_personal_data') == 'Y');
806 * Checks whether for birthday shall be asked
808 * @return $required Whether birthday shall be asked
810 public function ifProfileIncludesBirthDay () {
811 $required = ($this->getConfigInstance()->getConfigEntry('profile_includes_birthday') == 'Y');
816 * Checks whether email addresses can only be once used
820 public function ifEmailMustBeUnique () {
821 $isUnique = ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y');
826 * Checks whether the specified chat protocol is enabled in this form
828 * @return $required Whether the specified chat protocol is enabled
830 public function ifChatEnabled ($chatProtocol) {
831 $required = ($this->getConfigInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y');
836 * Checks whether login is enabled or disabled
838 * @return $isEnabled Whether the login is enabled or disabled
840 public function ifLoginIsEnabled () {
841 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_enabled') == 'Y');
846 * Checks whether login shall be done by username
848 * @return $isEnabled Whether the login shall be done by username
850 public function ifLoginWithUsername () {
851 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "username");
856 * Checks whether login shall be done by email
858 * @return $isEnabled Whether the login shall be done by email
860 public function ifLoginWithEmail () {
861 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "email");
866 * Checks whether guest login is allowed
868 * @return $isAllowed Whether guest login is allowed
870 public function ifGuestLoginAllowed () {
871 $isAllowed = ($this->getConfigInstance()->getConfigEntry('guest_login_allowed') == 'Y');
876 * Checks whether the email address change must be confirmed
878 * @return $requireConfirm Whether email change must be confirmed
880 public function ifEmailChangeRequireConfirmation () {
881 $requireConfirm = ($this->getConfigInstance()->getConfigEntry('email_change_confirmation') == 'Y');
882 return $requireConfirm;
886 * Checks whether the rules has been updated
888 * @return $rulesUpdated Whether rules has been updated
889 * @todo Implement check if rules have been changed
891 public function ifRulesHaveChanged () {
896 * Checks whether email change is allowed
898 * @return $emailChange Whether changing email address is allowed
900 public function ifEmailChangeAllowed () {
901 $emailChange = ($this->getConfigInstance()->getConfigEntry('email_change_allowed') == 'Y');
906 * Checks whether the user account is unconfirmed
908 * @return $isUnconfirmed Whether the user account is unconfirmed
910 public function ifUserAccountUnconfirmed () {
911 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed'));
912 return $isUnconfirmed;
916 * Checks whether the user account is locked
918 * @return $isUnconfirmed Whether the user account is locked
920 public function ifUserAccountLocked () {
921 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_locked'));
922 return $isUnconfirmed;
926 * Checks whether the user account is a guest
928 * @return $isUnconfirmed Whether the user account is a guest
930 public function ifUserAccountGuest () {
931 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_guest'));
932 return $isUnconfirmed;
936 * Checks whether the refill page is active which should be not the default
937 * on non-web applications.
939 * @return $refillActive Whether the refill page is active
941 public function ifRefillPageActive () {
942 $refillActive = ($this->getConfigInstance()->getConfigEntry('refill_page_active') == 'Y');
943 return $refillActive;
947 * Flushs the content out (not yet secured against open forms, etc.!) or
948 * close the form automatically
951 * @throws FormOpenedException If the form is still open
953 public function flushContent () {
954 // Is the form still open?
955 if (($this->formOpened === true) && ($this->formEnabled === true)) {
956 // Close the form automatically
958 } elseif ($this->formEnabled === false) {
959 if ($this->ifSubGroupOpenedPreviously()) {
961 $this->addFormSubGroup();
962 } elseif ($this->ifGroupOpenedPreviously()) {
964 $this->addFormGroup();
968 // Send content to template engine
969 //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."<br />\n";
970 $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent());