コード例 #1
0
ファイル: modalImport.php プロジェクト: scoutrul/infoscon
        <div class="modal-body sg-modal-body">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="col-md-2 control-label sg-upload-label" for="textinput"><?php 
_t('SGBP file');
?>
</label>
                    <div class="col-md-10">
                        <div class="input-group">
                            <span class="input-group-btn">
                                <span class="btn btn-primary btn-file">
                                    <?php 
_t('Browse');
?>
&hellip; <input type="file" class="sg-backup-upload-input" name="sgbpFile" accept=".sgbp" data-max-file-size="<?php 
echo convertToBytes($maxUploadSize . 'B');
?>
">
                                </span>
                            </span>
                            <input type="text" class="form-control" readonly>
                        </div>
                        <br/>
                        <span class="help-block">Note: If your file is bigger than <?php 
echo $maxUploadSize;
?>
B, you can copy it inside the following folder and it will be automatically detected: <br/><strong><?php 
echo realpath($backupDirectory);
?>
</strong></span>
                    </div>
コード例 #2
0
 /**
  * Returns registry data of tinebase.
  * @see Tinebase_Application_Json_Abstract
  *
  * @return mixed array 'variable name' => 'data'
  */
 public function getRegistryData()
 {
     $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 = '';
     }
     $registryData = array('serviceMap' => $tbFrontendHttp->getServiceMap(), 'timeZone' => Tinebase_Core::get(Tinebase_Core::USERTIMEZONE), '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()->getConfig(Tinebase_Model_Config::PAGETITLEPOSTFIX, NULL, '')->value, 'redirectUrl' => Tinebase_Config::getInstance()->getConfig(Tinebase_Model_Config::REDIRECTURL, NULL, '')->value, 'maxFileUploadSize' => convertToBytes(ini_get('upload_max_filesize')), 'maxPostSize' => convertToBytes(ini_get('post_max_size')));
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $user = Tinebase_Core::getUser();
         $userContactArray = array();
         if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
             try {
                 $userContactArray = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId(), TRUE)->toArray();
             } catch (Addressbook_Exception_NotFound $aenf) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                     Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' User not found in Addressbook: ' . $user->accountDisplayName);
                 }
             }
         }
         $registryData += array('currentAccount' => $user->toArray(), 'userContact' => $userContactArray, 'accountBackend' => Tinebase_User::getConfiguredBackend(), 'jsonKey' => Tinebase_Core::get('jsonKey'), 'userApplications' => $user->getApplications()->toArray(), 'NoteTypes' => $this->getNoteTypes(), 'stateInfo' => Tinebase_State::getInstance()->loadStateInfo(), 'changepw' => Tinebase_User::getBackendConfiguration('changepw', true), 'mustchangepw' => $user->mustChangePassword(), 'mapPanel' => Tinebase_Config::getInstance()->getConfig(Tinebase_Config::MAPPANEL, NULL, TRUE)->value, 'confirmLogout' => Tinebase_Core::getPreference()->getValue(Tinebase_Preference::CONFIRM_LOGOUT, 1), 'persistentFilters' => Tinebase_Frontend_Json_PersistentFilter::getAllPersistentFilters(), 'messenger' => $this->getMessengerConfig());
     }
     return $registryData;
 }
コード例 #3
0
 /**
  * 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 = 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);
                     break;
                 case 'emailUserId':
                 case 'emailGID':
                 case 'emailUsername':
                     // do nothing
                     break;
                 case 'emailMailQuota':
                 case 'emailMailSize':
                 case 'emailSieveQuota':
                 case 'emailSieveSize':
                     // convert to bytes
                     $rawData[$property] = 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);
     $rawData[$this->_propertyMapping['emailScheme']] = $this->_config['emailScheme'];
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($rawData, TRUE));
     }
     return $rawData;
 }
コード例 #4
0
 /**
  * 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);
     $limit = $_user->imapUser->emailMailQuota > 0 ? convertToBytes($_user->imapUser->emailMailQuota . 'M') / 1024 : null;
     $imap->setQuota($mailboxString, 'STORAGE', $limit);
 }
コード例 #5
0
 /**
  * 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 = convertToBytes($newValue);
             $set = 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);
 }
コード例 #6
0
 public function testConvertToBytes()
 {
     $this->assertEquals(1024, convertToBytes('1024'));
     $this->assertEquals(1024, convertToBytes('1K'));
     $this->assertEquals(1024 * 1024, convertToBytes('1M'));
 }
コード例 #7
0
 /**
  * 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->_backendType == Tinebase_Config::SMTP) {
         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}) ? 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 (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;
         }
     }
 }