]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/helper/web/class_WebFormHelper.php
User login (non-guest) basicly finished, news stubs added, registration and final...
[shipsimu.git] / inc / classes / main / helper / web / class_WebFormHelper.php
index fc14638408cca3c5214e30ed4887e4ba709d54ff..6dbffb5c01a33ed1c02b32856b2140420e875b68 100644 (file)
@@ -49,13 +49,13 @@ class WebFormHelper extends BaseHelper {
        private $subGroupName = "";
 
        // Class Constants
-       const EXCEPTION_FORM_NAME_INVALID       = 0xb00;
-       const EXCEPTION_CLOSED_FORM             = 0xb01;
-       const EXCEPTION_OPENED_FORM             = 0xb02;
-       const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0xb03;
+       const EXCEPTION_FORM_NAME_INVALID       = 0x030;
+       const EXCEPTION_CLOSED_FORM             = 0x031;
+       const EXCEPTION_OPENED_FORM             = 0x032;
+       const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x033;
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -64,7 +64,10 @@ class WebFormHelper extends BaseHelper {
                parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("HTML-Formularhilfsklasse");
+               $this->setObjectDescription("Helper class for HTML forms");
+
+               // Create unique ID number
+               $this->generateUniqueId();
        }
 
        /**
@@ -116,8 +119,9 @@ class WebFormHelper extends BaseHelper {
                // Check wether we shall open or close the form
                if ($this->formOpened === false) {
                        // Add HTML code
-                       $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s\" method=\"%s\" target=\"%s\"",
+                       $formContent = sprintf("<form name=\"%s\" class=\"forms\" action=\"%s/%s\" method=\"%s\" target=\"%s\"",
                                $formName,
+                               $this->getConfigInstance()->readConfig('base_url'),
                                $this->getConfigInstance()->readConfig('form_action'),
                                $this->getConfigInstance()->readConfig('form_method'),
                                $this->getConfigInstance()->readConfig('form_target')
@@ -499,7 +503,7 @@ class WebFormHelper extends BaseHelper {
                // Is a group open?
                if ($this->groupOpened === true) {
                        // Then automatically close it here
-                       $this->addFormGroup("unknown", "");
+                       $this->addFormGroup("", "");
                }
 
                // Generate the content
@@ -543,6 +547,16 @@ class WebFormHelper extends BaseHelper {
                return $required;
        }
 
+       /**
+        * Checks wether email addresses can only be once used
+        *
+        * @return      $isUnique
+        */
+       public function ifEmailMustBeUnique () {
+               $isUnique = ($this->getConfigInstance()->readConfig('register_email_unique') == "Y");
+               return $isUnique;
+       }
+
        /**
         * Checks wether the specified chat protocol is enabled in this form
         *
@@ -553,6 +567,46 @@ class WebFormHelper extends BaseHelper {
                return $required;
        }
 
+       /**
+        * Checks wether login is enabled or disabled
+        *
+        * @return      $isEnabled      Wether the login is enabled or disabled
+        */
+       public function ifLoginIsEnabled () {
+               $isEnabled = ($this->getConfigInstance()->readConfig('login_enabled') == "Y");
+               return $isEnabled;
+       }
+
+       /**
+        * Checks wether login shall be done by username
+        *
+        * @return      $isEnabled      Wether the login shall be done by username
+        */
+       public function ifLoginWithUsername () {
+               $isEnabled = ($this->getConfigInstance()->readConfig('login_type') == "username");
+               return $isEnabled;
+       }
+
+       /**
+        * Checks wether login shall be done by email
+        *
+        * @return      $isEnabled      Wether the login shall be done by email
+        */
+       public function ifLoginWithEmail () {
+               $isEnabled = ($this->getConfigInstance()->readConfig('login_type') == "email");
+               return $isEnabled;
+       }
+
+       /**
+        * Checks wether guest login is allowed
+        *
+        * @return      $isAllowed      Wether guest login is allowed
+        */
+       public function ifGuestLoginAllowed () {
+               $isAllowed = ($this->getConfigInstance()->readConfig('guest_login_allowed') == "Y");
+               return $isAllowed;
+       }
+
        /**
         * Flushs the content out (not yet secured against open forms, etc.!) or
         * throw an exception if it is not yet closed