コード例 #1
0
 /**
  * @param FolderCollection $folderCollection
  * @return String
  */
 function CreateHtmlFolderTree($folderCollection)
 {
     $out = '';
     for ($i = 0, $c = $folderCollection->Count(); $i < $c; $i++) {
         $folder =& $folderCollection->Get($i);
         $foldername = '';
         if (ConvertUtils::IsLatin($folder->Name)) {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->_pagebuilder->_proc->account->GetUserCharset());
         } else {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->_pagebuilder->_proc->account->DefaultIncCharset, $this->_pagebuilder->_proc->account->GetUserCharset());
         }
         $isselect = '';
         if ($this->_pagebuilder->_proc->currentFolder && $this->_pagebuilder->_proc->currentFolder->IdDb == $folder->IdDb) {
             $isselect = 'class="wm_select_folder"';
         }
         if (!$folder->Hide) {
             $out .= '<div style="padding-left: ' . $folder->Level * 8 . 'px;" ' . $isselect . '>';
             $out .= '<a href="?' . FOLDER_ID . '=' . $folder->IdDb . '">';
             $out .= '<img src="./skins/' . $this->_pagebuilder->SkinName() . '/folders/' . $this->GetFolderImg($folder) . '" />';
             switch ($folder->Type) {
                 default:
                 case FOLDERTYPE_Custom:
                     $out .= ConvertUtils::WMHtmlSpecialChars($foldername);
                     break;
                 case FOLDERTYPE_Inbox:
                     $out .= FolderInbox;
                     break;
                 case FOLDERTYPE_Drafts:
                     $out .= FolderDrafts;
                     break;
                 case FOLDERTYPE_SentItems:
                     $out .= FolderSentItems;
                     break;
                 case FOLDERTYPE_Trash:
                     $out .= FolderTrash;
                     break;
             }
             if ($folder->SyncType == FOLDERSYNC_DirectMode) {
                 $out .= '&nbsp;<span id="cnt_' . $folder->IdDb . '" class="wm_hide"></span></a>';
                 $out .= '&nbsp;<span title="' . ConvertUtils::AttributeQuote(DirectAccessTitle) . '" class="wm_folder_direct_mode">&nbsp;' . DirectAccess . '&nbsp;</span>';
             } else {
                 $out .= $folder->UnreadMessageCount > 0 ? '&nbsp;<span id="cnt_' . $folder->IdDb . '">(' . $folder->UnreadMessageCount . ')</span></a>' : '&nbsp;<span id="cnt_' . $folder->IdDb . '"></span></a>';
             }
             $out .= '</div>';
             if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
                 $out .= $this->CreateHtmlFolderTree($folder->SubFolders);
             }
         }
     }
     return $out;
 }
