本文整理匯總了PHP中SugarFolder::copyBean方法的典型用法代碼示例。如果您正苦於以下問題:PHP SugarFolder::copyBean方法的具體用法?PHP SugarFolder::copyBean怎麽用?PHP SugarFolder::copyBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SugarFolder
的用法示例。
在下文中一共展示了SugarFolder::copyBean方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: moveEmails
/**
* moves emails from folder to folder
* @param string $fromIe I-E id
* @param string $fromFolder IMAP path to folder in which the email lives
* @param string $toIe I-E id
* @param string $toFolder
* @param string $uids UIDs of emails to move, either Sugar GUIDS or IMAP
* UIDs
* @param bool $copy Default false
* @return bool True on successful execution
*/
function moveEmails($fromIe, $fromFolder, $toIe, $toFolder, $uids, $copy = false)
{
global $app_strings;
global $current_user;
// same I-E server
if ($fromIe == $toIe) {
$GLOBALS['log']->debug("********* SUGARFOLDER - moveEmails() moving email from I-E to I-E");
//$exDestFolder = explode("::", $toFolder);
//preserve $this->mailbox
if (isset($this->mailbox)) {
$oldMailbox = $this->mailbox;
}
$this->retrieve($fromIe);
$this->mailbox = $fromFolder;
$this->connectMailserver();
$exUids = explode('::;::', $uids);
$uids = implode(",", $exUids);
// imap_mail_move accepts comma-delimited lists of UIDs
if ($copy) {
if (imap_mail_copy($this->conn, $uids, $toFolder, CP_UID)) {
$this->mailbox = $toFolder;
$this->connectMailserver();
$newOverviews = imap_fetch_overview($this->conn, $uids, FT_UID);
$this->updateOverviewCacheFile($newOverviews, 'append');
if (isset($oldMailbox)) {
$this->mailbox = $oldMailbox;
}
return true;
} else {
$GLOBALS['log']->debug("INBOUNDEMAIL: could not imap_mail_copy() [ {$uids} ] to folder [ {$toFolder} ] from folder [ {$fromFolder} ]");
}
} else {
if (imap_mail_move($this->conn, $uids, $toFolder, CP_UID)) {
$GLOBALS['log']->info("INBOUNDEMAIL: imap_mail_move() [ {$uids} ] to folder [ {$toFolder} ] from folder [ {$fromFolder} ]");
imap_expunge($this->conn);
// hard deletes moved messages
// update cache on fromFolder
$newOverviews = $this->getOverviewsFromCacheFile($uids, $fromFolder, true);
$this->deleteCachedMessages($uids, $fromFolder);
// update cache on toFolder
$this->checkEmailOneMailbox($toFolder, true, true);
if (isset($oldMailbox)) {
$this->mailbox = $oldMailbox;
}
return true;
} else {
$GLOBALS['log']->debug("INBOUNDEMAIL: could not imap_mail_move() [ {$uids} ] to folder [ {$toFolder} ] from folder [ {$fromFolder} ]");
}
}
} elseif ($toIe == 'folder' && $fromFolder == 'sugar::Emails') {
$GLOBALS['log']->debug("********* SUGARFOLDER - moveEmails() moving email from SugarFolder to SugarFolder");
// move from sugar folder to sugar folder
require_once "include/SugarFolders/SugarFolders.php";
$sugarFolder = new SugarFolder();
$exUids = explode($app_strings['LBL_EMAIL_DELIMITER'], $uids);
foreach ($exUids as $id) {
if ($copy) {
$sugarFolder->copyBean($fromIe, $toFolder, $id, "Emails");
} else {
$fromSugarFolder = new SugarFolder();
$fromSugarFolder->retrieve($fromIe);
$toSugarFolder = new SugarFolder();
$toSugarFolder->retrieve($toFolder);
$email = new Email();
$email->retrieve($id);
$email->status = 'unread';
// when you move from My Emails to Group Folder, Assign To field for the Email should become null
if ($fromSugarFolder->is_dynamic && $toSugarFolder->is_group) {
$email->assigned_user_id = "";
$email->save();
if (!$toSugarFolder->checkEmailExistForFolder($id)) {
$fromSugarFolder->deleteEmailFromAllFolder($id);
$toSugarFolder->addBean($email);
}
} elseif ($fromSugarFolder->is_group && $toSugarFolder->is_dynamic) {
$fromSugarFolder->deleteEmailFromAllFolder($id);
$email->assigned_user_id = $current_user->id;
$email->save();
} else {
// If you are moving something from personal folder then delete an entry from all folder
if (!$fromSugarFolder->is_dynamic && !$fromSugarFolder->is_group) {
$fromSugarFolder->deleteEmailFromAllFolder($id);
}
// if
if ($fromSugarFolder->is_dynamic && !$toSugarFolder->is_dynamic && !$toSugarFolder->is_group) {
$email->assigned_user_id = "";
$toSugarFolder->addBean($email);
}
// if
//.........這裏部分代碼省略.........