本文整理汇总了PHP中Localization::isAllowedNameFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP Localization::isAllowedNameFormat方法的具体用法?PHP Localization::isAllowedNameFormat怎么用?PHP Localization::isAllowedNameFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Localization
的用法示例。
在下文中一共展示了Localization::isAllowedNameFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgradeUserPreferences
/**
* upgradeUserPreferences
* This method updates the user_preferences table and sets the pages/dashlets for users
* which have ACL access to Trackers so that the Tracker dashlets are set in their user perferences
*
*/
function upgradeUserPreferences()
{
global $sugar_config, $sugar_version;
$uw_strings = return_module_language($GLOBALS['current_language'], 'UpgradeWizard');
$localization = new Localization();
$localeCoreDefaults = $localization->getLocaleConfigDefaults();
// check the current system wide default_locale_name_format and add it to the list if it's not there
if (empty($sugar_config['name_formats'])) {
$sugar_config['name_formats'] = $localeCoreDefaults['name_formats'];
if (!rebuildConfigFile($sugar_config, $sugar_version)) {
$errors[] = $uw_strings['ERR_UW_CONFIG_WRITE'];
}
}
$currentDefaultLocaleNameFormat = $sugar_config['default_locale_name_format'];
if ($localization->isAllowedNameFormat($currentDefaultLocaleNameFormat)) {
upgradeLocaleNameFormat($currentDefaultLocaleNameFormat);
} else {
$sugar_config['default_locale_name_format'] = $localeCoreDefaults['default_locale_name_format'];
if (!rebuildConfigFile($sugar_config, $sugar_version)) {
$errors[] = $uw_strings['ERR_UW_CONFIG_WRITE'];
}
$localization->createInvalidLocaleNameFormatUpgradeNotice();
}
$db =& DBManagerFactory::getInstance();
$result = $db->query("SELECT id FROM users where deleted = '0'");
while ($row = $db->fetchByAssoc($result)) {
$current_user = new User();
$current_user->retrieve($row['id']);
// get the user's name locale format, check if it's in our list, add it if it's not, keep it as user's default
$currentUserNameFormat = $current_user->getPreference('default_locale_name_format');
if ($localization->isAllowedNameFormat($currentUserNameFormat)) {
upgradeLocaleNameFormat($currentUserNameFormat);
} else {
$current_user->setPreference('default_locale_name_format', 's f l', 0, 'global');
$current_user->savePreferencesToDB();
}
$changed = false;
if (!$current_user->getPreference('calendar_publish_key')) {
// set publish key if not set already
$current_user->setPreference('calendar_publish_key', create_guid());
$changed = true;
}
// we need to force save the changes to disk, otherwise we lose them.
if ($changed) {
$current_user->savePreferencesToDB();
}
}
//while
}