mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
get some more actions working (delete, view header, view message body)
This commit is contained in:
parent
c1593b8d84
commit
df1a2e20b5
@ -547,7 +547,7 @@ class mail_bo
|
||||
static $folderOpened;
|
||||
//if (empty($folderOpened) || $folderOpened!=$_foldername)
|
||||
//{
|
||||
//error_log( "------------------------reopen- $_foldername <br>");
|
||||
//error_log( __METHOD__.__LINE__." $_foldername ".function_backtrace());
|
||||
//error_log(__METHOD__.__LINE__.' Connected with icServer for Profile:'.$this->profileID.'?'.print_r($this->icServer->_connected,true));
|
||||
if (!($this->icServer->_connected == 1)) {
|
||||
$tretval = $this->openConnection($this->profileID,false);
|
||||
@ -2329,6 +2329,134 @@ class mail_bo
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a Message
|
||||
*
|
||||
* @param mixed array/string _messageUID array of ids to flag, or 'all'
|
||||
* @param string _folder foldername
|
||||
* @param string _forceDeleteMethod - "no", or deleteMethod like 'move_to_trash',"mark_as_deleted","remove_immediately"
|
||||
*
|
||||
* @return bool true, as we do not handle return values yet
|
||||
*/
|
||||
function deleteMessages($_messageUID, $_folder=NULL, $_forceDeleteMethod='no')
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.'->'.array2string($_messageUID).','.array2string($_folder));
|
||||
$msglist = '';
|
||||
$oldMailbox = '';
|
||||
if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox'];
|
||||
if(!is_array($_messageUID) || count($_messageUID) === 0)
|
||||
{
|
||||
if ($_messageUID=='all')
|
||||
{
|
||||
$_messageUID= null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method
|
||||
if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions = $this->mailPreferences->preferences['deleteOptions'];
|
||||
//error_log(__METHOD__.__LINE__.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
|
||||
$trashFolder = $this->getTrashFolder();
|
||||
$draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['felamimail']['draftFolder'];
|
||||
$templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['felamimail']['templateFolder'];
|
||||
if(($_folder == $trashFolder && $deleteOptions == "move_to_trash") ||
|
||||
($_folder == $draftFolder)) {
|
||||
$deleteOptions = "remove_immediately";
|
||||
}
|
||||
if($this->icServer->getCurrentMailbox() != $_folder) {
|
||||
$oldMailbox = $this->icServer->getCurrentMailbox();
|
||||
$this->icServer->selectMailbox($_folder);
|
||||
}
|
||||
$updateCache = false;
|
||||
switch($deleteOptions) {
|
||||
case "move_to_trash":
|
||||
$updateCache = true;
|
||||
if(!empty($trashFolder)) {
|
||||
if (self::$debug) error_log(implode(' : ', $_messageUID));
|
||||
if (self::$debug) error_log("$trashFolder <= ". $this->sessionData['mailbox']);
|
||||
// copy messages
|
||||
$retValue = $this->icServer->copyMessages($trashFolder, $_messageUID, $_folder, true);
|
||||
if ( PEAR::isError($retValue) ) {
|
||||
if (self::$debug) error_log(__METHOD__." failed to copy Message(s) from $_folder to $trashFolder: ".implode(',',$_messageUID));
|
||||
throw new egw_exception("failed to copy Message(s) from $_folder to $trashFolder: ".implode(',',$_messageUID).' due to:'.array2string($retValue->message));
|
||||
return false;
|
||||
}
|
||||
// mark messages as deleted
|
||||
$retValue = $this->icServer->deleteMessages($_messageUID, true);
|
||||
if ( PEAR::isError($retValue)) {
|
||||
if (self::$debug) error_log(__METHOD__." failed to delete Message(s) from $_folder: ".implode(',',$_messageUID)." due to:".$retValue->message);
|
||||
throw new egw_exception("failed to delete Message(s) from $_folder: ".implode(',',$_messageUID)." due to:".array2string($retValue->message));
|
||||
return false;
|
||||
}
|
||||
// delete the messages finaly
|
||||
$rv = $this->icServer->expunge();
|
||||
if ( PEAR::isError($rv)) error_log(__METHOD__." failed to expunge Message(s) from Folder: ".$_folder.' due to:'.$rv->message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "mark_as_deleted":
|
||||
// mark messages as deleted
|
||||
foreach((array)$_messageUID as $key =>$uid)
|
||||
{
|
||||
//flag messages, that are flagged for deletion as seen too
|
||||
$this->flagMessages('read', $uid, $_folder);
|
||||
$flags = $this->getFlags($uid);
|
||||
//error_log(__METHOD__.__LINE__.array2string($flags));
|
||||
if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid;
|
||||
unset($flags);
|
||||
}
|
||||
$retValue = PEAR::isError($this->icServer->deleteMessages($_messageUID, true));
|
||||
foreach((array)$undelete as $key =>$uid)
|
||||
{
|
||||
$this->flagMessages('undelete', $uid, $_folder);
|
||||
}
|
||||
if ( PEAR::isError($retValue)) {
|
||||
if (self::$debug) error_log(__METHOD__." failed to mark as deleted for Message(s) from $_folder: ".implode(',',$_messageUID));
|
||||
throw new egw_exception("failed to mark as deleted for Message(s) from $_folder: ".implode(',',$_messageUID).' due to:'.array2string($retValue->message));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case "remove_immediately":
|
||||
$updateCache = true;
|
||||
// mark messages as deleted
|
||||
$retValue = $this->icServer->deleteMessages($_messageUID, true);
|
||||
if ( PEAR::isError($retValue)) {
|
||||
if (self::$debug) error_log(__METHOD__." failed to remove immediately Message(s) from $_folder: ".implode(',',$_messageUID));
|
||||
throw new egw_exception("failed to remove immediately Message(s) from $_folder: ".implode(',',$_messageUID).' due to:'.array2string($retValue->message));
|
||||
return false;
|
||||
}
|
||||
// delete the messages finaly
|
||||
$this->icServer->expunge();
|
||||
break;
|
||||
}
|
||||
if ($updateCache)
|
||||
{
|
||||
$structure = egw_cache::getCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
|
||||
$cachemodified = false;
|
||||
foreach ((array)$_messageUID as $k => $_uid)
|
||||
{
|
||||
if (isset($structure[$this->icServer->ImapServerId][$_folder][$_uid]) || $_uid=='all')
|
||||
{
|
||||
$cachemodified = true;
|
||||
if ($_uid=='all')
|
||||
unset($structure[$this->icServer->ImapServerId][$_folder]);
|
||||
else
|
||||
unset($structure[$this->icServer->ImapServerId][$_folder][$_uid]);
|
||||
}
|
||||
}
|
||||
if ($cachemodified) egw_cache::setCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$structure,$expiration=60*60*1);
|
||||
}
|
||||
if($oldMailbox != '') {
|
||||
$this->icServer->selectMailbox($oldMailbox);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* flag a Message
|
||||
*
|
||||
@ -2525,6 +2653,87 @@ class mail_bo
|
||||
return $structure[$this->icServer->ImapServerId][$_folder][$_uid];
|
||||
}
|
||||
|
||||
/**
|
||||
* getMessageRawHeader
|
||||
* get parsed headers from message
|
||||
* @param string/int $_uid the messageuid,
|
||||
* @param string/int $_partID='' , the partID, may be omitted
|
||||
* @param boolean $decode flag to do the decoding on the fly
|
||||
* @return string the message header
|
||||
*/
|
||||
function getMessageHeader($_uid, $_partID = '',$decode=false)
|
||||
{
|
||||
$retValue = $this->icServer->getParsedHeaders($_uid, true, $_partID, true);
|
||||
if (PEAR::isError($retValue))
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.array2string($retValue->message));
|
||||
$retValue = null;
|
||||
}
|
||||
return ($decode ? self::decode_header($retValue,true):$retValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* getMessageRawHeader
|
||||
* get messages raw header data
|
||||
* @param string/int $_uid the messageuid,
|
||||
* @param string/int $_partID='' , the partID, may be omitted
|
||||
* @return string the message header
|
||||
*/
|
||||
function getMessageRawHeader($_uid, $_partID = '')
|
||||
{
|
||||
static $rawHeaders;
|
||||
$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
|
||||
//error_log(__METHOD__.__LINE__." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder");
|
||||
|
||||
if (is_null($rawHeaders)) $rawHeaders = egw_cache::getCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
|
||||
if (isset($rawHeaders[$this->icServer->ImapServerId][$_folder][$_uid][($_partID==''?'NIL':$_partID)]))
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__." Using Cache for raw Header $_uid, $_partID in Folder $_folder");
|
||||
return $rawHeaders[$this->icServer->ImapServerId][$_folder][$_uid][($_partID==''?'NIL':$_partID)];
|
||||
}
|
||||
|
||||
$retValue = $this->icServer->getRawHeaders($_uid, $_partID, true);
|
||||
if (PEAR::isError($retValue))
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.array2string($retValue->message));
|
||||
$retValue = "Could not retrieve RawHeaders in ".__METHOD__.__LINE__." PEAR::Error:".array2string($retValue->message);
|
||||
}
|
||||
$rawHeaders[$this->icServer->ImapServerId][$_folder][$_uid][($_partID==''?'NIL':$_partID)]=$retValue;
|
||||
egw_cache::setCache(egw_cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$rawHeaders,$expiration=60*60*1);
|
||||
return $retValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* getMessageRawBody
|
||||
* get the message raw body
|
||||
* @param string/int $_uid the messageuid,
|
||||
* @param string/int $_partID='' , the partID, may be omitted
|
||||
* @return string the message body
|
||||
*/
|
||||
function getMessageRawBody($_uid, $_partID = '')
|
||||
{
|
||||
//TODO: caching einbauen static!
|
||||
static $rawBody;
|
||||
$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
|
||||
if (isset($rawBody[$_folder][$_uid][($_partID==''?'NIL':$_partID)]))
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__." Using Cache for raw Body $_uid, $_partID in Folder $_folder");
|
||||
return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][($_partID==''?'NIL':$_partID)];
|
||||
}
|
||||
if($_partID != '') {
|
||||
$body = $this->icServer->getBody($_uid, true);
|
||||
} else {
|
||||
$body = $this->icServer->getBodyPart($_uid, $_partID, true);
|
||||
}
|
||||
if (PEAR::isError($body))
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.' failed:'.$body->message);
|
||||
return false;
|
||||
}
|
||||
$rawBody[$this->icServer->ImapServerId][$_folder][$_uid][($_partID==''?'NIL':$_partID)] = $body;
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* getMessageAttachments
|
||||
* parse the structure for attachments, it returns not the attachments itself, but an array of information about the attachment
|
||||
|
@ -453,11 +453,12 @@ class mail_hooks
|
||||
'admin' => False,
|
||||
'default'=> 50,
|
||||
),
|
||||
'PreViewFrameHeight' => array(
|
||||
'type' => 'input',
|
||||
'label' => 'Message preview size',
|
||||
'help' => 'If you want to see a preview of a mail by single clicking onto the subject, set the height for the message-list and the preview area here. 300 seems to be a good working value. The preview will be displayed at the end of the message list when a message is selected.',
|
||||
'name' => 'PreViewFrameHeight',
|
||||
'enablePreViewArea' => array(
|
||||
'type' => 'select',
|
||||
'label' => 'Message preview area',
|
||||
'help' => 'If you want to see a preview of a mail by single clicking onto the subject, enable this.',
|
||||
'name' => 'enablePreViewArea',
|
||||
'values' => $no_yes_copy,
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
'forced' => '300',
|
||||
|
@ -23,6 +23,8 @@ class mail_ui
|
||||
var $public_functions = array
|
||||
(
|
||||
'index' => True,
|
||||
'displayHeader' => True,
|
||||
'saveMessage' => True,
|
||||
'TestConnection' => True,
|
||||
);
|
||||
|
||||
@ -66,12 +68,12 @@ class mail_ui
|
||||
}
|
||||
if ($connectionReset)
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.' Connection Reset triggered:'.$connectionReset.' for Profile with ID:'.self::$icServerID);
|
||||
if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Connection Reset triggered:'.$connectionReset.' for Profile with ID:'.self::$icServerID);
|
||||
emailadmin_bo::unsetCachedObjects(self::$icServerID);
|
||||
}
|
||||
|
||||
$this->mail_bo = mail_bo::getInstance(false,$icServerID);
|
||||
error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
|
||||
if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
|
||||
// no icServer Object: something failed big time
|
||||
if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config
|
||||
if (!($this->mail_bo->icServer->_connected == 1)) $this->mail_bo->openConnection(self::$icServerID);
|
||||
@ -85,10 +87,10 @@ class mail_ui
|
||||
function changeProfile($_icServerID)
|
||||
{
|
||||
self::$icServerID = $_icServerID;
|
||||
error_log(__METHOD__.__LINE__.'->'.self::$icServerID);
|
||||
if (mail_bo::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID);
|
||||
emailadmin_bo::unsetCachedObjects(self::$icServerID);
|
||||
$this->mail_bo = mail_bo::getInstance(false,self::$icServerID);
|
||||
error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
|
||||
if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
|
||||
// no icServer Object: something failed big time
|
||||
if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config
|
||||
/*if (!($this->mail_bo->icServer->_connected == 1))*/ $this->mail_bo->openConnection(self::$icServerID);
|
||||
@ -397,7 +399,7 @@ class mail_ui
|
||||
{
|
||||
if ($_profileID && $_profileID != $this->mail_bo->profileID)
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.' change Profile to ->'.$_profileID);
|
||||
//error_log(__METHOD__.__LINE__.' change Profile to ->'.$_profileID);
|
||||
$this->changeProfile($_profileID);
|
||||
}
|
||||
}
|
||||
@ -434,7 +436,7 @@ class mail_ui
|
||||
'im1' => 'thunderbird.png',
|
||||
'im2' => 'thunderbird.png',
|
||||
'path'=> array($icServer->ImapServerId),
|
||||
'child'=> 1,
|
||||
'child'=> 1, // dynamic loading on unfold
|
||||
'parent' => ''
|
||||
);
|
||||
$this->setOutStructure($oA,$out,self::$delimiter);
|
||||
@ -484,13 +486,13 @@ class mail_ui
|
||||
}
|
||||
$path = $this->mail_bo->profileID.self::$delimiter.$key; //$obj->folderName; //$obj->delimiter
|
||||
$oA['id'] = $path; // ID holds the PATH
|
||||
if (stripos(array2string($fS['attributes']),'\noselect')!== false)
|
||||
if (!empty($fS['attributes']) && stripos(array2string($fS['attributes']),'\noselect')!== false)
|
||||
{
|
||||
$oA['im0'] = "folderNoSelectClosed.gif"; // one Level
|
||||
$oA['im1'] = "folderNoSelectOpen.gif";
|
||||
$oA['im2'] = "folderNoSelectClosed.gif"; // has Children
|
||||
}
|
||||
if (stripos(array2string($fS['attributes']),'\hasnochildren')=== false)
|
||||
if (!empty($fS['attributes']) && stripos(array2string($fS['attributes']),'\hasnochildren')=== false)
|
||||
{
|
||||
$oA['child']=1; // translates to: hasChildren -> dynamicLoading
|
||||
}
|
||||
@ -923,7 +925,7 @@ class mail_ui
|
||||
unset($query['actions']);
|
||||
//error_log(__METHOD__.__LINE__.array2string($query));
|
||||
//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows']);
|
||||
$starttime = microtime(true);
|
||||
//$starttime = microtime(true);
|
||||
//error_log(__METHOD__.__LINE__.array2string($query['search']));
|
||||
//$query['search'] is the phrase in the searchbox
|
||||
|
||||
@ -943,7 +945,7 @@ $starttime = microtime(true);
|
||||
{
|
||||
if ($_profileID && $_profileID != $this->mail_bo->profileID)
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.' change Profile to ->'.$_profileID);
|
||||
//error_log(__METHOD__.__LINE__.' change Profile to ->'.$_profileID);
|
||||
$this->changeProfile($_profileID);
|
||||
}
|
||||
$_folderName = $folderName;
|
||||
@ -1031,8 +1033,8 @@ $starttime = microtime(true);
|
||||
if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
|
||||
$rows = $this->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType,$previewMessage);
|
||||
//error_log(__METHOD__.__LINE__.array2string($rows));
|
||||
$endtime = microtime(true) - $starttime;
|
||||
error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].' Took:'.$endtime);
|
||||
//$endtime = microtime(true) - $starttime;
|
||||
//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].' Took:'.$endtime);
|
||||
|
||||
return $rowsFetched['messages'];
|
||||
}
|
||||
@ -1373,6 +1375,102 @@ error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Star
|
||||
return $rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* display messages header lines
|
||||
*
|
||||
* all params are passed as GET Parameters
|
||||
*/
|
||||
function displayHeader()
|
||||
{
|
||||
if(isset($_GET['id'])) $rowID = $_GET['id'];
|
||||
if(isset($_GET['part'])) $partID = $_GET['part'];
|
||||
|
||||
$hA = $this->splitRowID($rowID);
|
||||
$uid = $hA['msgUID'];
|
||||
$mailbox = $hA['folder'];
|
||||
|
||||
//$transformdate =& CreateObject('felamimail.transformdate');
|
||||
//$htmlFilter =& CreateObject('felamimail.htmlfilter');
|
||||
//$uiWidgets =& CreateObject('felamimail.uiwidgets');
|
||||
$this->mail_bo->reopen($mailbox);
|
||||
$rawheaders = $this->mail_bo->getMessageRawHeader($uid, $partID);
|
||||
|
||||
$webserverURL = $GLOBALS['egw_info']['server']['webserver_url'];
|
||||
|
||||
#$nonDisplayAbleCharacters = array('[\016]','[\017]',
|
||||
# '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
|
||||
# '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
|
||||
|
||||
#print "<pre>";print_r($rawheaders);print"</pre>";exit;
|
||||
|
||||
// add line breaks to $rawheaders
|
||||
$newRawHeaders = explode("\n",$rawheaders);
|
||||
reset($newRawHeaders);
|
||||
|
||||
// reset $rawheaders
|
||||
$rawheaders = "";
|
||||
// create it new, with good line breaks
|
||||
reset($newRawHeaders);
|
||||
while(list($key,$value) = @each($newRawHeaders)) {
|
||||
$rawheaders .= wordwrap($value, 90, "\n ");
|
||||
}
|
||||
|
||||
$this->mail_bo->closeConnection();
|
||||
|
||||
header('Content-type: text/html; charset=iso-8859-1');
|
||||
print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* save messages on disk or filemanager, or display it in popup
|
||||
*
|
||||
* all params are passed as GET Parameters
|
||||
*/
|
||||
function saveMessage()
|
||||
{
|
||||
$display = false;
|
||||
if(isset($_GET['id'])) $rowID = $_GET['id'];
|
||||
if(isset($_GET['part'])) $partID = $_GET['part'];
|
||||
if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display = $_GET['location'];
|
||||
|
||||
$hA = $this->splitRowID($rowID);
|
||||
$uid = $hA['msgUID'];
|
||||
$mailbox = $hA['folder'];
|
||||
|
||||
$this->mail_bo->reopen($mailbox);
|
||||
|
||||
$message = $this->mail_bo->getMessageRawBody($uid, $partID);
|
||||
$headers = $this->mail_bo->getMessageHeader($uid, $partID);
|
||||
|
||||
$this->mail_bo->closeConnection();
|
||||
|
||||
$GLOBALS['egw']->session->commit_session();
|
||||
if ($display==false)
|
||||
{
|
||||
$subject = str_replace('$$','__',mail_bo::decode_header($headers['SUBJECT']));
|
||||
header ("Content-Type: message/rfc822; name=\"". $subject .".eml\"");
|
||||
header ("Content-Disposition: attachment; filename=\"". $subject .".eml\"");
|
||||
header("Expires: 0");
|
||||
// the next headers are for IE and SSL
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
header("Pragma: public");
|
||||
|
||||
echo $message;
|
||||
|
||||
$GLOBALS['egw']->common->egw_exit();
|
||||
exit;
|
||||
}
|
||||
//elseif ($display=='filemanager') // done in vfsSaveMessage
|
||||
//{
|
||||
//}
|
||||
else
|
||||
{
|
||||
header('Content-type: text/html; charset=iso-8859-1');
|
||||
print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES, 'iso-8859-1') .'</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getFolderStatus - its called via json, so the function must start with ajax (or the class-name must contain ajax)
|
||||
* gets the counters and sets the text of a treenode if needed (unread Messages found)
|
||||
@ -1420,7 +1518,7 @@ error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Star
|
||||
function ajax_changeProfile($icServerID)
|
||||
{
|
||||
if ($icServerID && $icServerID != $this->mail_bo->profileID)
|
||||
error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
|
||||
//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
|
||||
$this->changeProfile($icServerID);
|
||||
$response = egw_json_response::get();
|
||||
$response->call('egw_refresh',lang('changed profile'),'mail');
|
||||
@ -1470,7 +1568,7 @@ error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Star
|
||||
*/
|
||||
function ajax_flagMessages($_flag, $_messageList)
|
||||
{
|
||||
if($this->_debug) error_log(__METHOD__."->".$_flag.':'.print_r($_messageList,true));
|
||||
if(mail_bo::$debug) error_log(__METHOD__."->".$_flag.':'.print_r($_messageList,true));
|
||||
if ($_messageList=='all' || !empty($_messageList['msg']))
|
||||
{
|
||||
if ($_messageList=='all')
|
||||
@ -1492,7 +1590,7 @@ error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Star
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->_debug) error_log(__METHOD__."-> No messages selected.");
|
||||
if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
|
||||
}
|
||||
|
||||
// unset preview, as refresh would mark message again read
|
||||
@ -1507,4 +1605,40 @@ error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Star
|
||||
$response->call('egw_refresh',lang('flagged %1 messages as %2 in %3',count($_messageList['msg']),$_flag,$folder),'mail');
|
||||
}
|
||||
|
||||
/**
|
||||
* delete messages
|
||||
*
|
||||
* @param array _messageList list of UID's
|
||||
*
|
||||
* @return xajax response
|
||||
*/
|
||||
function ajax_deleteMessages($_messageList)
|
||||
{
|
||||
if(mail_bo::$debug) error_log(__METHOD__."->".$_flag.':'.print_r($_messageList,true));
|
||||
if ($_messageList=='all' || !empty($_messageList['msg']))
|
||||
{
|
||||
if ($_messageList=='all')
|
||||
{
|
||||
// we have no folder information
|
||||
$folder=null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$uidA = $this->splitRowID($_messageList['msg'][0]);
|
||||
$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
|
||||
}
|
||||
foreach($_messageList['msg'] as $rowID)
|
||||
{
|
||||
$hA = $this->splitRowID($rowID);
|
||||
$messageList[] = $hA['msgUID'];
|
||||
}
|
||||
$this->mail_bo->deleteMessages(($_messageList=='all' ? 'all':$messageList),$folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected.");
|
||||
}
|
||||
$response = egw_json_response::get();
|
||||
$response->call('egw_refresh',lang('deleted %1 messages in %2',count($_messageList['msg']),$folder),'mail');
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +160,44 @@ function mail_setMsg(myMsg)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete mails
|
||||
* takes in all arguments
|
||||
* @param _action
|
||||
* @param _elems
|
||||
*/
|
||||
function mail_delete(_action,_elems)
|
||||
{
|
||||
var msg = mail_getFormData(_elems);
|
||||
//alert(_action.id+','+ msg);
|
||||
app_refresh(egw.lang('delete messages'), 'mail');
|
||||
mail_setRowClass(_elems,'deleted');
|
||||
var request = new egw_json_request('mail.mail_ui.ajax_deleteMessages',[msg]);
|
||||
request.sendRequest(false);
|
||||
mail_refreshMessageGrid()
|
||||
}
|
||||
|
||||
/**
|
||||
* UnDelete mailMessages
|
||||
*
|
||||
* @param _messageList
|
||||
*/
|
||||
function mail_undeleteMessages(_messageList) {
|
||||
// setting class of row, the old style
|
||||
/*
|
||||
for(var i=0;i<_messageList['msg'].length;i++) {
|
||||
_id = _messageList['msg'][i];
|
||||
var dataElem = egw_appWindow('felamimail').mailGrid.dataRoot.getElementById(_id);
|
||||
if (dataElem)
|
||||
{
|
||||
//dataElem.clearData();
|
||||
//dataElem.addClass('deleted');
|
||||
dataElem.removeClass('deleted');
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* mail_emptyTrash
|
||||
*/
|
||||
@ -271,6 +309,47 @@ function mail_flagMessages(_flag, _elems)
|
||||
mail_refreshMessageGrid()
|
||||
}
|
||||
|
||||
/**
|
||||
* display header lines, or source of mail, depending on the url given
|
||||
*
|
||||
* @param _url
|
||||
*/
|
||||
function mail_displayHeaderLines(_url) {
|
||||
// only used by right clickaction
|
||||
egw_openWindowCentered(_url,'mail_display_headerLines','700','600',window.outerWidth/2,window.outerHeight/2);
|
||||
}
|
||||
|
||||
/**
|
||||
* View header of a message
|
||||
*
|
||||
* @param _action
|
||||
* @param _elems _elems[0].id is the row-id
|
||||
*/
|
||||
function mail_header(_action, _elems)
|
||||
{
|
||||
//alert('mail_header('+_elems[0].id+')');
|
||||
var url = window.egw_webserverUrl+'/index.php?';
|
||||
url += 'menuaction=mail.mail_ui.displayHeader'; // todo compose for Draft folder
|
||||
url += '&id='+_elems[0].id;
|
||||
mail_displayHeaderLines(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* View message source
|
||||
*
|
||||
* @param _action
|
||||
* @param _elems _elems[0].id is the row-id
|
||||
*/
|
||||
function mail_mailsource(_action, _elems)
|
||||
{
|
||||
//alert('mail_mailsource('+_elems[0].id+')');
|
||||
var url = window.egw_webserverUrl+'/index.php?';
|
||||
url += 'menuaction=mail.mail_ui.saveMessage'; // todo compose for Draft folder
|
||||
url += '&id='+_elems[0].id;
|
||||
url += '&location=display';
|
||||
mail_displayHeaderLines(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* mail_getFormData
|
||||
*
|
||||
@ -295,6 +374,26 @@ function mail_getFormData(_actionObjects) {
|
||||
return messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* mail_setRowClass
|
||||
*
|
||||
* @param _actionObjects, the senders
|
||||
*/
|
||||
function mail_setRowClass(_actionObjects,_class) {
|
||||
if (typeof _class == 'undefined') return false;
|
||||
|
||||
for (var i = 0; i < _actionObjects.length; i++)
|
||||
{
|
||||
if (_actionObjects[i].id.length>0)
|
||||
{
|
||||
var _id = _actionObjects[i].id;
|
||||
var dataElem = $j(_actionObjects[i].iface.getDOMNode());
|
||||
dataElem.addClass(_class);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tree widget stubs
|
||||
mail_dragStart = function(action,sender) {
|
||||
console.log(action,sender);
|
||||
|
Loading…
Reference in New Issue
Block a user