コード例 #1
0
 /**
  * @param Array $messageIdUidSet
  * @param Folder $fromFolder
  * @param Folder $toFolder
  * @return bool
  */
 function MoveMessages(&$messageIdUidSet, &$fromFolder, &$toFolder)
 {
     $GLOBALS[MailDefaultCharset] = $this->_account->DefaultIncCharset;
     $GLOBALS[MailOutputCharset] = $this->_account->DefaultOutCharset;
     $messageIdSet = array_keys($messageIdUidSet);
     $messageUidSet = array_values($messageIdUidSet);
     if (!$this->DbStorage->Connect() || !$this->MailStorage->Connect()) {
         return false;
     }
     $result = true;
     switch ($this->_account->MailProtocol) {
         case MAILPROTOCOL_POP3:
         case MAILPROTOCOL_WMSERVER:
             switch ($fromFolder->SyncType) {
                 case FOLDERSYNC_DontSync:
                     return $this->DbStorage->MoveMessages($messageIdSet, false, $fromFolder, $toFolder);
                     break;
                 default:
                     $result = $this->DbStorage->SaveMessages($this->GetMessages($messageIdUidSet, $fromFolder), $toFolder);
                     if ($result) {
                         if ($result && $fromFolder->SyncType != FOLDERSYNC_DirectMode) {
                             $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                         } else {
                             $result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                         }
                     }
                     return $result;
                     break;
             }
             break;
         case MAILPROTOCOL_IMAP4:
             switch ($fromFolder->SyncType) {
                 case FOLDERSYNC_DontSync:
                     switch ($toFolder->SyncType) {
                         case FOLDERSYNC_DontSync:
                             return $this->DbStorage->MoveMessages($messageIdSet, false, $fromFolder, $toFolder);
                         case FOLDERSYNC_AllEntireMessages:
                         case FOLDERSYNC_AllHeadersOnly:
                         case FOLDERSYNC_NewEntireMessages:
                         case FOLDERSYNC_NewHeadersOnly:
                             $result = $this->MailStorage->SaveMessages($this->GetMessages($messageIdUidSet, $fromFolder), $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                 $result &= $this->MailStorage->SynchronizeFolder($toFolder);
                             }
                             return $result;
                         case FOLDERSYNC_DirectMode:
                             $result = $this->MailStorage->SaveMessages($this->DbStorage->LoadMessages($messageIdSet, false, $fromFolder), $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                             }
                             return $result;
                     }
                     break;
                 case FOLDERSYNC_AllEntireMessages:
                 case FOLDERSYNC_AllHeadersOnly:
                 case FOLDERSYNC_NewEntireMessages:
                 case FOLDERSYNC_NewHeadersOnly:
                     switch ($toFolder->SyncType) {
                         case FOLDERSYNC_DontSync:
                             $result = $this->DbStorage->SaveMessages($this->GetMessages($messageIdUidSet, $fromFolder), $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                 $result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                                 if ($this->MailStorage->PurgeUidFolder($fromFolder, $messageUidSet)) {
                                 } elseif (!$this->MailStorage->PurgeFolder($fromFolder)) {
                                     return false;
                                 }
                             }
                             return $result;
                         case FOLDERSYNC_AllEntireMessages:
                         case FOLDERSYNC_AllHeadersOnly:
                         case FOLDERSYNC_NewEntireMessages:
                         case FOLDERSYNC_NewHeadersOnly:
                             $result = $this->MailStorage->CopyMessages($messageUidSet, true, $fromFolder, $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                 $result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                                 if ($this->MailStorage->PurgeUidFolder($fromFolder, $messageUidSet)) {
                                 } elseif (!$this->MailStorage->PurgeFolder($fromFolder)) {
                                     return false;
                                 }
                                 $GLOBALS[MailDefaultCharset] = $this->_account->GetDefaultIncCharset();
                                 $GLOBALS[MailOutputCharset] = $this->_account->DbCharset;
                                 $result &= $this->MailStorage->SynchronizeFolder($toFolder);
                             }
                             return $result;
                         case FOLDERSYNC_DirectMode:
                             $result = $this->MailStorage->CopyMessages($messageUidSet, true, $fromFolder, $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                 $result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                                 if ($this->MailStorage->PurgeUidFolder($fromFolder, $messageUidSet)) {
                                 } elseif (!$this->MailStorage->PurgeFolder($fromFolder)) {
                                     return false;
                                 }
                             }
                             return $result;
                     }
                     break;
                 case FOLDERSYNC_DirectMode:
                     switch ($toFolder->SyncType) {
                         case FOLDERSYNC_DontSync:
                             $result = $this->DbStorage->SaveMessages($this->GetMessages($messageIdUidSet, $fromFolder), $toFolder);
                             if ($result) {
                                 $result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                                 if ($this->MailStorage->PurgeUidFolder($fromFolder, $messageUidSet)) {
                                 } elseif (!$this->MailStorage->PurgeFolder($fromFolder)) {
                                     return false;
                                 }
                             }
                             return $result;
                         case FOLDERSYNC_AllEntireMessages:
                         case FOLDERSYNC_AllHeadersOnly:
                         case FOLDERSYNC_NewEntireMessages:
                         case FOLDERSYNC_NewHeadersOnly:
                             $result = $this->MailStorage->CopyMessages($messageUidSet, true, $fromFolder, $toFolder);
                             if ($result) {
                                 $result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                                 if ($this->MailStorage->PurgeUidFolder($fromFolder, $messageUidSet)) {
                                 } elseif (!$this->MailStorage->PurgeFolder($fromFolder)) {
                                     return false;
                                 }
                                 $GLOBALS[MailDefaultCharset] = $this->_account->GetDefaultIncCharset();
                                 $GLOBALS[MailOutputCharset] = $this->_account->DbCharset;
                                 $result &= $this->MailStorage->SynchronizeFolder($toFolder);
                             }
                             return $result;
                         case FOLDERSYNC_DirectMode:
                             $result = $this->MailStorage->CopyMessages($messageUidSet, true, $fromFolder, $toFolder);
                             if ($result) {
                                 $result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                                 if ($this->MailStorage->PurgeUidFolder($fromFolder, $messageUidSet)) {
                                 } elseif (!$this->MailStorage->PurgeFolder($fromFolder)) {
                                     return false;
                                 }
                             }
                             return $result;
                     }
                     break;
             }
             if ($fromFolder->SyncType != FOLDERSYNC_DirectMode) {
                 if ($this->DbStorage->Connect()) {
                     $result &= $this->DbStorage->DeleteMessages($messageIndexSet, $indexAsUid, $fromFolder, $toFolder);
                 }
             }
             if ($fromFolder->SyncType != FOLDERSYNC_DontSync && $toFolder->SyncType != FOLDERSYNC_DontSync) {
                 if ($this->MailStorage->Connect()) {
                     $result &= $this->MailStorage->MoveMessages($messageIndexSet, $indexAsUid, $fromFolder, $toFolder);
                     $folders =& $this->GetFolders();
                     $result &= $this->Synchronize($folders);
                 }
             }
             break;
     }
     return $result;
 }
