mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
provide a more presentable attachment section
This commit is contained in:
parent
079b919bbe
commit
9c2ff7cf80
@ -361,7 +361,17 @@ class mail_bopreferences extends mail_sopreferences
|
||||
}
|
||||
}
|
||||
// make sure there is one profile marked as default (either 0 or the one found)
|
||||
$profileData->identities[$IdIsDefault]->default = true;
|
||||
$markedAsDefault = false;
|
||||
foreach ($profileData->identities as &$id)
|
||||
{
|
||||
if ($id->id == $idIsDefault)
|
||||
{
|
||||
$id->default = true;
|
||||
$markedAsDefault = true;
|
||||
}
|
||||
}
|
||||
// none found; mark identity 0 as default
|
||||
if ($markedAsDefault == false) $profileData->identities[0]->default = true;
|
||||
|
||||
$userPrefs = $this->mergeUserAndProfilePrefs($userPreferences,$profileData,$profileID);
|
||||
$profileData->setPreferences($userPrefs);
|
||||
|
@ -1511,166 +1511,8 @@ unset($query['actions']);
|
||||
$fetchEmbeddedImages = false;
|
||||
if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
|
||||
$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, '',$fetchEmbeddedImages);
|
||||
//_debug_array($headers);
|
||||
// attachments
|
||||
/* if(is_array($attachments) && count($attachments) > 0 && count($attachments) > 4) {
|
||||
// this is to account for maxheight minheight of the attachment div
|
||||
$this->t->set_var('attachment_div_height',' bottom:'.(count($attachments)>4?(count($attachments)*20<=240?count($attachments)*20:240):80).'px');
|
||||
} else {
|
||||
$this->t->set_var('attachment_div_height',''); // app.css bodyDIVAttachment
|
||||
}
|
||||
*/
|
||||
if (is_array($attachments) && count($attachments) > 0) {
|
||||
$url_img_vfs = html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
|
||||
$url_img_vfs_save_all = html::image('felamimail','save_all', lang('Save all'));
|
||||
|
||||
$detectedCharSet=$charset2use=mail_bo::$displayCharset;
|
||||
foreach ($attachments as $key => $value)
|
||||
{
|
||||
//_debug_array($value);
|
||||
#$detectedCharSet = mb_detect_encoding($value['name'].'a',strtoupper($this->displayCharset).",UTF-8, ISO-8559-1");
|
||||
if (function_exists('mb_convert_variables')) mb_convert_variables("UTF-8","ISO-8559-1",$value['name']); # iso 2 UTF8
|
||||
//if (mb_convert_variables("ISO-8859-1","UTF-8",$value['name'])){echo "Juhu utf8 2 ISO\n";};
|
||||
//echo $value['name']."\n";
|
||||
$filename=htmlentities($value['name'], ENT_QUOTES, $detectedCharSet);
|
||||
/*
|
||||
$this->t->set_var('row_color',$this->rowColor[($key+1)%2]);
|
||||
$this->t->set_var('filename',($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)')));
|
||||
$this->t->set_var('mimetype',mime_magic::mime2label($value['mimeType']));
|
||||
$this->t->set_var('size',egw_vfs::hsize($value['size']));
|
||||
$this->t->set_var('attachment_number',$key);
|
||||
*/
|
||||
switch(strtoupper($value['mimeType']))
|
||||
{
|
||||
case 'MESSAGE/RFC822':
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.displayMessage',
|
||||
'id' => $rowID,
|
||||
'part' => $value['partID'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
'is_winmail' => $value['is_winmail']
|
||||
);
|
||||
$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
|
||||
$linkView = "egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
|
||||
break;
|
||||
case 'IMAGE/JPEG':
|
||||
case 'IMAGE/PNG':
|
||||
case 'IMAGE/GIF':
|
||||
case 'IMAGE/BMP':
|
||||
case 'APPLICATION/PDF':
|
||||
case 'TEXT/PLAIN':
|
||||
case 'TEXT/HTML':
|
||||
case 'TEXT/DIRECTORY':
|
||||
$sfxMimeType = $value['mimeType'];
|
||||
$buff = explode('.',$value['name']);
|
||||
$suffix = '';
|
||||
if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
|
||||
if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
|
||||
if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
|
||||
{
|
||||
$attachments[$key]['mimeType'] = $sfxMimeType;
|
||||
$value['mimeType'] = strtoupper($sfxMimeType);
|
||||
}
|
||||
case 'TEXT/X-VCARD':
|
||||
case 'TEXT/VCARD':
|
||||
case 'TEXT/CALENDAR':
|
||||
case 'TEXT/X-VCALENDAR':
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.getAttachment',
|
||||
'id' => $rowID,
|
||||
'part' => $value['partID'],
|
||||
'is_winmail' => $value['is_winmail'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
);
|
||||
$windowName = 'displayAttachment_'. $uid;
|
||||
$reg = '800x600';
|
||||
// handle calendar/vcard
|
||||
if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
|
||||
{
|
||||
$windowName = 'displayEvent_'. $rowID;
|
||||
$reg2 = egw_link::get_registry('calendar','view_popup');
|
||||
}
|
||||
if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
|
||||
{
|
||||
$windowName = 'displayContact_'. $rowID;
|
||||
$reg2 = egw_link::get_registry('addressbook','add_popup');
|
||||
}
|
||||
// apply to action
|
||||
list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
|
||||
$linkView = "egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',$width,$height);";
|
||||
break;
|
||||
default:
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.getAttachment',
|
||||
'id' => $rowID,
|
||||
'part' => $value['partID'],
|
||||
'is_winmail' => $value['is_winmail'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
);
|
||||
$linkView = "window.location.href = '".$GLOBALS['egw']->link('/index.php',$linkData)."';";
|
||||
break;
|
||||
}
|
||||
error_log(__METHOD__.__LINE__.$linkView);
|
||||
$attachmentHTML[] = '<a href="#" onclick="'.$linkView.' return false;"><b>'.
|
||||
($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)')).
|
||||
'</b></a>';
|
||||
// $this->t->set_var("link_view",$linkView);
|
||||
// $this->t->set_var("target",$target);
|
||||
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.getAttachment',
|
||||
'mode' => 'save',
|
||||
'id' => $rowID,
|
||||
'part' => $value['partID'],
|
||||
'is_winmail' => $value['is_winmail'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
);
|
||||
//$this->t->set_var("link_save",$GLOBALS['egw']->link('/index.php',$linkData));
|
||||
|
||||
if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
|
||||
{
|
||||
$link_vfs_save = egw::link('/index.php',array(
|
||||
'menuaction' => 'filemanager.filemanager_select.select',
|
||||
'mode' => 'saveas',
|
||||
'name' => $value['name'],
|
||||
'mime' => strtolower($value['mimeType']),
|
||||
'method' => 'felamimail.uidisplay.vfsSaveAttachment',
|
||||
'id' => $mailbox.'::'.$uid.'::'.$value['partID'].'::'.$value['is_winmail'],
|
||||
'label' => lang('Save'),
|
||||
));
|
||||
$vfs_save = "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','570',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs</a>";
|
||||
// add save-all icon for first attachment
|
||||
if (!$key && count($attachments) > 1)
|
||||
{
|
||||
foreach ($attachments as $key => $value)
|
||||
{
|
||||
//$rowID
|
||||
$ids["id[$key]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
|
||||
}
|
||||
$link_vfs_save = egw::link('/index.php',array(
|
||||
'menuaction' => 'filemanager.filemanager_select.select',
|
||||
'mode' => 'select-dir',
|
||||
'method' => 'mail.mail_ui.vfsSaveAttachment',
|
||||
'label' => lang('Save all'),
|
||||
)+$ids);
|
||||
$vfs_save .= "\n<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','530',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs_save_all</a>";
|
||||
}
|
||||
//$this->t->set_var('vfs_save',$vfs_save);
|
||||
}
|
||||
else
|
||||
{
|
||||
//$this->t->set_var('vfs_save','');
|
||||
}
|
||||
//$this->t->parse('attachment_rows','message_attachement_row',True);
|
||||
}
|
||||
} else {
|
||||
//$this->t->set_var('attachment_rows','');
|
||||
}
|
||||
|
||||
//_debug_array($headers);
|
||||
$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
|
||||
$webserverURL = $GLOBALS['egw_info']['server']['webserver_url'];
|
||||
|
||||
$nonDisplayAbleCharacters = array('[\016]','[\017]',
|
||||
@ -1679,7 +1521,7 @@ error_log(__METHOD__.__LINE__.$linkView);
|
||||
|
||||
#print "<pre>";print_r($rawheaders);print"</pre>";exit;
|
||||
$mailBody = $this->get_load_email_data($uid, $partID, $mailbox,false);
|
||||
//error_log(__METHOD__.__LINE__.$mailBody);
|
||||
//error_log(__METHOD__.__LINE__.$mailBody);
|
||||
$this->mail_bo->closeConnection();
|
||||
$etpl = new etemplate_new('mail.display');
|
||||
|
||||
@ -1695,19 +1537,185 @@ error_log(__METHOD__.__LINE__.$linkView);
|
||||
),
|
||||
));
|
||||
*/
|
||||
egw_framework::set_onload("");
|
||||
egw_framework::set_onload("");
|
||||
$subject = mail_bo::htmlspecialchars($this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false),
|
||||
mail_bo::$displayCharset);
|
||||
if (empty($subject)) $subject = lang('no subject');
|
||||
$content['msg'] = $subject.(is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
|
||||
$content['mail_displaysubject'] = $subject;
|
||||
$content['mail_displaybody'] = $mailBody;
|
||||
//_debug_array($attachments);
|
||||
$content['mail_displayattachments'] = (count($attachments)?implode('<br>',$attachmentHTML):'');
|
||||
$readonlys = $preserv = $content;
|
||||
$content['msg'] = $subject.(is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
|
||||
$content['mail_displaysubject'] = $subject;
|
||||
$content['mail_displaybody'] = $mailBody;
|
||||
//_debug_array($attachments);
|
||||
$content['mail_displayattachments'] = $attachmentHTMLBlock;
|
||||
$readonlys = $preserv = $content;
|
||||
echo $etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2);
|
||||
}
|
||||
|
||||
/**
|
||||
* createAttachmentBlock
|
||||
* helper function to create the attachment block/table
|
||||
*
|
||||
* @param array $attachments, array with the attachments information
|
||||
* @param string $rowID, rowid of the message
|
||||
* @param int $uid, uid of the message
|
||||
* @param string $mailbox, the mailbox identifier
|
||||
* @return string html or empty string
|
||||
*/
|
||||
static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox)
|
||||
{
|
||||
$attachmentHTMLBlock='';
|
||||
if (is_array($attachments) && count($attachments) > 0) {
|
||||
$url_img_vfs = html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
|
||||
$url_img_vfs_save_all = html::image('felamimail','save_all', lang('Save all'));
|
||||
|
||||
$detectedCharSet=$charset2use=mail_bo::$displayCharset;
|
||||
foreach ($attachments as $key => $value)
|
||||
{
|
||||
//_debug_array($value);
|
||||
#$detectedCharSet = mb_detect_encoding($value['name'].'a',strtoupper($this->displayCharset).",UTF-8, ISO-8559-1");
|
||||
if (function_exists('mb_convert_variables')) mb_convert_variables("UTF-8","ISO-8559-1",$value['name']); # iso 2 UTF8
|
||||
//if (mb_convert_variables("ISO-8859-1","UTF-8",$value['name'])){echo "Juhu utf8 2 ISO\n";};
|
||||
//echo $value['name']."\n";
|
||||
$filename=htmlentities($value['name'], ENT_QUOTES, $detectedCharSet);
|
||||
|
||||
$attachmentHTML[$key]['filename']= ($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)'));
|
||||
$attachmentHTML[$key]['mimetype']=mime_magic::mime2label($value['mimeType']);
|
||||
$attachmentHTML[$key]['size']=egw_vfs::hsize($value['size']);
|
||||
$attachmentHTML[$key]['attachment_number']=$key;
|
||||
|
||||
switch(strtoupper($value['mimeType']))
|
||||
{
|
||||
case 'MESSAGE/RFC822':
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.displayMessage',
|
||||
'id' => $rowID,
|
||||
'part' => $value['partID'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
'is_winmail' => $value['is_winmail']
|
||||
);
|
||||
$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
|
||||
$linkView = "egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
|
||||
break;
|
||||
case 'IMAGE/JPEG':
|
||||
case 'IMAGE/PNG':
|
||||
case 'IMAGE/GIF':
|
||||
case 'IMAGE/BMP':
|
||||
case 'APPLICATION/PDF':
|
||||
case 'TEXT/PLAIN':
|
||||
case 'TEXT/HTML':
|
||||
case 'TEXT/DIRECTORY':
|
||||
$sfxMimeType = $value['mimeType'];
|
||||
$buff = explode('.',$value['name']);
|
||||
$suffix = '';
|
||||
if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
|
||||
if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
|
||||
if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
|
||||
{
|
||||
$attachments[$key]['mimeType'] = $sfxMimeType;
|
||||
$value['mimeType'] = strtoupper($sfxMimeType);
|
||||
}
|
||||
case 'TEXT/X-VCARD':
|
||||
case 'TEXT/VCARD':
|
||||
case 'TEXT/CALENDAR':
|
||||
case 'TEXT/X-VCALENDAR':
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.getAttachment',
|
||||
'id' => $rowID,
|
||||
'part' => $value['partID'],
|
||||
'is_winmail' => $value['is_winmail'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
);
|
||||
$windowName = 'displayAttachment_'. $uid;
|
||||
$reg = '800x600';
|
||||
// handle calendar/vcard
|
||||
if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
|
||||
{
|
||||
$windowName = 'displayEvent_'. $rowID;
|
||||
$reg2 = egw_link::get_registry('calendar','view_popup');
|
||||
}
|
||||
if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
|
||||
{
|
||||
$windowName = 'displayContact_'. $rowID;
|
||||
$reg2 = egw_link::get_registry('addressbook','add_popup');
|
||||
}
|
||||
// apply to action
|
||||
list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
|
||||
$linkView = "egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',$width,$height);";
|
||||
break;
|
||||
default:
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.getAttachment',
|
||||
'id' => $rowID,
|
||||
'part' => $value['partID'],
|
||||
'is_winmail' => $value['is_winmail'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
);
|
||||
$linkView = "window.location.href = '".$GLOBALS['egw']->link('/index.php',$linkData)."';";
|
||||
break;
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.$linkView);
|
||||
$attachmentHTML[$key]['link_view'] = '<a href="#" onclick="'.$linkView.' return false;"><b>'.
|
||||
($value['name'] ? ( $filename ? $filename : $value['name'] ) : lang('(no subject)')).
|
||||
'</b></a>';
|
||||
|
||||
$linkData = array
|
||||
(
|
||||
'menuaction' => 'mail.mail_ui.getAttachment',
|
||||
'mode' => 'save',
|
||||
'id' => $rowID,
|
||||
'part' => $value['partID'],
|
||||
'is_winmail' => $value['is_winmail'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
);
|
||||
$attachmentHTML[$key]['link_save'] ="<a href='".$GLOBALS['egw']->link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".html::image('felamimail','fileexport')."</a>";
|
||||
|
||||
if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
|
||||
{
|
||||
$link_vfs_save = egw::link('/index.php',array(
|
||||
'menuaction' => 'filemanager.filemanager_select.select',
|
||||
'mode' => 'saveas',
|
||||
'name' => $value['name'],
|
||||
'mime' => strtolower($value['mimeType']),
|
||||
'method' => 'felamimail.uidisplay.vfsSaveAttachment',
|
||||
'id' => $mailbox.'::'.$uid.'::'.$value['partID'].'::'.$value['is_winmail'],
|
||||
'label' => lang('Save'),
|
||||
));
|
||||
$vfs_save = "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','570',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs</a>";
|
||||
// add save-all icon for first attachment
|
||||
if (!$key && count($attachments) > 1)
|
||||
{
|
||||
foreach ($attachments as $ikey => $value)
|
||||
{
|
||||
//$rowID
|
||||
$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
|
||||
}
|
||||
$link_vfs_save = egw::link('/index.php',array(
|
||||
'menuaction' => 'filemanager.filemanager_select.select',
|
||||
'mode' => 'select-dir',
|
||||
'method' => 'mail.mail_ui.vfsSaveAttachment',
|
||||
'label' => lang('Save all'),
|
||||
)+$ids);
|
||||
$vfs_save .= "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','530',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs_save_all</a>";
|
||||
}
|
||||
$attachmentHTML[$key]['link_save'] .= $vfs_save;
|
||||
//error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']);
|
||||
}
|
||||
}
|
||||
$attachmentHTMLBlock="<table width='100%'>";
|
||||
foreach ((array)$attachmentHTML as $row)
|
||||
{
|
||||
$attachmentHTMLBlock .= "<tr><td>".$row['link_view'].'</td>';
|
||||
$attachmentHTMLBlock .= "<td>".$row['mimetype'].'</td>';
|
||||
$attachmentHTMLBlock .= "<td>".$row['size'].'</td>';
|
||||
$attachmentHTMLBlock .= "<td>".$row['link_save'].'</td></tr>';
|
||||
}
|
||||
$attachmentHTMLBlock .= "</table>";
|
||||
}
|
||||
return $attachmentHTMLBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* display image
|
||||
*
|
||||
|
@ -65,7 +65,12 @@ app.mail = AppJS.extend(
|
||||
|
||||
this.et2 = et2.widgetContainer;
|
||||
var isMainView = false;
|
||||
for (var t in et2.templates) if (t=='mail.index') {isMainView=true;break;};
|
||||
var isDisplay = false;
|
||||
for (var t in et2.templates)
|
||||
{
|
||||
if (t=='mail.index') {isMainView=true;break;};
|
||||
if (t=='mail.display') {isDisplay=true;break;};
|
||||
}
|
||||
if (isMainView) this.mail_disablePreviewArea(true);
|
||||
},
|
||||
|
||||
|
@ -351,6 +351,7 @@ input[type=button] {
|
||||
-moz-opacity:1:
|
||||
filter: Alpha(opacity=100);
|
||||
}
|
||||
/*
|
||||
#divGenTime {
|
||||
background-color:#efefdf;
|
||||
max-height: 10%;
|
||||
@ -364,6 +365,7 @@ input[type=button] {
|
||||
-moz-opacity:1:
|
||||
filter: Alpha(opacity=100);
|
||||
}
|
||||
*/
|
||||
.mailDisplayHeaders {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user