示例#1
0
 public function __construct($providerName)
 {
     parent::__construct('login-form');
     $language = OW::getLanguage();
     $this->setAction("");
     $label = $language->text('yncontactimporter', 'login_email');
     if ($providerName == 'hyves') {
         $label = $language->text('yncontactimporter', 'login_username');
     }
     // email
     $email = new TextField('email');
     $email->setLabel($label)->setRequired(true);
     $this->addElement($email);
     //pass
     $password = new PasswordField('password');
     $password->setLabel($language->text('yncontactimporter', 'login_password'))->setRequired(true);
     $this->addElement($password);
     //providerName
     $hiddenProviderName = new HiddenField('providerName');
     $hiddenProviderName->setValue($providerName);
     $this->addElement($hiddenProviderName);
     // button submit
     $submit = new Submit('submit');
     $submit->setValue($language->text('yncontactimporter', 'submit_btn_label'));
     $this->addElement($submit);
 }
示例#2
0
文件: sign_in.php 项目: vazahat/dudex
 /**
  * Constructor.
  */
 public function __construct($ajax = false)
 {
     parent::__construct();
     $form = new Form('sign-in');
     $form->setAction("");
     $username = new TextField('identity');
     $username->setRequired(true);
     $username->setHasInvitation(true);
     $username->setInvitation(OW::getLanguage()->text('base', 'component_sign_in_login_invitation'));
     $form->addElement($username);
     $password = new PasswordField('password');
     $password->setHasInvitation(true);
     $password->setInvitation('password');
     $password->setRequired(true);
     $form->addElement($password);
     $remeberMe = new CheckboxField('remember');
     $remeberMe->setValue(true);
     $remeberMe->setLabel(OW::getLanguage()->text('base', 'sign_in_remember_me_label'));
     $form->addElement($remeberMe);
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('base', 'sign_in_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if ($ajax) {
         $form->setAjaxResetOnSuccess(false);
         $form->setAjax();
         $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_User', 'ajaxSignIn'));
         $form->bindJsFunction(Form::BIND_SUCCESS, 'function(data){if( data.result ){if(data.message){OW.info(data.message);}setTimeout(function(){window.location.reload();}, 1000);}else{OW.error(data.message);}}');
         $this->assign('forgot_url', OW::getRouter()->urlForRoute('base_forgot_password'));
     }
     $this->assign('joinUrl', OW::getRouter()->urlForRoute('base_join'));
 }
示例#3
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->setAction(OW::getRouter()->urlForRoute('ocsaffiliates.action_signup'));
     $this->setAjax();
     $lang = OW::getLanguage();
     $affName = new TextField('name');
     $affName->setRequired(true);
     $affName->setLabel($lang->text('ocsaffiliates', 'affiliate_name'));
     $this->addElement($affName);
     $email = new TextField('email');
     $email->setRequired(true);
     $email->setLabel($lang->text('ocsaffiliates', 'email'));
     $email->addValidator(new EmailValidator());
     $this->addElement($email);
     $password = new PasswordField('password');
     $password->setRequired(true);
     $password->setLabel($lang->text('ocsaffiliates', 'password'));
     $this->addElement($password);
     $payment = new Textarea('payment');
     $payment->setRequired(true);
     $payment->setLabel($lang->text('ocsaffiliates', 'payment_details'));
     $this->addElement($payment);
     if (OW::getConfig()->getValue('ocsaffiliates', 'terms_agreement')) {
         $terms = new CheckboxField('terms');
         $validator = new RequiredValidator();
         $validator->setErrorMessage($lang->text('ocsaffiliates', 'terms_required_msg'));
         $terms->addValidator($validator);
         $this->addElement($terms);
     }
     $submit = new Submit('signup');
     $submit->setValue($lang->text('ocsaffiliates', 'signup_btn'));
     $this->addElement($submit);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n            if ( !data.result ) {\n                OW.error(data.error);\n            }\n            else {\n                document.location.reload();\n            }\n        }");
 }
