Пример #1
0
 /**
  * @return bool
  */
 function SaveToXml()
 {
     $xmlDocument = new XmlDocument();
     $xmlDocument->CreateElement('Settings');
     $xmlDocument->XmlRoot->AppendAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
     $xmlDocument->XmlRoot->AppendAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $common = new XmlDomNode('Common');
     $this->AddNode($common, 'SiteName', $this->WindowTitle);
     $this->AddNode($common, 'LicenseKey', $this->LicenseKey);
     $this->AddNode($common, 'AdminPassword', $this->AdminPassword);
     $this->AddNode($common, 'DBType', (int) $this->DbType);
     $this->AddNode($common, 'DBLogin', $this->DbLogin);
     $this->AddNode($common, 'DBPassword', $this->DbPassword);
     $this->AddNode($common, 'DBName', $this->DbName);
     $this->AddNode($common, 'UseDsn', (int) $this->UseDsn);
     $this->AddNode($common, 'DBDSN', $this->DbDsn);
     $this->AddNode($common, 'DBHost', $this->DbHost);
     $this->AddNode($common, 'UseCustomConnectionString', (int) $this->UseCustomConnectionString);
     $this->AddNode($common, 'DBCustomConnectionString', $this->DbCustomConnectionString);
     $this->AddNode($common, 'DBPrefix', ap_Utils::ClearPrefix($this->DbPrefix));
     $this->AddNode($common, 'DefaultSkin', $this->DefaultSkin);
     $this->AddNode($common, 'AllowUsersChangeSkin', (int) $this->AllowUsersChangeSkin);
     $this->AddNode($common, 'DefaultLanguage', $this->DefaultLanguage);
     $this->AddNode($common, 'AllowUsersChangeLanguage', (int) $this->AllowUsersChangeLanguage);
     $this->AddNode($common, 'EnableMobileSync', (bool) $this->EnableMobileSync);
     $this->AddNode($common, 'MobileSyncUrl', $this->MobileSyncUrl);
     $this->AddNode($common, 'MobileSyncContactDataBase', $this->MobileSyncContactDataBase);
     $this->AddNode($common, 'MobileSyncCalendarDataBase', $this->MobileSyncCalendarDataBase);
     $xmlDocument->XmlRoot->AppendChild($common);
     $webmail = new XmlDomNode('WebMail');
     $this->AddNode($webmail, 'IncomingMailProtocol', (int) $this->IncomingMailProtocol);
     $this->AddNode($webmail, 'IncomingMailServer', $this->IncomingMailServer);
     $this->AddNode($webmail, 'IncomingMailPort', (int) $this->IncomingMailPort);
     $this->AddNode($webmail, 'OutgoingMailServer', $this->OutgoingMailServer);
     $this->AddNode($webmail, 'OutgoingMailPort', (int) $this->OutgoingMailPort);
     $this->AddNode($webmail, 'ReqSmtpAuth', (int) $this->ReqSmtpAuth);
     $this->AddNode($webmail, 'AllowAdvancedLogin', (int) $this->AllowAdvancedLogin);
     $this->AddNode($webmail, 'HideLoginMode', (int) $this->HideLoginMode);
     $this->AddNode($webmail, 'DefaultDomainOptional', $this->DefaultDomainOptional);
     $this->AddNode($webmail, 'UseMultipleDomainsSelection', (int) $this->UseMultipleDomainsSelection);
     $this->AddNode($webmail, 'UseCaptcha', (int) $this->UseCaptcha);
     $this->AddNode($webmail, 'ShowTextLabels', (int) $this->ShowTextLabels);
     $this->AddNode($webmail, 'AutomaticCorrectLoginSettings', (int) $this->AutomaticCorrectLoginSettings);
     $EnableLogging = (int) $this->EnableLogging;
     if ($this->LoggingSpecialUsers) {
         $EnableLogging++;
     }
     $this->AddNode($webmail, 'EnableLogging', (int) $EnableLogging);
     $this->AddNode($webmail, 'LogLevel', (int) $this->LogLevel);
     $this->AddNode($webmail, 'EnableEventsLogging', (int) $this->EnableEventsLogging);
     $this->AddNode($webmail, 'DisableErrorHandling', (int) $this->DisableErrorHandling);
     $this->AddNode($webmail, 'AllowAjax', (int) $this->AllowAjax);
     $this->AddNode($webmail, 'MailsPerPage', (int) $this->MailsPerPage);
     $this->AddNode($webmail, 'EnableAttachmentSizeLimit', (int) $this->EnableAttachmentSizeLimit);
     $this->AddNode($webmail, 'AttachmentSizeLimit', GetGoodBigInt($this->AttachmentSizeLimit));
     $this->AddNode($webmail, 'EnableMailboxSizeLimit', (int) $this->EnableMailboxSizeLimit);
     $this->AddNode($webmail, 'MailboxSizeLimit', GetGoodBigInt($this->MailboxSizeLimit));
     $this->AddNode($webmail, 'TakeImapQuota', (int) $this->TakeImapQuota);
     $this->AddNode($webmail, 'DefaultTimeZone', $this->DefaultTimeZone);
     $this->AddNode($webmail, 'AllowUsersChangeTimeZone', (int) $this->AllowUsersChangeTimeZone);
     $this->AddNode($webmail, 'DefaultUserCharset', (int) CWebMail_Plugin::GetCodePageNumber($this->DefaultUserCharset));
     $this->AddNode($webmail, 'AllowUsersChangeCharset', (int) $this->AllowUsersChangeCharset);
     $this->AddNode($webmail, 'AllowDHTMLEditor', (int) $this->AllowDhtmlEditor);
     $this->AddNode($webmail, 'AllowUsersChangeEmailSettings', (int) $this->AllowUsersChangeEmailSettings);
     $this->AddNode($webmail, 'AllowDirectMode', (int) $this->AllowDirectMode);
     $this->AddNode($webmail, 'DirectModeIsDefault', (int) $this->DirectModeIsDefault);
     $this->AddNode($webmail, 'AllowNewUsersRegister', (int) $this->AllowNewUsersRegister);
     $this->AddNode($webmail, 'AllowUsersAddNewAccounts', (int) $this->AllowUsersAddNewAccounts);
     $this->AddNode($webmail, 'AllowUsersChangeAccountsDef', (int) $this->AllowUsersChangeAccountsDef);
     $this->AddNode($webmail, 'StoreMailsInDb', (int) $this->StoreMailsInDb);
     $this->AddNode($webmail, 'AllowContacts', (int) $this->AllowContacts);
     $this->AddNode($webmail, 'AllowCalendar', (int) $this->AllowCalendar);
     $this->AddNode($webmail, 'AllowLanguageOnLogin', (int) $this->AllowLanguageOnLogin);
     $this->AddNode($webmail, 'Imap4DeleteLikePop3', (int) $this->Imap4DeleteLikePop3);
     $this->AddNode($webmail, 'AllowInsertImage', (int) $this->AllowInsertImage);
     $this->AddNode($webmail, 'AllowBodySize', (int) $this->AllowBodySize);
     $this->AddNode($webmail, 'MaxBodySize', (int) $this->MaxBodySize);
     $this->AddNode($webmail, 'MaxSubjectSize', (int) $this->MaxSubjectSize);
     $this->AddNode($webmail, 'EnableWmServer', (int) $this->EnableWmServer);
     $this->AddNode($webmail, 'WmServerRootPath', $this->WmServerRootPath);
     $this->AddNode($webmail, 'WmServerHost', $this->WmServerHost);
     $this->AddNode($webmail, 'WmAllowManageXMailAccounts', (int) $this->WmAllowManageXMailAccounts);
     $this->AddNode($webmail, 'IdleSessionTimeout', (int) $this->IdleSessionTimeout);
     $this->AddNode($webmail, 'AllowRegistration', (int) $this->AllowRegistration);
     $this->AddNode($webmail, 'AllowPasswordReset', (int) $this->AllowPasswordReset);
     $this->AddNode($webmail, 'GlobalAddressBook', $this->GlobalAddressBook);
     $this->AddNode($webmail, 'FlagsLangSelect', (int) $this->FlagsLangSelect);
     $this->AddNode($webmail, 'ViewMode', (int) $this->ViewMode);
     $this->AddNode($webmail, 'SaveInSent', (int) $this->SaveInSent);
     $xmlDocument->XmlRoot->AppendChild($webmail);
     $calendar = new XmlDomNode('Calendar');
     $this->AddNode($calendar, 'DefaultTimeFormat', (int) $this->Cal_DefaultTimeFormat);
     $this->AddNode($calendar, 'DefaultDateFormat', (int) $this->Cal_DefaultDateFormat);
     $this->AddNode($calendar, 'ShowWeekends', (int) $this->Cal_ShowWeekends);
     $this->AddNode($calendar, 'WorkdayStarts', (int) $this->Cal_WorkdayStarts);
     $this->AddNode($calendar, 'WorkdayEnds', (int) $this->Cal_WorkdayEnds);
     $this->AddNode($calendar, 'ShowWorkDay', (int) $this->Cal_ShowWorkDay);
     $this->AddNode($calendar, 'WeekStartsOn', (int) $this->Cal_WeekStartsOn);
     $this->AddNode($calendar, 'DefaultTab', (int) $this->Cal_DefaultTab);
     $this->AddNode($calendar, 'DefaultCountry', $this->Cal_DefaultCountry);
     $this->AddNode($calendar, 'DefaultTimeZone', (int) $this->Cal_DefaultTimeZone);
     $this->AddNode($calendar, 'AllTimeZones', (int) $this->Cal_AllTimeZones);
     $this->AddNode($calendar, 'AllowReminders', (int) $this->Cal_AllowReminders);
     $this->AddNode($calendar, 'AutoAddInvitation', (int) $this->Cal_AutoAddInvitation);
     $xmlDocument->XmlRoot->AppendChild($calendar);
     if (strlen($this->Dev) > 0) {
         $xmlDocument->XmlRoot->AppendChild(new XmlDomNode('Dev', ap_Utils::EncodeSpecialXmlChars($this->Dev)));
     }
     if (AP_USE_XML_CACHE) {
         $out = array();
         foreach ($this as $key => $value) {
             if (strlen($key) > 0) {
                 if ($key[0] === '_' || $key === 'isLoad') {
                     continue;
                 }
                 if (is_int($value)) {
                     $out[] = '\'' . $key . '\'=>' . $value;
                 } else {
                     $out[] = '\'' . $key . '\'=>\'' . ap_Utils::ClearStringValue(ap_Utils::EncodeSpecialXmlChars($value), '\'') . '\'';
                 }
             }
         }
         file_put_contents($this->_path . '/settings/settings.xml.cache', '<?php return array(' . implode(",\r\n", $out) . ');');
     }
     return $xmlDocument->SaveToFile($this->_path . '/settings/settings.xml');
 }
