function GetSettingsList(&$_xmlRes, &$_account, $_settings, &$_dbStorage, &$mailProcessor) { $_mailBoxesSize = $_account->MailboxSize; $_accountSize = $_account->MailboxSize; if ($_account->ImapQuota) { if ($mailProcessor && $mailProcessor->MailStorage->Connect(true)) { $usedQuota = $mailProcessor->GetUsedQuota(); if (false !== $usedQuota) { $_mailBoxesSize = $usedQuota; $_accountSize = $usedQuota; } } } else { if (USE_DB && $_dbStorage && $_dbStorage->Connect()) { $_mailBoxesSize = $_dbStorage->SelectMailboxesSize(); } } $_settingsListNode = new XmlDomNode('settings_list'); $_settingsListNode->AppendAttribute('show_text_labels', (int) $_settings->ShowTextLabels); $_settingsListNode->AppendAttribute('allow_change_settings', (int) $_account->AllowChangeSettings); $_settingsListNode->AppendAttribute('allow_dhtml_editor', (int) $_account->AllowDhtmlEditor); $_settingsListNode->AppendAttribute('allow_add_account', (int) $_settings->AllowUsersAddNewAccounts); $_settingsListNode->AppendAttribute('allow_account_def', (int) $_settings->AllowUsersChangeAccountsDef); $_settingsListNode->AppendAttribute('msgs_per_page', (int) $_account->MailsPerPage); $_settingsListNode->AppendAttribute('contacts_per_page', (int) $_account->ContactsPerPage); $_settingsListNode->AppendAttribute('auto_checkmail_interval', (int) $_account->AutoCheckMailInterval); $_settingsListNode->AppendAttribute('mailbox_limit', GetGoodBigInt($_account->MailboxLimit)); $_settingsListNode->AppendAttribute('enable_mailbox_size_limit', (int) $_settings->EnableMailboxSizeLimit); $_settingsListNode->AppendAttribute('mailbox_size', GetGoodBigInt($_mailBoxesSize)); $_settingsListNode->AppendAttribute('account_size', GetGoodBigInt($_accountSize)); $_settingsListNode->AppendAttribute('hide_folders', (int) $_account->HideFolders); $_settingsListNode->AppendAttribute('horiz_resizer', (int) $_account->HorizResizer); $_settingsListNode->AppendAttribute('vert_resizer', (int) $_account->VertResizer); $_settingsListNode->AppendAttribute('mark', (int) $_account->Mark); $_settingsListNode->AppendAttribute('reply', (int) $_account->Reply); $_settingsListNode->AppendAttribute('view_mode', (int) $_account->ViewMode); $_settingsListNode->AppendAttribute('def_timezone', $_account->DefaultTimeZone); $_settingsListNode->AppendAttribute('allow_direct_mode', (int) $_account->AllowDirectMode); $_settingsListNode->AppendAttribute('direct_mode_is_default', (int) $_settings->DirectModeIsDefault); $_settingsListNode->AppendAttribute('allow_contacts', (int) $_settings->AllowContacts); $_settingsListNode->AppendAttribute('allow_calendar', (int) $_settings->AllowCalendar); $_settingsListNode->AppendAttribute('imap4_delete_like_pop3', (int) $_settings->Imap4DeleteLikePop3); $_settingsListNode->AppendAttribute('idle_session_timeout', (int) $_settings->IdleSessionTimeout); $_settingsListNode->AppendAttribute('allow_insert_image', (int) $_settings->AllowInsertImage); $_settingsListNode->AppendAttribute('allow_body_size', (int) $_settings->AllowBodySize); $_settingsListNode->AppendAttribute('max_body_size', (int) $_settings->MaxBodySize); $_settingsListNode->AppendAttribute('max_subject_size', (int) $_settings->MaxSubjectSize); $_settingsListNode->AppendAttribute('mobile_sync_enable_system', (int) ($_settings->EnableMobileSync && function_exists('mcrypt_encrypt'))); $_skin = ''; $_skins =& FileSystem::GetSkinsList(); $_hasDefSettingsSkin = false; foreach ($_skins as $_skinName) { if ($_skinName == $_settings->DefaultSkin) { $_hasDefSettingsSkin = true; } if ($_skinName == $_account->DefaultSkin) { $_skin = $_account->DefaultSkin; break; } } if ($_skin === '') { $_skin = $_hasDefSettingsSkin ? $_settings->DefaultSkin : $_skins[0]; } $_settingsListNode->AppendChild(new XmlDomNode('def_skin', $_skin, true)); $_settingsListNode->AppendChild(new XmlDomNode('def_lang', $_account->DefaultLanguage, true)); $_settingsListNode->AppendChild(new XmlDomNode('def_date_fmt', $_account->DefaultDateFormat, true)); $_settingsListNode->AppendAttribute('time_format', $_account->DefaultTimeFormat); if (is_array($_account->Columns) && count($_account->Columns) > 0) { $_columnsNode = new XmlDomNode('columns'); foreach ($_account->Columns as $_id_column => $_column_value) { $_columnNode = new XmlDomNode('column'); $_columnNode->AppendAttribute('id', $_id_column); $_columnNode->AppendAttribute('value', $_column_value); $_columnsNode->AppendChild($_columnNode); unset($_columnNode); } $_settingsListNode->AppendChild($_columnsNode); } $_xmlRes->XmlRoot->AppendChild($_settingsListNode); }
/** * @param string $name * @return int */ function GetValueAsInt($name) { return GetGoodBigInt($this->GetValue($name)); }
/** * @return int */ function SelectMailboxesSize() { $mailBoxesSize = 0; if ($this->_dbConnection->Execute($this->_commandCreator->SelectMailboxesSize($this->Account->IdUser))) { while (false !== ($row = $this->_dbConnection->GetNextRecord())) { $mailBoxesSize = GetGoodBigInt($row->mailboxes_size); } } return $mailBoxesSize; }
/** * * @param WebMail_Settings $settings * @param CWebMailDomain $domain[optional] = null * @return Account */ function Account($settings, $domain = null) { $this->_settings =& $settings; if ($settings->MailsPerPage > 0) { $this->MailsPerPage = (int) $settings->MailsPerPage; } $this->DefaultSkin = $settings->DefaultSkin; $this->DefaultLanguage = $settings->DefaultLanguage; $this->DefaultTimeZone = $settings->DefaultTimeZone; $this->MailboxLimit = GetGoodBigInt($settings->MailboxSizeLimit); $this->AllowDirectMode = $settings->AllowDirectMode; $this->AllowChangeSettings = $settings->AllowUsersChangeEmailSettings; $this->ViewMode = $settings->ViewMode; if ($domain !== null) { $this->MailProtocol = $domain->_mailProtocol; $this->DomainId = $domain->_id; $this->MailIncHost = $domain->_mailIncomingHost; $this->MailIncPort = $domain->_mailIncomingPort; $this->MailOutHost = $domain->_mailSmtpHost; $this->MailOutPort = $domain->_mailSmtpPort; $this->MailOutAuthentication = $domain->_mailSmtpAuth; $this->IsInternal = (bool) $domain->_isInternal; } $this->DefaultIncCharset = $settings->DefaultUserCharset; $this->DefaultOutCharset = $settings->DefaultUserCharset; $this->Columns = array(); $this->Aliases = array(); $this->Forwards = array(); $this->MailingList = array(); $this->AllowDhtmlEditor = $settings->AllowDhtmlEditor; $this->ImapQuota = (int) $settings->TakeImapQuota; $this->ViewMode = (int) $settings->ViewMode; /* custom class */ ap_Custom::StaticUseMethod('wm_ChangeAccountAfterClassCreate', array(&$this)); }
/** * @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'); }
/** * @access private * @param XmlDomNode $xmlTree */ function _loadFromXML(&$xmlTree) { foreach ($xmlTree->Children as $node) { switch ($node->TagName) { case 'Common': case 'WebMail': case 'Calendar': if (count($node->Children) > 0) { $this->_loadFromXML($node); } break; case 'SiteName': $this->WindowTitle = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'WindowTitle': $this->WindowTitle = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'LicenseKey': $this->LicenseKey = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'AdminPassword': $this->AdminPassword = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'DBType': $this->DbType = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'DBLogin': $this->DbLogin = trim(ConvertUtils::WMBackHtmlSpecialChars($node->Value)); break; case 'DBPassword': $this->DbPassword = trim(ConvertUtils::WMBackHtmlSpecialChars($node->Value)); break; case 'DBName': $this->DbName = trim(ConvertUtils::WMBackHtmlSpecialChars($node->Value)); break; case 'UseDsn': $this->UseDsn = (bool) $node->Value; case 'DBDSN': $this->DbDsn = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'DBHost': $this->DbHost = trim(ConvertUtils::WMBackHtmlSpecialChars($node->Value)); break; case 'UseCustomConnectionString': $this->UseCustomConnectionString = (bool) $node->Value; break; case 'DBCustomConnectionString': $this->DbCustomConnectionString = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'DBPrefix': $this->DbPrefix = ConvertUtils::ClearPrefix(ConvertUtils::WMBackHtmlSpecialChars($node->Value)); break; case 'IncomingMailProtocol': $this->IncomingMailProtocol = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'IncomingMailServer': $this->IncomingMailServer = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'IncomingMailPort': $this->IncomingMailPort = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'OutgoingMailServer': $this->OutgoingMailServer = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'OutgoingMailPort': $this->OutgoingMailPort = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'ReqSmtpAuth': $this->ReqSmtpAuth = (bool) $node->Value; break; case 'AllowAdvancedLogin': $this->AllowAdvancedLogin = (bool) $node->Value; break; case 'HideLoginMode': $this->HideLoginMode = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'DefaultDomainOptional': $this->DefaultDomainOptional = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'UseMultipleDomainsSelection': $this->UseMultipleDomainsSelection = (bool) $node->Value; break; case 'UseCaptcha': $this->UseCaptcha = (bool) $node->Value; break; case 'ShowTextLabels': $this->ShowTextLabels = (bool) $node->Value; break; case 'AutomaticCorrectLoginSettings': $this->AutomaticCorrectLoginSettings = (bool) $node->Value; break; case 'EnableLogging': $this->EnableLogging = (bool) (0 < (int) $node->Value); $this->LoggingSpecialUsers = (bool) (2 === (int) $node->Value); break; case 'LogLevel': $this->LogLevel = (int) $node->Value; break; case 'EnableEventsLogging': $this->EnableEventsLogging = (bool) $node->Value; break; case 'DisableErrorHandling': $this->DisableErrorHandling = (bool) $node->Value; break; case 'AllowAjax': $this->AllowAjax = true; break; case 'MailsPerPage': $this->MailsPerPage = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'EnableAttachmentSizeLimit': $this->EnableAttachmentSizeLimit = (bool) $node->Value; break; case 'AttachmentSizeLimit': $this->AttachmentSizeLimit = GetGoodBigInt(ConvertUtils::WMBackHtmlSpecialChars($node->Value)); break; case 'EnableMailboxSizeLimit': $this->EnableMailboxSizeLimit = (bool) $node->Value; break; case 'MailboxSizeLimit': $this->MailboxSizeLimit = GetGoodBigInt(ConvertUtils::WMBackHtmlSpecialChars($node->Value)); break; case 'TakeImapQuota': $this->TakeImapQuota = (bool) $node->Value; break; case 'AllowUsersChangeTimeZone': $this->AllowUsersChangeTimeZone = (bool) $node->Value; break; case 'DefaultUserCharset': $this->DefaultUserCharset = ConvertUtils::GetCodePageName($node->Value); break; case 'AllowUsersChangeCharset': $this->AllowUsersChangeCharset = (bool) ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'DefaultSkin': $this->DefaultSkin = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'AllowUsersChangeSkin': $this->AllowUsersChangeSkin = (bool) $node->Value; break; case 'DefaultLanguage': $this->DefaultLanguage = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'AllowUsersChangeLanguage': $this->AllowUsersChangeLanguage = (bool) $node->Value; break; case 'AllowDHTMLEditor': $this->AllowDhtmlEditor = (bool) $node->Value; break; case 'AllowUsersChangeEmailSettings': $this->AllowUsersChangeEmailSettings = (bool) $node->Value; break; case 'AllowDirectMode': $this->AllowDirectMode = (bool) $node->Value; break; case 'DirectModeIsDefault': $this->DirectModeIsDefault = (bool) $node->Value; break; case 'AllowNewUsersRegister': $this->AllowNewUsersRegister = true; break; case 'AllowUsersAddNewAccounts': $this->AllowUsersAddNewAccounts = false; break; case 'AllowUsersChangeAccountsDef': $this->AllowUsersChangeAccountsDef = (bool) $node->Value; break; case 'StoreMailsInDb': $this->StoreMailsInDb = (bool) $node->Value; break; case 'Imap4DeleteLikePop3': $this->Imap4DeleteLikePop3 = (bool) $node->Value; break; case 'EnableWmServer': $this->EnableWmServer = (bool) $node->Value; break; case 'WmServerRootPath': $this->WmServerRootPath = rtrim(ConvertUtils::WMBackHtmlSpecialChars($node->Value), '\\/'); break; case 'WmServerHost': $this->WmServerHost = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'WmAllowManageXMailAccounts': $this->WmAllowManageXMailAccounts = (bool) $node->Value; break; case 'AllowContacts': $this->AllowContacts = (bool) $node->Value; break; case 'AllowCalendar': $this->AllowCalendar = false; break; case 'DefaultTimeZone': if ($xmlTree->TagName == 'Calendar') { $this->Cal_DefaultTimeZone = (int) $node->Value; } else { $this->DefaultTimeZone = (int) $node->Value; } break; case 'DefaultTimeFormat': $this->Cal_DefaultTimeFormat = (int) $node->Value; break; case 'DefaultDateFormat': $this->Cal_DefaultDateFormat = (int) $node->Value; break; case 'ShowWeekends': $this->Cal_ShowWeekends = (int) $node->Value; break; case 'WorkdayStarts': $this->Cal_WorkdayStarts = (int) $node->Value; break; case 'WorkdayEnds': $this->Cal_WorkdayEnds = (int) $node->Value; break; case 'ShowWorkDay': $this->Cal_ShowWorkDay = (int) $node->Value; break; case 'WeekStartsOn': $this->Cal_WeekStartsOn = (int) $node->Value; break; case 'DefaultTab': $this->Cal_DefaultTab = (int) $node->Value; break; case 'DefaultCountry': $this->Cal_DefaultCountry = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'AllTimeZones': $this->Cal_AllTimeZones = (int) $node->Value; break; case 'AllowReminders': $this->Cal_AllowReminders = (bool) $node->Value; break; case 'AutoAddInvitation': $this->Cal_AutoAddInvitation = (int) $node->Value; break; case 'AllowLanguageOnLogin': $this->AllowLanguageOnLogin = (bool) $node->Value; break; case 'IdleSessionTimeout': $this->IdleSessionTimeout = (int) $node->Value; break; case 'AllowInsertImage': $this->AllowInsertImage = (bool) $node->Value; break; case 'AllowBodySize': $this->AllowBodySize = (bool) $node->Value; break; case 'MaxBodySize': $this->MaxBodySize = (int) $node->Value; break; case 'MaxSubjectSize': $this->MaxSubjectSize = (int) $node->Value; break; case 'AllowRegistration': $this->AllowRegistration = (int) $node->Value; break; case 'AllowPasswordReset': $this->AllowPasswordReset = (int) $node->Value; break; case 'GlobalAddressBook': $this->GlobalAddressBook = GLOBAL_ADDRESS_BOOK_OFF; break; case 'EnableMobileSync': $this->EnableMobileSync = (bool) $node->Value; break; case 'MobileSyncUrl': $this->MobileSyncUrl = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'MobileSyncContactDataBase': $this->MobileSyncContactDataBase = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'MobileSyncCalendarDataBase': $this->MobileSyncCalendarDataBase = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; case 'FlagsLangSelect': $this->FlagsLangSelect = (bool) $node->Value; break; case 'ViewMode': $this->ViewMode = (int) $node->Value; break; case 'SaveInSent': $this->SaveInSent = (int) $node->Value; break; case 'Dev': $this->Dev = ConvertUtils::WMBackHtmlSpecialChars($node->Value); break; } } }
/** * @param Settings $_settings * @param MySqlStorage $_dbStorage * @param CWebMailLoginInfo $loginInfo * @param Account $refAccount * @param string $errorString */ function Init(&$_settings, &$_dbStorage, &$loginInfo, &$refAccount, &$errorString) { $accountCustomValues = array(); $_log =& CLog::CreateInstance(); $_isNoLoginField = false; $_sendSettingsList = false; /* custom class */ wm_Custom::StaticUseMethod('ChangeLoginInfoBeforeInit', array(&$loginInfo)); $_infoEmail = trim($loginInfo->getEmail()); $_infoLogin = trim($loginInfo->getLogin()); $_infoPassword = $loginInfo->getPassword(); $_infoAdvancedLogin = $loginInfo->getAdvancedLogin(); $_infoLang = trim($loginInfo->getLanguage()); $_domain = $loginInfo->getDomainsSelectValue(); $_email = $_login = $_optLogin = ''; if ($_infoAdvancedLogin && $_settings->AllowAdvancedLogin) { $_email = $_infoEmail; $_login = $_infoLogin; } else { switch ($_settings->HideLoginMode) { case 0: $_email = $_infoEmail; $_login = $_infoLogin; break; case 10: $_email = $_infoEmail; $_isNoLoginField = true; $_emailAddress = new EmailAddress(); $_emailAddress->SetAsString($_email); $_optLogin = $_emailAddress->GetAccountName(); break; case 11: $_email = $_infoEmail; $_isNoLoginField = true; $_optLogin = $_email; break; case 20: case 21: $_login = $_infoLogin; $loginArray = ConvertUtils::ParseEmail($_login); if (20 == $_settings->HideLoginMode) { if (is_array($loginArray) && 2 === count($loginArray)) { $_email = $_login; } else { $_email = $_login . '@'; $_email .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional; } } else { $_email = is_array($loginArray) && 2 === count($loginArray) ? $loginArray[0] . '@' : $_login . '@'; $_email .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional; } break; case 22: case 23: $loginArray = ConvertUtils::ParseEmail($_infoLogin); $_login = is_array($loginArray) && isset($loginArray[0]) ? $loginArray[0] . '@' : $_infoLogin . '@'; $_login .= $_domain && $_settings->UseMultipleDomainsSelection ? $_domain : $_settings->DefaultDomainOptional; $_email = $_login; } } /* custom class */ wm_Custom::StaticUseMethod('ChangeLoginDuringInit', array(&$_login, &$_email)); $bReturn = true; wm_Custom::StaticUseMethod('LdapCustomLoginFunction', array(&$_login, &$_email, &$_infoPassword, &$accountCustomValues, &$errorString, &$bReturn)); if (!$bReturn) { return false; } $_loginArray = null; if (USE_DB) { if ($_isNoLoginField) { $_loginArray =& Account::LoadFromDbOnlyByEmail($_email); if (is_array($_loginArray) && count($_loginArray) > 3) { $_eAccount =& Account::LoadFromDb((int) $_loginArray[0]); if ($_eAccount) { if ($_loginArray[5]) { $errorString = 'Your account is inactive, please contact the system administrator on this.'; return false; } $_login = ConvertUtils::DecodePassword($_loginArray[1], $_eAccount) == $_infoPassword ? $_loginArray[4] : $_optLogin; } else { $_login = $_optLogin; } } else { $_login = $_optLogin; } /* custom class */ wm_Custom::StaticUseMethod('ChangeLoginInfoAfterInit', array(&$_login, &$_email)); } else { /* custom class */ wm_Custom::StaticUseMethod('ChangeLoginInfoAfterInit', array(&$_login, &$_email)); $_loginArray =& Account::LoadFromDbByLogin($_email, $_login); if ($_loginArray[4]) { $errorString = 'Your account is inactive, please contact the system administrator on this.'; return false; } } } if (!$_dbStorage || !$_dbStorage->Connect()) { $_sendSettingsList = false; $errorString = getGlobalError(); return false; } if ($_loginArray === false) { $errorString = getGlobalError(); return false; } else { if ($_loginArray === null) { if ($_settings->AllowNewUsersRegister) { if (!NumOLCallBackFunction($_settings, $_dbStorage, $errorString)) { return false; } $_account = new Account(); $_account->DefaultAccount = true; $_account->Email = $_email; $_account->MailIncLogin = $_login; $_account->MailIncPassword = $_infoPassword; if (strlen($_infoLang) > 0) { $_account->DefaultLanguage = $_infoLang; } $_account->CustomValues = $accountCustomValues; if ($_infoAdvancedLogin && $_settings->AllowAdvancedLogin) { $_account->MailProtocol = $loginInfo->getMailProtocol(); $_account->MailIncPort = $loginInfo->getMailIncPort(); $_account->MailOutPort = $loginInfo->getMailOutPort(); $_account->MailOutAuthentication = $loginInfo->getMailOutAuth(); $_account->MailIncHost = $loginInfo->getMailIncHost(); $_account->MailOutHost = $loginInfo->getMailOutHost(); } else { $_account->MailProtocol = (int) $_settings->IncomingMailProtocol; $_account->MailIncPort = (int) $_settings->IncomingMailPort; $_account->MailOutPort = (int) $_settings->OutgoingMailPort; $_account->MailOutAuthentication = (bool) $_settings->ReqSmtpAuth; $_account->MailIncHost = $_settings->IncomingMailServer; $_account->MailOutHost = $_settings->OutgoingMailServer; } if (DEMOACCOUNTALLOW && $_email == DEMOACCOUNTEMAIL) { $_account->MailIncPassword = DEMOACCOUNTPASS; } /* custom class */ wm_Custom::StaticUseMethod('InitLdapSettingsAccountOnLogin', array(&$_account)); if (0 < strlen($_infoLang)) { $_account->DefaultLanguage = $_infoLang; } /* custom class */ wm_Custom::StaticUseMethod('ChangeAccountBeforeCreateOnLogin', array(&$_account)); if (USE_DB) { $_domain =& $_dbStorage->SelectDomainByName(EmailAddress::GetDomainFromEmail($_account->Email)); if (null !== $_domain) { $_domain->UpdateAccount($_account, $_settings); } } $_validate = $_account->ValidateData(); if ($_validate !== true) { $errorString = $_validate; return false; } else { if ($_account->IsInternal) { $errorString = ErrorPOP3IMAP4Auth; $_log->WriteLine('LOGIN Error: IsInternal = true', LOG_LEVEL_WARNING); return false; } $_processor = new MailProcessor($_account); if ($_processor->MailStorage->Connect(true)) { $_user =& User::CreateUser($_account); if ($_user && $_account) { if (!USE_DB) { $_account->Id = 1; } $_account->IdUser = $_user->Id; } $_inboxSyncType = $_account->GetDefaultFolderSync($_settings); if ($_user != null && $_user->CreateAccount($_account, $_inboxSyncType, false, $_processor->MailStorage)) { if ($_settings->EnableMobileSync && function_exists('mcrypt_encrypt')) { // create Funambol user for loginable user require_once WM_ROOTPATH . 'common/class_funambol_sync_users.php'; $fnSyncUsers = new FunambolSyncUsers($_account); $fnSyncUsers->PerformSync(); } $_SESSION[ACCOUNT_ID] = $_account->Id; $_SESSION[USER_ID] = $_account->IdUser; $_SESSION[SESSION_LANG] = $_account->DefaultLanguage; $_sendSettingsList = true; if (!USE_DB) { Account::SaveInSession($_account); } $_log->WriteEvent('User login', $_account); self::AfterLoginAction($_account, $_processor, $_settings); } else { if ($_user) { User::DeleteUserSettings($_user->Id); } $_error = getGlobalError(); $_error = strlen($_error) > 0 ? $_error : CantCreateUser; $errorString = $_error; return false; } } else { $errorString = getGlobalError(); return false; } } } else { $_log->WriteLine('LOGIN Error: AllowNewUsersRegister = false', LOG_LEVEL_WARNING); $errorString = ErrorPOP3IMAP4Auth; return false; } } else { if ($_loginArray[2] == 0) { $errorString = PROC_CANT_LOG_NONDEF; return false; } else { if (USE_DB) { $_newAccount =& Account::LoadFromDb($_loginArray[0]); if (!$_newAccount) { $errorString = getGlobalError(); return false; } else { $_deleted = $_dbStorage->GetAUserDeleted($_newAccount->IdUser); if (false === $_deleted) { $errorString = getGlobalError(); return false; } else { if (1 === $_deleted) { $errorString = ErrorMaximumUsersLicenseIsExceeded; return false; } } $_mailIncPass = $_infoPassword; if (DEMOACCOUNTALLOW && $_email == DEMOACCOUNTEMAIL) { $_mailIncPass = DEMOACCOUNTPASS; } $_useLangUpdate = false; if (strlen($_infoLang) > 0 && $_newAccount->DefaultLanguage != $_infoLang) { $_newAccount->DefaultLanguage = $_infoLang; $_useLangUpdate = true; } $_account = null; $bIsPasswordCorrect = ConvertUtils::DecodePassword($_loginArray[1], $_newAccount) == $_mailIncPass; $_account =& $_newAccount; $_account->MailIncPassword = $_mailIncPass; $_newprocessor = new MailProcessor($_account); if ($_newprocessor->MailStorage->Connect(true)) { if (!$bIsPasswordCorrect && !$_account->Update()) { return ErrorPOP3IMAP4Auth; } $_SESSION[ACCOUNT_ID] = $_account->Id; $_SESSION[USER_ID] = $_account->IdUser; $_SESSION[SESSION_LANG] = $_account->DefaultLanguage; $tempFiles =& CTempFiles::CreateInstance($_account); $tempFiles->ClearAccount(); unset($tempFiles); $_sendSettingsList = true; $_log->WriteEvent('User login', $_account); if ($_account->MailProtocol == MAILPROTOCOL_IMAP4 && $_account->ImapQuota === 1) { $quota = $_newprocessor->GetQuota(); if ($quota !== false && $quota !== $_account->MailboxLimit) { $_account->MailboxLimit = GetGoodBigInt($quota); $_account->UpdateMailBoxLimit(); } } self::AfterLoginAction($_account, $_newprocessor, $_settings); } else { $errorString = ErrorPOP3IMAP4Auth; return false; } } } } } } if ($_sendSettingsList && USE_DB) { if (!$_dbStorage->UpdateLastLoginAndLoginsCount($_account->IdUser)) { $_sendSettingsList = false; $errorString = getGlobalError(); return false; } } if (isset($_account)) { $refAccount = $_account; } return true; }
/** * @param Account $account * @param int $inboxSyncType = FOLDERSYNC_NewEntireMessages * @param bool $integrCall = false * @return bool */ function CreateAccount(&$account, $inboxSyncType = FOLDERSYNC_NewEntireMessages, $integrCall = false, $mailStorage = null) { $null = $folders = null; $account->IdUser = $this->Id; $result = false; setGlobalError(PROC_ERROR_ACCT_CREATE); $dbStorage =& DbStorageCreator::CreateDatabaseStorage($account); if ($dbStorage->Connect()) { if (USE_DB && !$account->IsInternal) { $defaultAccount =& $dbStorage->SelectAccountDataByLogin($account->Email, $account->MailIncLogin, true); if ($account->DefaultAccount && $defaultAccount != null && $defaultAccount[2] == 1) { setGlobalError(ACCT_CANT_ADD_DEF_ACCT); return false; } } $settings =& Settings::CreateInstance(); if ($settings->AllowDirectMode && $settings->DirectModeIsDefault) { $inboxSyncType = FOLDERSYNC_DirectMode; } $addFolders = null; /* load or create folder tree here */ switch ($account->MailProtocol) { case MAILPROTOCOL_POP3: $result = $account->IsInternal ? $dbStorage->UpdateOnlyAccoutnData($account) : $dbStorage->InsertAccountData($account); if ($result) { $folders = new FolderCollection(); $inboxFolder = new Folder($account->Id, -1, FOLDERNAME_Inbox, FOLDERNAME_Inbox); $inboxFolder->SyncType = $inboxSyncType; $folders->Add($inboxFolder); $createSystemFoldersInInbox = false; /* custom class */ wm_Custom::StaticUseMethod('ChangeValueOfSystemFoldersInInbox', array(&$createSystemFoldersInInbox)); $folderPrefix = ''; if ($createSystemFoldersInInbox) { $folderPrefix = $inboxFolder->FullName . $account->Delimiter; $inboxFolder->SubFolders = $inboxFolder->SubFolders ? $inboxFolder->SubFolders : new FolderCollection(); $addFolders =& $inboxFolder->SubFolders; } else { $addFolders =& $folders; } $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_SentItems, FOLDERNAME_SentItems, FOLDERSYNC_DontSync)); $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Drafts, FOLDERNAME_Drafts, FOLDERSYNC_DontSync)); $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Spam, FOLDERNAME_Spam, FOLDERSYNC_DontSync)); $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Trash, FOLDERNAME_Trash, FOLDERSYNC_DontSync)); } break; case MAILPROTOCOL_IMAP4: setGlobalError(ACCT_CANT_CREATE_IMAP_ACCT); if (null === $mailStorage) { $mailStorage = new ImapStorage($account, $null); } if ($mailStorage->Connect()) { if ($settings->TakeImapQuota) { if ($mailStorage->IsQuotaSupport()) { if ($account->ImapQuota === 1) { $mbl = $mailStorage->GetQuota(); if (false !== $mbl) { $account->MailboxLimit = GetGoodBigInt($mbl); } else { $account->ImapQuota = -1; } } } else { $account->ImapQuota = -1; } } if (USE_DB) { $result = $account->IsInternal ? $dbStorage->UpdateOnlyAccoutnData($account) : $dbStorage->InsertAccountData($account); if (!$result) { return false; } } else { $result = true; } $folders =& $mailStorage->GetFolders(); if ($folders == null) { if (USE_DB) { $dbStorage->DeleteAccountData($account->Id); } setGlobalError(PROC_ERROR_ACCT_CREATE); return false; } $inb =& $folders->GetFolderByType(FOLDERTYPE_Inbox); if ($inb === null) { if (USE_DB) { $dbStorage->DeleteAccountData($account->Id); } setGlobalError(PROC_ERROR_ACCT_CREATE); return false; } $folders->SetSyncTypeToAll($inboxSyncType); if (!$result) { return false; } $s = $d = $t = $sp = null; $s =& $folders->GetFolderByType(FOLDERTYPE_SentItems); $d =& $folders->GetFolderByType(FOLDERTYPE_Drafts); $sp =& $folders->GetFolderByType(FOLDERTYPE_Spam); if ($settings->Imap4DeleteLikePop3) { $t =& $folders->GetFolderByType(FOLDERTYPE_Trash); } $account->NameSpace = $mailStorage->GetNameSpacePrefix(); $account->UpdateNameSpace(); $createSystemFoldersInInbox = 0 === strpos($account->NameSpace, $inb->FullName); $createFoldersIfNotExist = $account->IsInternal ? true : CREATE_FOLDERS_IF_NOT_EXIST; /* custom class */ wm_Custom::StaticUseMethod('ChangeValueOfSystemFoldersInInbox', array(&$createSystemFoldersInInbox)); wm_Custom::StaticUseMethod('ChangeValueOfCreateFolderIfNotExist', array(&$createFoldersIfNotExist)); $folderPrefix = ''; if ($createSystemFoldersInInbox) { $folderPrefix = $inb->FullName . $account->Delimiter; $inb->SubFolders = $inb->SubFolders ? $inb->SubFolders : new FolderCollection(); $addFolders =& $inb->SubFolders; } else { $addFolders =& $folders; } if ($s === null) { $sentFolder = new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_SentItems, FOLDERNAME_SentItems, FOLDERSYNC_DontSync); if ($createFoldersIfNotExist) { $sentFolder->SetFolderSync($inboxSyncType); $mailStorage->CreateFolder($sentFolder); } $addFolders->Add($sentFolder); } if ($d === null) { $draftsFolder = new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Drafts, FOLDERNAME_Drafts, FOLDERSYNC_DontSync); if ($createFoldersIfNotExist) { $draftsFolder->SetFolderSync($inboxSyncType); $mailStorage->CreateFolder($draftsFolder); } $addFolders->Add($draftsFolder); } if ($sp === null) { $spamFolder = new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Spam, FOLDERNAME_Spam, FOLDERSYNC_DontSync); if ($createFoldersIfNotExist) { $spamFolder->SetFolderSync($inboxSyncType); $mailStorage->CreateFolder($spamFolder); } $addFolders->Add($spamFolder); } if ($settings->Imap4DeleteLikePop3 && $t === null) { $trashFolder = new Folder($account->Id, -1, $folderPrefix . FOLDERNAME_Trash, FOLDERNAME_Trash, FOLDERSYNC_DontSync); if ($createFoldersIfNotExist) { $trashFolder->SetFolderSync($inboxSyncType); $mailStorage->CreateFolder($trashFolder); } $addFolders->Add($trashFolder); } $mailStorage->Disconnect(); } else { return false; } break; default: return false; } if ($result && $folders) { $folders = $folders->SortRootTree(); if (USE_DB) { $result &= $dbStorage->CreateFolders($folders); } } } if ($result) { setGlobalError(''); if ($account && $account->MailProtocol == MAILPROTOCOL_IMAP4 && $account->ImapQuota === 1) { $account->UpdateMailBoxLimit(); } } return $result; }
/** * @param int $id * @return Account */ function &SelectAccountData($id) { $null = null; if (!$this->_connector->Execute($this->_commandCreator->SelectAccountData($id))) { return $null; } $account = new Account($this->_settings); $row = $this->_connector->GetNextRecord(); if ($row) { $account->Id = (int) $row->id_acct; $account->IdUser = (int) $row->id_user; $account->DefaultAccount = (bool) abs($row->def_acct); $account->Deleted = (bool) abs($row->deleted); $account->Email = $row->email; $account->MailProtocol = (int) $row->mail_protocol; $account->MailIncHost = $row->mail_inc_host; $account->MailIncLogin = $row->mail_inc_login; $account->MailIncPort = (int) $row->mail_inc_port; $account->MailOutHost = $row->mail_out_host; $account->MailOutLogin = $row->mail_out_login; $account->MailOutPort = (int) $row->mail_out_port; $account->MailOutAuthentication = (int) $row->mail_out_auth; $account->FriendlyName = $row->friendly_nm; $account->UseFriendlyName = (bool) abs($row->use_friendly_nm); $account->DefaultOrder = (int) $row->def_order; $account->GetMailAtLogin = (bool) abs($row->getmail_at_login); $account->MailMode = (int) $row->mail_mode; $account->MailsOnServerDays = (int) $row->mails_on_server_days; $account->SignatureType = (int) $row->signature_type; $account->SignatureOptions = (int) $row->signature_opt; $account->HideContacts = (bool) abs($row->hide_contacts); $account->MailsPerPage = (int) $row->msgs_per_page > 0 ? (int) $row->msgs_per_page : 20; $account->Delimiter = $row->delimiter; $account->NameSpace = $row->personal_namespace; $account->DomainId = (int) $row->id_domain; $account->WhiteListing = (bool) abs($row->white_listing); $account->XSpam = (bool) abs($row->x_spam); $account->LastLogin = (int) $row->last_login; $account->LoginsCount = (int) $row->logins_count; $account->DefaultSkin = $row->def_skin; $account->DefaultLanguage = $row->def_lang; $account->DefaultIncCharset = ap_Utils::GetCodePageName((int) $row->def_charset_inc); $account->DefaultOutCharset = ap_Utils::GetCodePageName((int) $row->def_charset_out); $account->DefaultTimeZone = (int) $row->def_timezone; $account->DefaultDateFormat = CDateTime::GetDateFormatFromBd($row->def_date_fmt); $account->DefaultTimeFormat = CDateTime::GetTimeFormatFromBd($row->def_date_fmt); $account->HideFolders = (bool) abs($row->hide_folders); $account->MailboxLimit = GetGoodBigInt($row->mailbox_limit); $account->MailboxSize = GetGoodBigInt($row->mailbox_size); $account->AllowChangeSettings = (bool) abs($row->allow_change_settings); $account->AllowDhtmlEditor = (bool) abs($row->allow_dhtml_editor); $account->AllowDirectMode = (bool) abs($row->allow_direct_mode); $account->DbCharset = ap_Utils::GetCodePageName((int) $row->db_charset); $account->HorizResizer = (int) $row->horiz_resizer; $account->VertResizer = (int) $row->vert_resizer; $account->Mark = (int) $row->mark; $account->Reply = (int) $row->reply; $account->ContactsPerPage = (int) $row->contacts_per_page > 0 ? (int) $row->contacts_per_page : 20; $account->ViewMode = (int) $row->view_mode; $account->MailIncPassword = ap_Utils::DecodePassword($row->mail_inc_pass); $account->MailOutPassword = ap_Utils::DecodePassword($row->mail_out_pass); $account->IsMailList = (bool) $row->mailing_list; $account->ImapQuota = (int) $row->imap_quota; $this->_connector->FreeResult(); } else { $account = $null; } if ($account && !$account->IsMailList) { if (!is_object($account) || !$this->_connector->Execute($this->_commandCreator->SelectSignature($account->Id))) { return $null; } $row = $this->_connector->GetNextRecord(); if ($row) { $account->Signature = $row->signature; $this->_connector->FreeResult(); } if (!is_object($account) || !$this->_connector->Execute($this->_commandCreator->SelectAccountColumnsData($account->IdUser))) { return $null; } while (($row = $this->_connector->GetNextRecord()) != false) { $account->Columns[(int) $row->id_column] = $row->column_value; } if ($account->DomainId > 0 && $this->_connector->Execute($this->_commandCreator->SelectAccountAliases($account->Id))) { while (($row = $this->_connector->GetNextRecord()) != false) { $account->Aliases[] = $row->alias_name; } } if ($account->DomainId > 0 && $this->_connector->Execute($this->_commandCreator->SelectAccountForwards($account->Id))) { while (($row = $this->_connector->GetNextRecord()) != false) { $account->Forwards[] = $row->forward_to; } } } else { if ($account && $account->IsMailList) { if ($this->_connector->Execute($this->_commandCreator->SelectMailListAccountUsers($account->Id))) { while (($row = $this->_connector->GetNextRecord()) != false) { $account->MailingList[] = $row->list_to; } } } } return $account; }
/** * @param Account $account * @param int $synchronize */ function AccountFromPost(&$_account, &$_synchronize) { $_account->MailboxSize = 0; if (isset($_POST['intLimitMailbox']) && strlen($_POST['intLimitMailbox']) < 8) { $_account->MailboxLimit = GetGoodBigInt(round($_POST['intLimitMailbox'] * 1024)); } if (isset($_POST['MaxMailboxSize']) && strlen($_POST['MaxMailboxSize']) < 8) { $_account->MailboxLimit = GetGoodBigInt(round($_POST['MaxMailboxSize']) * 1024); } $_account->FriendlyName = isset($_POST['txtFriendlyName']) ? $_POST['txtFriendlyName'] : $_account->FriendlyName; if ($_account->DomainId === 0) { $_account->MailIncHost = isset($_POST['txtIncomingMail']) ? $_POST['txtIncomingMail'] : $_account->MailIncHost; $_account->MailIncPort = isset($_POST['intIncomingPort']) ? (int) $_POST['intIncomingPort'] : $_account->MailIncPort; $_account->MailOutHost = isset($_POST['txtSmtpServer']) ? $_POST['txtSmtpServer'] : $_account->MailOutHost; $_account->MailOutPort = isset($_POST['intSmtpPort']) ? (int) $_POST['intSmtpPort'] : $_account->MailOutPort; } $_account->MailIncLogin = isset($_POST['txtIncomingLogin']) ? $_POST['txtIncomingLogin'] : $_account->MailIncLogin; $_password = isset($_POST['txtIncomingPassword']) ? $_POST['txtIncomingPassword'] : AP_DUMMYPASSWORD; if ($_password != AP_DUMMYPASSWORD) { $_account->MailIncPassword = $_password; } $_password = isset($_POST['UserPassword_PassMode']) ? $_POST['UserPassword_PassMode'] : AP_DUMMYPASSWORD; if ($_password != AP_DUMMYPASSWORD) { $_account->MailIncPassword = $_password; } $_account->MailOutLogin = isset($_POST['txtSmtpLogin']) ? $_POST['txtSmtpLogin'] : $_account->MailOutLogin; $_password = isset($_POST['txtSmtpPassword']) ? $_POST['txtSmtpPassword'] : AP_DUMMYPASSWORD; if ($_password != AP_DUMMYPASSWORD) { $_account->MailOutPassword = $_password; } $_protocol = isset($_POST['intMailProtocol']) ? $_POST['intMailProtocol'] : WM_MAILPROTOCOL_POP3; switch ($_protocol) { default: $_account->MailProtocol = WM_MAILPROTOCOL_POP3; break; case WM_MAILPROTOCOL_POP3: case WM_MAILPROTOCOL_IMAP4: case WM_MAILPROTOCOL_WMSERVER: $_account->MailProtocol = (int) $_protocol; break; } if ($_account->MailProtocol != WM_MAILPROTOCOL_WMSERVER) { $_account->Email = isset($_POST['txtEmail']) ? strtolower($_POST['txtEmail']) : $_account->Email; } if ($_account->DomainId === 0) { $_account->MailOutAuthentication = isset($_POST['chkUseSmtpAuth']); } if ($this->_settings->TakeImapQuota && $_account->MailProtocol == WM_MAILPROTOCOL_IMAP4) { $_account->ImapQuota = (int) isset($_POST['intTakeImapQuota']); } $_account->UseFriendlyName = isset($_POST['chkUseFriendlyName']); $_account->GetMailAtLogin = isset($_POST['chkGetMailAtLogin']); if ($_account->MailProtocol !== WM_MAILPROTOCOL_WMSERVER) { $_account->AllowDirectMode = isset($_POST['chkAllowDM']); } $_account->AllowChangeSettings = isset($_POST['chkAllowChangeEmail']); $_account->Deleted = isset($_POST['chkUserEnabled']) ? false : true; $_synchronize = isset($_POST['synchronizeSelect']) && $_account->MailProtocol == WM_MAILPROTOCOL_POP3 ? (int) $_POST['synchronizeSelect'] : $_account->GetDefaultFolderSync(); if ($_account->MailProtocol === WM_MAILPROTOCOL_POP3) { $_account->MailsOnServerDays = isset($_POST['txtKeepMsgsDays']) ? (int) $_POST['txtKeepMsgsDays'] : $_account->MailsOnServerDays; if (isset($_POST['chkDelMsgsDB'])) { if ($_synchronize == WM_FOLDERSYNC_NewHeadersOnly || $_synchronize == WM_FOLDERSYNC_NewEntireMessages) { $_synchronize++; } } $_mailmode = WM_MAILMODE_LeaveMessagesOnServer; if (isset($_POST['mailMode'])) { if ((int) $_POST['mailMode'] == 1) { $_mailmode = WM_MAILMODE_DeleteMessagesFromServer; } else { $_p = 0; if (isset($_POST['chkKeepMsgs'])) { $_mailmode = WM_MAILMODE_KeepMessagesOnServer; $_p++; } if (isset($_POST['chkDelMsgsSrv'])) { $_mailmode = WM_MAILMODE_DeleteMessageWhenItsRemovedFromTrash; $_p++; } if ($_p == 2) { $_mailmode = WM_MAILMODE_KeepMessagesOnServerAndDeleteMessageWhenItsRemovedFromTrash; } } } $_account->MailMode = $_mailmode; } // Advanced $_account->MailsPerPage = isset($_POST['txtMessagesPerPage']) ? (int) $_POST['txtMessagesPerPage'] : $_account->MailsPerPage; $_account->ContactsPerPage = isset($_POST['txtContactsPerPage']) ? (int) $_POST['txtContactsPerPage'] : $_account->ContactsPerPage; $_account->AllowDhtmlEditor = !(isset($_POST['intDisableRichEditor']) && $_POST['intDisableRichEditor'] == 1); $isPreviewPane = isset($_POST['intMessageListWithPreviewPane']) && $_POST['intMessageListWithPreviewPane'] == 1; $isAlwaysShowPictures = isset($_POST['intAlwaysShowPictures']) && $_POST['intAlwaysShowPictures'] == 1; if ($isPreviewPane) { $_account->ViewMode = $isAlwaysShowPictures ? WM_VIEW_MODE_PREVIEW_PANE : WM_VIEW_MODE_PREVIEW_PANE_NO_IMG; } else { $_account->ViewMode = $isAlwaysShowPictures ? WM_VIEW_MODE_WITHOUT_PREVIEW_PANE : WM_VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG; } $_account->DefaultSkin = isset($_POST['txtDefaultSkin']) ? $_POST['txtDefaultSkin'] : $_account->DefaultSkin; $_account->DefaultIncCharset = isset($_POST['txtDefaultUserCharset']) ? $_POST['txtDefaultUserCharset'] : $_account->DefaultIncCharset; $_account->DefaultOutCharset = isset($_POST['txtDefaultUserCharset']) ? $_POST['txtDefaultUserCharset'] : $_account->DefaultOutCharset; $_account->DefaultTimeZone = isset($_POST['txtDefaultTimeZone']) ? $_POST['txtDefaultTimeZone'] : $_account->DefaultTimeZone; $_account->DefaultLanguage = isset($_POST['txtDefaultLanguage']) ? $_POST['txtDefaultLanguage'] : $_account->DefaultLanguage; if (isset($_POST['AliasesListDDL']) && is_array($_POST['AliasesListDDL'])) { $_account->Aliases = $_POST['AliasesListDDL']; } else { $_account->Aliases = array(); } if (isset($_POST['ForwardsListDDL']) && is_array($_POST['ForwardsListDDL'])) { $_account->Forwards = $_POST['ForwardsListDDL']; } else { $_account->Forwards = array(); } if (isset($_POST['ListMembersDDL']) && is_array($_POST['ListMembersDDL'])) { $_account->MailingList = $_POST['ListMembersDDL']; } else { $_account->MailingList = array(); } }
/** * @param Account $account * @param int $sync[optional] = null * @return bool */ function UpdateAccount($account, $sync = null) { $result = true; if ($this->DbStorage->Connect()) { if ($account->DefaultAccount) { $defaultAccountArray = $this->DbStorage->SelectAccountDataByLogin($account->Email, $account->MailIncLogin, true, $account->Id); if (is_array($defaultAccountArray) && count($defaultAccountArray) > 0) { $this->SetError(ap_Utils::TakePhrase('WM_CANT_ADD_DEF_ACCT')); $result = false; } } if ($result && $account->MailProtocol == WM_MAILPROTOCOL_POP3 && $sync != null) { $folders =& $this->DbStorage->GetFolders($account); if ($folders) { $inboxFolder =& $folders->GetFolderByType(WM_FOLDERTYPE_Inbox); if ($inboxFolder) { $inboxFolder->SyncType = $sync; $result &= $this->DbStorage->UpdateFolder($inboxFolder); } } } if ($result && $account->MailProtocol == WM_MAILPROTOCOL_IMAP4 && $this->_account->_settings->TakeImapQuota) { if ($this->_account->ImapQuota === 1) { $mbl = $this->GetQuota(); if (false !== $mbl && $mbl >= 0) { $account->MailboxLimit = GetGoodBigInt($mbl); } } else { if ($this->_account->ImapQuota === -1 && $this->IsQuotaSupport()) { $this->_account->ImapQuota = 0; } } $result = $this->DbStorage->UpdateAccountImapQuota($account); } if ($result) { $result = $this->DbStorage->UpdateAccountData($account); } if ($result && $account->IsInternal) { $result &= $this->DbStorage->SaveMailAliases($account); $result &= $this->DbStorage->SaveMailForwards($account); } } return $result; }