示例#4
0
 public function __construct()
 {
     parent::__construct();
     $language = OW::getLanguage();
     $form = new Form("change-user-password");
     $form->setId("change-user-password");
     $oldPassword = new PasswordField('oldPassword');
     $oldPassword->setLabel($language->text('base', 'change_password_old_password'));
     $oldPassword->addValidator(new OldPasswordValidator());
     $oldPassword->setRequired();
     $form->addElement($oldPassword);
     $newPassword = new PasswordField('password');
     $newPassword->setLabel($language->text('base', 'change_password_new_password'));
     $newPassword->setRequired();
     $newPassword->addValidator(new NewPasswordValidator());
     $form->addElement($newPassword);
     $repeatPassword = new PasswordField('repeatPassword');
     $repeatPassword->setLabel($language->text('base', 'change_password_repeat_password'));
     $repeatPassword->setRequired();
     $form->addElement($repeatPassword);
     $submit = new Submit("change");
     $submit->setLabel($language->text('base', 'change_password_submit'));
     $form->setAjax(true);
     $form->addElement($submit);
     if (OW::getRequest()->isAjax()) {
         $result = false;
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             BOL_UserService::getInstance()->updatePassword(OW::getUser()->getId(), $data['password']);
             $result = true;
         }
         echo json_encode(array('result' => $result));
         exit;
     } else {
         $messageError = $language->text('base', 'change_password_error');
         $messageSuccess = $language->text('base', 'change_password_success');
         $js = " owForms['" . $form->getName() . "'].bind( 'success',\n            function( json )\n            {\n            \tif( json.result == true )\n            \t{\n            \t    \$('#TB_closeWindowButton').click();\n            \t    OW.info('{$messageSuccess}');\n                }\n                else\n                {\n                    OW.error('{$messageError}');\n                }\n\n            } ); ";
         OW::getDocument()->addOnloadScript($js);
         $this->addForm($form);
         $language->addKeyForJs('base', 'join_error_password_not_valid');
         $language->addKeyForJs('base', 'join_error_password_too_short');
         $language->addKeyForJs('base', 'join_error_password_too_long');
         //include js
         $onLoadJs = " window.changePassword = new OW_BaseFieldValidators( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Join", "ajaxResponder"), 'passwordMaxLength' => UTIL_Validator::PASSWORD_MAX_LENGTH, 'passwordMinLength' => UTIL_Validator::PASSWORD_MIN_LENGTH)) . ",\n                                                            " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . " ); ";
         $onLoadJs .= " window.oldPassword = new OW_ChangePassword( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . " ); ";
         OW::getDocument()->addOnloadScript($onLoadJs);
         $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
         OW::getDocument()->addScript($jsDir . "base_field_validators.js");
         OW::getDocument()->addScript($jsDir . "change_password.js");
     }
 }
