From db0879f4a6ddf2f8dad1fe4590278d1412f02a6e Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 9 Dec 2013 09:57:03 +0000 Subject: [PATCH] controlling some requirements on a send attempt (recipient, subject, mailbody) --- mail/inc/class.mail_bo.inc.php | 4 +-- mail/inc/class.mail_compose.inc.php | 50 +++++++++++++++++++++-------- mail/inc/class.mail_ui.inc.php | 16 +++++++-- mail/js/app.js | 3 ++ mail/templates/default/compose.xet | 2 +- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/mail/inc/class.mail_bo.inc.php b/mail/inc/class.mail_bo.inc.php index 79ece86a13..3d751f0202 100644 --- a/mail/inc/class.mail_bo.inc.php +++ b/mail/inc/class.mail_bo.inc.php @@ -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(); diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index bf3d668d6b..ee492d115b 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -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) { diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 4eaa0fc570..449838643b 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -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); diff --git a/mail/js/app.js b/mail/js/app.js index 1aa971c7d7..24d8641121 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -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 }, diff --git a/mail/templates/default/compose.xet b/mail/templates/default/compose.xet index cdc3e2acd9..d43bcfb9fe 100644 --- a/mail/templates/default/compose.xet +++ b/mail/templates/default/compose.xet @@ -2,7 +2,7 @@