Пример #1
0
 function SetLimits()
 {
     /* custom class */
     if (ap_Custom::StaticMethodExist('ap_SetLimits')) {
         ap_Custom::StaticUseMethod('ap_SetLimits');
     } else {
         @ini_set('memory_limit', AP_MEMORYLIMIT);
         @set_time_limit(AP_TIMELIMIT);
     }
 }
Пример #2
0
 /**
  * @return FolderCollection
  */
 function GetFolders(&$accountDelimiter)
 {
     $folderCollection = new FolderCollection();
     $folders =& $this->_imapMail->list_mailbox($accountDelimiter);
     $subsScrFolders = $this->_imapMail->list_subscribed_mailbox($accountDelimiter);
     $existsIndex = array('VirusAdd' => true);
     $folderCollection = $this->GetFolderCollectionFromArrays($folders, $subsScrFolders, $accountDelimiter, $existsIndex);
     /* custom class */
     ap_Custom::StaticUseMethod('wm_ChangeServerImapFoldersAfterGet', array(&$folderCollection));
     return $folderCollection;
 }
Пример #3
0
 /**
  * @return	int
  */
 function GetDefaultFolderSync()
 {
     $s = WM_FOLDERSYNC_AllHeadersOnly;
     if ($this->_settings && $this->_settings->AllowDirectMode && $this->_settings->DirectModeIsDefault && $this->MailProtocol != WM_MAILPROTOCOL_WMSERVER) {
         $s = WM_FOLDERSYNC_DirectMode;
     } else {
         switch ($this->MailProtocol) {
             case WM_MAILPROTOCOL_POP3:
                 $s = WM_FOLDERSYNC_AllEntireMessages;
                 break;
             case WM_MAILPROTOCOL_IMAP4:
                 $s = WM_FOLDERSYNC_DirectMode;
                 //$s = WM_FOLDERSYNC_AllHeadersOnly;
                 break;
         }
     }
     /* custom class */
     ap_Custom::StaticUseMethod('wm_UpdateDefaultFolderSync', array(&$s, $this->MailProtocol));
     return $s;
 }
Пример #4
0
 /**
  * @param	string	$dataFolderPath
  */
 function WebMail_Settings($dataFolderPath, $webFolderPath)
 {
     $this->_path =& $dataFolderPath;
     $this->_webpath =& $webFolderPath;
     $this->UseDsn = false;
     $this->AllowUsersChangeAccountsDef = false;
     $this->AllowContacts = true;
     $this->AllowCalendar = true;
     $this->Imap4DeleteLikePop3 = true;
     $this->AllowLanguageOnLogin = true;
     $this->UseCaptcha = true;
     $this->EnableWmServer = false;
     $this->WmServerHost = '127.0.0.1';
     $this->WmAllowManageXMailAccounts = false;
     $this->Cal_DefaultTimeFormat = 1;
     $this->Cal_DefaultTimeZone = 38;
     $this->Cal_DefaultDateFormat = 1;
     $this->Cal_ShowWeekends = true;
     $this->Cal_WorkdayStarts = 9;
     $this->Cal_WorkdayEnds = 18;
     $this->Cal_ShowWorkDay = 1;
     $this->Cal_WeekStartsOn = 0;
     $this->Cal_DefaultTab = 2;
     $this->Cal_DefaultCountry = 'US';
     $this->Cal_AllTimeZones = false;
     $this->Cal_AllowReminders = false;
     $this->Cal_AutoAddInvitation = 0;
     $this->AllowInsertImage = true;
     $this->AllowBodySize = false;
     $this->MaxBodySize = 600;
     $this->MaxSubjectSize = 255;
     $this->AllowRegistration = false;
     $this->AllowPasswordReset = false;
     $this->EnableEventsLogging = false;
     $this->LoggingSpecialUsers = false;
     $this->LogLevel = WM_LOG_LEVEL_DEBUG;
     $this->UseMultipleDomainsSelection = false;
     $this->GlobalAddressBook = WM_GLOBAL_ADDRESS_BOOK_DOMAIN;
     $this->EnableMobileSync = false;
     $this->MobileSyncUrl = 'http://your.host.com:8080/funambol/ds';
     $this->MobileSyncContactDataBase = 'card';
     $this->MobileSyncCalendarDataBase = 'cal';
     $this->FlagsLangSelect = false;
     $this->ViewMode = WM_NEW_VIEW_MODE_CENTRAL_LIST_PANE;
     $this->SaveInSent = WM_SAVE_IN_SENT_ALWAYS;
     $this->isLoad = false;
     $this->_langIsInclude = false;
     $xmlDocument = new XmlDocument();
     if ($xmlDocument->LoadFromFile($this->_path . '/settings/settings.xml')) {
         $this->isLoad = true;
         $this->_loadFromXML($xmlDocument->XmlRoot);
         /* custom class */
         ap_Custom::StaticUseMethod('wm_ChangeSettingsAfterLoad', array(&$this));
     }
 }