示例#5
0
 public function __construct()
 {
     parent::__construct('ccbill-config-form');
     $language = OW::getLanguage();
     $billingService = BOL_BillingService::getInstance();
     $gwKey = BILLINGCCBILL_CLASS_CcbillAdapter::GATEWAY_KEY;
     $clientAccnum = new TextField('clientAccnum');
     $clientAccnum->setValue($billingService->getGatewayConfigValue($gwKey, 'clientAccnum'));
     $this->addElement($clientAccnum);
     $clientSubacc = new TextField('clientSubacc');
     $clientSubacc->setValue($billingService->getGatewayConfigValue($gwKey, 'clientSubacc'));
     $this->addElement($clientSubacc);
     $adapter = new BILLINGCCBILL_CLASS_CcbillAdapter();
     $subAccounts = $adapter->getAdditionalSubaccounts();
     if ($subAccounts) {
         foreach ($subAccounts as $key => $sub) {
             $field = new TextField($key);
             $field->setLabel($sub['label']);
             $field->setValue($sub['value']);
             $this->addElement($field);
         }
     }
     $ccFormName = new TextField('ccFormName');
     $ccFormName->setValue($billingService->getGatewayConfigValue($gwKey, 'ccFormName'));
     $this->addElement($ccFormName);
     $ckFormName = new TextField('ckFormName');
     $ckFormName->setValue($billingService->getGatewayConfigValue($gwKey, 'ckFormName'));
     $this->addElement($ckFormName);
     $dpFormName = new TextField('dpFormName');
     $dpFormName->setValue($billingService->getGatewayConfigValue($gwKey, 'dpFormName'));
     $this->addElement($dpFormName);
     $edFormName = new TextField('edFormName');
     $edFormName->setValue($billingService->getGatewayConfigValue($gwKey, 'edFormName'));
     $this->addElement($edFormName);
     $dynamicPricingSalt = new TextField('dynamicPricingSalt');
     $dynamicPricingSalt->setValue($billingService->getGatewayConfigValue($gwKey, 'dynamicPricingSalt'));
     $this->addElement($dynamicPricingSalt);
     $datalinkUsername = new TextField('datalinkUsername');
     $datalinkUsername->setValue($billingService->getGatewayConfigValue($gwKey, 'datalinkUsername'));
     $this->addElement($datalinkUsername);
     $datalinkPassword = new PasswordField('datalinkPassword');
     $datalinkPassword->setValue($billingService->getGatewayConfigValue($gwKey, 'datalinkPassword'));
     $this->addElement($datalinkPassword);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('billingccbill', 'btn_save'));
     $this->addElement($submit);
 }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet("Root", new Tab("Main", HeaderField::create("Application Settings", 3), TextField::create("FacebookConsumerKey", "Consumer Key"), PasswordField::create("FacebookConsumerSecret", "Consumer Secret"), OptionsetField::create("EnableFacebookLogin", "Facebook Login", array(0 => "Disabled", 1 => "Enabled")), OptionsetField::create("EnableFacebookSignup", "Facebook Signup", array(0 => "Disabled", 1 => "Enabled")))));
     $this->extend("updateCMSFields", $fields);
     return $fields;
 }
 /**
  * EmailVerificationLoginForm is the same as MemberLoginForm with the following changes:
  *  - The code has been cleaned up.
  *  - A form action for users who have lost their verification email has been added.
  *
  * We add fields in the constructor so the form is generated when instantiated.
  *
  * @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 FieldList|FormField $fields All of the fields in the form - a {@link FieldList} of {@link FormField} objects.
  * @param FieldList|FormAction $actions All of the action buttons in the form - a {@link FieldList} 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
  */
 function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     $email_field_label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
     $email_field = TextField::create('Email', $email_field_label, null, null, $this)->setAttribute('autofocus', 'autofocus');
     $password_field = PasswordField::create('Password', _t('Member.PASSWORD', 'Password'));
     $authentication_method_field = HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this);
     $remember_me_field = CheckboxField::create('Remember', 'Remember me next time?', true);
     if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
         $fields = FieldList::create($authentication_method_field);
         $actions = FieldList::create(FormAction::create('logout', _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
     } else {
         if (!$fields) {
             $fields = FieldList::create($authentication_method_field, $email_field, $password_field);
             if (Security::config()->remember_username) {
                 $email_field->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
             } else {
                 // Some browsers won't respect this attribute unless it's added to the form
                 $this->setAttribute('autocomplete', 'off');
                 $email_field->setAttribute('autocomplete', 'off');
             }
         }
         if (!$actions) {
             $actions = FieldList::create(FormAction::create('doLogin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verify-email">' . _t('MemberEmailVerification.BUTTONLOSTVERIFICATIONEMAIL', "I've lost my verification email") . '</a></p>'));
         }
     }
     if (isset($_REQUEST['BackURL'])) {
         $fields->push(HiddenField::create('BackURL', 'BackURL', $_REQUEST['BackURL']));
     }
     // Reduce attack surface by enforcing POST requests
     $this->setFormMethod('POST', true);
     parent::__construct($controller, $name, $fields, $actions);
     $this->setValidator(RequiredFields::create('Email', 'Password'));
 }
 /**
  * RegistrationForm constructor
  *
  * @param Controller $controller
  * @param String $name
  * @param array $arguments
  */
 public function __construct($controller, $name, $arguments = array())
 {
     /** -----------------------------------------
      * Fields
      * ----------------------------------------*/
     /** @var TextField $firstName */
     $firstName = TextField::create('FirstName');
     $firstName->setAttribute('placeholder', 'Enter your first name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>First Name</strong>')->setCustomValidationMessage('Please enter your <strong>First Name</strong>');
     /** @var EmailField $email */
     $email = EmailField::create('Email');
     $email->setAttribute('placeholder', 'Enter your email address')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
     /** @var PasswordField $password */
     $password = PasswordField::create('Password');
     $password->setAttribute('placeholder', 'Enter your password')->setCustomValidationMessage('Please enter your <strong>Password</strong>')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Password</strong>');
     $fields = FieldList::create($email, $password);
     /** -----------------------------------------
      * Actions
      * ----------------------------------------*/
     $actions = FieldList::create(FormAction::create('Register')->setTitle('Register')->addExtraClass('btn--primary'));
     /** -----------------------------------------
      * Validation
      * ----------------------------------------*/
     $required = RequiredFields::create('FirstName', 'Email', 'Password');
     /** @var Form $form */
     $form = Form::create($this, $name, $fields, $actions, $required);
     if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) {
         $form->loadDataFrom($formData);
     }
     parent::__construct($controller, $name, $fields, $actions, $required);
     $this->setAttribute('data-parsley-validate', true);
     $this->addExtraClass('form form--registration');
 }
 public function getPasswordField($confirmed = true)
 {
     if ($confirmed) {
         return ConfirmedPasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
     }
     return PasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
 }
 public function __construct($controller, $name, $fields = null, $actions = null)
 {
     $fields = new FieldList($Nickname = TextField::create('Nickname')->setTitle(_t('Member.NICKNAME', 'Member.NICKNAME')), $Type = OptionsetField::create('Type')->setTitle(_t('Member.TYPE', 'Member.TYPE'))->setSource(array("refugee" => _t('Member.TYPEREFUGEESIGNUP', 'Member.TYPEREFUGEESIGNUP'), "hostel" => _t('Member.TYPEHOSTELSIGNUP', 'Member.TYPEHOSTELSIGNUP'), "donator" => _t('Member.TYPEDONATORSIGNUP', 'Member.TYPEDONATORSIGNUP'))), $Location = BootstrapGeoLocationField::create('Location')->setTitle(_t('Member.LOCATION', 'Member.LOCATION')), $Email = EmailField::create('Email')->setTitle(_t('Member.EMAIL', 'Member.EMAIL')), PasswordField::create('Password')->setTitle(_t('Member.PASSWORD', 'Member.PASSWORD')), LiteralField::create('Accept_TOS', _t('SignupForm.CONFIRMTOS', 'SignupForm.CONFIRMTOS')));
     $Type->setRightTitle(_t('Member.TYPEDESCRIPTION', 'Member.TYPEDESCRIPTION'));
     $Location->setRightTitle(_t('Member.LOCATIONDESCRIPTION', 'Member.LOCATIONDESCRIPTION'));
     $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doSignup')->setTitle(_t('SignupForm.BUTTONSIGNUP', 'SignupForm.BUTTONSIGNUP')));
     parent::__construct($controller, $name, $fields, $actions, new RequiredUniqueFields($required = array("Nickname", "Type", "Location", "Email", "Password"), $unique = array("Email" => _t('SignupForm.EMAILEXISTS', 'SignupForm.EMAILEXISTS')), $objectClass = 'Member'));
 }
 public function getPasswordField()
 {
     if ($this->confirmed) {
         //relies on fix: https://github.com/silverstripe/silverstripe-framework/pull/2757
         return ConfirmedPasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'))->setCanBeEmpty(!Checkout::membership_required());
     }
     return PasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
 }
 /**
  * Creates a form to set a password
  *
  * @return  Form
  */
 public function SetPasswordForm()
 {
     if (!Member::currentUser()) {
         return false;
     }
     $form = Form::create($this->owner, FieldList::create(PasswordField::create('Password', 'Password'), PasswordField::Create('Password_confirm', 'Confirm password'), HiddenField::create('BackURL', '', $this->owner->requestVar('BackURL'))), FieldList::create(FormAction::create('doSetPassword', 'Set my password')), RequiredFields::create('Password', 'Password_confirm'));
     return $form;
 }
 /**
  *CMS fields for configuring Pardot plugin 
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab("Root.Pardot", new LiteralField($name = "pardot_logo", $content = '<div class="field"><img src="/silverstripe-pardot/images/pardot-logo.png" height="50"></div>'));
     $fields->addFieldToTab("Root.Pardot", new EmailField("pardot_email", "Email Address"));
     $password_field = new PasswordField("new_pardot_password", "Password");
     $password_field->setAttribute('placeholder', '********');
     $fields->addFieldToTab("Root.Pardot", $password_field);
     $fields->addFieldToTab("Root.Pardot", new TextField("pardot_user_key", "User Key"));
     //option to select campaign available after they have connected
     if (PardotConfig::validApiCredentials()) {
         $fields->addFieldToTab("Root.Pardot", self::getCampaignCmsDropdown());
     } else {
         $fields->addFieldToTab("Root.Pardot", new LiteralField($name = "pardot_campaign", $content = '<p class="message bad"> No valid credentials</p>'));
         $fields->addFieldToTab("Root.Pardot", new LiteralField($name = "pardot_campaign", $content = '<p class="message notice"> Once you are connected, re-visit this page and select a campaign.</p>'));
     }
     $fields->addFieldToTab("Root.Pardot", new CheckboxField("pardot_https", "Use HTTPS?"));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->ID) {
         $fields->addFieldToTab("Root.Main", TextField::create('InstallID', 'Instalation ID'), "Summary");
         $fields->addFieldToTab("Root.Main", PasswordField::create("ResponsePassword", "Payment Response Password"), "Summary");
     }
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab("Root", new Tab('GoogleAnalytics'));
     $fields->addFieldToTab('Root.GoogleAnalytics', TextField::create("GoogleAnalyticsCode")->setTitle(_t('GoogleConfig.CODE', "Google Analytics Code"))->setRightTitle("(UA-XXXXXX-X)"));
     $fields->addFieldToTab('Root.GoogleAnalytics', TextField::create("GoogleAnalyticsProfileId")->setTitle(_t('GoogleConfig.PROFILEID', "Google Analytics Profile ID"))->setRightTitle(_t('GoogleConfig.PROFILEIDEXPLANATION', 'Hidden in the URL parameter "id" of the "View Report" link inside Google Analytics')));
     $fields->addFieldToTab('Root.GoogleAnalytics', TextField::create("GoogleAnalyticsEmail")->setTitle(_t('GoogleConfig.EMAIL', "Google Analytics Email"))->setRightTitle(_t('GoogleConfig.EMAILEXPLANATION', "The email address of the Google Analytics account to use")));
     $fields->addFieldToTab('Root.GoogleAnalytics', PasswordField::create("GoogleAnalyticsPassword")->setTitle(_t('GoogleConfig.PASSWORD', "Google Analytics Password"))->setRightTitle(_t('GoogleConfig.PASSWORDEXPLANATION', "The password for the above account")));
     $fields->addFieldToTab('Root.GoogleAnalytics', CheckboxField::create('UseGoogleUniversalSnippet')->setTitle(_t('GoogleConfig.UNIVERSAL', 'Use Google Universal Snippet')));
 }
示例#16
0
 public function __construct($name, $mode)
 {
     parent::__construct($name);
     $this->setAction(OW::getRouter()->urlForRoute('ocsaffiliates.action_edit'));
     $this->setAjax();
     $lang = OW::getLanguage();
     $idField = new HiddenField('affiliateId');
     $this->addElement($idField);
     $modeField = new HiddenField('mode');
     $modeField->setValue($mode);
     $this->addElement($modeField);
     if ($mode == 'admin') {
         $emailVerified = new CheckboxField('emailVerified');
         $emailVerified->setLabel($lang->text('ocsaffiliates', 'email_verified'));
         $this->addElement($emailVerified);
         $status = new Selectbox('status');
         $status->setLabel($lang->text('ocsaffiliates', 'status'));
         $status->setHasInvitation(false);
         $status->setRequired(true);
         $options = array('active' => $lang->text('ocsaffiliates', 'status_active'), 'unverified' => $lang->text('ocsaffiliates', 'status_unverified'));
         $status->setOptions($options);
         $this->addElement($status);
     }
     $affName = new TextField('name');
     $affName->setRequired(true);
     $affName->setLabel($lang->text('ocsaffiliates', 'affiliate_name'));
     $this->addElement($affName);
     $email = new TextField('email');
     $email->setRequired(true);
     $email->setLabel($lang->text('ocsaffiliates', 'email'));
     $email->addValidator(new EmailValidator());
     $this->addElement($email);
     $password = new PasswordField('password');
     $password->setLabel($lang->text('ocsaffiliates', 'password'));
     $this->addElement($password);
     $payment = new Textarea('payment');
     $payment->setRequired(true);
     $payment->setLabel($lang->text('ocsaffiliates', 'payment_details'));
     $this->addElement($payment);
     $submit = new Submit('save');
     $submit->setValue($lang->text('ocsaffiliates', 'edit'));
     $this->addElement($submit);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n            if ( !data.result ) {\n                OW.error(data.error);\n            }\n            else {\n                document.location.reload();\n            }\n        }");
 }
 /**
  * This is a generic form, but it will probably work in most cases.
  *
  * @param array $fields
  * @return array
  */
 public function addInstallFormFields(array $fields)
 {
     $fields[] = HiddenField::create('RepoType', '', $this->getType());
     $fields[] = HiddenField::create('RepoID', '', $this->repoID);
     $fields[] = LiteralField::create('repo', sprintf("<p>" . "You appear to be deploying from %s (%s.git). " . "If you enter your username and password below we will set up a service hook to deploy automatically. " . "Your credentials will not be logged or saved." . "</p>", $this->getHumanName(), $this->repoID));
     $fields[] = TextField::create('PostURL', 'Commit Hook URL (must be unique to this server)', DeployController::default_hook_url());
     $fields[] = TextField::create('ApiUser', $this->getHumanName() . ' Username');
     $fields[] = PasswordField::create('ApiPassword', $this->getHumanName() . ' Password');
     return $fields;
 }
