if ($nAcct !== null && USE_DB) { $dbStorage =& DbStorageCreator::CreateDatabaseStorage($null); if ($dbStorage->Connect() && $dbStorage->IsAccountInRing($_SESSION[ACCOUNT_ID], $nAcct)) { $_SESSION[ACCOUNT_ID] = $nAcct; } else { header('Location: index.php?error=2'); exit; } } $account =& Account::LoadFromDb($_SESSION[ACCOUNT_ID]); if (!$account) { header('Location: index.php?error=2'); exit; } define('defaultTitle', $settings->WindowTitle); $skins =& FileSystem::GetSkinsList(); $hasDefSettingsSkin = false; foreach ($skins as $skinName) { if ($skinName == $settings->DefaultSkin) { $hasDefSettingsSkin = true; } if ($skinName == $account->DefaultSkin) { define('defaultSkin', $account->DefaultSkin); break; } } if (!defined('defaultSkin')) { if ($hasDefSettingsSkin) { define('defaultSkin', $settings->DefaultSkin); } else { define('defaultSkin', $skins[0]);
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); }
function DoGetSettings() { $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null; $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId); $_account =& CXmlProcessing::AccountCheckAndLoad($_xmlRes, $_accountId, false, false); $_settingsNode = new XmlDomNode('settings'); $_settingsNode->AppendAttribute('msgs_per_page', (int) $_account->MailsPerPage); $_settingsNode->AppendAttribute('contacts_per_page', (int) $_account->ContactsPerPage); $_settingsNode->AppendAttribute('allow_dhtml_editor', (int) $_account->AllowDhtmlEditor); $_settingsNode->AppendAttribute('auto_checkmail_interval', (int) $_account->AutoCheckMailInterval); if ($_settings->AllowUsersChangeCharset) { $_settingsNode->AppendAttribute('def_charset_inc', ConvertUtils::GetCodePageNumber($_account->DefaultIncCharset)); $_settingsNode->AppendAttribute('def_charset_out', ConvertUtils::GetCodePageNumber($_account->DefaultOutCharset)); } if ($_settings->AllowUsersChangeTimeZone) { $_settingsNode->AppendAttribute('def_timezone', (int) $_account->DefaultTimeZone); } $_settingsNode->AppendAttribute('view_mode', (int) $_account->ViewMode); if ($_settings->AllowUsersChangeSkin) { $_skinsNode = new XmlDomNode('skins'); $_skinsList =& FileSystem::GetSkinsList(); foreach ($_skinsList as $_skin) { $_skinNode = new XmlDomNode('skin', $_skin, true); $_skinNode->AppendAttribute('def', (int) (strtolower($_account->DefaultSkin) == strtolower($_skin))); $_skinsNode->AppendChild($_skinNode); unset($_skinNode); } $_settingsNode->AppendChild($_skinsNode); } if ($_settings->AllowUsersChangeLanguage) { $_langsNode = new XmlDomNode('langs'); $_langList =& FileSystem::GetLangList(); foreach ($_langList as $_lang) { $_langNode = new XmlDomNode('lang', $_lang, true); $_langNode->AppendAttribute('def', (int) (strtolower($_account->DefaultLanguage) == strtolower($_lang))); $_langsNode->AppendChild($_langNode); unset($_langNode); } $_settingsNode->AppendChild($_langsNode); } $_settingsNode->AppendChild(new XmlDomNode('def_date_fmt', $_account->DefaultDateFormat)); $_settingsNode->AppendAttribute('time_format', $_account->DefaultTimeFormat); $_xmlRes->XmlRoot->AppendChild($_settingsNode); }
/** * @return BaseProcessor */ function BaseProcessor() { if (!Session::has(ACCOUNT_ID)) { $this->SetError(1); } $accountId = Session::val(ACCOUNT_ID); $this->sArray = Session::val(SARRAY, array()); $this->settings =& Settings::CreateInstance(); if (!$this->settings || !$this->settings->isLoad) { $this->SetError(3); } if ($accountId) { if (Get::has(CHANGE_ACCID)) { $oldaccount =& Account::LoadFromDb(Session::val(ACCOUNT_ID, -1)); $accountId = Get::val(CHANGE_ACCID); if (!isset($_SESSION['attachtempdir'])) { $_SESSION['attachtempdir'] = md5(session_id()); } $fs =& new FileSystem(INI_DIR . '/temp', $oldaccount->Email, $oldaccount->Id); $attfolder =& new Folder($oldaccount->Id, -1, $_SESSION['attachtempdir']); $fs->DeleteDir($attfolder); unset($fs, $attfolder); $this->sArray[ACCOUNT_ID] = $accountId; $this->account =& Account::LoadFromDb($accountId); if (!$this->account || $this->account->IdUser != $oldaccount->IdUser) { $this->account = null; } else { $_SESSION[ACCOUNT_ID] = $accountId; unset($_SESSION[SARRAY]); $this->sArray = array(); } } else { $this->sArray[ACCOUNT_ID] = $accountId; $this->account =& Account::LoadFromDb($accountId); } if (!$this->account) { $this->SetError(2); } } else { $this->SetError(1); } if (!isset($this->sArray[ACCOUNT_ID]) || $this->sArray[ACCOUNT_ID] != $accountId) { $this->sArray[EDIT_ACCOUNT_ID] = $accountId; } $this->processor =& new MailProcessor($this->account); if (!$this->processor->DbStorage || !$this->processor->DbStorage->Connect()) { $this->SetError(5); } $this->db =& $this->processor->DbStorage; $this->accounts =& $this->GetAccounts(); $skins =& FileSystem::GetSkinsList(); $hasDefSettingsSkin = false; $normalSkin = false; foreach ($skins as $skinName) { if ($skinName == $this->settings->DefaultSkin) { $hasDefSettingsSkin = true; } if ($skinName == $this->account->DefaultSkin) { $normalSkin = true; break; } } if (!$normalSkin) { $this->account->DefaultSkin = $hasDefSettingsSkin ? $this->settings->DefaultSkin : ($this->account->DefaultSkin = $skins[0]); } $_SESSION[ATTACH_DIR] = Session::val(ATTACH_DIR, md5(session_id())); if (isset($this->sArray[SCREEN])) { $screen = Get::val(SCREEN, $this->sArray[SCREEN]); $this->sArray[SCREEN] = $screen; if ($this->account->AllowChangeSettings == false && ($screen == SET_ACCOUNT_PROF || $screen == SET_ACCOUNT_ADDACC)) { $this->sArray[SCREEN] = SCREEN_MAILBOX; } if (!$this->settings->AllowContacts && $screen == SCREEN_CONTACTS) { $this->sArray[SCREEN] = SCREEN_MAILBOX; } } else { $this->sArray[SCREEN] = Get::val(SCREEN, SCREEN_MAILBOX); } if (isset($this->sArray[FOLDER_ID])) { $this->sArray[FOLDER_ID] = Get::val(FOLDER_ID, $this->sArray[FOLDER_ID]); } else { $this->sArray[FOLDER_ID] = Get::val(FOLDER_ID, -1); } if (Get::has(FOLDER_ID) || Get::has(SCREEN)) { if (isset($this->sArray[SEARCH_ARRAY])) { unset($this->sArray[SEARCH_ARRAY]); } } if (Session::has(GOTOFOLDER)) { $this->sArray[GOTOFOLDER] = Session::val(GOTOFOLDER, ''); unset($_SESSION[GOTOFOLDER]); } if (isset($this->sArray[PAGE])) { $this->sArray[PAGE] = Get::val(PAGE, $this->sArray[PAGE]); } else { $this->sArray[PAGE] = 1; } if (Get::has(S_GETMODE)) { $this->sArray[SEARCH_ARRAY][S_TEXT] = Get::val(S_GETMODE, 'mini') == 'mini' ? Post::val('smallLookFor', '') : Post::val('bigLookFor', ''); if (!empty($this->sArray[SEARCH_ARRAY][S_TEXT])) { $this->sArray[SEARCH_ARRAY][S_FOLDER] = Post::val('qfolder', -2); $this->sArray[SEARCH_ARRAY][S_MODE] = Post::val('qmmode', 'onlyheaders'); $this->sArray[FOLDER_ID] = $this->sArray[SEARCH_ARRAY][S_FOLDER]; $this->sArray[PAGE] = 1; } else { if (Post::val('qfolder', -2) < 1) { $this->sArray[FOLDER_ID] = -1; } unset($this->sArray[SEARCH_ARRAY]); $this->sArray[PAGE] = 1; } } if (Get::has(S_GETMODECONTACT)) { $this->sArray[SEARCH_ARRAY][S_TEXT] = Get::val(S_GETMODECONTACT, 'mini') == 'mini' ? Post::val('smallLookFor', '') : Post::val('bigLookFor', ''); $this->sArray[CONTACT_ID] = Post::val(CONTACT_ID, -1); $this->sArray[CONTACT_PAGE] = 1; } if (isset($this->sArray[SEARCH_ARRAY][S_FOLDER])) { $this->sArray[FOLDER_ID] = $this->sArray[SEARCH_ARRAY][S_FOLDER]; } if (isset($this->sArray[EDIT_ACCOUNT_ID])) { $this->sArray[EDIT_ACCOUNT_ID] = Get::val(EDIT_ACCOUNT_ID, $this->sArray[EDIT_ACCOUNT_ID]); } else { $this->sArray[EDIT_ACCOUNT_ID] = $accountId; } if (Get::has(EDIT_ACCOUNT_ID)) { $this->sArray[SCREEN] = $this->sArray[SCREEN] == SET_ACCOUNT_ADDACC ? SET_ACCOUNT_PROF : $this->sArray[SCREEN]; } $this->sArray[CONTACT_PAGE] = isset($this->sArray[CONTACT_PAGE]) ? Get::val(CONTACT_PAGE, $this->sArray[CONTACT_PAGE]) : Get::val(CONTACT_PAGE, 1); $this->sArray[CONTACT_ORD] = isset($this->sArray[CONTACT_ORD]) ? Get::val(CONTACT_ORD, $this->sArray[CONTACT_ORD]) : Get::val(CONTACT_ORD, 0); if (isset($this->sArray[CONTACT_FLD])) { if (Get::val(CONTACT_FLD, $this->sArray[CONTACT_FLD]) != $this->sArray[CONTACT_FLD]) { $this->sArray[CONTACT_ORD] = 0; } $this->sArray[CONTACT_FLD] = Get::val(CONTACT_FLD, $this->sArray[CONTACT_FLD]); } else { $this->sArray[CONTACT_FLD] = Get::val(CONTACT_FLD, 0); } if (isset($_COOKIE['wm_vert_resizer']) || isset($_COOKIE['wm_horiz_resizer']) || isset($_COOKIE['wm_hide_folders'])) { if (isset($_COOKIE['wm_vert_resizer']) && strlen($_COOKIE['wm_vert_resizer']) > 0) { $this->account->VertResizer = (int) $_COOKIE['wm_vert_resizer']; setcookie('wm_vert_resizer', '0', time() - 24 * 3600); } if (isset($_COOKIE['wm_horiz_resizer']) && strlen($_COOKIE['wm_horiz_resizer']) > 0) { $this->account->HorizResizer = (int) $_COOKIE['wm_horiz_resizer']; setcookie('wm_horiz_resizer', '0', time() - 24 * 3600); } if (isset($_COOKIE['wm_hide_folders']) && strlen($_COOKIE['wm_hide_folders']) > 0) { $this->account->HideFolders = (bool) $_COOKIE['wm_hide_folders']; setcookie('wm_hide_folders', '0', time() - 24 * 3600); } $this->account->Update(); } $this->FillData(); $this->UpdateSession(); }
/** * @param PageBuilder $pagebuilder * @return SettingsCommon */ function SettingsCommon(&$pagebuilder) { $this->data = array(); $this->_pagebuilder =& $pagebuilder; $this->_proc =& $pagebuilder->_proc; $this->_pagebuilder->_js->AddText(' function SetAdvanced() { var select = document.getElementById("str_date_format"); if (select) select.value = "advanced"; } function ChangeAdvanced(objSelect) { var advInput = document.getElementById("strInputDateFormat"); if (advInput && objSelect && objSelect.value != "advanced") { advInput.value = objSelect.value; } } '); $this->data['mails_per_page'] = $this->_proc->account->MailsPerPage; $this->data['int_disable_dhtml_editor'] = $this->_proc->account->AllowDhtmlEditor ? '' : 'checked="checked"'; $this->data['int_use_preview_pane'] = $this->_proc->account->ViewMode == VIEW_MODE_PREVIEW_PANE || $this->_proc->account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG ? 'checked="checked"' : ''; $this->data['int_showimg'] = $this->_proc->account->ViewMode == VIEW_MODE_PREVIEW_PANE || $this->_proc->account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE ? 'checked="checked"' : ''; $this->data['skin_select'] = ''; if ($this->_proc->settings->AllowUsersChangeSkin) { $this->data['skin_select'] = '<tr> <td class="wm_settings_title">' . JS_LANG_Skin . ':</td> <td colspan="2"> <select name="str_skin_path" id="skin_path">'; $skinsList =& FileSystem::GetSkinsList(); for ($i = 0, $c = count($skinsList); $i < $c; $i++) { $temp = $this->_proc->account->DefaultSkin == $skinsList[$i] ? 'selected="selected"' : ''; $this->data['skin_select'] .= '<option value="' . ConvertUtils::AttributeQuote($skinsList[$i]) . '" ' . $temp . '> ' . $skinsList[$i] . '</option>' . "\n"; } $this->data['skin_select'] .= '</select></td></tr>'; } $this->data['CharsetSelect'] = ''; if ($this->_proc->settings->AllowUsersChangeCharset) { $this->data['CharsetSelect'] = '<tr> <td class="wm_settings_title">' . JS_LANG_DefCharsetOut . ':</td> <td colspan="2"> <select name="str_charset" id="strCharset">'; global $CHARSETS; for ($i = 0, $c = count($CHARSETS); $i < $c; $i++) { $temp = $this->_proc->account->DefaultOutCharset == $CHARSETS[$i][0] ? 'selected="selected"' : ''; $this->data['CharsetSelect'] .= '<option value="' . ConvertUtils::AttributeQuote($CHARSETS[$i][0]) . '" ' . $temp . '> ' . $CHARSETS[$i][1] . '</option>' . "\n"; } $this->data['CharsetSelect'] .= '</select></td></tr>'; } $this->data['TimeZoneSelect'] = ''; if ($this->_proc->settings->AllowUsersChangeTimeZone) { $this->data['TimeZoneSelect'] = '<tr> <td class="wm_settings_title">' . JS_LANG_DefTimeOffset . ':</td> <td colspan="2"> <select name="str_time_zone" id="strTimeZone">'; global $TIMEZONE; for ($i = 0, $c = count($TIMEZONE); $i < $c; $i++) { $temp = $this->_proc->account->DefaultTimeZone == $i ? 'selected="selected"' : ''; $this->data['TimeZoneSelect'] .= '<option value="' . $i . '" ' . $temp . '> ' . $TIMEZONE[$i] . '</option>' . "\n"; } $this->data['TimeZoneSelect'] .= '</select></td></tr>'; } $this->data['LangSelect'] = ''; if ($this->_proc->settings->AllowUsersChangeLanguage) { $this->data['LangSelect'] = '<tr> <td class="wm_settings_title">' . JS_LANG_DefLanguage . ':</td> <td colspan="2"> <select name="str_def_language" id="strDefLanguage">'; $langList =& FileSystem::GetLangList(); for ($i = 0, $c = count($langList); $i < $c; $i++) { $temp = $this->_proc->account->DefaultLanguage == $langList[$i] ? 'selected="selected"' : ''; $this->data['LangSelect'] .= '<option value="' . ConvertUtils::AttributeQuote($langList[$i]) . '" ' . $temp . '> ' . $langList[$i] . '</option>' . "\n"; } $this->data['LangSelect'] .= '</select> </td> </tr>'; } $time = time(); $day = (int) date('d', $time); $month = (int) date('m', $time); if ($day == $month) { $time = $time + (21 - $day) * 3600 * 24; } $data_format = $this->_proc->account->DefaultDateFormat; $time_format = $this->_proc->account->DefaultTimeFormat; $this->data['data_format'] = array('', '', '', '', ''); $this->data['data_value'] = array(date('d/m/y', $time), date('m/d/y', $time), date('d M', $time)); $this->data['time_format'] = array('', ''); $this->data['time_format'][$time_format] = 'checked="checked"'; switch (strtolower($data_format)) { default: case 'default': $this->data['data_format'][0] = 'selected="selected"'; break; case 'dd/mm/yy': $this->data['data_format'][1] = 'selected="selected"'; break; case 'mm/dd/yy': $this->data['data_format'][2] = 'selected="selected"'; break; case 'dd month': $this->data['data_format'][3] = 'selected="selected"'; break; } $this->data['data_format'][5] = $data_format; }