diff --git a/zmsdb/src/Zmsdb/Calldisplay.php b/zmsdb/src/Zmsdb/Calldisplay.php index 95e4bbe8b..b525f5531 100644 --- a/zmsdb/src/Zmsdb/Calldisplay.php +++ b/zmsdb/src/Zmsdb/Calldisplay.php @@ -85,6 +85,7 @@ public function readImage(Entity $entity) ->fetchOne((new Query\Calldisplay(Query\Base::SELECT)) ->getQueryImage(), ['name' => "logo.png"]); } + $mime = pathinfo($image['name'], PATHINFO_EXTENSION); $image['mime'] = ($mime == 'jpg') ? 'jpeg' : $mime; return $image; diff --git a/zmsentities/src/Zmsentities/Helper/Messaging.php b/zmsentities/src/Zmsentities/Helper/Messaging.php index 35f6136ba..e730c83c4 100644 --- a/zmsentities/src/Zmsentities/Helper/Messaging.php +++ b/zmsentities/src/Zmsentities/Helper/Messaging.php @@ -114,7 +114,7 @@ public static function getMailContent( $client = $mainProcess->getFirstClient(); } - $template = self::getTemplate('mail', $status); + $template = self::getTemplate('mail', $status, $mainProcess); if ($initiator) { $template = self::getTemplate('admin', $status); } @@ -193,7 +193,7 @@ public static function getNotificationContent(Process $process, Config $config, return $message; } - protected static function getTemplate($type, $status) + protected static function getTemplate($type, $status, ?Process $process = null) { $template = null; if (Property::__keyExists($type, self::$templates)) { @@ -201,9 +201,41 @@ protected static function getTemplate($type, $status) $template = self::$templates[$type][$status]; } } + + if ($process) { + $provider = $process->scope->provider; + $providerName = $provider->displayName; + $providerTemplateName = self::getProviderTemplateName($providerName); + $providerTemplateFolder = 'custom/' . $providerTemplateName . '/'; + + if (file_exists(TemplateFinder::getTemplatePath() . '/messaging/' . $providerTemplateFolder . $template)) { + return $providerTemplateFolder . $template; + } + } + return $template; } + private static function getProviderTemplateName($providerName) + { + if (strpos($providerName, '(')) { + $providerName = substr($providerName, 0, strpos($providerName, '(')); + } + $divider = '-'; + $providerTemplate = preg_replace('~[^\pL\d]+~u', $divider, $providerName); + $providerTemplate = iconv('utf-8', 'us-ascii//TRANSLIT', $providerTemplate); + $providerTemplate = preg_replace('~[^-\w]+~', '', $providerTemplate); + $providerTemplate = trim($providerTemplate, $divider); + $providerTemplate = preg_replace('~-+~', $divider, $providerTemplate); + $providerTemplate = strtolower($providerTemplate); + + if (empty($providerTemplate)) { + return 'none'; + } + + return $providerTemplate; + } + public static function getMailSubject( Process $process, Config $config,