示例#18
0
 /**
  * The default page which shows the login form.
  * @see lib/controllers/Controller#getContents()
  */
 public function getContents()
 {
     Application::addStylesheet("css/login.css");
     Application::$template = "login.tpl";
     Application::setTitle("Login");
     if ($_SESSION["logged_in"]) {
         Application::redirect("/");
     }
     $form = new Form();
     $form->setRenderer("default");
     $username = new TextField("Username", "username");
     $form->add($username);
     $password = new PasswordField("Password", "password");
     $password->setEncrypted(false);
     $form->add($password);
     $form->setSubmitValue("Login");
     $form->setValidatorCallback("{$this->getClassName()}::callback");
     $form->setShowClear(false);
     return $form->render();
 }
 /**
  * This method holds the functionality to complete the oauth flow through the CMS
  *
  * @param $fields FieldList
  **/
 public function updateCMSFields(FieldList $fields)
 {
     // Remove fields that may have been added elsewhere.
     $fields->removeByName("TwitterUser");
     $fields->removeByName("TwitterScreenName");
     $fields->removeByName("TwitterUserID");
     $fields->removeByName("TwitterAccessToken");
     $fields->removeByName("TwitterAccessSecret");
     // Add our new fields.
     $fields->push(ToggleCompositeField::create('TwitterUser', 'Twitter User', array(TextField::create("TwitterScreenName", "Screen Name"), TextField::create("TwitterUserID", "User ID"), TextField::create("TwitterAccessToken", "Access Token"), PasswordField::create("TwitterAccessSecret", "Access Secret")))->setHeadingLevel(4));
 }
