public function DomainsMainEdit(ap_Table_Screen &$oScreen) { $sDomainSkin = $sDomainLang = $sDomainZone = ''; /* @var $oDomain CDomain */ $oDomain =& $this->oAdminPanel->GetMainObject('domain_edit'); if ($oDomain) { $oScreen->Data->SetValue('hiddenDomainId', $oDomain->IdDomain); $oScreen->Data->SetValue('classHideDefault', $oDomain->IsDefaultDomain ? 'wm_hide' : ''); $oScreen->Data->SetValue('classHideNotDefault', $oDomain->IsDefaultDomain ? '' : 'wm_hide'); $oScreen->Data->SetValue('classHideOverrideSettings', 0 < $oDomain->IdTenant ? 'wm_hide' : ''); $oScreen->Data->SetValue('classHideSsl', $this->oModule->HasSslSupport() ? '' : 'wm_hide'); $oScreen->Data->SetValue('chOverrideSettings', $oDomain->OverrideSettings); $sDomainSkin = $oDomain->DefaultSkin; $sDomainLang = $oDomain->DefaultLanguage; $sDomainZone = $oDomain->DefaultTimeZone; $sDefaultTab = $oDomain->DefaultTab; $oScreen->Data->SetValue('txtSiteName', $oDomain->SiteName); $oScreen->Data->SetValue('radioTimeFormat12', ETimeFormat::F12 === $oDomain->DefaultTimeFormat); $oScreen->Data->SetValue('radioTimeFormat24', ETimeFormat::F24 === $oDomain->DefaultTimeFormat); $oScreen->Data->SetValue('optDateFormatDDMonthYYYY', EDateFormat::DD_MONTH_YYYY === $oDomain->DefaultDateFormat); $oScreen->Data->SetValue('optDateFormatMMDDYY', EDateFormat::MMDDYY === $oDomain->DefaultDateFormat); $oScreen->Data->SetValue('optDateFormatDDMMYY', EDateFormat::DDMMYY === $oDomain->DefaultDateFormat); $oScreen->Data->SetValue('optDateFormatMMDDYYYY', EDateFormat::MMDDYYYY === $oDomain->DefaultDateFormat); $oScreen->Data->SetValue('optDateFormatDDMMYYYY', EDateFormat::DDMMYYYY === $oDomain->DefaultDateFormat); } $sSkinsOptions = ''; $aSkins = $this->oModule->GetSkinList(); if (is_array($aSkins)) { foreach ($aSkins as $sSkin) { $sSelected = $sSkin === $sDomainSkin ? ' selected="selected"' : ''; $sSkinsOptions .= '<option value="' . ap_Utils::AttributeQuote($sSkin) . '"' . $sSelected . '>' . ap_Utils::EncodeSpecialXmlChars($sSkin) . '</option>'; } $oScreen->Data->SetValue('selSkinsOptions', $sSkinsOptions); } $sTabsOptions = ''; $aTabs = $this->oModule->GetTabList($oDomain); if (is_array($aTabs)) { foreach ($aTabs as $sKeyTab => $sValueTab) { $sSelected = $sKeyTab === $sDefaultTab ? ' selected="selected"' : ''; $sTabsOptions .= '<option value="' . ap_Utils::AttributeQuote($sKeyTab) . '"' . $sSelected . '>' . ap_Utils::EncodeSpecialXmlChars($sValueTab) . '</option>'; } $oScreen->Data->SetValue('selTabsOptions', $sTabsOptions); } $sLanguageOptions = ''; $aLangs = $this->oModule->GetLangsList(); if (is_array($aLangs)) { foreach ($aLangs as $sLang) { $sSelected = $sLang === $sDomainLang ? ' selected="selected"' : ''; $sLanguageOptions .= '<option value="' . ap_Utils::AttributeQuote($sLang) . '"' . $sSelected . '>' . ap_Utils::EncodeSpecialXmlChars($sLang) . '</option>'; } $oScreen->Data->SetValue('selLanguageOptions', $sLanguageOptions); } $sTimeZoneOptions = ''; $aTimeZones = $this->oModule->GetTimeZoneList(); if (is_array($aTimeZones)) { foreach ($aTimeZones as $iIndex => $aTimeZone) { $sSelected = (int) $sDomainZone === (int) $iIndex ? ' selected="selected"' : ''; $sTimeZoneOptions .= '<option value="' . ap_Utils::AttributeQuote($iIndex) . '"' . $sSelected . '>' . ap_Utils::EncodeSpecialXmlChars($aTimeZone) . '</option>'; } $oScreen->Data->SetValue('selTimeZone', $sTimeZoneOptions); } }
/** * @param string $_password * @return bool */ function SaveAdminPassword($_password) { $_path = $this->GetCfg('adminpanel_data_path'); $_xml = new XmlDocument(); if ($_path !== false && $_xml->LoadFromFile($_path . '/settings/' . AP_XML_CFG_FILE)) { $_plugins =& $_xml->XmlRoot->GetChildNodeByTagName('login'); if (!$_plugins) { $_plugins = new XmlDomNode('login'); $_xml->XmlRoot->AppendChild($_plugins); } if ($_plugins) { if ($_password !== null) { $_xml_pass =& $_plugins->GetChildNodeByTagName('password'); if ($_xml_pass) { $_xml_pass->Value = ap_Utils::EncodeSpecialXmlChars($_password); } else { $_xml_pass = new XmlDomNode('password', ap_Utils::EncodeSpecialXmlChars($_password)); $_plugins->AppendChild($_xml_pass); } } if ($_xml->SaveToFile($_path . '/settings/' . AP_XML_CFG_FILE)) { return true; } } } return false; }
/** * @param string $_licenseKey * @return bool */ function _saveLicenseKeyData($_licenseKey) { $_ap =& $this->GetAp(); $_path = $_ap->GetCfg('adminpanel_data_path'); $_xml = new XmlDocument(); if ($_path !== false && $_xml->LoadFromFile($_path . '/settings/' . AP_XML_CFG_FILE)) { $_license_node =& $_xml->XmlRoot->GetChildNodeByTagName('licensekey'); if ($_license_node) { $_license_node->Value = ap_Utils::EncodeSpecialXmlChars($_licenseKey); } else { $_plugins = new XmlDomNode('licensekey', ap_Utils::EncodeSpecialXmlChars($_licenseKey)); $_xml->XmlRoot->AppendChild($_plugins); } if ($_xml->SaveToFile($_path . '/settings/' . AP_XML_CFG_FILE)) { return true; } } else { $_ap->GlobalError(ap_Utils::TakePhrase('CM_FILE_ERROR_OCCURRED')); } return false; }
/** * @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'); }
/** * @param ap_Screen_Data $data * @param Account $account */ function ScreenDataFromAccount(&$_data, &$_account, $_isNewAccount = false) { $_data->SetValue('txtIncomingLogin', $_account->MailIncLogin); if (!$_isNewAccount) { if (strlen($_account->MailIncPassword) > 0) { $_data->SetValue('txtIncomingPassword', AP_DUMMYPASSWORD); } if (strlen($_account->MailOutPassword) > 0) { $_data->SetValue('txtSmtpPassword', AP_DUMMYPASSWORD); } } $_data->SetValue('selectMailProtocolPop3', $_account->MailProtocol == WM_MAILPROTOCOL_POP3); $_data->SetValue('selectMailProtocolImap4', $_account->MailProtocol == WM_MAILPROTOCOL_IMAP4); $_data->SetValue('txtIncomingMail', $_account->MailIncHost); $_data->SetValue('txtSmtpServer', $_account->MailOutHost); $_data->SetValue('intIncomingPort', (int) $_account->MailIncPort); $_data->SetValue('intSmtpPort', (int) $_account->MailOutPort); $_data->SetValue('intLimitMailbox', (int) ceil($_account->MailboxLimit / 1024)); $_data->SetValue('txtFriendlyName', $_account->FriendlyName); $_data->SetValue('txtEmail', $_account->Email); $_quotaJs = ''; if ($this->_settings->TakeImapQuota) { $_quotaJs .= ' var TakeImapQuota = true; '; $_data->SetValue('intTakeImapQuota', (int) ($_account->ImapQuota === 1)); } else { $_quotaJs .= ' var TakeImapQuota = false; '; $_data->SetValue('classTakeImapQuota', 'wm_hide'); } if ($_account->ImapQuota === -1) { $_data->SetValue('infoTakeImapQuotaText', '<br />(IMAP quota is not supported by the server.)'); $_quotaJs .= ' SetDisabled(document.getElementById("intTakeImapQuota"), true, true); '; } if (strlen($_quotaJs) > 0) { $_data->SetValue('infoTakeImapQuotaJs', '<script> ' . $_quotaJs . ' </script>'); } $_data->SetValue('txtSmtpLogin', $_account->MailOutLogin); $_data->SetValue('txtKeepMsgsDays', $_account->MailsOnServerDays); $_data->SetValue('chkUseSmtpAuth', $_account->MailOutAuthentication); $_data->SetValue('chkUseFriendlyName', $_account->UseFriendlyName); $_data->SetValue('chkGetMailAtLogin', $_account->GetMailAtLogin); $_data->SetValue('chkAllowDM', $_account->AllowDirectMode); $_data->SetValue('chkAllowChangeEmail', $_account->AllowChangeSettings); $_data->SetValue('chkUserEnabled', !$_account->Deleted); switch ($_account->MailMode) { case WM_MAILMODE_DeleteMessagesFromServer: $_data->SetValue('radioDelRecvMsgs', true); break; case WM_MAILMODE_LeaveMessagesOnServer: $_data->SetValue('radioLeaveMsgs', true); break; case WM_MAILMODE_KeepMessagesOnServer: $_data->SetValue('radioLeaveMsgs', true); $_data->SetValue('chkKeepMsgs', true); break; case WM_MAILMODE_DeleteMessageWhenItsRemovedFromTrash: $_data->SetValue('radioLeaveMsgs', true); $_data->SetValue('chkDelMsgsSrv', true); break; case WM_MAILMODE_KeepMessagesOnServerAndDeleteMessageWhenItsRemovedFromTrash: $_data->SetValue('radioLeaveMsgs', true); $_data->SetValue('chkKeepMsgs', true); $_data->SetValue('chkDelMsgsSrv', true); break; } $_folderSyncType = $_data->GetValueAsInt('folderSyncType'); if ($_folderSyncType == WM_FOLDERSYNC_NewHeadersOnly || $_folderSyncType == WM_FOLDERSYNC_AllHeadersOnly) { $_data->SetValue('synchronizeSelect1', true); } else { if ($_folderSyncType == WM_FOLDERSYNC_DirectMode) { $_data->SetValue('synchronizeSelect5', true); } else { $_data->SetValue('synchronizeSelect3', true); } } if ($_folderSyncType == WM_FOLDERSYNC_AllHeadersOnly || $_folderSyncType == WM_FOLDERSYNC_AllEntireMessages) { $_data->SetValue('chkDelMsgsDB', true); } // Advanced $_data->SetValue('txtMessagesPerPage', $_account->MailsPerPage); $_data->SetValue('txtContactsPerPage', $_account->ContactsPerPage); $_data->SetValue('intDisableRichEditor', !$_account->AllowDhtmlEditor); $_data->SetValue('intMessageListWithPreviewPane', $_account->ViewMode == WM_VIEW_MODE_PREVIEW_PANE || $_account->ViewMode == WM_VIEW_MODE_PREVIEW_PANE_NO_IMG); $_data->SetValue('intAlwaysShowPictures', $_account->ViewMode == WM_VIEW_MODE_PREVIEW_PANE || $_account->ViewMode == WM_VIEW_MODE_WITHOUT_PREVIEW_PANE); $_skins =& $this->GetSkinsList(); $_skinsString = ''; foreach ($_skins as $_skin) { $_selected = $_skin == $_account->DefaultSkin ? ' selected="selected"' : ''; $_skinsString .= '<option value="' . ap_Utils::AttributeQuote($_skin) . '"' . $_selected . '>' . ap_Utils::EncodeSpecialXmlChars($_skin) . '</option>' . AP_CRLF; } $_data->SetValue('txtDefaultSkin', $_skinsString); $_charsets =& $this->GetCharsetsList(); $_charsetsString = ''; foreach ($_charsets as $_charset) { $_selected = $_charset[0] == $_account->DefaultIncCharset ? ' selected="selected"' : ''; $_charsetsString .= '<option value="' . ap_Utils::AttributeQuote($_charset[0]) . '"' . $_selected . '>' . ap_Utils::EncodeSpecialXmlChars($_charset[1]) . '</option>' . AP_CRLF; } $_data->SetValue('txtDefaultUserCharset', $_charsetsString); $_timezones =& $this->GetTimeZoneList(); $_timezonesString = ''; foreach ($_timezones as $_timezoneKey => $_timezoneValue) { $_selected = $_timezoneKey == $_account->DefaultTimeZone ? ' selected="selected"' : ''; $_timezonesString .= '<option value="' . ap_Utils::AttributeQuote($_timezoneKey) . '"' . $_selected . '>' . ap_Utils::EncodeSpecialXmlChars($_timezoneValue) . '</option>' . AP_CRLF; } $_data->SetValue('txtDefaultTimeZone', $_timezonesString); $_langs =& $this->GetLangsList(); $_langsString = ''; foreach ($_langs as $_lang) { $_selected = $_lang == $_account->DefaultLanguage ? ' selected="selected"' : ''; $_langsString .= '<option value="' . ap_Utils::AttributeQuote($_lang) . '"' . $_selected . '>' . ap_Utils::EncodeSpecialXmlChars($_lang) . '</option>' . AP_CRLF; } $_data->SetValue('txtDefaultLanguage', $_langsString); if ($_account->Aliases && count($_account->Aliases) > 0) { $text = ''; foreach ($_account->Aliases as $value) { $text .= '<option value="' . ap_Utils::AttributeQuote($value) . '">' . ap_Utils::EncodeSpecialXmlChars($value) . '</option>'; } if (strlen($text) > 0) { $_data->SetValue('AliasesListDDL', $text); $text = ''; } } if ($_account->Forwards && count($_account->Forwards) > 0) { $text = ''; foreach ($_account->Forwards as $value) { $text .= '<option value="' . ap_Utils::AttributeQuote($value) . '">' . ap_Utils::EncodeSpecialXmlChars($value) . '</option>'; } if (strlen($text) > 0) { $_data->SetValue('ForwardsListDDL', $text); $text = ''; } } }