| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <?php
- namespace ThurData\Servers\KerioEmail\App\Libs\Migrations\Drivers\Version1To2;
- use ThurData\Servers\KerioEmail\App\Helpers\KerioManager;
- use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
- /**
- * Class Settings
- * User: Nessandro
- * Date: 2019-11-12
- * Time: 19:47
- */
- class Settings
- {
- /**
- * @var string
- */
- protected $fromTable = 'mg_prodConfig';
- /**
- * @var string
- */
- protected $toTable = '';
- /**
- * @return string
- */
- public function getFromTable()
- {
- return $this->fromTable;
- }
- /**
- * @param $key
- * @param $value
- * @return array
- */
- public function unsupported($key, $value)
- {
- if(strpos($key, 'cos_') === 0)
- {
- $name = str_replace('cos_', 'cosQuota_', $key);
- return [$name, $value];
- }
- }
- /**
- * @return array
- */
- public function getMapped()
- {
- return [
- 'acc_limit' => 'acc_limit',
- 'acc_size' => 'acc_size',
- 'alias_limit' => 'alias_limit',
- 'cos_name' => 'cos_name',
- 'dist_list_limit' => 'dist_list_limit',
- 'domainMaxSize' => 'domainMaxSize',
- 'domain_alias_limit' => 'domain_alias_limit',
- 'filterAccountsByCOS' => 'filterAccountsByCOS',
- 'login_link' => 'login_link',
- 'useCos', //todo ?
- 'kerioDumpsterEnabled' => 'kerioDumpsterEnabled',
- 'kerioDumpsterPurgeEnabled' => 'kerioDumpsterPurgeEnabled',
- 'kerioFeatureAdvancedSearchEnabled' => 'kerioFeatureAdvancedSearchEnabled',
- 'kerioFeatureBriefcasesEnabled' => 'kerioFeatureBriefcasesEnabled',
- 'kerioFeatureCalendarEnabled' => 'kerioFeatureCalendarEnabled',
- 'kerioFeatureCalendarReminderDeviceEmailEnabled' => 'kerioFeatureCalendarReminderDeviceEmailEnabled',
- 'kerioFeatureChangePasswordEnabled',
- 'kerioFeatureContactsEnabled',
- 'kerioFeatureConversationsEnabled',
- 'kerioFeatureDistributionListFolderEnabled',
- 'kerioFeatureEwsEnabled',
- 'kerioFeatureExportFolderEnabled',
- 'kerioFeatureFiltersEnabled',
- 'kerioFeatureFlaggingEnabled',
- 'kerioFeatureGalAutoCompleteEnabled',
- 'kerioFeatureGalEnabled',
- 'kerioFeatureGroupCalendarEnabled',
- 'kerioFeatureHtmlComposeEnabled',
- 'kerioFeatureIdentitiesEnabled',
- 'kerioFeatureImapDataSourceEnabled',
- 'kerioFeatureImportFolderEnabled',
- 'kerioFeatureInitialSearchPreferenceEnabled',
- 'kerioFeatureMailEnabled',
- 'kerioFeatureMailPriorityEnabled',
- 'kerioFeatureMailSendLaterEnabled',
- 'kerioFeatureManageZimlets',
- 'kerioFeatureMAPIConnectorEnabled',
- 'kerioFeatureNewMailNotificationEnabled',
- 'kerioFeatureOptionsEnabled',
- 'kerioFeatureOutOfOfficeReplyEnabled',
- 'kerioFeaturePeopleSearchEnabled',
- 'kerioFeaturePop3DataSourceEnabled',
- 'kerioFeatureReadReceiptsEnabled',
- 'kerioFeatureSavedSearchesEnabled',
- 'kerioFeatureSharingEnabled',
- 'kerioFeatureSkinChangeEnabled',
- 'kerioFeatureSMIMEEnabled',
- 'kerioFeatureTaggingEnabled',
- 'kerioFeatureTasksEnabled',
- 'kerioFeatureTouchClientEnabled',
- 'kerioFeatureWebClientOfflineAccessEnabled',
- 'kerioImapEnabled',
- 'kerioPop3Enabled',
- ];
- }
- /**
- * @param $params
- * @return mixed
- */
- public function updateValues($params, $prodId)
- {
- foreach($params as $key => $value)
- {
- if(strpos($key, 'cos_') === 0 && $key !== 'cos_name')
- {
- $name = str_replace('cos_', '', $key);
- $cos[$name] = $value;
- unset($params[$key]);
- }
- }
- if($cos)
- {
- $params['cos'] = json_encode($cos);
- }
- /**
- * update cosName
- *
- */
- $defaultTypes = [
- ClassOfServices::CUSTOM_ZIMBRA,
- ClassOfServices::ZIMBRA_CONFIG_OPTIONS,
- ClassOfServices::CLASS_OF_SERVICE_QUOTA,
- ];
- /**
- *
- *
- */
- if(!in_array($params['cos_name'], $defaultTypes))
- {
- $manager = new KerioManager();
- $repository = $manager->getApiByProduct($prodId)->soap->repository();
- $cosList = $repository->cos->all();
- /**
- * class of services from API
- */
- foreach ($cosList as $cos)
- {
- /**
- * @var $cos \ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\ClassOfService
- */
- $cosList[$cos->getName()] = $cos->getId();
- }
- $params['cos_name'] = $cosList[$params['cos_name']];
- }
- return $params;
- }
- /**
- *
- * return new fields as name => default value
- *
- * @return array
- */
- public function getNewFields()
- {
- return [
- 'clientAreaFeaturesLeft' => 'on',
- 'ca_emailAccountPage' => 'on',
- 'ca_ressourcePage' => 'on',
- 'ca_distributionListPage' => 'on',
- 'ca_goToWebmailPage' => 'on',
- 'clientAreaFeaturesRight' => 'on',
- 'ca_emailAliasesPage' => 'on',
- 'ca_domainAliasesPage' => 'on',
- ];
- }
- }
|