Пример #2
0
 function UpdateSettings(&$settings)
 {
     if (!$settings) {
         return false;
     }
     $settings->WindowTitle = $this->GetSettingsValue('site_name');
     $settings->IncomingMailProtocol = (int) $this->GetSettingsValue('settings_mail_protocol');
     $settings->IncomingMailServer = $this->GetSettingsValue('settings_mail_inc_host');
     $settings->IncomingMailPort = (int) $this->GetSettingsValue('settings_mail_inc_port');
     $settings->OutgoingMailServer = $this->GetSettingsValue('settings_mail_out_host');
     $settings->OutgoingMailPort = (int) $this->GetSettingsValue('settings_mail_out_port');
     $settings->ReqSmtpAuth = (bool) $this->GetSettingsValue('settings_mail_out_auth');
     $settings->AllowDirectMode = (bool) $this->GetSettingsValue('allow_direct_mode');
     $settings->DirectModeIsDefault = (bool) $this->GetSettingsValue('direct_mode_id_def');
     $settings->AttachmentSizeLimit = (int) $this->GetSettingsValue('attachment_size_limit');
     $settings->EnableAttachmentSizeLimit = (bool) $this->GetSettingsValue('allow_attachment_limit');
     $settings->MailboxSizeLimit = (int) $this->GetSettingsValue('mailbox_size_limit');
     $settings->EnableMailboxSizeLimit = (bool) $this->GetSettingsValue('allow_mailbox_limit');
     $settings->TakeImapQuota = (bool) $this->GetSettingsValue('take_quota');
     $settings->AllowUsersChangeEmailSettings = (bool) $this->GetSettingsValue('allow_new_users_change_set');
     $settings->AllowNewUsersRegister = (bool) $this->GetSettingsValue('allow_auto_reg_on_login');
     $settings->AllowUsersAddNewAccounts = (bool) $this->GetSettingsValue('allow_users_add_accounts');
     $settings->AllowUsersChangeAccountsDef = (bool) $this->GetSettingsValue('allow_users_change_account_def');
     $settings->DefaultUserCharset = CWebMail_Plugin::GetCodePageName((int) $this->GetSettingsValue('def_user_charset'));
     $settings->AllowUsersChangeCharset = (bool) $this->GetSettingsValue('allow_users_change_charset');
     $settings->DefaultTimeZone = (int) $this->GetSettingsValue('def_user_timezone');
     $settings->AllowUsersChangeTimeZone = (bool) $this->GetSettingsValue('allow_users_change_timezone');
     $settings->MailsPerPage = (int) $this->GetSettingsValue('msgs_per_page');
     $settings->DefaultSkin = $this->GetSettingsValue('skin');
     $settings->AllowUsersChangeSkin = (bool) $this->GetSettingsValue('allow_users_change_skin');
     $settings->DefaultLanguage = $this->GetSettingsValue('lang');
     $settings->AllowUsersChangeLanguage = (bool) $this->GetSettingsValue('allow_users_change_lang');
     $settings->ShowTextLabels = (bool) $this->GetSettingsValue('show_text_labels');
     $settings->AllowAjax = true;
     $settings->AllowDhtmlEditor = (bool) $this->GetSettingsValue('allow_editor');
     $settings->AllowContacts = (bool) $this->GetSettingsValue('allow_contacts');
     $settings->AllowCalendar = (bool) $this->GetSettingsValue('allow_calendar');
     $settings->HideLoginMode = (int) $this->GetSettingsValue('hide_login_mode');
     $settings->DefaultDomainOptional = $this->GetSettingsValue('domain_to_use');
     $settings->AllowLanguageOnLogin = (bool) $this->GetSettingsValue('allow_choosing_lang');
     $settings->AllowAdvancedLogin = (bool) $this->GetSettingsValue('allow_advanced_login');
     $settings->AutomaticCorrectLoginSettings = (bool) $this->GetSettingsValue('allow_auto_detect_and_correct');
     $settings->UseCaptcha = (bool) $this->GetSettingsValue('use_captcha');
     $settings->UseMultipleDomainsSelection = (bool) $this->GetSettingsValue('use_domain_selection');
     $settings->ViewMode = (int) $this->GetSettingsValue('view_mode');
     $settings->SaveInSent = (int) $this->GetSettingsValue('save_mail');
 }