mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +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);
|
||||
|
@ -1512,14 +1512,57 @@ unset($query['actions']);
|
||||
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
|
||||
}
|
||||
$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
|
||||
$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;
|
||||
$mailBody = $this->get_load_email_data($uid, $partID, $mailbox,false);
|
||||
//error_log(__METHOD__.__LINE__.$mailBody);
|
||||
$this->mail_bo->closeConnection();
|
||||
$etpl = new etemplate_new('mail.display');
|
||||
|
||||
// Set cell attributes directly
|
||||
/*
|
||||
$etpl->set_cell_attribute('nm[foldertree]','actions', array(
|
||||
'drop_move_mail' => array(
|
||||
'type' => 'drop',
|
||||
'acceptedTypes' => 'mail',
|
||||
'icon' => 'move',
|
||||
'caption' => 'Move to',
|
||||
'onExecute' => 'javaScript:app.mail.mail_move'
|
||||
),
|
||||
));
|
||||
*/
|
||||
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'] = $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'));
|
||||
@ -1533,13 +1576,12 @@ unset($query['actions']);
|
||||
//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);
|
||||
*/
|
||||
|
||||
$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':
|
||||
@ -1613,12 +1655,10 @@ unset($query['actions']);
|
||||
$linkView = "window.location.href = '".$GLOBALS['egw']->link('/index.php',$linkData)."';";
|
||||
break;
|
||||
}
|
||||
error_log(__METHOD__.__LINE__.$linkView);
|
||||
$attachmentHTML[] = '<a href="#" onclick="'.$linkView.' return false;"><b>'.
|
||||
//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>';
|
||||
// $this->t->set_var("link_view",$linkView);
|
||||
// $this->t->set_var("target",$target);
|
||||
|
||||
$linkData = array
|
||||
(
|
||||
@ -1629,7 +1669,7 @@ error_log(__METHOD__.__LINE__.$linkView);
|
||||
'is_winmail' => $value['is_winmail'],
|
||||
'mailbox' => base64_encode($mailbox),
|
||||
);
|
||||
//$this->t->set_var("link_save",$GLOBALS['egw']->link('/index.php',$linkData));
|
||||
$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'])
|
||||
{
|
||||
@ -1646,10 +1686,10 @@ error_log(__METHOD__.__LINE__.$linkView);
|
||||
// add save-all icon for first attachment
|
||||
if (!$key && count($attachments) > 1)
|
||||
{
|
||||
foreach ($attachments as $key => $value)
|
||||
foreach ($attachments as $ikey => $value)
|
||||
{
|
||||
//$rowID
|
||||
$ids["id[$key]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
|
||||
$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
|
||||
}
|
||||
$link_vfs_save = egw::link('/index.php',array(
|
||||
'menuaction' => 'filemanager.filemanager_select.select',
|
||||
@ -1657,55 +1697,23 @@ error_log(__METHOD__.__LINE__.$linkView);
|
||||
'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>";
|
||||
$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>";
|
||||
}
|
||||
//$this->t->set_var('vfs_save',$vfs_save);
|
||||
$attachmentHTML[$key]['link_save'] .= $vfs_save;
|
||||
//error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']);
|
||||
}
|
||||
else
|
||||
}
|
||||
$attachmentHTMLBlock="<table width='100%'>";
|
||||
foreach ((array)$attachmentHTML as $row)
|
||||
{
|
||||
//$this->t->set_var('vfs_save','');
|
||||
$attachmentHTMLBlock .= "<tr><td>".$row['link_view'].'</td>';
|
||||
$attachmentHTMLBlock .= "<td>".$row['mimetype'].'</td>';
|
||||
$attachmentHTMLBlock .= "<td>".$row['size'].'</td>';
|
||||
$attachmentHTMLBlock .= "<td>".$row['link_save'].'</td></tr>';
|
||||
}
|
||||
//$this->t->parse('attachment_rows','message_attachement_row',True);
|
||||
$attachmentHTMLBlock .= "</table>";
|
||||
}
|
||||
} else {
|
||||
//$this->t->set_var('attachment_rows','');
|
||||
}
|
||||
|
||||
$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;
|
||||
$mailBody = $this->get_load_email_data($uid, $partID, $mailbox,false);
|
||||
//error_log(__METHOD__.__LINE__.$mailBody);
|
||||
$this->mail_bo->closeConnection();
|
||||
$etpl = new etemplate_new('mail.display');
|
||||
|
||||
// Set cell attributes directly
|
||||
/*
|
||||
$etpl->set_cell_attribute('nm[foldertree]','actions', array(
|
||||
'drop_move_mail' => array(
|
||||
'type' => 'drop',
|
||||
'acceptedTypes' => 'mail',
|
||||
'icon' => 'move',
|
||||
'caption' => 'Move to',
|
||||
'onExecute' => 'javaScript:app.mail.mail_move'
|
||||
),
|
||||
));
|
||||
*/
|
||||
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;
|
||||
echo $etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2);
|
||||
return $attachmentHTMLBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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