3 namespace CoreFramework\Helper;
5 // Import framework stuff
6 use CoreFramework\Factory\ObjectFactory;
7 use CoreFramework\Generic\EmptyVariableException;
8 use CoreFramework\Generic\NullPointerException;
9 use CoreFramework\Registry\Registry;
10 use CoreFramework\Template\CompileableTemplate;
11 use CoreFramework\Wrapper\Database\User\UserDatabaseWrapper;
14 * A helper for constructing web forms
16 * @author Roland Haeder <webmaster@shipsimu.org>
18 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
19 * @license GNU GPL 3.0 or any newer version
20 * @link http://www.shipsimu.org
22 * This program is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <http://www.gnu.org/licenses/>.
35 class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
37 * Whether the form tag is opened (keep at FALSE or else your forms will
40 private $formOpened = FALSE;
45 private $formName = '';
48 * Whether form tag is enabled (default: TRUE)
50 private $formEnabled = TRUE;
53 const EXCEPTION_FORM_NAME_INVALID = 0x120;
54 const EXCEPTION_CLOSED_FORM = 0x121;
55 const EXCEPTION_OPENED_FORM = 0x122;
56 const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123;
59 * Protected constructor
63 protected function __construct () {
64 // Call parent constructor
65 parent::__construct(__CLASS__);
69 * Creates the helper class with the given template engine instance and form name
71 * @param $templateInstance An instance of a valid template engine
72 * @param $formName Name of the form
73 * @param $formId Value for 'id' attribute (default: $formName)
74 * @param $withForm Whether include the form tag
75 * @return $helperInstance A preparedf instance of this helper
77 public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = FALSE, $withForm = TRUE) {
79 $helperInstance = new HtmlFormHelper();
81 // Set template instance
82 $helperInstance->setTemplateInstance($templateInstance);
84 // Is the form id not set?
85 if ($formId === FALSE) {
86 // Use form id from form name
91 $helperInstance->setFormName($formName);
93 // A form-less field may say 'FALSE' here...
94 if ($withForm === TRUE) {
96 $helperInstance->addFormTag($formName, $formId);
99 $helperInstance->enableForm(FALSE);
102 // Return the prepared instance
103 return $helperInstance;
107 * Add the form tag or close it an already opened form tag
109 * @param $formName Name of the form (default: FALSE)
110 * @param $formId Id of the form (attribute 'id'; default: FALSE)
112 * @throws InvalidFormNameException If the form name is invalid ( = FALSE)
113 * @todo Add some unique PIN here to bypass problems with some browser and/or extensions
115 public function addFormTag ($formName = FALSE, $formId = FALSE) {
116 // When the form is not yet opened at least form name must be valid
117 if (($this->formOpened === FALSE) && ($formName === FALSE)) {
118 // Thrown an exception
119 throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
122 // Close the form is default
123 $formContent = '</form>';
125 // Check whether we shall open or close the form
126 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
128 $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s/%s\" method=\"%s\" target=\"%s\"",
130 $this->getConfigInstance()->getConfigEntry('base_url'),
131 $this->getConfigInstance()->getConfigEntry('form_action'),
132 $this->getConfigInstance()->getConfigEntry('form_method'),
133 $this->getConfigInstance()->getConfigEntry('form_target')
136 // Add form id as well
137 $formContent .= sprintf(" id=\"%s_form\"",
144 // Open the form and remeber the form name
145 $this->formOpened = TRUE;
147 // Add it to the content
148 $this->addHeaderContent($formContent);
150 // Add the hidden field required to identify safely this form
151 $this->addInputHiddenField('form', $this->getFormName());
154 if ($this->ifGroupOpenedPreviously()) {
155 // Then automatically close it here
156 $this->addFormGroup();
160 $this->formOpened = FALSE;
162 // Add it to the content
163 $this->addFooterContent($formContent);
168 * Add a text input tag to the form or throw an exception if it is not yet
169 * opened. The field's name will be set as id.
171 * @param $fieldName Input field name
172 * @param $fieldValue Input default value (default: empty)
174 * @throws FormClosedException If the form is not yet opened
176 public function addInputTextField ($fieldName, $fieldValue = '') {
177 // Is the form opened?
178 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
179 // Throw an exception
180 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
183 // Generate the content
184 $inputContent = sprintf("<input type=\"text\" class=\"textfield %s_field\" name=\"%s\" value=\"%s\" />",
190 // And add it maybe with a 'li' tag
191 $this->addContentToPreviousGroup($inputContent);
195 * Add a text input tag to the form with pre-loaded default value
197 * @param $fieldName Input field name
200 public function addInputTextFieldWithDefault ($fieldName) {
201 // Get the value from instance
202 $fieldValue = $this->getValueField($fieldName);
203 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
205 // Add the text field
206 $this->addInputTextField($fieldName, $fieldValue);
210 * Add a password input tag to the form or throw an exception if it is not
211 * yet opened. The field's name will be set as id.
213 * @param $fieldName Input field name
214 * @param $fieldValue Input default value (default: empty)
216 * @throws FormClosedException If the form is not yet opened
218 public function addInputPasswordField ($fieldName, $fieldValue = '') {
219 // Is the form opened?
220 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
221 // Throw an exception
222 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
225 // Generate the content
226 $inputContent = sprintf("<input type=\"password\" class=\"password %s_field\" name=\"%s\" value=\"%s\" />",
233 $this->addContentToPreviousGroup($inputContent);
237 * Add a hidden input tag to the form or throw an exception if it is not
238 * yet opened. The field's name will be set as id.
240 * @param $fieldName Input field name
241 * @param $fieldValue Input default value (default: empty)
243 * @throws FormClosedException If the form is not yet opened
245 public function addInputHiddenField ($fieldName, $fieldValue = '') {
246 // Is the form opened?
247 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
248 // Throw an exception
249 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
252 // Generate the content
253 $inputContent = sprintf("<input type=\"hidden\" name=\"%s\" value=\"%s\" />",
259 $this->addContentToPreviousGroup($inputContent);
263 * Add a hidden input tag to the form with pre-loaded default value
265 * @param $fieldName Input field name
268 public function addInputHiddenFieldWithDefault ($fieldName) {
269 // Get the value from instance
270 $fieldValue = $this->getValueField($fieldName);
271 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
273 // Add the text field
274 $this->addInputHiddenField($fieldName, $fieldValue);
278 * Add a hidden input tag to the form with configuration value
280 * @param $fieldName Input field name
281 * @param $prefix Prefix for configuration without trailing _
284 public function addInputHiddenConfiguredField ($fieldName, $prefix) {
285 // Get the value from instance
286 $fieldValue = $this->getConfigInstance()->getConfigEntry("{$prefix}_{$fieldName}");
287 //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
289 // Add the text field
290 $this->addInputHiddenField($fieldName, $fieldValue);
294 * Add a checkbox input tag to the form or throw an exception if it is not
295 * yet opened. The field's name will be set as id.
297 * @param $fieldName Input field name
298 * @param $fieldChecked Whether the field is checked (defaut: checked)
300 * @throws FormClosedException If the form is not yet opened
302 public function addInputCheckboxField ($fieldName, $fieldChecked = TRUE) {
303 // Is the form opened?
304 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
305 // Throw an exception
306 throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM);
309 // Set whether the check box is checked...
310 $checked = " checked=\"checked\"";
311 if ($fieldChecked === FALSE) $checked = ' ';
313 // Generate the content
314 $inputContent = sprintf("<input type=\"checkbox\" name=\"%s\" class=\"checkbox %s_field\" value=\"1\"%s/>",
321 $this->addContentToPreviousGroup($inputContent);
325 * Add a reset input tag to the form or throw an exception if it is not
326 * yet opened. The field's name will be set as id.
328 * @param $buttonText Text displayed on the button
330 * @throws FormClosedException If the form is not yet opened
332 public function addInputResetButton ($buttonText) {
333 // Is the form opened?
334 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
335 // Throw an exception
336 throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM);
339 // Generate the content
340 $inputContent = sprintf("<input type=\"reset\" class=\"reset_button\" id=\"%s_reset\" value=\"%s\" />",
341 $this->getFormName(),
346 $this->addContentToPreviousGroup($inputContent);
350 * Add a reset input tag to the form or throw an exception if it is not
351 * yet opened. The field's name will be set as id.
353 * @param $buttonText Text displayed on the button
355 * @throws FormClosedException If the form is not yet opened
357 public function addInputSubmitButton ($buttonText) {
358 // Is the form opened?
359 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
360 // Throw an exception
361 throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM);
364 // Generate the content
365 $inputContent = sprintf("<input type=\"submit\" class=\"submit_button\" id=\"%s_submit\" name=\"%s_button\" value=\"%s\" />",
366 $this->getFormName(),
367 $this->getFormName(),
372 $this->addContentToPreviousGroup($inputContent);
376 * Add a form group or close an already opened and open a new one
378 * @param $groupId Name of the group or last opened if empty
379 * @param $groupText Text including HTML to show above this group
381 * @throws FormClosedException If no form has been opened before
382 * @throws EmptyVariableException If $groupId is not set
384 public function addFormGroup ($groupId = '', $groupText = '') {
386 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
387 // Throw exception here
388 throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM);
391 // At least the group name should be set
392 if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === FALSE)) {
393 // Throw exception here
394 throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
395 } elseif (empty($groupId)) {
396 // Close the last opened
397 $groupId = $this->getPreviousGroupId();
400 // Same group to open?
401 if (($this->ifGroupOpenedPreviously() === FALSE) && ($groupId === $this->getPreviousGroupId())) {
402 // Abort here silently
406 // Initialize content with closing div by default
407 $content = " </div>\n</div><!-- Group - CLOSE //-->";
409 // Is this group opened?
410 if ($this->ifGroupOpenedPreviously() === FALSE) {
411 // Begin the div/span blocks
412 $content = sprintf("<!-- Group %s - OPEN //-->
413 <div class=\"group_box\" id=\"%s_group_box\">
414 <span class=\"group_text\" id=\"%s_group_text\">
417 <div class=\"group_field\" id=\"%s_group_field\">",
426 $this->openGroupByIdContent($groupId, $content, "div");
428 // Is a sub group opened?
429 if ($this->ifSubGroupOpenedPreviously()) {
431 $this->addFormSubGroup();
434 // Get previous group id
435 $prevGroupId = $this->getPreviousGroupId();
438 $this->closePreviousGroupByContent($content);
440 // All call it again if group name is not empty
441 if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
442 //* DEBUG: */ echo $groupId.'/'.$prevGroupId."<br />\n";
443 $this->addFormGroup($groupId, $groupText);
449 * Add a form sub group or close an already opened and open a new one or
450 * throws an exception if no group has been opened before or if sub group
453 * @param $subGroupId Name of the group or last opened if empty
454 * @param $subGroupText Text including HTML to show above this group
456 * @throws FormFormClosedException If no group has been opened before
457 * @throws EmptyVariableException If $subGroupId is not set
459 public function addFormSubGroup ($subGroupId = '', $subGroupText = '') {
460 // Is a group opened?
461 if ($this->ifGroupOpenedPreviously() === FALSE) {
462 // Throw exception here
463 throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
466 // At least the sub group name should be set
467 if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === FALSE)) {
468 // Throw exception here
469 throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
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 * Add text surrounded by a span block when there is a group opened before
518 * or else by a div block.
520 * @param $fieldName Field name
521 * @param $fieldText Text for the field
523 * @throws FormClosedException If the form is not yet opened
525 public function addFieldText ($fieldName, $fieldText) {
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 // Set the block type
534 if ($this->ifGroupOpenedPreviously()) $block = 'span';
536 // Generate the content
537 $inputContent = sprintf(" <%s id=\"%s_text\">
547 $this->addContentToPreviousGroup($inputContent);
551 * Add text (notes) surrounded by a div block. Still opened groups or sub
552 * groups will be automatically closed.
554 * @param $noteId Id for this note
555 * @param $formNotes The form notes we shell addd
557 * @throws FormClosedException If the form is not yet opened
559 public function addFormNote ($noteId, $formNotes) {
560 // Is the form opened?
561 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
562 // Throw an exception
563 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
566 // Generate the content
567 $inputContent = sprintf(" <div id=\"form_note_%s\">
575 $this->addContentToPreviousGroup($inputContent);
579 * Adds a selection box as a sub group to the form. Do not box this into
580 * another sub group. Sub-sub groups are not (yet) supported.
582 * @param $selectId Id of the selection box
583 * @param $firstEntry Content to be added as first non-selectable entry
585 * @throws FormClosedException If the form is not yet opened
587 public function addInputSelectField ($selectId, $firstEntry) {
588 // Is the form group opened?
589 if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) {
590 // Throw an exception
591 throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM);
594 // Shall we close or open the sub group?
595 if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($this->getPreviousSubGroupId() !== $selectId)) {
596 // Initialize first entry (which might be non-selectable if content is provided
597 if (!empty($firstEntry)) {
598 // Add selection around it
599 $firstEntry = sprintf("<option value=\"invalid\" disabled=\"disabled\">%s</option>\n",
604 // Construct the opening select tag
605 $content = sprintf("<select class=\"select_box\" id=\"%s_%s\" name=\"%s\">\n%s",
606 $this->getFormName(),
612 // Open the sub group
613 $this->openSubGroupByIdContent($selectId, $content, "select");
614 } elseif ($this->getPreviousSubGroupId() != $selectId) {
615 // Something went wrong!
616 $this->debugInstance(__METHOD__."(): Previous sub group id {$this->getPreviousSubGroupId()} does not match current id {$selectId}.");
618 // Close the sub group
619 $this->closePreviousSubGroupByContent("</select>");
624 * Adds a non-selectable sub option to a previously added selection box.
625 * This method does *not* validate if there is already a sub option added
626 * with the same name. We need to finish this here!
628 * @param $subName Name of the sub action
629 * @param $subValue Value of the sub action
631 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
632 * @todo Add checking if sub option is already added
634 public function addSelectSubOption ($subName, $subValue) {
635 // Is there a sub group (shall be a selection box!)
636 if ($this->ifSubGroupOpenedPreviously() === FALSE) {
637 // Then throw an exception here
638 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
641 // Render the content
642 $content = sprintf("<option value=\"invalid\" class=\"suboption suboption_%s\" disabled=\"disabled\">%s</option>\n",
647 // Add the content to the previously opened sub group
648 $this->addContentToPreviousGroup($content);
652 * Adds a selectable option to a previously added selection box. This method
653 * does *not* validate if there is already a sub option added with the same
654 * name. We need to finish this here!
656 * @param $optionName Name of the sub action
657 * @param $optionValue Value of the sub action
659 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
660 * @todo Add checking if sub option is already added
662 public function addSelectOption ($optionName, $optionValue) {
663 // Is there a sub group (shall be a selection box!)
664 if ($this->ifSubGroupOpenedPreviously() === FALSE) {
665 // Then throw an exception here
666 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
669 // Render the content
670 $content = sprintf("<option value=\"%s\" class=\"option option_%s\">%s</option>\n",
676 // Add the content to the previously opened sub group
677 $this->addContentToPreviousGroup($content);
681 * Adds a pre-configured CAPTCHA
685 public function addCaptcha () {
687 $extraInstance = NULL;
690 // Get last executed pre filter
691 $extraInstance = Registry::getRegistry()->getInstance('extra');
692 } catch (NullPointerException $e) {
693 // Instance in registry is not set (NULL)
694 // @TODO We need to log this later
697 // Get a configured instance
698 $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha_class', array($this, $extraInstance));
700 // Initiate the CAPTCHA
701 $captchaInstance->initiateCaptcha();
703 // Render the CAPTCHA code
704 $captchaInstance->renderCode();
706 // Get the content and add it to the helper
707 $this->addContentToPreviousGroup($captchaInstance->renderContent());
711 * Enables/disables the form tag usage
713 * @param $formEnabled Whether form is enabled or disabled
716 public final function enableForm ($formEnabled = TRUE) {
717 $this->formEnabled = (bool) $formEnabled;
721 * Setter for form name
723 * @param $formName Name of this form
726 public final function setFormName ($formName) {
727 $this->formName = (string) $formName;
731 * Getter for form name
733 * @return $formName Name of this form
735 public final function getFormName () {
736 return $this->formName;
740 * Checks whether the registration requires a valid email address
742 * @return $required Whether the email address is required
744 public function ifRegisterRequiresEmailVerification () {
745 $required = ($this->getConfigInstance()->getConfigEntry('register_requires_email') == 'Y');
750 * Checks whether profile data shall be asked
752 * @return $required Whether profile data shall be asked
754 public function ifRegisterIncludesProfile () {
755 $required = ($this->getConfigInstance()->getConfigEntry('register_includes_profile') == 'Y');
760 * Checks whether this form is secured by a CAPTCHA
762 * @return $isSecured Whether this form is secured by a CAPTCHA
764 public function ifFormSecuredWithCaptcha () {
765 $isSecured = ($this->getConfigInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y');
770 * Checks whether personal data shall be asked
772 * @return $required Whether personal data shall be asked
774 public function ifRegisterIncludesPersonaData () {
775 $required = ($this->getConfigInstance()->getConfigEntry('register_personal_data') == 'Y');
780 * Checks whether for birthday shall be asked
782 * @return $required Whether birthday shall be asked
784 public function ifProfileIncludesBirthDay () {
785 $required = ($this->getConfigInstance()->getConfigEntry('profile_includes_birthday') == 'Y');
790 * Checks whether email addresses can only be once used
794 public function ifEmailMustBeUnique () {
795 $isUnique = ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y');
800 * Checks whether the specified chat protocol is enabled in this form
802 * @return $required Whether the specified chat protocol is enabled
804 public function ifChatEnabled ($chatProtocol) {
805 $required = ($this->getConfigInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y');
810 * Checks whether login is enabled or disabled
812 * @return $isEnabled Whether the login is enabled or disabled
814 public function ifLoginIsEnabled () {
815 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_enabled') == 'Y');
820 * Checks whether login shall be done by username
822 * @return $isEnabled Whether the login shall be done by username
824 public function ifLoginWithUsername () {
825 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "username");
830 * Checks whether login shall be done by email
832 * @return $isEnabled Whether the login shall be done by email
834 public function ifLoginWithEmail () {
835 $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "email");
840 * Checks whether guest login is allowed
842 * @return $isAllowed Whether guest login is allowed
844 public function ifGuestLoginAllowed () {
845 $isAllowed = ($this->getConfigInstance()->getConfigEntry('guest_login_allowed') == 'Y');
850 * Checks whether the email address change must be confirmed
852 * @return $requireConfirm Whether email change must be confirmed
854 public function ifEmailChangeRequireConfirmation () {
855 $requireConfirm = ($this->getConfigInstance()->getConfigEntry('email_change_confirmation') == 'Y');
856 return $requireConfirm;
860 * Checks whether the rules has been updated
862 * @return $rulesUpdated Whether rules has been updated
863 * @todo Implement check if rules have been changed
865 public function ifRulesHaveChanged () {
870 * Checks whether email change is allowed
872 * @return $emailChange Whether changing email address is allowed
874 public function ifEmailChangeAllowed () {
875 $emailChange = ($this->getConfigInstance()->getConfigEntry('email_change_allowed') == 'Y');
880 * Checks whether the user account is unconfirmed
882 * @return $isUnconfirmed Whether the user account is unconfirmed
884 public function ifUserAccountUnconfirmed () {
885 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed'));
886 return $isUnconfirmed;
890 * Checks whether the user account is locked
892 * @return $isUnconfirmed Whether the user account is locked
894 public function ifUserAccountLocked () {
895 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_locked'));
896 return $isUnconfirmed;
900 * Checks whether the user account is a guest
902 * @return $isUnconfirmed Whether the user account is a guest
904 public function ifUserAccountGuest () {
905 $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_guest'));
906 return $isUnconfirmed;
910 * Checks whether the refill page is active which should be not the default
911 * on non-web applications.
913 * @return $refillActive Whether the refill page is active
915 public function ifRefillPageActive () {
916 $refillActive = ($this->getConfigInstance()->getConfigEntry('refill_page_active') == 'Y');
917 return $refillActive;
921 * Flushs the content out (not yet secured against open forms, etc.!) or
922 * close the form automatically
925 * @throws FormOpenedException If the form is still open
927 public function flushContent () {
928 // Is the form still open?
929 if (($this->formOpened === TRUE) && ($this->formEnabled === TRUE)) {
930 // Close the form automatically
932 } elseif ($this->formEnabled === FALSE) {
933 if ($this->ifSubGroupOpenedPreviously()) {
935 $this->addFormSubGroup();
936 } elseif ($this->ifGroupOpenedPreviously()) {
938 $this->addFormGroup();
942 // Send content to template engine
943 //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."<br />\n";
944 $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent());