controlling some requirements on a send attempt (recipient, subject, mailbody)

This commit is contained in:
Klaus Leithoff 2013-12-09 09:57:03 +00:00
parent 8da1afca1e
commit db0879f4a6
5 changed files with 57 additions and 18 deletions

View File

@ -4575,8 +4575,8 @@ class mail_bo
//error_log(__METHOD__.__LINE__."$_folderName, $_header, $_body, $_flags");
$header = ltrim(str_replace("\n","\r\n",$_header));
$body = str_replace("\n","\r\n",$_body);
if (!is_array($_flags) && stripos($_flags,',')!==false) $_flags=explode(',',$_flags);
if (!is_array($_flags)) $_flags = (array) $_flags;
//if (!is_array($_flags) && stripos($_flags,',')!==false) $_flags=explode(',',$_flags);
//if (!is_array($_flags)) $_flags = (array) $_flags;
try
{
$dataNflags = array();

View File

@ -240,7 +240,7 @@ class mail_compose
//lang('compose'),lang('from') // needed to be found by translationtools
//error_log(__METHOD__.__LINE__.array2string($_REQUEST));
//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
$_contenHasSigID = array_key_exists('signatureid',$_content);
$_contenHasSigID = array_key_exists('signatureid',(array)$_content);
if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
if (isset($_GET['part_id'])) $partID = $_GET['part_id'];
@ -349,20 +349,44 @@ class mail_compose
{
$buttonClicked = $suppressSigOnTop = true;
$sendOK = true;
try
{
$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']);
$success = $this->send($_content);
if ($success==false)
{
$sendOK=false;
$message = $this->errorInfo;
}
}
catch (egw_exception_wrong_userinput $e)
$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']);
/*
perform some simple checks, before trying to send on:
$_content['to'];$_content['cc'];$_content['bcc'];
trim($_content['subject']);
trim(strip_tags(str_replace(' ','',$_content['body'])));
*/
if (strlen(trim(strip_tags(str_replace(' ','',$_content['body']))))==0 && count($_content['attachments'])==0)
{
$sendOK = false;
$message = $e->getMessage();
$_content['msg'] = $message = lang("no message body supplied");
}
if ($sendOK && strlen(trim($_content['subject']))==0)
{
$sendOK = false;
$_content['msg'] = $message = lang("no subject supplied");
}
if ($sendOK && empty($_content['to']) && empty($_content['cc']) && empty($_content['bcc']))
{
$sendOK = false;
$_content['msg'] = $message = lang("no adress, to send this mail to, supplied");
}
if ($sendOK)
{
try
{
$success = $this->send($_content);
if ($success==false)
{
$sendOK=false;
$message = $this->errorInfo;
}
}
catch (egw_exception_wrong_userinput $e)
{
$sendOK = false;
$message = $e->getMessage();
}
}
if ($activeProfile != $composeProfile)
{

View File

@ -1312,13 +1312,13 @@ unset($query['actions']);
$actionsenabled[$act]=$actions['view']['children'][$act];
break;
case 'flagged':
$actionsenabled[$act]=$actions['mark']['children'][$act]=array(
$actionsenabled[$act]=array(
'group' => $group,
'caption' => 'Flagged',
'icon' => 'unread_flagged_small',
'onExecute' => 'javaScript:app.mail.mail_flag',
);
$actionsenabled['unflagged']=$actions['mark']['children']['unflagged']=array(
$actionsenabled['unflagged']=array(
'group' => $group,
'caption' => 'Unflagged',
'icon' => 'read_flagged_small',
@ -1725,6 +1725,18 @@ unset($query['actions']);
unset($actionsenabled['mark']['children']['read']);
unset($actionsenabled['mark']['children']['unread']);
unset($actionsenabled['mark']['children']['undelete']);
$actionsenabled['mark']['children']['flagged']=array(
'group' => $actionsenabled['mark']['children']['flagged']['group'],
'caption' => 'Flagged',
'icon' => 'unread_flagged_small',
'onExecute' => 'javaScript:app.mail.mail_flag',
);
$actionsenabled['mark']['children']['unflagged']=array(
'group' => $actionsenabled['mark']['children']['flagged']['group'],
'caption' => 'Unflagged',
'icon' => 'read_flagged_small',
'onExecute' => 'javaScript:app.mail.mail_flag',
);
$cAN = $actionsenabled['composeasnew'];
unset($actionsenabled['composeasnew']);
$actionsenabled = array_reverse($actionsenabled,true);

View File

@ -637,6 +637,9 @@ app.classes.mail = AppJS.extend(
//if (mode == "forced") this.mail_refreshMessageGrid();
this.mail_refreshMessageGrid();
}
//the two lines below are not working yet.
//var no =tree_wdg.getSelectedNode();
//tree_wdg.focusItem(no.id);
} catch(e) { } // ignore the error; maybe the template is not loaded yet
},

View File

@ -2,7 +2,7 @@
<!-- $Id$ -->
<overlay>
<template id="mail.compose" template="" lang="" group="0" version="1.9.001">
<html id="msg"/>
<html id="msg" class="message"/>
<vbox class="mailCompose mailComposeHeaderSection" width="100%">
<hbox class="mailComposeHeaders" width="99%">
<description value="Identity"/>