Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions forms/FormAgreement.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,25 @@ public function __get($strKey)
break;
}
}

/**
* Validate input and set value
*/
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()
Expand Down
28 changes: 27 additions & 1 deletion modules/ModuleRegistrationExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}

?>