コード例 #2
0
 /**
  * @param FolderCollection $_folders
  * @param XmlDomNode $_nodeTree
  * @param MailProcessor $_processor
  */
 function GetFoldersTreeXml(&$_folders, &$_nodeTree, &$_processor)
 {
     for ($_i = 0, $_count = $_folders->Count(); $_i < $_count; $_i++) {
         $_folder =& $_folders->Get($_i);
         $_folderNode = new XmlDomNode('folder');
         $_folderNode->AppendAttribute('id', $_folder->IdDb);
         $_folderNode->AppendAttribute('id_parent', $_folder->IdParent);
         $_folderNode->AppendAttribute('type', $_folder->Type);
         $_folderNode->AppendAttribute('sync_type', $_folder->SyncType);
         $_folderNode->AppendAttribute('hide', (int) $_folder->Hide);
         $_folderNode->AppendAttribute('fld_order', (int) $_folder->FolderOrder);
         if ($_folder->SyncType == FOLDERSYNC_DirectMode) {
             $_processor->GetFolderMessageCount($_folder);
         }
         $_folderNode->AppendAttribute('count', $_folder->MessageCount);
         $_folderNode->AppendAttribute('count_new', $_folder->UnreadMessageCount);
         $_folderNode->AppendAttribute('size', $_folder->Size);
         if (ConvertUtils::IsLatin($_folder->Name)) {
             $_folderNode->AppendChild(new XmlDomNode('name', ConvertUtils::ConvertEncoding($_folder->Name, CPAGE_UTF7_Imap, CPAGE_UTF8), true));
         } else {
             $_folderNode->AppendChild(new XmlDomNode('name', ConvertUtils::ConvertEncoding($_folder->Name, $_processor->_account->DefaultIncCharset, CPAGE_UTF8), true));
         }
         $_folderNode->AppendChild(new XmlDomNode('full_name', $_folder->FullName, true));
         if ($_folder->SubFolders != null && $_folder->SubFolders->Count() > 0) {
             $_foldersNode = new XmlDomNode('folders');
             CXmlProcessing::GetFoldersTreeXml($_folder->SubFolders, $_foldersNode, $_processor);
             $_folderNode->AppendChild($_foldersNode);
             unset($_foldersNode);
         }
         $_nodeTree->AppendChild($_folderNode);
         unset($_folderNode, $_folder);
     }
 }
コード例 #3
0
ファイル: class_dbstorage.php プロジェクト: JDevelopers/Mail
 /**
  * @param FolderCollection $folders
  * @return bool
  */
 function CreateFolders(&$folders)
 {
     $result = true;
     if ($folders == null) {
         return $result;
     }
     for ($i = 0, $count = $folders->Count(); $i < $count; $i++) {
         $folder =& $folders->Get($i);
         $result &= $this->CreateFolder($folder);
         if (!is_null($folder->SubFolders)) {
             for ($j = 0, $cc = $folder->SubFolders->Count(); $j < $cc; $j++) {
                 $subFolder =& $folder->SubFolders->Get($j);
                 $subFolder->IdParent = $folder->IdDb;
                 unset($subFolder);
             }
             $result &= $this->CreateFolders($folder->SubFolders);
         }
         unset($folder);
     }
     return $result;
 }
コード例 #4
0
ファイル: dbstorage.php プロジェクト: JDevelopers/Mail
 /**
  * @param FolderCollection $folders
  * @return bool
  */
 function CreateFolders(&$folders)
 {
     $result = true;
     if ($folders == null) {
         return $result;
     }
     for ($i = 0, $c = $folders->Count(); $i < $c; $i++) {
         $folder =& $folders->Get($i);
         if ($result && $folder) {
             $result &= $this->CreateFolder($folder);
             if ($folder->SubFolders && $result) {
                 for ($j = 0, $t = count($folder->SubFolders->Instance()); $j < $t; $j++) {
                     $subFolder =& $folder->SubFolders->Get($j);
                     $subFolder->IdParent = $folder->IdDb;
                     unset($subFolder);
                 }
                 $result &= $this->CreateFolders($folder->SubFolders);
             }
         }
         unset($folder);
     }
     return $result;
 }
