dolibarr 21.0.0-alpha
mailtemplate.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
25// Just for display errors in editor
26ini_set('display_errors', 1);
27
28if (!defined('NOTOKENRENEWAL')) {
29 define('NOTOKENRENEWAL', '1'); // Disables token renewal
30}
31if (!defined('NOREQUIREMENU')) {
32 define('NOREQUIREMENU', '1');
33}
34if (!defined('NOREQUIREHTML')) {
35 define('NOREQUIREHTML', '1');
36}
37if (!defined('NOREQUIREAJAX')) {
38 define('NOREQUIREAJAX', '1');
39}
40if (!defined('NOREQUIRESOC')) {
41 define('NOREQUIRESOC', '1');
42}
43require_once '../../main.inc.php';
44require_once '../lib/files.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
48
49
50/*
51 * View
52 */
53
55
56// TODO Replace with ID of template
57if (GETPOSTISSET('content')) {
58 $content = filter_input(INPUT_POST, 'content', FILTER_UNSAFE_RAW);
59
60 $selectedPostsStr = GETPOST('selectedPosts', 'alpha');
61 $selectedPosts = explode(',', $selectedPostsStr);
62
63 if (is_array($selectedPosts) && !empty($selectedPosts)) {
64 $newsList = '';
65
66 foreach ($selectedPosts as $postId) {
67 $post = getNewsDetailsById($postId);
68 $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;">
69 <div style="flex-grow: 1; margin-right: 30px; max-width: 600px; margin-left: 100px;">
70 <h2 style="margin: 0; font-size: 1.5em;">' . htmlentities($post['title']) . '</h2>
71 <p style="margin: 10px 0; color: #555;">' . htmlentities($post['description']) . '</p>
72 <span style="display: block; margin-bottom: 5px; color: #888;">Created By: <strong>' . htmlentities($post['user_fullname']) . '</strong></span>
73 <br>
74 <span style="display: block; color: #888;">' . dol_print_date($post['date_creation'], 'daytext', 'tzserver', $langs) . '</span>
75 </div>
76 <div style="flex-shrink: 0; margin-left: 100px; float: right;">
77 ' . ($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__">') . '
78 </div>
79 </div>';
80 }
81
82 $content = str_replace('__NEWS_LIST__', $newsList, $content);
83 } else {
84 $content = str_replace('__NEWS_LIST__', 'No articles selected', $content);
85 }
86
87
88 print $content;
89} else {
90 print 'No content provided or invalid token';
91}
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.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
getNewsDetailsById($postId)
Retrieves the details of a news post by its ID.