コード例 #2
0
 /**
  * @param Array $messageIdUidSet
  * @param Folder $fromFolder
  * @param Folder $toFolder
  * @return bool
  */
 function MoveMessages(&$messageIdUidSet, &$fromFolder, &$toFolder)
 {
     $GLOBALS[MailDefaultCharset] = $this->_account->DefaultIncCharset;
     $GLOBALS[MailOutputCharset] = $this->_account->DefaultOutCharset;
     $messageIdSet = array_keys($messageIdUidSet);
     $messageUidSet = array_values($messageIdUidSet);
     $result = true;
     switch ($this->_account->MailProtocol) {
         case MAILPROTOCOL_WMSERVER:
             if (!$this->MailStorage->Connect()) {
                 return false;
             }
             $result = $this->MailStorage->MoveMessages($messageUidSet, $fromFolder, $toFolder);
             if (!$result) {
                 $this->IsMoveError = true;
             }
             $_index = 0;
             foreach ($messageIdSet as $_id) {
                 $messageIdUidSet[$_id] = $messageUidSet[$_index];
                 $_index = $_index + 1;
             }
             if ($result && $this->DbStorage->Connect()) {
                 $result &= $this->DbStorage->MoveMessagesWithUidUpdate($messageIdUidSet, $fromFolder, $toFolder);
             }
             return $result;
             break;
         case MAILPROTOCOL_POP3:
             switch ($fromFolder->SyncType) {
                 case FOLDERSYNC_DontSync:
                     if (!$this->DbStorage->Connect()) {
                         return false;
                     }
                     return $this->DbStorage->MoveMessages($messageIdSet, false, $fromFolder, $toFolder);
                     break;
                 default:
                     if (!$this->DbStorage->Connect()) {
                         return false;
                     }
                     $result = $this->DbStorage->SaveMessages($this->GetMessages($messageIdUidSet, $fromFolder), $toFolder);
                     if ($result) {
                         if ($result && $fromFolder->SyncType != FOLDERSYNC_DirectMode) {
                             $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                         } else {
                             /*
                             									if (!$this->MailStorage->Connect())
                             									{
                             										$result = false;
                             									}
                             									else 
                             									{
                             										$result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                             									}*/
                         }
                     }
                     return $result;
                     break;
             }
             break;
         case MAILPROTOCOL_IMAP4:
             switch ($fromFolder->SyncType) {
                 case FOLDERSYNC_DontSync:
                     switch ($toFolder->SyncType) {
                         case FOLDERSYNC_DontSync:
                             if ($this->DbStorage->Connect()) {
                                 return $this->DbStorage->MoveMessages($messageIdSet, false, $fromFolder, $toFolder);
                             }
                             return false;
                         case FOLDERSYNC_AllEntireMessages:
                         case FOLDERSYNC_AllHeadersOnly:
                         case FOLDERSYNC_NewEntireMessages:
                         case FOLDERSYNC_NewHeadersOnly:
                             if (!$this->DbStorage->Connect() || !$this->MailStorage->Connect()) {
                                 return false;
                             }
                             $result = $this->MailStorage->SaveMessages($this->GetMessages($messageIdUidSet, $fromFolder), $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                 $result &= $this->MailStorage->SynchronizeFolder($toFolder);
                             } else {
                                 $this->IsMoveError = true;
                             }
                             return $result;
                         case FOLDERSYNC_DirectMode:
                             if (!$this->DbStorage->Connect() || !$this->MailStorage->Connect()) {
                                 return false;
                             }
                             $result = $this->MailStorage->SaveMessages($this->DbStorage->LoadMessages($messageIdSet, false, $fromFolder), $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                             } else {
                                 $this->IsMoveError = true;
                             }
                             return $result;
                     }
                     break;
                 case FOLDERSYNC_AllEntireMessages:
                 case FOLDERSYNC_AllHeadersOnly:
                 case FOLDERSYNC_NewEntireMessages:
                 case FOLDERSYNC_NewHeadersOnly:
                     if (!$this->DbStorage->Connect() || !$this->MailStorage->Connect()) {
                         return false;
                     }
                     switch ($toFolder->SyncType) {
                         case FOLDERSYNC_DontSync:
                             $result = $this->DbStorage->SaveMessages($this->GetMessages($messageIdUidSet, $fromFolder), $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                 $result &= $this->MailStorage->SetDeleteFlagAndPurgeByUids($messageUidSet, $fromFolder);
                             }
                             return $result;
                         case FOLDERSYNC_AllEntireMessages:
                         case FOLDERSYNC_AllHeadersOnly:
                         case FOLDERSYNC_NewEntireMessages:
                         case FOLDERSYNC_NewHeadersOnly:
                             $result = $this->MailStorage->CopyMessages($messageUidSet, true, $fromFolder, $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                 $result &= $this->MailStorage->SetDeleteFlagAndPurgeByUids($messageUidSet, $fromFolder);
                                 $GLOBALS[MailDefaultCharset] = $this->_account->GetDefaultIncCharset();
                                 $GLOBALS[MailOutputCharset] = $this->_account->DbCharset;
                                 $result &= $this->MailStorage->SynchronizeFolder($toFolder);
                             } else {
                                 $this->IsMoveError = true;
                             }
                             return $result;
                         case FOLDERSYNC_DirectMode:
                             $result = $this->MailStorage->CopyMessages($messageUidSet, true, $fromFolder, $toFolder);
                             if ($result) {
                                 $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                 $result &= $this->MailStorage->SetDeleteFlagAndPurgeByUids($messageUidSet, $fromFolder);
                             } else {
                                 $this->IsMoveError = true;
                             }
                             return $result;
                     }
                     break;
                 case FOLDERSYNC_DirectMode:
                     if (!$this->DbStorage->Connect() || !$this->MailStorage->Connect()) {
                         return false;
                     }
                     switch ($toFolder->SyncType) {
                         case FOLDERSYNC_DontSync:
                             $result = $this->DbStorage->SaveMessages($this->GetMessages($messageIdUidSet, $fromFolder), $toFolder);
                             if ($result) {
                                 $result &= $this->MailStorage->SetDeleteFlagAndPurgeByUids($messageUidSet, $fromFolder);
                             }
                             return $result;
                         case FOLDERSYNC_AllEntireMessages:
                         case FOLDERSYNC_AllHeadersOnly:
                         case FOLDERSYNC_NewEntireMessages:
                         case FOLDERSYNC_NewHeadersOnly:
                             $result = $this->MailStorage->CopyMessages($messageUidSet, true, $fromFolder, $toFolder);
                             if ($result) {
                                 $result &= $this->MailStorage->SetDeleteFlagAndPurgeByUids($messageUidSet, $fromFolder);
                                 $GLOBALS[MailDefaultCharset] = $this->_account->GetDefaultIncCharset();
                                 $GLOBALS[MailOutputCharset] = $this->_account->DbCharset;
                                 $result &= $this->MailStorage->SynchronizeFolder($toFolder);
                             } else {
                                 $this->IsMoveError = true;
                             }
                             return $result;
                         case FOLDERSYNC_DirectMode:
                             $result = $this->MailStorage->CopyMessages($messageUidSet, true, $fromFolder, $toFolder);
                             if ($result) {
                                 $result &= $this->MailStorage->SetDeleteFlagAndPurgeByUids($messageUidSet, $fromFolder);
                             } else {
                                 $this->IsMoveError = true;
                             }
                             return $result;
                     }
                     break;
             }
             if ($fromFolder->SyncType != FOLDERSYNC_DirectMode) {
                 if ($this->DbStorage->Connect()) {
                     $result &= $this->DbStorage->DeleteMessages($messageIdSet, true, $fromFolder, $toFolder);
                 }
             }
             if ($fromFolder->SyncType != FOLDERSYNC_DontSync && $toFolder->SyncType != FOLDERSYNC_DontSync) {
                 if ($this->MailStorage->Connect()) {
                     $result &= $this->MailStorage->MoveMessages($messageUidSet, false, $fromFolder, $toFolder);
                     $folders =& $this->GetFolders();
                     $result &= $this->Synchronize($folders);
                 }
             }
             break;
     }
     return $result;
 }