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';
47
48// There is no permission test on this component for the moment. Test will be added when knowing which data it read.
49
50// TODO $selectedPosts is not initialised, i set it to '' but this is surely a bug and not the expected behaviour.
51// Should be set to list of last news...
52$selectedPosts = '';
53
54
55/*
56 * View
57 */
58
60
61// TODO Replace with ID of template
62if (GETPOSTISSET('content')) {
63 $content = GETPOST('content');
64
65 if (!empty($selectedPosts)) {
66 $newsList = '';
67
68 foreach ($selectedPosts as $post) {
69 $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;">
70 <div style="flex-grow: 1; margin-right: 30px; max-width: 600px; margin-left: 100px;">
71 <h2 style="margin: 0; font-size: 1.5em;">' . htmlentities($post['title']) . '</h2>
72 <p style="margin: 10px 0; color: #555;">' . htmlentities($post['description']) . '</p>
73 <span style="display: block; margin-bottom: 5px; color: #888;">Created By: <strong>' . htmlentities($post['user_fullname']) . '</strong></span>
74 <br>
75 <span style="display: block; color: #888;">' . dol_print_date($post['date_creation'], 'daytext', 'tzserver', $langs) . '</span>
76 </div>
77 <div style="flex-shrink: 0; margin-left: 100px; float: right;">
78 ' . ($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__">') . '
79 </div>
80 </div>';
81 }
82
83 $content = str_replace('__NEWS_LIST__', $newsList, $content);
84 } else {
85 $content = str_replace('__NEWS_LIST__', 'No articles selected', $content);
86 }
87
88
89 print $content;
90} else {
91 print 'No content provided or invalid token';
92}
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.