示例#1
0
 /**
  * @return array
  */
 public function AjaxUserSettingsUpdate()
 {
     setcookie('aft-cache-ctrl', '', time() - 3600);
     $oAccount = $this->getAccountFromParam();
     $iMailsPerPage = (int) $this->oHttp->GetPost('MailsPerPage', $oAccount->User->MailsPerPage);
     if ($iMailsPerPage < 1) {
         $iMailsPerPage = 1;
     }
     $iContactsPerPage = (int) $this->oHttp->GetPost('ContactsPerPage', $oAccount->User->ContactsPerPage);
     if ($iContactsPerPage < 1) {
         $iContactsPerPage = 1;
     }
     $iAutoCheckMailInterval = (int) $this->oHttp->GetPost('AutoCheckMailInterval', $oAccount->User->AutoCheckMailInterval);
     if (!in_array($iAutoCheckMailInterval, array(0, 1, 3, 5, 10, 15, 20, 30))) {
         $iAutoCheckMailInterval = 0;
     }
     $iLayout = (int) $this->oHttp->GetPost('Layout', $oAccount->User->Layout);
     $iDefaultEditor = (int) $this->oHttp->GetPost('DefaultEditor', $oAccount->User->DefaultEditor);
     $bUseThreads = '1' === (string) $this->oHttp->GetPost('UseThreads', $oAccount->User->UseThreads ? '1' : '0');
     $bSaveRepliedMessagesToCurrentFolder = '1' === (string) $this->oHttp->GetPost('SaveRepliedMessagesToCurrentFolder', $oAccount->User->SaveRepliedMessagesToCurrentFolder ? '1' : '0');
     $bDesktopNotifications = '1' === (string) $this->oHttp->GetPost('DesktopNotifications', $oAccount->User->DesktopNotifications ? '1' : '0');
     $bAllowChangeInputDirection = '1' === (string) $this->oHttp->GetPost('AllowChangeInputDirection', $oAccount->User->AllowChangeInputDirection ? '1' : '0');
     $bFilesEnable = '1' === (string) $this->oHttp->GetPost('FilesEnable', $oAccount->User->FilesEnable ? '1' : '0');
     $sTheme = (string) $this->oHttp->GetPost('DefaultTheme', $oAccount->User->DefaultSkin);
     //		$sTheme = $this->validateTheme($sTheme);
     $sLang = (string) $this->oHttp->GetPost('DefaultLanguage', $oAccount->User->DefaultLanguage);
     //		$sLang = $this->validateLang($sLang);
     $sDateFormat = (string) $this->oHttp->GetPost('DefaultDateFormat', $oAccount->User->DefaultDateFormat);
     $iTimeFormat = (int) $this->oHttp->GetPost('DefaultTimeFormat', $oAccount->User->DefaultTimeFormat);
     $sEmailNotification = (string) $this->oHttp->GetPost('EmailNotification', $oAccount->User->EmailNotification);
     $oAccount->User->MailsPerPage = $iMailsPerPage;
     $oAccount->User->ContactsPerPage = $iContactsPerPage;
     $oAccount->User->Layout = $iLayout;
     $oAccount->User->DefaultSkin = $sTheme;
     $oAccount->User->DefaultEditor = $iDefaultEditor;
     $oAccount->User->DefaultLanguage = $sLang;
     $oAccount->User->DefaultDateFormat = $sDateFormat;
     $oAccount->User->DefaultTimeFormat = $iTimeFormat;
     $oAccount->User->AutoCheckMailInterval = $iAutoCheckMailInterval;
     $oAccount->User->UseThreads = $bUseThreads;
     $oAccount->User->SaveRepliedMessagesToCurrentFolder = $bSaveRepliedMessagesToCurrentFolder;
     $oAccount->User->DesktopNotifications = $bDesktopNotifications;
     $oAccount->User->AllowChangeInputDirection = $bAllowChangeInputDirection;
     $oAccount->User->EnableOpenPgp = '1' === (string) $this->oHttp->GetPost('EnableOpenPgp', $oAccount->User->EnableOpenPgp ? '1' : '0');
     $oAccount->User->AllowAutosaveInDrafts = '1' === (string) $this->oHttp->GetPost('AllowAutosaveInDrafts', $oAccount->User->AllowAutosaveInDrafts ? '1' : '0');
     $oAccount->User->AutosignOutgoingEmails = '1' === (string) $this->oHttp->GetPost('AutosignOutgoingEmails', $oAccount->User->AutosignOutgoingEmails ? '1' : '0');
     $oAccount->User->FilesEnable = $bFilesEnable;
     $oAccount->User->EmailNotification = $sEmailNotification;
     // calendar
     $oCalUser = $this->oApiUsers->getOrCreateCalUser($oAccount->IdUser);
     if ($oCalUser) {
         $oCalUser->ShowWeekEnds = (bool) $this->oHttp->GetPost('ShowWeekEnds', $oCalUser->ShowWeekEnds);
         $oCalUser->ShowWorkDay = (bool) $this->oHttp->GetPost('ShowWorkDay', $oCalUser->ShowWorkDay);
         $oCalUser->WorkDayStarts = (int) $this->oHttp->GetPost('WorkDayStarts', $oCalUser->WorkDayStarts);
         $oCalUser->WorkDayEnds = (int) $this->oHttp->GetPost('WorkDayEnds', $oCalUser->WorkDayEnds);
         $oCalUser->WeekStartsOn = (int) $this->oHttp->GetPost('WeekStartsOn', $oCalUser->WeekStartsOn);
         $oCalUser->DefaultTab = (int) $this->oHttp->GetPost('DefaultTab', $oCalUser->DefaultTab);
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $this->oApiUsers->updateAccount($oAccount) && $oCalUser && $this->oApiUsers->updateCalUser($oCalUser));
 }