示例#20
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->setAction(OW::getRouter()->urlForRoute('ocsaffiliates.action_signin'));
     $this->setAjax();
     $this->setAjaxResetOnSuccess(false);
     $lang = OW::getLanguage();
     $email = new TextField('email');
     $email->setRequired(true);
     $email->setLabel($lang->text('ocsaffiliates', 'email'));
     $email->addValidator(new EmailValidator());
     $this->addElement($email);
     $password = new PasswordField('password');
     $password->setRequired(true);
     $password->setLabel($lang->text('ocsaffiliates', 'password'));
     $this->addElement($password);
     $submit = new Submit('signin');
     $submit->setValue($lang->text('ocsaffiliates', 'signin_btn'));
     $this->addElement($submit);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n            if ( !data.result ) {\n                OW.error(data.error);\n            }\n            else {\n                document.location.reload();\n            }\n        }");
 }
 /**
  * @return static
  */
 function RegistrationForm()
 {
     // Email
     $email = new EmailField('Email');
     $email->setAttribute('placeholder', _t('RegistrationPage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
     // Password Conformation
     $password = new PasswordField('Password');
     $password->setAttribute('placeholder', _t('RegistrationPage.PasswordPlaceholder', 'Enter your password'))->setCustomValidationMessage(_t('RegistrationPage.PasswordValidationText', 'Your passwords do not match'), 'validation')->setAttribute('required', 'required')->addExtraClass('form-control');
     // Generate the fields
     $fields = new FieldList($email, $password);
     // Submit Button
     $action = new FormAction('Register', 'Register');
     $action->addExtraClass('btn btn-primary btn-lg');
     $actions = new FieldList($action);
     $validator = new RequiredFields('Email', 'Password');
     $form = Form::create($this, 'RegistrationForm', $fields, $actions, $validator);
     if ($formData = Session::get('FormInfo.Form_RegistrationForm.data')) {
         $form->loadDataFrom($formData);
     }
     return $form;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->ID) {
         // Payment Gateway Options
         $email_options = array("Don't", 'Send to customer and vendor', 'Send only to vendor');
         $fields->addFieldToTab("Root.Main", TextField::create('VendorName', 'Vendor name'), "Summary");
         $fields->addFieldToTab("Root.Main", DropdownField::create('ProtocolVersion', 'Version of forms protocol to use?', singleton('SagePay')->dbObject('ProtocolVersion')->enumValues()), "Summary");
         $fields->addFieldToTab('Root.Main', PasswordField::create('EncryptedPassword', 'Password'), "Summary");
         $fields->addFieldToTab("Root.Main", OptionsetField::create('SendEmail', 'How would you like SagePay to send emails?', $email_options), "Summary");
         $fields->addFieldToTab("Root.Main", EmailField::create('EmailRecipient', 'Email address of user to recieve email'), "Summary");
     }
     return $fields;
 }
 public function __construct(Controller $controller, $name)
 {
     // Set default fields
     $fields = new FieldList(HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this), HiddenField::create('tempid', null, $controller->getRequest()->requestVar('tempid')), PasswordField::create("Password", _t('Member.PASSWORD', 'Password')), LiteralField::create('forgotPassword', sprintf('<p id="ForgotPassword"><a href="%s" target="_top">%s</a></p>', $this->getExternalLink('lostpassword'), _t('CMSMemberLoginForm.BUTTONFORGOTPASSWORD', "Forgot password?"))));
     if (Security::config()->autologin_enabled) {
         $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?")));
     }
     // Determine returnurl to redirect to parent page
     $logoutLink = $this->getExternalLink('logout');
     if ($returnURL = $controller->getRequest()->requestVar('BackURL')) {
         $logoutLink = Controller::join_links($logoutLink, '?BackURL=' . urlencode($returnURL));
     }
     // Make actions
     $actions = new FieldList(FormAction::create('dologin', _t('CMSMemberLoginForm.BUTTONLOGIN', "Log back in")), LiteralField::create('doLogout', sprintf('<p id="doLogout"><a href="%s" target="_top">%s</a></p>', $logoutLink, _t('CMSMemberLoginForm.BUTTONLOGOUT', "Log out"))));
     parent::__construct($controller, $name, $fields, $actions);
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     $form_action_url = Controller::join_links(BASE_URL, "Security", $name);
     $lost_password_url = Controller::join_links(BASE_URL, "Security", "lostpassword");
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } else {
         $backURL = Session::get('BackURL');
     }
     $fields = new FieldList(HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this), TextField::create('Identity', 'Username or Email'), PasswordField::create("Password", _t('Member.PASSWORD', 'Password')));
     if (Security::config()->autologin_enabled) {
         $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me?")));
     }
     $actions = new FieldList(FormAction::create('dologin', 'Login'), LiteralField::create('forgotPassword', '<p id="ForgotPassword"><a href="' . $lost_password_url . '">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'));
     // LoginForm does its magic
     parent::__construct($controller, $name, $fields, $actions);
     $this->setAttribute("action", $form_action_url);
 }
 function FoundationForm()
 {
     $fields = new FieldList(HeaderField::create('FormFieldsHeader', 'Form Fields', 3), TextField::create('TextField', 'TextField'), EmailField::create('EmailField', 'EmailField'), PasswordField::create('PasswordField', 'PasswordField'), TextareaField::create('TextareaField', 'TextareaField'), FileField::create('FileField', 'FileField'), CheckboxField::create('CheckboxField', 'CheckboxField'), DropdownField::create('DropdownField', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->setEmptyString(''), CheckboxsetField::create('CheckboxsetField', 'CheckboxsetField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany')), OptionsetField::create('OptionsetField', 'OptionsetField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany')), HeaderField::create('FieldGroupHeader', 'Field Groups', 3), FieldGroup::create(TextField::create('FieldGroupTextField', 'TextField')->addExtraClass('small-6 columns'), TextField::create('FieldGroupTextField1', 'TextField')->addExtraClass('small-6 columns')), FieldGroup::create(TextField::create('FieldGroupTextField2', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField3', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField4', 'TextField')->addExtraClass('small-4 columns')), FieldGroup::create(TextField::create('FieldGroupTextField5', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField6', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField7', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField8', 'TextField')->addExtraClass('small-3 columns')), FieldGroup::create(TextField::create('FieldGroupTextField9', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField10', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField11', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField12', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField13', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField14', 'TextField')->addExtraClass('large-2 small-4 columns')), FieldGroup::create(TextField::create('FieldGroupTextField15', 'TextField')->addExtraClass('small-6 columns'), TextField::create('FieldGroupTextField16', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField17', 'TextField')->addExtraClass('small-2 columns')), FieldGroup::create(DropdownField::create('DropdownField2', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->addExtraClass('large-6 small-6 columns')->setEmptyString(''), DropdownField::create('DropdownField3', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->addExtraClass('large-6 small-6 columns')->setEmptyString('')), HeaderField::create('SwitchFieldsHeader', 'Switch Fields', 3), FoundationSwitchField::create('SwitchField', 'SwitchField', array(0 => 'Off', 1 => 'On'))->addExtraClass('large-12'), FoundationSwitchField::create('SwitchField2', 'SwitchField', array(0 => 'Off', 1 => 'On'))->addExtraClass('large round'));
     $actions = new FieldList(new FormAction('submitFoundationForm', 'Submit'));
     // set all to required to see the validation message appearance
     $required = array();
     if ($dataFields = $fields->dataFields()) {
         foreach ($dataFields as $child) {
             $required[] = $child->getName();
         }
     }
     $validator = new RequiredFields($required);
     $form = new FoundationForm($this, __FUNCTION__, $fields, $actions, $validator);
     // load submitted data, and clear them from session
     if ($data = Session::get('FoundationForm' . $this->ID)) {
         $form->loadDataFrom($data);
         Session::clear('FoundationForm' . $this->ID);
     }
     return $form;
 }
示例#26
0
 public function getResetPasswordForm($formName = 'reset-password')
 {
     $language = OW::getLanguage();
     $form = new Form($formName);
     $pass = new PasswordField('password');
     $pass->setRequired();
     $pass->setLabel($language->text('base', 'reset_password_field_label'));
     $form->addElement($pass);
     $repeatPass = new PasswordField('repeatPassword');
     $repeatPass->setRequired();
     $repeatPass->setLabel($language->text('base', 'reset_password_repeat_field_label'));
     $form->addElement($repeatPass);
     $submit = new Submit('submit');
     $submit->setValue($language->text('base', 'reset_password_submit_label'));
     $form->addElement($submit);
     return $form;
 }
 public function extraClasses()
 {
     $classes = array('form-control', parent::extraClasses());
     return implode(' ', $classes);
 }
 /**
  * Set if the existing password should be required
  *
  * @param bool $show Flag to show or hide this field
  * @return $this
  */
 public function setRequireExistingPassword($show)
 {
     // Don't modify if already added / removed
     if ((bool) $show === $this->requireExistingPassword) {
         return $this;
     }
     $this->requireExistingPassword = $show;
     $name = $this->getName();
     $currentName = "{$name}[_CurrentPassword]";
     if ($show) {
         $confirmField = PasswordField::create($currentName, _t('Member.CURRENT_PASSWORD', 'Current Password'));
         $this->children->unshift($confirmField);
     } else {
         $this->children->removeByName($currentName, true);
     }
     return $this;
 }
示例#29
0
         }
     }
 }
 if (isset($_POST['new_password']) && isset($_POST['password_confirm'])) {
     // check if the password and confirmation match, if not display message uponn post operation
     if ($valid and $_POST["password_confirm"] != $_POST["new_password"]) {
         $err["password_confirm"] = "Passwords must match";
         $valid = false;
     }
 }
 $form->load_by_pk($_SESSION['usr_id']);
 //load the data from the table by using the user type
 $panel_head = false;
 if ($valid && isset($_POST['new_password']) && isset($_POST['password_confirm']) && isset($_POST['old_password'])) {
     //if old and new password are set, check if the old
     $pass = new PasswordField();
     //password matches the one that's currently in the database, if so check if the newpassowrd and the confirmation match. if they do, save it to the database
     $pass->new_password($_POST['old_password']);
     if ($pass->value == $form->fields['password']->value) {
         if ($_POST['new_password'] == $_POST['password_confirm']) {
             $form->fields['password']->new_password($_POST['new_password']);
             if ($form->save()) {
                 $panel_head = true;
             } else {
                 echo "Password not changed.";
             }
         }
     } else {
         $err['password_confirm'] = "Either old password is incorrect or new passwords do not match.";
     }
 }
