public function init() { $settings = Engine_Api::_()->getApi('settings', 'core'); $this->setTitle('SignUp - Required Info'); // Init email $this->addElement('Text', 'email', array('label' => 'Email Address', 'description' => 'You will use your email address to login.', 'required' => true, 'allowEmpty' => false, 'tabindex' => $tabIndex++, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email'))))); $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound'); // Add banned email validator $bannedEmailValidator = new Engine_Validate_Callback(array($this, 'checkBannedEmail'), $emailElement); $bannedEmailValidator->setMessage("This email address is not available, please use another one."); $this->email->addValidator($bannedEmailValidator); if ($settings->getSetting('socialconnect.inputpassword', 0)) { // Element: password $this->addElement('Password', 'password', array('label' => 'Password', 'description' => 'Passwords must be at least 6 characters in length.', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(6, 32))), 'tabindex' => $tabIndex++)); $this->password->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->password->getValidator('NotEmpty')->setMessage('Please enter a valid password.', 'isEmpty'); // Element: passconf $this->addElement('Password', 'passconf', array('label' => 'Password Again', 'description' => 'Enter your password again for confirmation.', 'required' => true, 'validators' => array(array('NotEmpty', true)), 'tabindex' => $tabIndex++)); $this->passconf->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->passconf->getValidator('NotEmpty')->setMessage('Please make sure the "password" and "password again" fields match.', 'isEmpty'); $specialValidator = new Engine_Validate_Callback(array($this, 'checkPasswordConfirm'), $this->password); $specialValidator->setMessage('Password did not match', 'invalid'); $this->passconf->addValidator($specialValidator); } // Init submit $this->addElement('Button', 'submit', array('label' => 'Continue', 'type' => 'submit', 'ignore' => true)); }
public function init() { parent::init(); // Set min age if (!is_null($this->min_age)) { // Set max year $date = new Zend_Date(); $this->_yearMax = (int) $date->get(Zend_Date::YEAR) - (int) $this->min_age; // Add validator $validator = new Engine_Validate_Callback(array($this, 'validateAge')); $validator->setMessage('The minimum age is ' . $this->min_age . '.', 'invalid'); $this->addValidator($validator); } }
public function init() { $settings = Engine_Api::_()->getApi('settings', 'core'); $this->setTitle('SignUp - Required Info'); // Element: password $this->addElement('Password', 'password', array('label' => 'Password', 'description' => 'Passwords must be at least 6 characters in length.', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(6, 32))), 'tabindex' => $tabIndex++)); $this->password->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->password->getValidator('NotEmpty')->setMessage('Please enter a valid password.', 'isEmpty'); // Element: passconf $this->addElement('Password', 'passconf', array('label' => 'Password Again', 'description' => 'Enter your password again for confirmation.', 'required' => true, 'validators' => array(array('NotEmpty', true)), 'tabindex' => $tabIndex++)); $this->passconf->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->passconf->getValidator('NotEmpty')->setMessage('Please make sure the "password" and "password again" fields match.', 'isEmpty'); $specialValidator = new Engine_Validate_Callback(array($this, 'checkPasswordConfirm'), $this->password); $specialValidator->setMessage('Password did not match', 'invalid'); $this->passconf->addValidator($specialValidator); // Init submit $this->addElement('Button', 'submit', array('label' => 'Continue', 'type' => 'submit', 'ignore' => true)); }
public function init() { // Init form $this->setTitle('Request Upgrade Membership'); $this->setDescription($description); $this->setAttrib('id', 'payment_form_subscribe'); $this->setAttrib('method', 'post'); $this->loadDefaultDecorators(); $this->getDecorator('Description')->setOption('escape', false); $this->addElement('Text', 'first_name', array('label' => 'First Name', 'required' => true, 'allowEmpty' => false, 'tabindex' => 1)); $this->first_name->setAttrib('required', true); $this->addElement('Text', 'last_name', array('label' => 'Last Name', 'required' => true, 'allowEmpty' => false, 'tabindex' => 2)); $this->last_name->setAttrib('required', true); // init email $this->addElement('Text', 'email', array('label' => 'Email', 'required' => true, 'allowEmpty' => false, 'validators' => array('EmailAddress'), 'tabindex' => 3)); $this->email->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false); $this->email->setAttrib('required', true); // init email $this->addElement('Text', 'emailconf', array('label' => 'Confirm Email', 'required' => true, 'allowEmpty' => false, 'validators' => array('EmailAddress'), 'tabindex' => 4)); $this->emailconf->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false); $this->emailconf->setAttrib('required', true); $specialValidator = new Engine_Validate_Callback(array($this, 'checkEmailConfirm'), $this->email); $specialValidator->setMessage('Email did not match', 'invalid'); $this->emailconf->addValidator($specialValidator); $countriesAssoc = Engine_Api::_()->getDbTable('locations', 'user')->getLocationsAssoc(0); $countriesAssoc = array('' => '') + $countriesAssoc; $this->addElement('Select', 'country_id', array('label' => 'Country', 'multiOptions' => $countriesAssoc, 'required' => true, 'tabindex' => 5)); $this->country_id->setAttrib('required', true); $this->addElement('Select', 'province_id', array('label' => 'Province/State', 'tabindex' => 6)); $this->addElement('Select', 'city_id', array('label' => 'City', 'tabindex' => 7)); $this->addElement('Text', 'phone', array('label' => 'Phone', 'required' => false, 'allowEmpty' => true, 'tabindex' => 8)); $this->addElement('Textarea', 'about', array('label' => 'More about you', 'required' => true, 'allowEmpty' => false, 'tabindex' => 9)); $this->about->setAttrib('required', true); // Init submit $this->addElement('Button', 'submit', array('label' => 'Send Request', 'type' => 'submit', 'ignore' => true, 'tabindex' => 10, 'decorators' => array('ViewHelper'))); }
public function init() { $settings = Engine_Api::_()->getApi('settings', 'core'); $this->_emailAntispamEnabled = $settings->getSetting('core.spam.email.antispam.signup', 1) == 1 && empty($_SESSION['facebook_signup']) && empty($_SESSION['twitter_signup']) && empty($_SESSION['janrain_signup']); $inviteSession = new Zend_Session_Namespace('invite'); $tabIndex = 1; // Init form $this->setTitle('Create Account'); $this->setAttrib('id', 'signup_account_form'); // Element: name (trap) $this->addElement('Text', 'name', array('class' => 'signup-name', 'label' => 'Name', 'validators' => array(array('StringLength', true, array('max' => 0))))); $this->name->getValidator('StringLength')->setMessage('An error has occured, please try again later.'); // Element: email $emailElement = $this->addEmailElement(array('label' => 'Email Address', 'description' => 'You will use your email address to login.', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email'))), 'filters' => array('StringTrim'), 'inputType' => 'email', 'autofocus' => 'autofocus', 'tabindex' => $tabIndex++)); $emailElement->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $emailElement->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty'); $emailElement->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound'); $emailElement->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false); // Add banned email validator $bannedEmailValidator = new Engine_Validate_Callback(array($this, 'checkBannedEmail'), $emailElement); $bannedEmailValidator->setMessage("This email address is not available, please use another one."); $emailElement->addValidator($bannedEmailValidator); if (!empty($inviteSession->invite_email)) { $emailElement->setValue($inviteSession->invite_email); } //if( $settings->getSetting('user.signup.verifyemail', 0) > 0 && $settings->getSetting('user.signup.checkemail', 0) == 1 ) { // $this->email->addValidator('Identical', true, array($inviteSession->invite_email)); // $this->email->getValidator('Identical')->setMessage('Your email address must match the address that was invited.', 'notSame'); //} // Element: code if ($settings->getSetting('user.signup.inviteonly') > 0) { $codeValidator = new Engine_Validate_Callback(array($this, 'checkInviteCode'), $emailElement); $codeValidator->setMessage("This invite code is invalid or does not match the selected email address"); $this->addElement('Text', 'code', array('label' => 'Invite Code', 'required' => true)); $this->code->addValidator($codeValidator); if (!empty($inviteSession->invite_code)) { $this->code->setValue($inviteSession->invite_code); } } if ($settings->getSetting('user.signup.random', 0) == 0 && empty($_SESSION['facebook_signup']) && empty($_SESSION['twitter_signup']) && empty($_SESSION['janrain_signup'])) { // Element: password $this->addElement('Password', 'password', array('label' => 'Password', 'description' => 'Passwords must be at least 6 characters in length.', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(6, 32))), 'tabindex' => $tabIndex++)); $this->password->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->password->getValidator('NotEmpty')->setMessage('Please enter a valid password.', 'isEmpty'); // Element: passconf $this->addElement('Password', 'passconf', array('label' => 'Password Again', 'description' => 'Enter your password again for confirmation.', 'required' => true, 'validators' => array(array('NotEmpty', true)), 'tabindex' => $tabIndex++)); $this->passconf->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->passconf->getValidator('NotEmpty')->setMessage('Please make sure the "password" and "password again" fields match.', 'isEmpty'); $specialValidator = new Engine_Validate_Callback(array($this, 'checkPasswordConfirm'), $this->password); $specialValidator->setMessage('Password did not match', 'invalid'); $this->passconf->addValidator($specialValidator); } // Element: username if ($settings->getSetting('user.signup.username', 1) > 0) { $description = Zend_Registry::get('Zend_Translate')->_('This will be the end of your profile link, for example: <br /> ' . '<span id="profile_address">http://%s</span>'); $description = sprintf($description, $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getRouter()->assemble(array('id' => 'yourname'), 'user_profile')); $this->addElement('Text', 'username', array('label' => 'Profile Address', 'description' => $description, 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z][a-z0-9]*$/i')), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'username'))), 'tabindex' => $tabIndex++)); $this->username->getDecorator('Description')->setOptions(array('placement' => 'APPEND', 'escape' => false)); $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile address.', 'isEmpty'); $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile address, please use another one.', 'recordFound'); $this->username->getValidator('Regex')->setMessage('Profile addresses must start with a letter.', 'regexNotMatch'); $this->username->getValidator('Alnum')->setMessage('Profile addresses must be alphanumeric.', 'notAlnum'); // Add banned username validator $bannedUsernameValidator = new Engine_Validate_Callback(array($this, 'checkBannedUsername'), $this->username); $bannedUsernameValidator->setMessage("This profile address is not available, please use another one."); $this->username->addValidator($bannedUsernameValidator); } // Element: profile_type $topStructure = Engine_Api::_()->fields()->getFieldStructureTop('user'); if (count($topStructure) == 1 && $topStructure[0]->getChild()->type == 'profile_type') { $profileTypeField = $topStructure[0]->getChild(); $options = $profileTypeField->getOptions(); if (count($options) > 1) { $options = $profileTypeField->getElementParams('user'); unset($options['options']['order']); unset($options['options']['multiOptions']['0']); $this->addElement('Select', 'profile_type', array_merge($options['options'], array('required' => true, 'allowEmpty' => false, 'tabindex' => $tabIndex++))); } else { if (count($options) == 1) { $this->addElement('Hidden', 'profile_type', array('value' => $options[0]->option_id)); } } } // Element: timezone $this->addElement('Select', 'timezone', array('label' => 'Timezone', 'value' => $settings->getSetting('core.locale.timezone'), 'multiOptions' => array('US/Pacific' => '(UTC-8) Pacific Time (US & Canada)', 'US/Mountain' => '(UTC-7) Mountain Time (US & Canada)', 'US/Central' => '(UTC-6) Central Time (US & Canada)', 'US/Eastern' => '(UTC-5) Eastern Time (US & Canada)', 'America/Halifax' => '(UTC-4) Atlantic Time (Canada)', 'America/Anchorage' => '(UTC-9) Alaska (US & Canada)', 'Pacific/Honolulu' => '(UTC-10) Hawaii (US)', 'Pacific/Samoa' => '(UTC-11) Midway Island, Samoa', 'Etc/GMT-12' => '(UTC-12) Eniwetok, Kwajalein', 'Canada/Newfoundland' => '(UTC-3:30) Canada/Newfoundland', 'America/Buenos_Aires' => '(UTC-3) Brasilia, Buenos Aires, Georgetown', 'Atlantic/South_Georgia' => '(UTC-2) Mid-Atlantic', 'Atlantic/Azores' => '(UTC-1) Azores, Cape Verde Is.', 'Europe/London' => 'Greenwich Mean Time (Lisbon, London)', 'Europe/Berlin' => '(UTC+1) Amsterdam, Berlin, Paris, Rome, Madrid', 'Europe/Athens' => '(UTC+2) Athens, Helsinki, Istanbul, Cairo, E. Europe', 'Europe/Moscow' => '(UTC+3) Baghdad, Kuwait, Nairobi, Moscow', 'Iran' => '(UTC+3:30) Tehran', 'Asia/Dubai' => '(UTC+4) Abu Dhabi, Kazan, Muscat', 'Asia/Kabul' => '(UTC+4:30) Kabul', 'Asia/Yekaterinburg' => '(UTC+5) Islamabad, Karachi, Tashkent', 'Asia/Calcutta' => '(UTC+5:30) Bombay, Calcutta, New Delhi', 'Asia/Katmandu' => '(UTC+5:45) Nepal', 'Asia/Omsk' => '(UTC+6) Almaty, Dhaka', 'Indian/Cocos' => '(UTC+6:30) Cocos Islands, Yangon', 'Asia/Krasnoyarsk' => '(UTC+7) Bangkok, Jakarta, Hanoi', 'Asia/Hong_Kong' => '(UTC+8) Beijing, Hong Kong, Singapore, Taipei', 'Asia/Tokyo' => '(UTC+9) Tokyo, Osaka, Sapporto, Seoul, Yakutsk', 'Australia/Adelaide' => '(UTC+9:30) Adelaide, Darwin', 'Australia/Sydney' => '(UTC+10) Brisbane, Melbourne, Sydney, Guam', 'Asia/Magadan' => '(UTC+11) Magadan, Solomon Is., New Caledonia', 'Pacific/Auckland' => '(UTC+12) Fiji, Kamchatka, Marshall Is., Wellington'), 'tabindex' => $tabIndex++)); $this->timezone->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); // Element: language // Languages $translate = Zend_Registry::get('Zend_Translate'); $languageList = $translate->getList(); //$currentLocale = Zend_Registry::get('Locale')->__toString(); // Prepare default langauge $defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en'); if (!in_array($defaultLanguage, $languageList)) { if ($defaultLanguage == 'auto' && isset($languageList['en'])) { $defaultLanguage = 'en'; } else { $defaultLanguage = null; } } // Prepare language name list $localeObject = Zend_Registry::get('Locale'); $languageNameList = array(); $languageDataList = Zend_Locale_Data::getList($localeObject, 'language'); $territoryDataList = Zend_Locale_Data::getList($localeObject, 'territory'); foreach ($languageList as $localeCode) { $languageNameList[$localeCode] = Zend_Locale::getTranslation($localeCode, 'language', $localeCode); if (empty($languageNameList[$localeCode])) { list($locale, $territory) = explode('_', $localeCode); $languageNameList[$localeCode] = "{$territoryDataList[$territory]} {$languageDataList[$locale]}"; } } $languageNameList = array_merge(array($defaultLanguage => $defaultLanguage), $languageNameList); if (count($languageNameList) > 1) { $this->addElement('Select', 'language', array('label' => 'Language', 'multiOptions' => $languageNameList, 'tabindex' => $tabIndex++)); $this->language->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); } else { $this->addElement('Hidden', 'language', array('value' => current((array) $languageNameList))); } // Element: captcha if (Engine_Api::_()->getApi('settings', 'core')->core_spam_signup) { $this->addElement('captcha', 'captcha', Engine_Api::_()->core()->getCaptchaOptions(array('tabindex' => $tabIndex++))); } if ($settings->getSetting('user.signup.terms', 1) == 1) { // Element: terms $description = Zend_Registry::get('Zend_Translate')->_('I have read and agree to the <a target="_blank" href="%s/help/terms">terms of service</a>.'); $description = sprintf($description, Zend_Controller_Front::getInstance()->getBaseUrl()); $this->addElement('Checkbox', 'terms', array('label' => 'Terms of Service', 'description' => $description, 'required' => true, 'validators' => array('notEmpty', array('GreaterThan', false, array(0))), 'tabindex' => $tabIndex++)); $this->terms->getValidator('GreaterThan')->setMessage('You must agree to the terms of service to continue.', 'notGreaterThan'); //$this->terms->getDecorator('Label')->setOption('escape', false); $this->terms->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Description', array('placement' => Zend_Form_Decorator_Abstract::APPEND, 'tag' => 'label', 'class' => 'null', 'escape' => false, 'for' => 'terms'))->addDecorator('DivDivDivWrapper'); //$this->terms->setDisableTranslator(true); } // Init submit $this->addElement('Button', 'submit', array('label' => 'Continue', 'type' => 'submit', 'ignore' => true, 'tabindex' => $tabIndex++)); if (empty($_SESSION['facebook_signup'])) { // Init facebook login link // if( 'none' != $settings->getSetting('core_facebook_enable', 'none') // && $settings->core_facebook_secret ) { // $this->addElement('Dummy', 'facebook', array( // 'content' => User_Model_DbTable_Facebook::loginButton(), // )); // } } if (empty($_SESSION['twitter_signup'])) { // Init twitter login link // if( 'none' != $settings->getSetting('core_twitter_enable', 'none') // && $settings->core_twitter_secret ) { // $this->addElement('Dummy', 'twitter', array( // 'content' => User_Model_DbTable_Twitter::loginButton(), // )); // } } // Set default action $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_signup', true)); }
public function init() { $settings = Engine_Api::_()->getApi('settings', 'core'); $tabIndex = 0; // Init form $email_address = Zend_Controller_Front::getInstance()->getRequest()->getParam('email'); $invite_code = Zend_Controller_Front::getInstance()->getRequest()->getParam('code'); $this->setTitle('Quick SignUp'); // Init email $this->addElement('Text', 'email', array('label' => 'Email Address', 'description' => 'You will use your email address to login.', 'required' => true, 'allowEmpty' => false, 'tabindex' => $tabIndex++, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email'))))); if ($settings->getSetting('user.signup.verifyemail') > 0 && $settings->getSetting('user.signup.checkemail') == 1) { $this->email->addValidator('Identical', true, array($email_address)); $this->email->getValidator('Identical')->setMessage('Your email address must match the address that was invited.', 'notSame'); } if (!empty($email_address)) { $this->email->setValue($email_address); } // Element: username if ($settings->getSetting('user.signup.username', 1) > 0) { $description = Zend_Registry::get('Zend_Translate')->_('This will be the end of your profile link, for example: <br /> ' . '<span id="profile_address">http://%s</span>'); $description = sprintf($description, $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getBaseUrl() . '/yourname'); $this->addElement('Text', 'username', array('label' => 'Profile Address', 'description' => $description, 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z][a-z0-9]*$/i')), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'username'))), 'tabindex' => $tabIndex++)); $this->username->getDecorator('Description')->setOptions(array('placement' => 'APPEND', 'escape' => false)); $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile address.', 'isEmpty'); $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile address, please use another one.', 'recordFound'); $this->username->getValidator('Regex')->setMessage('Profile addresses must start with a letter.', 'regexNotMatch'); $this->username->getValidator('Alnum')->setMessage('Profile addresses must be alphanumeric.', 'notAlnum'); // Add banned username validator $bannedUsernameValidator = new Engine_Validate_Callback(array($this, 'checkBannedUsername'), $this->username); $bannedUsernameValidator->setMessage("This profile address is not available, please use another one."); $this->username->addValidator($bannedUsernameValidator); } /** * add email by some other rule */ if ($settings->getSetting('user.signup.random', 0) == 0 && empty($_SESSION['facebook_signup']) && empty($_SESSION['twitter_signup']) && empty($_SESSION['janrain_signup'])) { // Element: password $this->addElement('Password', 'password', array('label' => 'Password', 'description' => 'Passwords must be at least 6 characters in length.', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(6, 32))), 'tabindex' => $tabIndex++)); $this->password->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->password->getValidator('NotEmpty')->setMessage('Please enter a valid password.', 'isEmpty'); // Element: passconf $this->addElement('Password', 'passconf', array('label' => 'Password Again', 'description' => 'Enter your password again for confirmation.', 'required' => true, 'validators' => array(array('NotEmpty', true)), 'tabindex' => $tabIndex++)); $this->passconf->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->passconf->getValidator('NotEmpty')->setMessage('Please make sure the "password" and "password again" fields match.', 'isEmpty'); $specialValidator = new Engine_Validate_Callback(array($this, 'checkPasswordConfirm'), $this->password); $specialValidator->setMessage('Password did not match', 'invalid'); $this->passconf->addValidator($specialValidator); } //'onblur' => 'var el = this; en4.user.checkEmailTaken(this.value, function(taken){ el.style.marginBottom = taken * 100 + // "px" });' $this->email->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->email->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty'); $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound'); $description = Zend_Registry::get('Zend_Translate')->_('This will be the end of your profile link, for example: <br /> <span id="profile_address">http://%s</span>'); $description = sprintf($description, $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getBaseUrl() . '/yourname'); // Init profile_type if ($settings->getSetting('user.signup.terms', 1) == 1) { // Init terms $description = Zend_Registry::get('Zend_Translate')->_('I have read and agree to the <a target="_blank" href="%s/help/terms">terms of service</a>.'); $description = sprintf($description, Zend_Controller_Front::getInstance()->getBaseUrl()); $this->addElement('Checkbox', 'terms', array('label' => 'Terms of Service', 'description' => $description, 'validators' => array('notEmpty', array('GreaterThan', false, array(0))))); $this->terms->getValidator('GreaterThan')->setMessage('You must agree to the terms of service to continue.', 'notGreaterThan'); $this->terms->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Description', array('placement' => Zend_Form_Decorator_Abstract::APPEND, 'tag' => 'label', 'class' => 'null', 'escape' => false, 'for' => 'terms'))->addDecorator('DivDivDivWrapper'); //$this->terms->setDisableTranslator(true); } // Init submit $this->addElement('Button', 'submit', array('label' => 'Continue', 'type' => 'submit', 'ignore' => true)); // Set default action $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'connect_signup')); }
public function init() { $settings = Engine_Api::_()->getApi('settings', 'core'); $inviteSession = new Zend_Session_Namespace('invite'); $tabIndex = 1; // Init form $this->setTitle('Create Account'); // Element: code if ($settings->getSetting('user.signup.inviteonly') > 0) { //require code $codeValidator = new Engine_Validate_Callback(array($this, 'checkInviteCode'), $emailElement); $codeValidator->setMessage("This invite code is invalid or does not match the selected email address"); $this->addElement('Text', 'code', array('label' => 'Invite Code', 'required' => true)); $this->code->addValidator($codeValidator); $this->code->setAttrib('required', true); if (!empty($inviteSession->invite_code)) { $this->code->setValue($inviteSession->invite_code); } } else { if (Engine_Api::_()->getApi('settings', 'core')->getSetting('user.referral_enable', 1)) { $this->addElement('Text', 'code', array('label' => 'Invite Code', 'description' => 'Enter referral code if you have')); $codeValidator = new Engine_Validate_Callback(array($this, 'checkInviteCode'), $emailElement); $codeValidator->setMessage("This invite code is invalid or does not match the selected email address"); $this->code->addValidator($codeValidator); } } // Element: email $emailElement = $this->addEmailElement(array('label' => 'Email Address', 'description' => 'You will use your email address to login.', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email'))), 'filters' => array('StringTrim'), 'inputType' => 'email', 'autofocus' => 'autofocus', 'tabindex' => $tabIndex++)); $emailElement->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $emailElement->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty'); $emailElement->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound'); $emailElement->setAttrib('required', true); // Add banned email validator $bannedEmailValidator = new Engine_Validate_Callback(array($this, 'checkBannedEmail'), $emailElement); $bannedEmailValidator->setMessage("This email address is not available, please use another one."); $emailElement->addValidator($bannedEmailValidator); if (!empty($inviteSession->invite_email)) { $emailElement->setValue($inviteSession->invite_email); } // Element: password $this->addElement('Password', 'password', array('label' => 'Password', 'description' => 'Passwords must be at least 6 characters in length.', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(6, 32))), 'tabindex' => $tabIndex++)); $this->password->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->password->getValidator('NotEmpty')->setMessage('Please enter a valid password.', 'isEmpty'); $this->password->setAttrib('required', true); // Element: captcha if (Engine_Api::_()->getApi('settings', 'core')->core_spam_signup) { $this->addElement('captcha', 'captcha', Engine_Api::_()->core()->getCaptchaOptions(array('tabindex' => $tabIndex++))); } if ($settings->getSetting('user.signup.terms', 1) == 1) { // Element: terms $description = Zend_Registry::get('Zend_Translate')->_('I have read and agree to the <a target="_blank" href="%s/help/terms">terms of service</a>.'); $description = sprintf($description, Zend_Controller_Front::getInstance()->getBaseUrl()); $this->addElement('Checkbox', 'terms', array('label' => 'Terms of Service', 'description' => $description, 'required' => true, 'validators' => array('notEmpty', array('GreaterThan', false, array(0))), 'tabindex' => $tabIndex++)); $this->terms->getValidator('GreaterThan')->setMessage('You must agree to the terms of service to continue.', 'notGreaterThan'); //$this->terms->getDecorator('Label')->setOption('escape', false); $this->terms->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Description', array('placement' => Zend_Form_Decorator_Abstract::APPEND, 'tag' => 'label', 'class' => 'null', 'escape' => false, 'for' => 'terms'))->addDecorator('DivDivDivWrapper'); //$this->terms->setDisableTranslator(true); } // Init submit $this->addElement('Button', 'submit', array('label' => 'Continue', 'type' => 'submit', 'ignore' => true, 'tabindex' => $tabIndex++, 'decorators' => array('ViewHelper'))); $this->addElement('Button', 'cancel', array('label' => 'cancel', 'link' => true, 'href' => '', 'onclick' => 'parent.Smoothbox.close();', 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('submit', 'cancel'), 'buttons', array('decorators' => array('FormElements', 'DivDivDivWrapper'))); // Set default action $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), 'user_signup1', true)); }
public function init() { // @todo fix form CSS/decorators // @todo replace fake values with real values $this->setTitle('General Settings')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); // Init email $this->addElement('Text', 'email', array('label' => 'Email Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity())))), 'filters' => array('StringTrim'))); $this->email->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty'); $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound'); $this->email->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false); // Init username if (Engine_Api::_()->getApi('settings', 'core')->getSetting('user.signup.username', 1) > 0) { $description = Zend_Registry::get('Zend_Translate')->_('This will be the end of your profile link, for example: <br /> ' . '<span id="profile_address">http://%s</span>'); $description = sprintf($description, $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getBaseUrl() . '/yourname'); $this->addElement('Text', 'username', array('label' => 'Profile URL', 'description' => $description, 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z][a-z0-9]*$/i')), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'username', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity())))))); $this->username->getDecorator('Description')->setOptions(array('placement' => 'APPEND', 'escape' => false)); $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile url.', 'isEmpty'); $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile url, please use another one.', 'recordFound'); $this->username->getValidator('Regex')->setMessage('Profile url must start with a letter.', 'regexNotMatch'); $this->username->getValidator('Alnum')->setMessage('Profile url must be alphanumeric.', 'notAlnum'); // Add banned username validator $bannedUsernameValidator = new Engine_Validate_Callback(array($this, 'checkBannedUsername'), $this->username); $bannedUsernameValidator->setMessage("This profile url is not available, please use another one."); $this->username->addValidator($bannedUsernameValidator); } // Init type $this->addElement('Select', 'accountType', array('label' => 'Account Type')); // Init Facebook $facebook_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_facebook_enable', 'none'); if ('none' != $facebook_enable) { $desc = 'Linking your Facebook account will let you login with Facebook'; if ('publish' == $facebook_enable) { $desc .= ' and publish content to your Facebook wall.'; } else { $desc .= '.'; } $this->addElement('Dummy', 'facebook', array('label' => 'Facebook Integration', 'description' => $desc, 'content' => User_Model_DbTable_Facebook::loginButton('Integrate with my Facebook'))); $this->addElement('Checkbox', 'facebook_id', array('label' => 'Integrate with my Facebook', 'description' => 'Facebook Integration')); } // Init Twitter $twitter_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_twitter_enable', 'none'); if ('none' != $twitter_enable) { $desc = 'Linking your Twitter account will let you login with Twitter'; if ('publish' == $twitter_enable) { $desc .= ' and publish content to your Twitter feed.'; } else { $desc .= '.'; } $this->addElement('Dummy', 'twitter', array('label' => 'Twitter Integration', 'description' => $desc, 'content' => User_Model_DbTable_Twitter::loginButton('Integrate with my Twitter'))); $this->addElement('Checkbox', 'twitter_id', array('label' => 'Integrate with my Twitter', 'description' => 'Twitter Integration')); } $janrain_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_janrain_enable', 'none'); if ($janrain_enable && $janrain_enable != 'none') { // Check if already linked $janrainTable = Engine_Api::_()->getDbtable('janrain', 'user'); $janrainExists = $janrainTable->select()->from($janrainTable, new Zend_Db_Expr('TRUE'))->where('user_id = ?', $this->getItem()->getIdentity())->limit(1)->query()->fetchColumn(); if (!$janrainExists) { $desc = 'Linking another account will let you login using that account.'; $this->addElement('Dummy', 'janrain', array('label' => 'Social Integration', 'description' => $desc, 'content' => User_Model_DbTable_Janrain::loginButton('page'))); } else { $this->addElement('Radio', 'janrainnoshare', array('label' => 'Share Dialog', 'description' => 'Do you want the option to share a post to ' . 'facebook or twitter to be displayed after posting?', 'multiOptions' => array('0' => 'Yes, display the dialog.', '1' => 'No, do not display the dialog.'), 'value' => 0)); } } // Init timezone $this->addElement('Select', 'timezone', array('label' => 'Timezone', 'description' => 'Select the city closest to you that shares your same timezone.', 'multiOptions' => array('US/Pacific' => '(UTC-8) Pacific Time (US & Canada)', 'US/Mountain' => '(UTC-7) Mountain Time (US & Canada)', 'US/Central' => '(UTC-6) Central Time (US & Canada)', 'US/Eastern' => '(UTC-5) Eastern Time (US & Canada)', 'America/Halifax' => '(UTC-4) Atlantic Time (Canada)', 'America/Anchorage' => '(UTC-9) Alaska (US & Canada)', 'Pacific/Honolulu' => '(UTC-10) Hawaii (US)', 'Pacific/Samoa' => '(UTC-11) Midway Island, Samoa', 'Etc/GMT-12' => '(UTC-12) Eniwetok, Kwajalein', 'Canada/Newfoundland' => '(UTC-3:30) Canada/Newfoundland', 'America/Buenos_Aires' => '(UTC-3) Brasilia, Buenos Aires, Georgetown', 'Atlantic/South_Georgia' => '(UTC-2) Mid-Atlantic', 'Atlantic/Azores' => '(UTC-1) Azores, Cape Verde Is.', 'Europe/London' => 'Greenwich Mean Time (Lisbon, London)', 'Europe/Berlin' => '(UTC+1) Amsterdam, Berlin, Paris, Rome, Madrid', 'Europe/Athens' => '(UTC+2) Athens, Helsinki, Istanbul, Cairo, E. Europe', 'Europe/Moscow' => '(UTC+3) Baghdad, Kuwait, Nairobi, Moscow', 'Iran' => '(UTC+3:30) Tehran', 'Asia/Dubai' => '(UTC+4) Abu Dhabi, Kazan, Muscat', 'Asia/Kabul' => '(UTC+4:30) Kabul', 'Asia/Yekaterinburg' => '(UTC+5) Islamabad, Karachi, Tashkent', 'Asia/Calcutta' => '(UTC+5:30) Bombay, Calcutta, New Delhi', 'Asia/Katmandu' => '(UTC+5:45) Nepal', 'Asia/Omsk' => '(UTC+6) Almaty, Dhaka', 'India/Cocos' => '(UTC+6:30) Cocos Islands, Yangon', 'Asia/Krasnoyarsk' => '(UTC+7) Bangkok, Jakarta, Hanoi', 'Asia/Hong_Kong' => '(UTC+8) Beijing, Hong Kong, Singapore, Taipei', 'Asia/Tokyo' => '(UTC+9) Tokyo, Osaka, Sapporto, Seoul, Yakutsk', 'Australia/Adelaide' => '(UTC+9:30) Adelaide, Darwin', 'Australia/Sydney' => '(UTC+10) Brisbane, Melbourne, Sydney, Guam', 'Asia/Magadan' => '(UTC+11) Magadan, Soloman Is., New Caledonia', 'Pacific/Auckland' => '(UTC+12) Fiji, Kamchatka, Marshall Is., Wellington'))); // Init default locale $locale = Zend_Registry::get('Locale'); $localeMultiKeys = array_merge(array_keys(Zend_Locale::getLocaleList())); $localeMultiOptions = array(); $languages = Zend_Locale::getTranslationList('language', $locale); $territories = Zend_Locale::getTranslationList('territory', $locale); foreach ($localeMultiKeys as $key) { if (!empty($languages[$key])) { $localeMultiOptions[$key] = $languages[$key]; } else { $locale = new Zend_Locale($key); $region = $locale->getRegion(); $language = $locale->getLanguage(); if (!empty($languages[$language]) && !empty($territories[$region])) { $localeMultiOptions[$key] = $languages[$language] . ' (' . $territories[$region] . ')'; } } } $localeMultiOptions = array_merge(array('auto' => '[Automatic]'), $localeMultiOptions); $this->addElement('Select', 'locale', array('label' => 'Locale', 'description' => 'Dates, times, and other settings will be displayed using this locale setting.', 'multiOptions' => $localeMultiOptions)); $languages = Engine_Api::_()->getDbTable('languages', 'user')->getLanguagesArray(); $this->addElement('MultiCheckbox', 'languages', array('label' => 'Language Preference', 'required' => false, 'allowEmpty' => true, 'multiOptions' => $languages, 'filters' => array('StripTags', new Engine_Filter_Censor()))); // Init submit $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true)); // Set default action $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'settings', 'action' => 'general'), 'default')); }