27ini_set(
'display_errors', 1);
29if (!defined(
'NOTOKENRENEWAL')) {
30 define(
'NOTOKENRENEWAL',
'1');
32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOREQUIREHTML')) {
36 define(
'NOREQUIREHTML',
'1');
38if (!defined(
'NOREQUIREAJAX')) {
39 define(
'NOREQUIREAJAX',
'1');
41require_once
'../../main.inc.php';
42require_once
'../lib/files.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
71if (GETPOSTISSET(
'template')) {
74 $content = file_get_contents($templatefile);
76 if ($content ===
false) {
77 print
'Failed to load template '.dol_escape_htmltag(
GETPOST(
'template'));
83 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
87 $specificSubstitutionArray = array(
88 '__TITLEOFMAILHOLDER__' => $langs->trans(
'TitleOfMailHolder'),
89 '__CONTENTOFMAILHOLDER__' =>
'Lorem ipsum ...',
90 '__GRAY_RECTANGLE__' =>
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC',
91 '__LAST_NEWS__' => $langs->trans(
'LastNews'),
92 '__LIST_PRODUCTS___' => $langs->trans(
'ListProducts'),
93 '__SUBJECT__' =>
GETPOST(
'subject'),
95 '__MYCOMPANY_ADDRESS__' => $mysoc->getFullAddress(0,
'<br>', 1,
''),
96 '__MYCOMPANY_EMAIL__' => $mysoc->email,
97 '__MYCOMPANY_PHONE_PRO__' => $mysoc->phone_pro,
98 '__MYCOMPANY_PHONE_MOBILE__' => $mysoc->phone_mobile,
99 '__MYCOMPANY_FAX__' => $mysoc->fax,
102 $listsocialnetworks =
'';
109 $specificSubstitutionArray[
'__MYCOMPANY_SOCIAL_NETWORKS__'] = $listsocialnetworks;
111 if (!empty($mysoc->logo) &&
dol_is_file(
$conf->mycompany->dir_output.
'/logos/'.$mysoc->logo)) {
112 $specificSubstitutionArray[
'__LOGO_URL__'] = $urlwithroot.
'/viewimage.php?modulepart=mycompany&file='.urlencode(
'logos/'.$mysoc->logo);
114 $specificSubstitutionArray[
'__LOGO_URL__'] =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC';
117 $specificSubstitutionArray[
'__USERSIGNATURE__'] = empty($user->signature) ?
'' : $user->signature;
119 if (
GETPOST(
'fromtype') ==
'user') {
120 $specificSubstitutionArray[
'__SENDEREMAIL_SIGNATURE__'] = empty($user->signature) ?
'' : $user->signature;
121 } elseif (
GETPOST(
'fromtype') ==
'company') {
122 $specificSubstitutionArray[
'__SENDEREMAIL_SIGNATURE__'] = $mysoc->name.
' '.$mysoc->email;
123 } elseif (
GETPOST(
'fromtype') ==
'main_from') {
124 $specificSubstitutionArray[
'__SENDEREMAIL_SIGNATURE__'] = $mysoc->name.
' '.
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM');
127 $specificSubstitutionArray[
'__SENDEREMAIL_SIGNATURE__'] =
'TODO Read database to get the signature of the profile';
133 foreach ($specificSubstitutionArray as $key => $val) {
134 $content = str_replace($key, $val, $content);
138 $langs->load(
"other");
139 $content = preg_replace_callback(
145 function ($matches) {
147 return $langs->trans($matches[1]);
152 $selectedPostsStr =
GETPOST(
'selectedPosts',
'alpha');
153 $selectedPosts = explode(
',', $selectedPostsStr);
155 if (is_array($selectedPosts) && !empty($selectedPosts)) {
158 foreach ($selectedPosts as $postId) {
161 $newsList .=
'<div style="display: flex; align-items: flex-start; justify-content: flex-start; width: 100%; max-width: 800px; margin-top: 20px;margin-bottom: 50px; padding: 20px;">
162 <div style="flex-grow: 1; margin-right: 30px; max-width: 600px; margin-left: 100px;">
163 <h2 style="margin: 0; font-size: 1.5em;">' . htmlentities(empty($post[
'title']) ?
'' : $post[
'title']) .
'</h2>
164 <p style="margin: 10px 0; color: #555;">' . htmlentities(empty($post[
'description']) ?
'' : $post[
'description']) .
'</p>
165 <span style="display: block; margin-bottom: 5px; color: #888;">Created By: <strong>' . htmlentities(empty($post[
'user_fullname']) ?
'' : $post[
'user_fullname']) .
'</strong></span>
167 <span style="display: block; color: #888;">' .
dol_print_date((empty($post[
'date_creation']) ?
dol_now() : $post[
'date_creation']),
'daytext',
'tzserver', $langs) .
'</span>
169 <div style="flex-shrink: 0; margin-left: 100px; float: right;">
170 ' . (!empty($post[
'image']) ?
'<img alt="Image" width="130px" height="130px" style="border-radius: 10px;" src="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=medias&file=' . htmlentities($post[
'image']) .
'">' :
'<img alt="Gray rectangle" width="130px" height="130px" style="border-radius: 10px;" src="__GRAY_RECTANGLE__">') .
'
175 $content = str_replace(
'__NEWS_LIST__', $newsList, $content);
177 $content = str_replace(
'__NEWS_LIST__',
'No articles selected', $content);
182 print
'No template ID provided or expired token';
global $dolibarr_main_url_root
getNewsDetailsById($postId)
Retrieves the details of a news post by its ID.
dol_is_file($pathoffile)
Return if path is a file.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...