Exemple #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');
 }