From 968b2ab2190fdf6be7f06ad732406f0ef91e4375 Mon Sep 17 00:00:00 2001 From: Alexandros Sigalas Date: Sun, 10 Nov 2024 22:53:00 +0200 Subject: [PATCH] Added mail_compose_prepare hook to allow manipulation of compose dialog via other apps --- mail/inc/class.mail_compose.inc.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 4d77346c83..d43c9c8471 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -1424,8 +1424,29 @@ class mail_compose if (isset($content['to'])) $content['to'] = self::resolveEmailAddressList($content['to']); $content['html_toolbar'] = empty(Mail::$mailConfig['html_toolbar']) ? implode(',', Etemplate\Widget\HtmlArea::$toolbar_default_list) : implode(',', Mail::$mailConfig['html_toolbar']); + + //Allow other apps to hook into mail_compose + $readonlys = []; + $temp = Api\Hooks::process( array( + 'location' => 'mail_compose_prepare', + 'content' => $content, + 'readonlys' => $readonlys, + 'sel_options' => $sel_options + )); + + foreach ($temp as $hook){ + if($hook){ + $content = array_merge($content, $hook['content']); + $readonlys = array_merge($readonlys,$hook['readonlys']); + $preserv = array_merge($readonlys, $hook['preserv']); + $sel_options = array_merge($readonlys, $hook['sel_options']); + } + + } + unset($temp,$hook); + //error_log(__METHOD__.__LINE__.array2string($content)); - $etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2); + $etpl->exec('mail.mail_compose.compose',$content,$sel_options,$readonlys,$preserv,2); } /**