diff --git a/forms/FormAgreement.php b/forms/FormAgreement.php index f06aaf7..b1d8433 100644 --- a/forms/FormAgreement.php +++ b/forms/FormAgreement.php @@ -88,7 +88,7 @@ public function __get($strKey) break; } } - + /** * Validate input and set value */ @@ -96,16 +96,17 @@ public function validate() { $accept = deserialize($this->getPost('accept_agreement')); + // Add class "error" and set session flag to cancel user creation if (!$accept) { + $this->Session->set('xtmembers_agreementNotAccepted', 1); $this->addError($GLOBALS['TL_LANG']['ERR']['agreement']); - } - - // Add class "error" - if (!$accept) - { $this->class = 'error'; } + else { + // unset session flag + $this->Session->set('xtmembers_agreementNotAccepted', ''); + } } public function generateLabel() diff --git a/modules/ModuleRegistrationExtended.php b/modules/ModuleRegistrationExtended.php index a5ad2e0..1a57a58 100644 --- a/modules/ModuleRegistrationExtended.php +++ b/modules/ModuleRegistrationExtended.php @@ -35,8 +35,11 @@ protected function compile() $this->editable = explode(",", $fields . ",groupselection"); } } - parent::compile(); + + // load the language file first, otherwise the agreement text is not shown + \System::loadLanguageFile('tl_member'); + // process agreement field first if ($this->show_agreement) { $arrAgreement = array @@ -67,6 +70,14 @@ protected function compile() { $objAgreement->validate(); } + } + + // process other form fields + parent::compile(); + + // all fields are processed now, we can go on and add the agreement field to the template + if ($this->show_agreement) + { $objAgreement->rowClass = 'row_'.$i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd'); $strAgreement = $objAgreement->parse(); @@ -96,6 +107,21 @@ protected function compile() } } } + + /** + * {@inheritDoc} + * Check if agreement is set and accepted + * + */ + protected function createNewUser($arrData) + { + if ($this->show_agreement && $this->Session->get('xtmembers_agreementNotAccepted')) + { + return; + } + + return parent::createNewUser($arrData); + } } ?> \ No newline at end of file