コード例 #5
0
    /**
     * @param FolderCollection $folders
     * @param int $messagesCount
     * @param int $messagesSize
     * @param Account $account
     * @return string
     */
    function CreateHtmlFolderTree(&$folders, &$messagesCount, &$messagesSize, &$account)
    {
        $out = array('', '');
        for ($i = 0, $count = $folders->Count(); $i < $count; $i++) {
            $folder =& $folders->Get($i);
            if ($i > 0) {
                $pr_folder =& $folders->Get($i - 1);
            }
            if ($i < $count - 1) {
                $nx_folder =& $folders->Get($i + 1);
            }
            $messagesCount += $folder->MessageCount;
            $messagesSize += $folder->Size;
            $foldername = '';
            if (ConvertUtils::IsLatin($folder->Name)) {
                $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->setaccount->_pagebuilder->_proc->account->GetUserCharset());
            } else {
                $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->setaccount->_pagebuilder->_proc->account->DefaultIncCharset, $this->setaccount->_pagebuilder->_proc->account->GetUserCharset());
            }
            $folderUrl = 'skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/' . GetFolderImg($folder->Type, MAILPROTOCOL_POP3);
            $hasChild = $folder->SubFolders != null;
            $hasMessages = $folder->MessageCount > 0;
            $disab = $hasChild || $hasMessages ? 'disabled="disabled" ' : '';
            $disab = $account->MailProtocol == MAILPROTOCOL_POP3 ? '' : $disab;
            $checkbox = $folder->Type == FOLDERTYPE_Custom ? '<input type="checkbox" id="ch_0" name="folders[' . ConvertUtils::AttributeQuote($folder->IdDb) . ']" value="' . ConvertUtils::AttributeQuote($folder->FullName) . '" class="wm_checkbox" ' . $disab . '/>' : '';
            $uphref = $i < 1 ? '<img src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/up_inactive.gif" />' : '<a onclick="return DoAlert();" href="' . ACTIONFILE . '?action=update&req=folderorder&cf_id=' . $folder->IdDb . '&rf_id=' . $pr_folder->IdDb . '"><img
					src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/up.gif" /></a>';
            $downhref = $i > $count - 2 ? '<img src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/down_inactive.gif" />' : '<a onclick="return DoAlert();" href="' . ACTIONFILE . '?action=update&req=folderorder&cf_id=' . $folder->IdDb . '&rf_id=' . $nx_folder->IdDb . '"><img
					src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/down.gif" /></a>';
            $eyeimg = $folder->Hide ? 'hide.gif' : 'show.gif';
            switch ($folder->Type) {
                default:
                case FOLDERTYPE_Custom:
                    $foldername = ConvertUtils::WMHtmlSpecialChars($foldername);
                    break;
                case FOLDERTYPE_Inbox:
                    $foldername = FolderInbox;
                    break;
                case FOLDERTYPE_Drafts:
                    $foldername = FolderDrafts;
                    break;
                case FOLDERTYPE_SentItems:
                    $foldername = FolderSentItems;
                    break;
                case FOLDERTYPE_Trash:
                    $foldername = FolderTrash;
                    break;
            }
            $nameSting = $folder->Type == FOLDERTYPE_Custom ? '<form action="' . ACTIONFILE . '?action=rename&req=folder" id="folder_form_' . $folder->IdDb . '" method="POST">
					<img src="' . $folderUrl . '" />
					<a href="#" onclick="EditFolder(' . $folder->IdDb . ');" id="folder_a_' . $folder->IdDb . '">' . $foldername . '</a>
					<input type="text" class="wm_hide" name="folderid" value="' . $folder->IdDb . '">
					<input type="text" class="wm_hide" name="fname" maxLength="30" id="folder_i_' . $folder->IdDb . '" value="' . ConvertUtils::AttributeQuote($foldername) . '"/></form>' : '<img src="' . ConvertUtils::AttributeQuote($folderUrl) . '" /> ' . $foldername;
            $imap4SyncTd = $this->setaccount->_editAccount->MailProtocol == MAILPROTOCOL_IMAP4 ? '
						<td><form id="syncform_' . $folder->IdDb . '" action="' . ACTIONFILE . '?action=update&req=foldersync" method="POST">
							<input type="hidden" name="folderid" value="' . $folder->IdDb . '">
							<select onchange="document.getElementById(\'syncform_' . $folder->IdDb . '\').submit();" name="synctype">
								<option value="' . FOLDERSYNC_DontSync . '" ' . ($folder->SyncType == FOLDERSYNC_DontSync ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNo . '</option>
								<option value="' . FOLDERSYNC_NewHeadersOnly . '" ' . ($folder->SyncType == FOLDERSYNC_NewHeadersOnly ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNewHeaders . '</option>
								<option value="' . FOLDERSYNC_AllHeadersOnly . '" ' . ($folder->SyncType == FOLDERSYNC_AllHeadersOnly ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeAllHeaders . '</option>
								<option value="' . FOLDERSYNC_NewEntireMessages . '" ' . ($folder->SyncType == FOLDERSYNC_NewEntireMessages ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNewMessages . '</option>
								<option value="' . FOLDERSYNC_AllEntireMessages . '" ' . ($folder->SyncType == FOLDERSYNC_AllEntireMessages ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeAllMessages . '</option>
								<option value="' . FOLDERSYNC_DirectMode . '" ' . ($folder->SyncType == FOLDERSYNC_DirectMode ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeDirectMode . '</option>
							</select></form>
						</td>
							' : '<td class="wm_hide"></td>';
            $out[0] .= '
						<tr>
							<td>' . $checkbox . '</td>
							<td class="wm_settings_mf_folder">
							<div style="padding-left: ' . $folder->Level * 8 . 'px;">
							' . $nameSting . '
							</div></td>
							<td>' . $folder->MessageCount . '</td>
							<td>' . GetFriendlySize($folder->Size) . '</td>
							' . $imap4SyncTd . '
							<td><a href="#" onclick="if (!DoAlert()) return false; document.location=\'' . ACTIONFILE . '?action=update&req=folderhide&folderid=' . $folder->IdDb . '\'"><img class="wm_settings_mf_show_hide" src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/' . $eyeimg . '"></a>
							</td>
							<td class="wm_settings_mf_up_down">
								' . $uphref . $downhref . '
							</td>
						</tr>			
				';
            $out[1] .= '<option value="' . $folder->IdDb . '">' . str_repeat('&nbsp;', $folder->Level * 3) . $foldername . '</option>' . "\r\n";
            if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
                $temp = $this->CreateHtmlFolderTree($folder->SubFolders, $messagesCount, $messagesSize, $account);
                $out[0] .= $temp[0];
                $out[1] .= $temp[1];
            }
        }
        return $out;
    }
