/** * Constructor * * @param Controller $controller The parent controller, necessary to * create the appropriate form action tag. * @param string $name The method on the controller that will return this * form object. * @param FieldSet|FormField $fields All of the fields in the form - a * {@link FieldSet} of {@link FormField} * objects. * @param FieldSet|FormAction $actions All of the action buttons in the * form - a {@link FieldSet} of * {@link FormAction} objects * @param bool $checkCurrentUser If set to TRUE, it will be checked if a * the user is currently logged in, and if * so, only a logout button will be rendered * @param string $authenticatorClassName Name of the authenticator class that this form uses. */ function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { // This is now set on the class directly to make it easier to create subclasses // $this->authenticator_class = $authenticatorClassName; if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } $member = Member::currentUser(); $label = singleton('Member')->fieldLabel(Member::get_unique_identifier_field()); if ($checkCurrentUser && $member) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("FirstNameSignup", "Voornaam", $member->FirstName), new TextField("SurnameSignup", "Achternaam", $member->Surname), new TextField("EmailSignup", $label, $member->Email), new PasswordField("PasswordSignup", _t('Member.PASSWORD', 'Password'))); $actions = new FieldSet(new FormAction("createorupdateaccount", _t('Member.UPDATEDETAILS', "Update your details")), new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("FirstNameSignup", "Voornaam", Session::get('SessionForms.MemberLoginFormWithSignup.FirstNameSignup'), null, $this), new TextField("SurnameSignup", "Achternaam", Session::get('SessionForms.MemberLoginFormWithSignup.SurnameSignup'), null, $this), new TextField("EmailSignup", $label, Session::get('SessionForms.MemberLoginFormWithSignup.EmailSignup'), null, $this), new PasswordField("PasswordSignup", _t('Member.PASSWORD', 'Password'))); if (Security::$autologin_enabled) { $fields->push(new CheckboxField("RememberSignup", _t('Member.REMEMBERME', "Remember me next time?"))); } } if (!$actions) { $actions = new FieldSet(new FormAction('createorupdateaccount', _t('Member.BUTTONCREATEACCOUNT', "Create account"))); } } if (isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } $requiredFields = parent::__construct($controller, $name, $fields, $actions); $validator = new RequiredFields(array("EmailSignup", "FirstNameSignup", "SurnameSignup", "PasswordSignup")); $validator->setForm($this); $this->validator = $validator; // Focus on the email input when the page is loaded // Only include this if other form JS validation is enabled if ($this->getValidator()->getJavascriptValidationHandler() != 'none') { Requirements::customScript(<<<JS \t\t\t\t(function() { \t\t\t\t\tvar el = document.getElementById("MemberLoginForm_LoginForm_EmailSignup"); \t\t\t\t\tif(el && el.focus) el.focus(); \t\t\t\t})(); JS ); } }