本文整理汇总了PHP中Tinebase_Helper::convertToBytes方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Helper::convertToBytes方法的具体用法?PHP Tinebase_Helper::convertToBytes怎么用?PHP Tinebase_Helper::convertToBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Helper
的用法示例。
在下文中一共展示了Tinebase_Helper::convertToBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConvertToBytes
public function testConvertToBytes()
{
$this->assertEquals(1024, Tinebase_Helper::convertToBytes('1024'));
$this->assertEquals(1024, Tinebase_Helper::convertToBytes('1K'));
$this->assertEquals(1024 * 1024, Tinebase_Helper::convertToBytes('1M'));
$this->assertEquals(1024 * 1024 * 1024, Tinebase_Helper::convertToBytes('1G'));
}
示例2: _getAnonymousRegistryData
/**
* get anonymous registry
*
* @return array
*/
protected function _getAnonymousRegistryData()
{
$locale = Tinebase_Core::get('locale');
$tbFrontendHttp = new Tinebase_Frontend_Http();
// default credentials
if (isset(Tinebase_Core::getConfig()->login)) {
$loginConfig = Tinebase_Core::getConfig()->login;
$defaultUsername = isset($loginConfig->username) ? $loginConfig->username : '';
$defaultPassword = isset($loginConfig->password) ? $loginConfig->password : '';
} else {
$defaultUsername = '';
$defaultPassword = '';
}
$symbols = Zend_Locale::getTranslationList('symbols', $locale);
$registryData = array('modSsl' => Tinebase_Auth::getConfiguredBackend() == Tinebase_Auth::MODSSL, 'serviceMap' => $tbFrontendHttp->getServiceMap(), 'locale' => array('locale' => $locale->toString(), 'language' => Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale), 'region' => Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale)), 'version' => array('buildType' => TINE20_BUILDTYPE, 'codeName' => TINE20_CODENAME, 'packageString' => TINE20_PACKAGESTRING, 'releaseTime' => TINE20_RELEASETIME, 'filesHash' => TINE20_BUILDTYPE != 'DEVELOPMENT' ? $tbFrontendHttp->getJsCssHash() : null), 'defaultUsername' => $defaultUsername, 'defaultPassword' => $defaultPassword, 'denySurveys' => Tinebase_Core::getConfig()->denySurveys, 'titlePostfix' => Tinebase_Config::getInstance()->get(Tinebase_Config::PAGETITLEPOSTFIX), 'redirectUrl' => Tinebase_Config::getInstance()->get(Tinebase_Config::REDIRECTURL), 'helpUrl' => Tinebase_Core::getConfig()->helpUrl, 'maxFileUploadSize' => Tinebase_Helper::convertToBytes(ini_get('upload_max_filesize')), 'maxPostSize' => Tinebase_Helper::convertToBytes(ini_get('post_max_size')), 'thousandSeparator' => $symbols['group'], 'decimalSeparator' => $symbols['decimal'], 'filesystemAvailable' => Tinebase_Core::isFilesystemAvailable());
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Anonymous registry: ' . print_r($registryData, TRUE));
}
return $registryData;
}
示例3: _user2Ldap
/**
* convert object with user data to ldap data array
*
* @param Tinebase_Model_FullUser $_user
* @param array $_ldapData the data to be written to ldap
* @param array $_ldapEntry the data currently stored in ldap
*/
protected function _user2Ldap(Tinebase_Model_FullUser $_user, array &$_ldapData, array &$_ldapEntry = array())
{
if ($this instanceof Tinebase_EmailUser_Smtp_Interface) {
if (empty($_user->smtpUser)) {
return;
}
$mailSettings = $_user->smtpUser;
} else {
if (empty($_user->imapUser)) {
return;
}
$mailSettings = $_user->imapUser;
}
foreach ($this->_propertyMapping as $objectProperty => $ldapAttribute) {
$value = empty($mailSettings->{$objectProperty}) ? array() : $mailSettings->{$objectProperty};
switch ($objectProperty) {
case 'emailMailQuota':
// convert to bytes
$_ldapData[$ldapAttribute] = !empty($mailSettings->{$objectProperty}) ? Tinebase_Helper::convertToBytes($mailSettings->{$objectProperty} . 'M') : array();
break;
case 'emailUID':
$_ldapData[$ldapAttribute] = $this->_appendDomain($_user->accountLoginName);
break;
case 'emailGID':
$_ldapData[$ldapAttribute] = $this->_config['emailGID'];
break;
case 'emailForwardOnly':
$_ldapData[$ldapAttribute] = $mailSettings->{$objectProperty} == true ? 'forwardonly' : array();
break;
case 'emailAddress':
$_ldapData[$ldapAttribute] = $_user->accountEmailAddress;
break;
default:
$_ldapData[$ldapAttribute] = $mailSettings->{$objectProperty};
break;
}
}
if ((isset($this->_propertyMapping['emailForwards']) || array_key_exists('emailForwards', $this->_propertyMapping)) && empty($_ldapData[$this->_propertyMapping['emailForwards']])) {
$_ldapData[$this->_propertyMapping['emailForwardOnly']] = array();
}
// check if user has all required object classes. This is needed
// when updating users which where created using different requirements
foreach ($this->_requiredObjectClass as $className) {
if (!in_array($className, $_ldapData['objectclass'])) {
// merge all required classes at once
$_ldapData['objectclass'] = array_unique(array_merge($_ldapData['objectclass'], $this->_requiredObjectClass));
break;
}
}
}
示例4: _getMaxAttachmentSize
/**
* get max attachment size for outgoing mails
*
* - currently it is set to memory_limit / 10
* - returns size in Bytes
*
* @return integer
*/
protected function _getMaxAttachmentSize()
{
$configuredMemoryLimit = ini_get('memory_limit');
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' memory_limit = ' . $configuredMemoryLimit);
}
if ($configuredMemoryLimit === FALSE or $configuredMemoryLimit == -1) {
// set to a big default value
$configuredMemoryLimit = '512M';
}
return Tinebase_Helper::convertToBytes($configuredMemoryLimit) / 10;
}
示例5: _recordToRawData
/**
* returns array of raw Dbmail data
*
* @param Tinebase_Model_EmailUser $_user
* @param Tinebase_Model_EmailUser $_newUserProperties
* @return array
*/
protected function _recordToRawData(Tinebase_Model_FullUser $_user, Tinebase_Model_FullUser $_newUserProperties)
{
$rawData = array();
foreach ($_newUserProperties->imapUser as $key => $value) {
$property = isset($this->_propertyMapping[$key]) || array_key_exists($key, $this->_propertyMapping) ? $this->_propertyMapping[$key] : false;
if ($property && !in_array($key, $this->_readOnlyFields)) {
switch ($key) {
case 'emailPassword':
$rawData[$property] = Hash_Password::generate($this->_config['emailScheme'], $value, false);
$rawData[$this->_propertyMapping['emailScheme']] = $this->_config['emailScheme'];
break;
case 'emailUserId':
case 'emailGID':
case 'emailUsername':
// do nothing
break;
case 'emailMailQuota':
case 'emailMailSize':
case 'emailSieveQuota':
case 'emailSieveSize':
// convert to bytes
$rawData[$property] = Tinebase_Helper::convertToBytes($value . 'M');
break;
default:
$rawData[$property] = $value;
}
}
}
$rawData[$this->_propertyMapping['emailUserId']] = $this->_hasTine20Userid === true ? $_user->getId() : $this->_convertToInt($_user->getId());
if ($this->_hasTine20Userid === true) {
$rawData[$this->_propertyMapping['emailGID']] = $this->_config['emailGID'];
$rawData['client_idnr'] = $this->_convertToInt($this->_config['emailGID']);
} else {
$rawData[$this->_propertyMapping['emailGID']] = $this->_convertToInt($this->_config['emailGID']);
}
$rawData[$this->_propertyMapping['emailUsername']] = $this->_appendDomain($_user->accountLoginName);
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($rawData, TRUE));
}
return $rawData;
}
示例6: environmentCheck
/**
* do php.ini environment check
*
* @return array
*/
public function environmentCheck()
{
$result = array();
$message = array();
$success = TRUE;
// check php environment
$requiredIniSettings = array('magic_quotes_sybase' => 0, 'magic_quotes_gpc' => 0, 'magic_quotes_runtime' => 0, 'mbstring.func_overload' => 0, 'eaccelerator.enable' => 0, 'memory_limit' => '48M');
foreach ($requiredIniSettings as $variable => $newValue) {
$oldValue = ini_get($variable);
if ($variable == 'memory_limit') {
$required = Tinebase_Helper::convertToBytes($newValue);
$set = Tinebase_Helper::convertToBytes($oldValue);
if ($set < $required) {
$result[] = array('key' => $variable, 'value' => FALSE, 'message' => "You need to set {$variable} equal or greater than {$required} (now: {$set})." . $this->_helperLink);
$success = FALSE;
}
} elseif ($oldValue != $newValue) {
if (ini_set($variable, $newValue) === false) {
$result[] = array('key' => $variable, 'value' => FALSE, 'message' => "You need to set {$variable} from {$oldValue} to {$newValue}." . $this->_helperLink);
$success = FALSE;
}
} else {
$result[] = array('key' => $variable, 'value' => TRUE, 'message' => '');
}
}
return array('result' => $result, 'success' => $success);
}
示例7: _isMemoryLeft
/**
* return true there is memory $needed left
*
* @param int $needed
* @return boolean
*/
protected function _isMemoryLeft($needed)
{
if (ini_get('memory_limit') == -1) {
return true;
}
// calculate with an overhead of 1.2
if (Tinebase_Helper::convertToBytes(ini_get('memory_limit')) > memory_get_usage(TRUE) + $needed * 1.2) {
return true;
}
return false;
}
示例8: _setImapQuota
/**
* set quota directly on IMAP server
*
* @param Tinebase_Model_FullUser $_user
* @param Zend_Mail_Protocol_Imap $_imap
* @param string $_mailboxString
*/
protected function _setImapQuota(Tinebase_Model_FullUser $_user, Zend_Mail_Protocol_Imap $_imap = NULL, $_mailboxString = NULL)
{
$imap = $_imap !== NULL ? $_imap : $this->_getImapConnection();
$mailboxString = $_mailboxString !== NULL ? $_mailboxString : $this->_getUserMailbox($_user->accountLoginName);
if (isset($_user->imapUser)) {
$limit = $_user->imapUser->emailMailQuota > 0 ? Tinebase_Helper::convertToBytes($_user->imapUser->emailMailQuota . 'M') / 1024 : null;
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " Setting quota of user " . $_user->getId() . " to " . $limit);
}
$imap->setQuota($mailboxString, 'STORAGE', $limit);
}
}
示例9: getAllRegistryData
/**
* Returns registry data of all applications current user has access to
* @see Tinebase_Application_Json_Abstract
*
* @return mixed array 'variable name' => 'data'
*
* TODO DRY: most of this already is part of Tinebase_Frontend_Json::_getAnonymousRegistryData
*/
public function getAllRegistryData()
{
$registryData['Setup'] = $this->getRegistryData();
// setup also need some core tinebase regdata
$locale = Tinebase_Core::get('locale');
$registryData['Tinebase'] = array('serviceMap' => Setup_Frontend_Http::getServiceMap(), 'timeZone' => Setup_Core::getUserTimezone(), 'jsonKey' => Setup_Core::get('jsonKey'), 'locale' => array('locale' => $locale->toString(), 'language' => Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale), 'region' => Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale)), 'version' => array('buildType' => TINE20_BUILDTYPE, 'codeName' => TINE20SETUP_CODENAME, 'packageString' => TINE20SETUP_PACKAGESTRING, 'releaseTime' => TINE20SETUP_RELEASETIME), 'maxFileUploadSize' => Tinebase_Helper::convertToBytes(ini_get('upload_max_filesize')), 'maxPostSize' => Tinebase_Helper::convertToBytes(ini_get('post_max_size')));
return $registryData;
}