コード例 #6
0
 /**
  * @param FolderCollection $folderCollection
  * @return String
  */
 function CreateFolderTree($folderCollection)
 {
     $out = '';
     for ($i = 0, $c = $folderCollection->Count(); $i < $c; $i++) {
         $folder =& $folderCollection->Get($i);
         if ($folder->Hide) {
             continue;
         }
         if ($folder->SyncType == FOLDERSYNC_DirectMode && $this->_pagebuilder->_proc->account->MailProtocol == MAILPROTOCOL_POP3) {
             continue;
         }
         $foldername = '';
         if (ConvertUtils::IsLatin($folder->Name)) {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->_pagebuilder->_proc->account->GetUserCharset());
         } else {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->_pagebuilder->_proc->account->DefaultIncCharset, $this->_pagebuilder->_proc->account->GetUserCharset());
         }
         $out .= '<div onclick="MoveToFolder(\'' . $folder->IdDb . '\');" class="wm_menu_item" onmouseover="this.className=\'wm_menu_item_over\';" onmouseout="this.className=\'wm_menu_item\';">' . str_repeat('&nbsp;', (int) $folder->Level * 4);
         switch ($folder->Type) {
             default:
             case FOLDERTYPE_Custom:
                 $out .= ConvertUtils::WMHtmlSpecialChars($foldername);
                 break;
             case FOLDERTYPE_Inbox:
                 $out .= FolderInbox;
                 break;
             case FOLDERTYPE_Drafts:
                 $out .= FolderDrafts;
                 break;
             case FOLDERTYPE_SentItems:
                 $out .= FolderSentItems;
                 break;
             case FOLDERTYPE_Trash:
                 $out .= FolderTrash;
                 break;
         }
         $out .= '</div>';
         if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
             $out .= $this->CreateFolderTree($folder->SubFolders);
         }
     }
     return $out;
 }
コード例 #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;
 }