本文整理汇总了PHP中Engine_Db_Table::getTablePrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine_Db_Table::getTablePrefix方法的具体用法?PHP Engine_Db_Table::getTablePrefix怎么用?PHP Engine_Db_Table::getTablePrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine_Db_Table
的用法示例。
在下文中一共展示了Engine_Db_Table::getTablePrefix方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
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));
}
示例2: init
public function init()
{
$this->setMethod('POST');
$defaultArgs = array('disableLoadDefaultDecorators' => true, 'decorators' => array('ViewHelper'));
$identity = $this->getAttrib('user_id');
$user_object = Engine_Api::_()->user()->getUser($identity);
$user_id = new Zend_Form_Element_Hidden('user_id');
$user_id->setValue($identity);
$email = new Zend_Form_Element_Text('email', $defaultArgs);
$email->addValidator('emailAddress', true)->addValidator(new Zend_Validate_Db_NoRecordExists(Engine_Db_Table::getTablePrefix() . 'users', 'email'));
$email->setValue($user_object->email);
$password = new Zend_Form_Element_Password('password', $defaultArgs);
$password->addValidator('stringLength', false, array(6, 32));
$passconf = new User_Form_Element_PasswordConfirm('passconf', $defaultArgs);
//$passconf->addDecorator('ViewHelper');
if ($settings->getSetting('user.signup.username', 1) > 0) {
$username = new Zend_Form_Element_Text('username', $defaultArgs);
$username->setValue($user_object->username);
$username->addValidator('stringLength', true, array(6, 32))->addValidator(new Zend_Validate_Db_NoRecordExists(Engine_Db_Table::getTablePrefix() . 'users', 'username'));
}
$language = new Zend_Form_Element_Select('language', $defaultArgs);
$language->addMultiOptions(array('English', 'post-English'));
$language->setValue($user_object->language_id);
$level_id = new Zend_Form_Element_Select('level_id', $defaultArgs);
$level_id->setValue($user_object->level_id);
$levels = Engine_Api::_()->authorization()->getLevelInfo();
foreach ($levels as $level) {
$level_id->addMultiOption($level['level_id'], $level['title']);
}
$this->addElements(array($user_id, $email, $password, $passconf, $username, $level_id, $language));
}
示例3: getProfileFields
/**
* get all profile fields
*
*/
public static function getProfileFields()
{
if (self::$profileFields == null) {
$prefix = Engine_Db_Table::getTablePrefix();
$adapter = Engine_Db_Table::getDefaultAdapter();
$sql = "SELECT engine4_user_fields_meta.* FROM `engine4_user_fields_maps` \n\t\t\t\t\tjoin engine4_user_fields_meta on (engine4_user_fields_maps.child_id = engine4_user_fields_meta.field_id )\n\t\t\t\t\twhere engine4_user_fields_maps.option_id = 1 \n\t\t\t\t\tand engine4_user_fields_meta.type NOT IN ('profile_type','heading','gender','birthdate')\n\t\t\t\t\t";
self::$profileFields = $adapter->fetchAll($sql);
}
return self::$profileFields;
}
示例4: init
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()))))));
$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');
// Init username
$this->addElement('Text', 'username', array('label' => 'Profile Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[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->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');
// 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) {
$and_publish = 'publish' == $facebook_enable ? ' and publish content to your Facebook wall.' : '.';
$this->addElement('Dummy', 'facebook', array('label' => 'Facebook Integration', 'description' => 'Linking your Facebook account will let you login with Facebook' . $and_publish, '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 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/Dili' => '(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));
// Init submit
$this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
// Create display group for buttons
#$this->addDisplayGroup($emailAlerts, 'checkboxes');
// Set default action
$this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'settings', 'action' => 'general'), 'default'));
}
示例5: init
public function init()
{
$this->setAttrib('id', 'admin_members_edit')->setTitle('Edit Member')->setDescription('You can change the details of this member\'s account here.')->setAction($_SERVER['REQUEST_URI']);
// init email
$this->addElement('Text', 'email', array('label' => 'Email Address', 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email', array('field' => 'user_id', 'value' => (int) $this->_userIdentity)))), 'filters' => array('StringTrim')));
$this->email->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false);
// init username
if (Engine_Api::_()->getApi('settings', 'core')->getSetting('user.signup.username', 1) > 0) {
$this->addElement('Text', 'username', array('label' => 'Username'));
}
// init password
$this->addElement('Password', 'password', array('label' => 'Password'));
$this->addElement('Password', 'password_conf', array('label' => 'Password Again'));
// Init level
$levelMultiOptions = array();
//0 => ' ');
$levels = Engine_Api::_()->getDbtable('levels', 'authorization')->fetchAll();
foreach ($levels as $row) {
$levelMultiOptions[$row->level_id] = $row->getTitle();
}
$this->addElement('Select', 'level_id', array('label' => 'Member Level', 'multiOptions' => $levelMultiOptions));
// Init level
$networkMultiOptions = array();
//0 => ' ');
$networks = Engine_Api::_()->getDbtable('networks', 'network')->fetchAll();
foreach ($networks as $row) {
$networkMultiOptions[$row->network_id] = $row->getTitle();
}
$this->addElement('Multiselect', 'network_id', array('label' => 'Networks', 'multiOptions' => $networkMultiOptions));
// Get list of Member Types
$db = Engine_Db_Table::getDefaultAdapter();
$member_type_result = $db->select('option_id, label')->from('engine4_user_fields_options')->where('field_id = 1')->query()->fetchAll();
$member_type_count = count($member_type_result);
$member_type_array = array();
for ($i = 0; $i < $member_type_count; $i++) {
$member_type_array[$member_type_result[$i]['option_id']] = $member_type_result[$i]['label'];
}
$this->addElement('Select', 'profile_type', array('label' => 'Profile Type', 'multiOptions' => $member_type_array));
// Init approved
$this->addElement('Checkbox', 'approved', array('label' => 'Approved?'));
// Init verified
$this->addElement('Checkbox', 'verified', array('label' => 'Verified?'));
// Init enabled
$this->addElement('Checkbox', 'enabled', array('label' => 'Enabled?'));
// Buttons
$this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true, 'decorators' => array('ViewHelper')));
$this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'onclick' => 'parent.Smoothbox.close();', 'decorators' => array('ViewHelper')));
$this->addDisplayGroup(array('submit', 'cancel'), 'buttons');
$button_group = $this->getDisplayGroup('buttons');
$button_group->addDecorator('DivDivDivWrapper');
}
示例6: init
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;
}
}
//.........这里部分代码省略.........
示例7: init
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'));
}
示例8: init
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));
}
示例9: getAuthAdapter
/**
* Get the authentication adapter
*
* @return Zend_Auth_Adapter_Interface
*/
public function getAuthAdapter()
{
if (null === $this->_authAdapter) {
$db = Engine_Db_Table::getDefaultAdapter();
$tablePrefix = Engine_Db_Table::getTablePrefix();
$salt = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.secret', 'staticSalt');
$this->_authAdapter = new Zend_Auth_Adapter_DbTable($db, Engine_Api::_()->getItemTable('user')->info('name'), 'user_id', 'password', "MD5(CONCAT('" . $salt . "', ?, salt))");
}
return $this->_authAdapter;
}
示例10: init
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'));
}