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 }"); }
/** * 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')); }
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"); } }
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 }"); }
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 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'); } } } }
/** * Requests local FTP attributes to update items/platform source code. */ public function ftpAttrs() { $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(); $ftpAttrs = array("host" => trim($data["host"]), "login" => trim($data["login"]), "password" => trim($data["password"]), "port" => (int) $data["port"]); OW::getSession()->set("ftpAttrs", $ftpAttrs); $this->redirectToBackUri($_GET); $this->redirectToAction('index'); } } }