示例#30
0
 public function ftpAttrs()
 {
     $this->checkXP();
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('admin', 'page_title_manage_plugins_ftp_info'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
     $form = new Form('ftp');
     $login = new TextField('host');
     $login->setValue('localhost');
     $login->setRequired(true);
     $login->setLabel($language->text('admin', 'plugins_manage_ftp_form_host_label'));
     $form->addElement($login);
     $login = new TextField('login');
     $login->setHasInvitation(true);
     $login->setInvitation('login');
     $login->setRequired(true);
     $login->setLabel($language->text('admin', 'plugins_manage_ftp_form_login_label'));
     $form->addElement($login);
     $password = new PasswordField('password');
     $password->setHasInvitation(true);
     $password->setInvitation('password');
     $password->setRequired(true);
     $password->setLabel($language->text('admin', 'plugins_manage_ftp_form_password_label'));
     $form->addElement($password);
     $port = new TextField('port');
     $port->setValue(21);
     $port->addValidator(new IntValidator());
     $port->setLabel($language->text('admin', 'plugins_manage_ftp_form_port_label'));
     $form->addElement($port);
     $submit = new Submit('submit');
     $submit->setValue($language->text('admin', 'plugins_manage_ftp_form_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             OW::getSession()->set('ftpAttrs', array('host' => trim($data['host']), 'login' => trim($data['login']), 'password' => trim($data['password']), 'port' => (int) $data['port']));
             if (!empty($_GET['back_uri'])) {
                 $this->redirect(OW_URL_HOME . urldecode($_GET['back_uri']));
             } else {
                 $this->redirectToAction('index');
             }
         }
     }
 }