Пример #5
0
 /**
  * @param string $name
  * return bool
  */
 function StaticMethodExist($name)
 {
     $c =& ap_Custom::CreateInstance();
     return $c->MethodExist($name);
 }
Пример #6
0
 /**
  * @param	Account	$account
  * @return	FolderCollection
  */
 function &GetFolders(&$account)
 {
     if (!$this->_connector->Execute($this->_commandCreator->GetFolders($account->Id))) {
         $null = null;
         return $null;
     }
     $folders = array();
     while (($row = $this->_connector->GetNextRecord()) != false) {
         $folder = new Folder($account->Id, (int) $row->id_folder, substr($row->full_path, 0, -1), substr($row->name, 0, -1));
         $folder->IdParent = $row->id_parent;
         $folder->Type = (int) $row->type;
         $folder->SyncType = (int) $row->sync_type;
         $folder->Hide = (bool) abs($row->hide);
         $folder->FolderOrder = (int) $row->fld_order;
         $folder->MessageCount = (int) $row->message_count;
         $folder->UnreadMessageCount = (int) $row->unread_message_count;
         $folder->Size = GetGoodBigInt($row->folder_size);
         $folder->Level = (int) $row->level;
         $folders[] =& $folder;
         unset($folder);
     }
     $folderCollection = new FolderCollection();
     $this->_addLevelToFolderTree($account, $folderCollection, $folders);
     /* custom class */
     ap_Custom::StaticUseMethod('wm_ChangeDbFoldersAfterGet', array(&$folderCollection));
     return $folderCollection;
 }
