本文整理汇总了PHP中Tinebase_Core::setupUserLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Core::setupUserLocale方法的具体用法?PHP Tinebase_Core::setupUserLocale怎么用?PHP Tinebase_Core::setupUserLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Core
的用法示例。
在下文中一共展示了Tinebase_Core::setupUserLocale方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initFramework
/**
* init the test framework
*/
public function initFramework()
{
$this->setWhiteAndBlacklists();
// get config
$configData = @(include 'phpunitconfig.inc.php');
if ($configData === false) {
$configData = (include 'config.inc.php');
}
if ($configData === false) {
die('central configuration file config.inc.php not found in includepath: ' . get_include_path());
}
$config = new Zend_Config($configData);
Zend_Registry::set('testConfig', $config);
$_SERVER['DOCUMENT_ROOT'] = $config->docroot;
$_SERVER['REQUEST_URI'] = '';
Tinebase_Core::startCoreSession();
Tinebase_Core::initFramework();
// set default test mailer
Tinebase_Smtp::setDefaultTransport(new Zend_Mail_Transport_Array());
// set max execution time
Tinebase_Core::setExecutionLifeTime(1200);
if ($config->locale) {
Tinebase_Core::setupUserLocale($config->locale);
}
// this is needed for session handling in unittests (deactivate Zend_Session::writeClose and others)
Zend_Session::$_unitTestEnabled = TRUE;
}
示例2: setLocale
/**
* sets locale
*
* @param string $localeString
* @param bool $saveaspreference
* @param bool $setcookie
* @return array
*/
public function setLocale($localeString, $saveaspreference, $setcookie)
{
Tinebase_Core::setupUserLocale($localeString, $saveaspreference);
$locale = Tinebase_Core::get('locale');
// save in cookie (expires in 365 days)
if ($setcookie) {
setcookie('TINE20LOCALE', $localeString, time() + 60 * 60 * 24 * 365);
}
return array('success' => TRUE);
}
示例3: setLocale
/**
* sets locale
*
* @param string $localeString
* @param bool $saveaspreference
* @param bool $setcookie
* @return array
*/
public function setLocale($localeString, $saveaspreference, $setcookie)
{
Tinebase_Core::setupUserLocale($localeString);
if ($saveaspreference && is_object(Tinebase_Core::getUser())) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Saving locale: " . $localeString);
}
Tinebase_Core::getPreference()->{Tinebase_Preference::LOCALE} = $localeString;
}
// save in cookie (expires in 365 days)
if ($setcookie) {
setcookie('TINE20LOCALE', $localeString, time() + 60 * 60 * 24 * 365);
}
return array('success' => TRUE);
}
示例4: _initFramework
/**
* init tine framework
*/
protected function _initFramework()
{
$this->_setupCliConfig();
Tinebase_Core::setupTempDir();
Tinebase_Core::setupServerTimezone();
Tinebase_Core::setupLogger();
Tinebase_Core::setupStreamWrapper();
Tinebase_Core::setupSession();
Tinebase_Core::set(Tinebase_Core::LOCALE, new Zend_Locale('en_US'));
Tinebase_Core::set(Tinebase_Core::USERTIMEZONE, 'UTC');
Tinebase_Core::setupDatabaseConnection();
Tinebase_Core::setupCache();
Tinebase_Core::setupUserTimezone();
Tinebase_Core::setupUserLocale();
}
示例5: initFramework
/**
* init the test framework
*/
public function initFramework()
{
$this->setWhiteAndBlacklists();
$config = $this->getConfig();
// set some server vars. sabredav complains if REQUEST_URI is not set
$_SERVER['DOCUMENT_ROOT'] = $config->docroot;
$_SERVER['REQUEST_URI'] = '';
Tinebase_Core::startCoreSession();
Tinebase_Core::initFramework();
// set default test mailer
Tinebase_Smtp::setDefaultTransport(new Zend_Mail_Transport_Array());
// set max execution time
Tinebase_Core::setExecutionLifeTime(1200);
if ($config->locale) {
Tinebase_Core::setupUserLocale($config->locale);
}
// this is needed for session handling in unittests (deactivate Zend_Session::writeClose and others)
Zend_Session::$_unitTestEnabled = TRUE;
Tinebase_Core::set('frameworkInitialized', true);
}
示例6: initUser
/**
* initialize user (session, locale, tz)
*
* @param Tinebase_Model_FullUser $_user
* @param boolean $fixCookieHeader
*/
public function initUser(Tinebase_Model_FullUser $_user, $fixCookieHeader = true)
{
Tinebase_Core::set(Tinebase_Core::USER, $_user);
if (Tinebase_Session_Abstract::getSessionEnabled()) {
$this->_initUserSession($fixCookieHeader);
}
// need to set locale again and because locale might not be set correctly during loginFromPost
// use 'auto' setting because it is fetched from cookie or preference then
Tinebase_Core::setupUserLocale('auto');
// need to set userTimeZone again
$userTimezone = Tinebase_Core::getPreference()->getValue(Tinebase_Preference::TIMEZONE);
Tinebase_Core::setupUserTimezone($userTimezone);
}
示例7: testCustomTranslations
public function testCustomTranslations()
{
$lang = 'en_GB';
$translationPath = Tinebase_Core::getTempDir() . "/tine20/translations";
Tinebase_Config::getInstance()->translations = $translationPath;
$translationDir = "{$translationPath}/{$lang}/Tinebase/translations";
@mkdir($translationDir, 0777, TRUE);
$poFile = "{$translationDir}/{$lang}.po";
$poData = 'msgid ""
msgstr ""
"Project-Id-Version: Tine 2.0 - Tinebase\\n"
"POT-Creation-Date: 2008-05-17 22:12+0100\\n"
"PO-Revision-Date: 2008-07-29 21:14+0100\\n"
"Last-Translator: Cornelius Weiss <c.weiss@metaways.de>\\n"
"Language-Team: Tine 2.0 Translators\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
"X-Poedit-Language: en\\n"
"X-Poedit-Country: US\\n"
"X-Poedit-SourceCharset: utf-8\\n"
"Plural-Forms: nplurals=2; plural=n != 1;\\n"
"X-Tine20-Language: My Language\\n"
"X-Tine20-Country: MY REGION\\n"
#: Acl/Rights/Abstract.php:75
msgid "run"
msgstr "изпълни"
';
file_put_contents($poFile, $poData);
$availableTranslations = Tinebase_Translation::getAvailableTranslations();
foreach ($availableTranslations as $langInfo) {
if ($langInfo['locale'] == $lang) {
$customInfo = $langInfo;
}
}
// assert cutom lang is available
$this->assertTrue(isset($customInfo), 'custom translation not in list of available translations');
$this->assertEquals('My Language', $customInfo['language'], 'custom language param missing');
$this->assertEquals('MY REGION', $customInfo['region'], 'custom region param missing');
// test the translation
$translation = Tinebase_Translation::getTranslation('Tinebase', new Zend_Locale($lang));
// NOTE: Zent_Translate does not work with .po files
//$this->assertEquals("изпълни", $translation->_('run'));
$jsTranslations = Tinebase_Translation::getJsTranslations($lang, 'Tinebase');
$this->assertEquals(1, preg_match('/изпълни/', $jsTranslations));
Tinebase_Core::setupUserLocale();
}
示例8: initFramework
/**
* init tine framework
*/
public static function initFramework()
{
// avoid autostart of sessions
Zend_Session::setOptions(array('strict' => true));
Tinebase_Core::setupTempDir();
Tinebase_Core::setupStreamWrapper();
//Cache must be setup before User Locale because otherwise Zend_Locale tries to setup
//its own cache handler which might result in a open_basedir restriction depending on the php.ini settings
Tinebase_Core::setupCache();
Tinebase_Core::setupBuildConstants();
// setup a temporary user locale. This will be overwritten later but we
// need to handle exceptions during initialisation process such as session timeout
// @todo add fallback locale to config file
Tinebase_Core::set('locale', new Zend_Locale('en_US'));
Tinebase_Core::setupUserLocale();
Tinebase_Core::enableProfiling();
if (PHP_SAPI !== 'cli') {
header('X-API: http://www.tine20.org/apidocs/tine20/');
if (isset($_SERVER['HTTP_X_TRANSACTIONID'])) {
header('X-TransactionID: ' . substr($_SERVER['HTTP_X_TRANSACTIONID'], 1, -1) . ';' . $_SERVER['SERVER_NAME'] . ';16.4.5009.816;' . date('Y-m-d H:i:s') . ' UTC;265.1558 ms');
}
}
}
示例9: initFramework
/**
* init tine framework
*/
public static function initFramework()
{
Tinebase_Core::setupConfig();
// Server Timezone must be setup before logger, as logger has timehandling!
Tinebase_Core::setupServerTimezone();
Tinebase_Core::setupLogger();
// Database Connection must be setup before cache because setupCache uses constant "SQL_TABLE_PREFIX"
Tinebase_Core::setupDatabaseConnection();
Tinebase_Core::setupTempDir();
Tinebase_Core::setupStreamWrapper();
//Cache must be setup before User Locale because otherwise Zend_Locale tries to setup
//its own cache handler which might result in a open_basedir restriction depending on the php.ini settings
Tinebase_Core::setupCache();
Tinebase_Core::setupSession();
// setup a temporary user locale/timezone. This will be overwritten later but we
// need to handle exceptions during initialisation process such as session timeout
// @todo add fallback locale to config file
Tinebase_Core::set('locale', new Zend_Locale('en_US'));
Tinebase_Core::set('userTimeZone', 'UTC');
// Tinebase_Core::setupMailer();
Tinebase_Core::setupUserCredentialCache();
Tinebase_Core::setupUserTimezone();
Tinebase_Core::setupUserLocale();
header('X-API: http://www.tine20.org/apidocs/tine20/');
}
示例10: _initUser
/**
* init user session
*
* @param Tinebase_Model_FullUser $_user
* @param Tinebase_Model_AccessLog $_accessLog
* @param string $_password
*/
protected function _initUser(Tinebase_Model_FullUser $_user, Tinebase_Model_AccessLog $_accessLog, $_password)
{
if ($_accessLog->result === Tinebase_Auth::SUCCESS && $_user->accountStatus === Tinebase_User::STATUS_ENABLED) {
$this->_initUserSession($_user);
Tinebase_Core::set(Tinebase_Core::USER, $_user);
$credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials($_user->accountLoginName, $_password);
Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache);
// need to set locale again and because locale might not be set correctly during loginFromPost
// use 'auto' setting because it is fetched from cookie or preference then
Tinebase_Core::setupUserLocale('auto');
// need to set userTimeZone again
$userTimezone = Tinebase_Core::getPreference()->getValue(Tinebase_Preference::TIMEZONE);
Tinebase_Core::setupUserTimezone($userTimezone);
$_user->setLoginTime($_accessLog->ip);
$_accessLog->sessionid = session_id();
$_accessLog->login_name = $_user->accountLoginName;
$_accessLog->account_id = $_user->getId();
}
}
示例11: _updateContractsFields
/**
* adds "start_date", "end_date" to contract and removes "status", "cleared", "cleared_in"
*/
protected function _updateContractsFields()
{
$adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
$groupMembers = Tinebase_Group::getInstance()->getGroupMembers($adminGroup->getId());
if (count($groupMembers) > 0) {
$user = Tinebase_User::getInstance()->getUserById($groupMembers[0]);
Tinebase_Core::set(Tinebase_Core::USER, $user);
// cleared, cleared_in, status gets deleted, if the update is not called on cli
$controller = Sales_Controller_Contract::getInstance();
$table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'status' => array('name' => 'status'), 'cleared' => array('name' => 'cleared'), 'cleared_in' => array('name' => 'cleared_in'), 'description' => array('name' => 'description'), 'last_modified_time' => array('name' => 'last_modified_time'))));
$count = 50;
$offset = 0;
$more = true;
$updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
$appId = Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId();
$pref = Tinebase_Core::getPreference('Tinebase');
Tinebase_Core::setupUserLocale($pref->locale);
$t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
$config = Sales_Config::getInstance()->get('contractStatus');
foreach ($config['records'] as $cfg) {
$statusConfig[$cfg['id']] = $cfg['value'];
}
$config = Sales_Config::getInstance()->get('contractCleared');
foreach ($config['records'] as $cfg) {
$clearedConfig[$cfg['id']] = $cfg['value'];
}
while ($more) {
$results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
foreach ($results as $row) {
if ($row['status'] == 'CLOSED') {
$setEndDate[$row['id']] = $row['last_modified_time'];
}
$desc = $row['description'];
$desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
$contents = FALSE;
if (!empty($row['status'])) {
$desc .= $t->_('Status') . ': ';
$desc .= isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared'])) {
$desc .= $t->_('Cleared') . ': ';
$desc .= isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared_in'])) {
$desc .= $t->_('Cleared In') . ': ';
$desc .= $row['cleared_in'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if ($contents) {
$updateDescription[$row['id']] = $desc . PHP_EOL;
}
}
if (count($updateDescription) > 50) {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
$updateDescription = array();
}
if (count($results) < $count) {
$more = FALSE;
} else {
$offset = $offset + $count;
}
}
try {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
} catch (Tinebase_Exception_AccessDenied $tead) {
// could not update contracts ...
Tinebase_Exception::log($tead);
}
}
// remove deprecated sales contract fields
foreach (array('status', 'cleared_in', 'cleared') as $colToDrop) {
try {
$this->_backend->dropCol('sales_contracts', $colToDrop);
} catch (Zend_Db_Statement_Exception $zdse) {
Tinebase_Exception::log($zdse);
}
}
// add new sales contract fields
$fields = array('<field>
<name>start_date</name>
<type>datetime</type>
</field>', '
<field>
<name>end_date</name>
<type>datetime</type>
</field>');
//.........这里部分代码省略.........
示例12: _updateContractsWithUser
protected function _updateContractsWithUser($user)
{
Tinebase_Core::set(Tinebase_Core::USER, $user);
// cleared, cleared_in, status gets deleted, if the update is not called on cli
$controller = Sales_Controller_Contract::getInstance();
$table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'status' => array('name' => 'status'), 'cleared' => array('name' => 'cleared'), 'cleared_in' => array('name' => 'cleared_in'), 'description' => array('name' => 'description'), 'last_modified_time' => array('name' => 'last_modified_time'))));
$count = 50;
$offset = 0;
$more = true;
$updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
$pref = Tinebase_Core::getPreference('Tinebase');
Tinebase_Core::setupUserLocale($pref->locale);
$t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
$config = Sales_Config::getInstance()->get('contractStatus');
foreach ($config['records'] as $cfg) {
$statusConfig[$cfg['id']] = $cfg['value'];
}
$config = Sales_Config::getInstance()->get('contractCleared');
foreach ($config['records'] as $cfg) {
$clearedConfig[$cfg['id']] = $cfg['value'];
}
while ($more) {
$results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
foreach ($results as $row) {
if ($row['status'] == 'CLOSED') {
$setEndDate[$row['id']] = $row['last_modified_time'];
}
$desc = $row['description'];
$desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
$contents = FALSE;
if (!empty($row['status'])) {
$desc .= $t->_('Status') . ': ';
$desc .= isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared'])) {
$desc .= $t->_('Cleared') . ': ';
$desc .= isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if (!empty($row['cleared_in'])) {
$desc .= $t->_('Cleared In') . ': ';
$desc .= $row['cleared_in'];
$desc .= PHP_EOL;
$contents = TRUE;
}
if ($contents) {
$updateDescription[$row['id']] = $desc . PHP_EOL;
}
}
if (count($updateDescription) > 50) {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
$updateDescription = array();
}
if (count($results) < $count) {
$more = FALSE;
} else {
$offset = $offset + $count;
}
}
try {
foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
$contr->description = $updateDescription[$contr->getId()];
$controller->update($contr, FALSE);
}
} catch (Tinebase_Exception_AccessDenied $tead) {
// could not update contracts ...
Tinebase_Exception::log($tead);
}
}