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