Пример #7
0
 /**
  * @param	Account		$account
  * @param	int			$sync = null
  * @return	bool
  */
 function CreateAccount(&$account, $sync = null)
 {
     $result = true;
     if ($this->DbStorage->Connect()) {
         if ($account->DefaultAccount && !$account->IsInternal) {
             $defaultAccountArray = $this->DbStorage->SelectAccountDataByLogin($account->Email, $account->MailIncLogin, true);
             if (is_array($defaultAccountArray) && count($defaultAccountArray) > 0) {
                 $this->SetError(ap_Utils::TakePhrase('WM_CANT_ADD_DEF_ACCT'));
                 $result = false;
             }
         }
         if ($result) {
             if ($account->MailProtocol == WM_MAILPROTOCOL_IMAP4) {
                 if (!$this->IsQuotaSupport()) {
                     $account->ImapQuota = -1;
                 }
                 if ($account->ImapQuota === 1) {
                     $quota = $this->GetQuota();
                     if (false !== $quota && $quota > 0) {
                         $account->MailboxLimit = GetGoodBigInt($quota);
                     } else {
                         $account->ImapQuota = -1;
                     }
                 }
             }
             if ($this->DbStorage->InsertUserData($account)) {
                 $addFolders = null;
                 $folders = new FolderCollection();
                 $result = $account->IsInternal ? $this->DbStorage->UpdateEximAccountData($account) : $this->DbStorage->InsertAccountData($account);
                 if ($result) {
                     switch ($account->MailProtocol) {
                         case WM_MAILPROTOCOL_POP3:
                             $inboxFolder = new Folder($account->Id, -1, WM_FOLDERNAME_Inbox, WM_FOLDERNAME_Inbox, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_Inbox);
                             if ($inboxFolder) {
                                 if ($account->_settings->AllowDirectMode && $account->_settings->DirectModeIsDefault) {
                                     $inboxFolder->SyncType = WM_FOLDERSYNC_DirectMode;
                                 } else {
                                     $inboxFolder->SyncType = $sync !== null ? $sync : WM_FOLDERSYNC_AllEntireMessages;
                                 }
                             }
                             $createSystemFoldersInInbox = false;
                             $createSystemFoldersNameSpace = $inboxFolder && 0 === strpos($nameSpacePrefix, $inboxFolder->FullName);
                             /* custom class */
                             ap_Custom::StaticUseMethod('wm_ChangeValueOfSystemFoldersInInbox', array(&$createSystemFoldersInInbox));
                             $folderPrefix = '';
                             if ($createSystemFoldersInInbox && $inboxFolder) {
                                 $folderPrefix = $inboxFolder->FullName . $account->Delimiter;
                                 $inboxFolder->SubFolders = $inboxFolder->SubFolders ? $inboxFolder->SubFolders : new FolderCollection();
                                 $addFolders =& $inboxFolder->SubFolders;
                             } else {
                                 $addFolders =& $folders;
                             }
                             $folders->Add($inboxFolder);
                             $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . WM_FOLDERNAME_SentItems, WM_FOLDERNAME_SentItems, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_SentItems));
                             $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . WM_FOLDERNAME_Drafts, WM_FOLDERNAME_Drafts, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_Drafts));
                             $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . WM_FOLDERNAME_Spam, WM_FOLDERNAME_Spam, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_Spam));
                             $addFolders->Add(new Folder($account->Id, -1, $folderPrefix . WM_FOLDERNAME_Trash, WM_FOLDERNAME_Trash, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_Trash));
                             break;
                         case WM_MAILPROTOCOL_IMAP4:
                             $accountDelimiter = $account->Delimiter;
                             $folders =& $this->MailStorage->GetFolders($accountDelimiter);
                             if ($accountDelimiter != $account->Delimiter) {
                                 $account->Delimiter = $accountDelimiter;
                                 $this->DbStorage->UpdateAccountDelimiter($account->Id, $accountDelimiter);
                             }
                             $result &= $folders != null;
                             if ($result) {
                                 $inb =& $folders->GetFolderByType(WM_FOLDERTYPE_Inbox);
                                 if ($inb === null) {
                                     $result = false;
                                     break;
                                 }
                                 $inboxSyncType = $sync !== null ? $sync : WM_FOLDERSYNC_AllHeadersOnly;
                                 if ($account->_settings->AllowDirectMode && $account->_settings->DirectModeIsDefault) {
                                     $inboxSyncType = WM_FOLDERSYNC_DirectMode;
                                 }
                                 $folders->SetSyncTypeToAll($inboxSyncType);
                                 $account->NameSpace = $this->MailStorage->GetNameSpacePrefix();
                                 $this->DbStorage->UpdateAccountNameSpace($account->Id, $account->NameSpace);
                                 $createSystemFoldersInInbox = 0 === strpos($account->NameSpace, $inb->FullName);
                                 $createFoldersIfNotExist = $account->IsInternal;
                                 /* custom class */
                                 ap_Custom::StaticUseMethod('wm_ChangeValueOfSystemFoldersInInbox', array(&$createSystemFoldersInInbox));
                                 ap_Custom::StaticUseMethod('wm_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;
                                 }
                                 $s = $d = $t = $sp = null;
                                 $s =& $folders->GetFolderByType(WM_FOLDERTYPE_SentItems);
                                 $d =& $folders->GetFolderByType(WM_FOLDERTYPE_Drafts);
                                 if ($account->_settings->Imap4DeleteLikePop3) {
                                     $t =& $folders->GetFolderByType(WM_FOLDERTYPE_Trash);
                                 }
                                 $sp =& $folders->GetFolderByType(WM_FOLDERTYPE_Spam);
                                 if ($s === null) {
                                     $sentFolder = new Folder($account->Id, -1, $folderPrefix . WM_FOLDERNAME_SentItems, WM_FOLDERNAME_SentItems, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_SentItems);
                                     if ($createFoldersIfNotExist) {
                                         $sentFolder->SetFolderSync($inboxSyncType);
                                         $this->MailStorage->CreateFolder($sentFolder);
                                     }
                                     $addFolders->Add($sentFolder);
                                 }
                                 if ($d === null) {
                                     $draftsFolder = new Folder($account->Id, -1, $folderPrefix . WM_FOLDERNAME_Drafts, WM_FOLDERNAME_Drafts, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_Drafts);
                                     if ($createFoldersIfNotExist) {
                                         $draftsFolder->SetFolderSync($inboxSyncType);
                                         $this->MailStorage->CreateFolder($draftsFolder);
                                     }
                                     $addFolders->Add($draftsFolder);
                                 }
                                 if ($sp === null) {
                                     $spamFolder = new Folder($account->Id, -1, $folderPrefix . WM_FOLDERNAME_Spam, WM_FOLDERNAME_Spam, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_Spam);
                                     if ($createFoldersIfNotExist) {
                                         $spamFolder->SetFolderSync($inboxSyncType);
                                         $this->MailStorage->CreateFolder($spamFolder);
                                     }
                                     $addFolders->Add($spamFolder);
                                 }
                                 if ($account->_settings->Imap4DeleteLikePop3 && $t === null) {
                                     $trashFolder = new Folder($account->Id, -1, $folderPrefix . WM_FOLDERNAME_Trash, WM_FOLDERNAME_Trash, WM_FOLDERSYNC_DontSync, WM_FOLDERTYPE_Trash);
                                     if ($createFoldersIfNotExist) {
                                         $trashFolder->SetFolderSync($inboxSyncType);
                                         $this->MailStorage->CreateFolder($trashFolder);
                                     }
                                     $addFolders->Add($trashFolder);
                                 }
                             } else {
                                 $this->DbStorage->DeleteUserData($account->IdUser, $account->Id);
                             }
                             $this->MailStorage->Disconnect();
                             break;
                     }
                 } else {
                     $result = false;
                     $this->DbStorage->DeleteUserData($account->IdUser);
                 }
                 if ($result && $folders && $folders->Count() > 0) {
                     $folders = $folders->SortRootTree();
                     $this->DbStorage->CreateFolders($folders);
                 }
             }
         }
     } else {
         $result = false;
     }
     if ($result && $account->IsInternal) {
         $this->DbStorage->SaveMailAliases($account);
         $this->DbStorage->SaveMailForwards($account);
     }
     if (!$result) {
         $this->SetError(ap_Utils::TakePhrase('WM_CANT_CREATE_ACCOUNT'));
     }
     return $result;
 }