diff --git a/htdocs/core/ajax/getnews.php b/htdocs/core/ajax/getnews.php new file mode 100644 index 00000000000..9e8b61c47b2 --- /dev/null +++ b/htdocs/core/ajax/getnews.php @@ -0,0 +1,48 @@ +fetch($id); + + $selectedPosts[] = array( + 'id' => $blog->id, + 'title' => $blog->title, + 'description' => $blog->description, + 'date_creation' => $blog->date_creation, + 'image' => $blog->image, + ); + } + + print json_encode($selectedPosts); +} else { + print json_encode(array('error' => 'Invalid request')); +} diff --git a/htdocs/core/ajax/mailtemplate.php b/htdocs/core/ajax/mailtemplate.php index 11d4b4ca1cb..b4d6257fb52 100644 --- a/htdocs/core/ajax/mailtemplate.php +++ b/htdocs/core/ajax/mailtemplate.php @@ -44,12 +44,7 @@ require_once '../../main.inc.php'; require_once '../lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - -// There is no permission test on this component for the moment. Test will be added when knowing which data it read. - -// TODO $selectedPosts is not initialised, i set it to '' but this is surely a bug and not the expected behaviour. -// Should be set to list of last news... -$selectedPosts = ''; +require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; /* @@ -60,12 +55,16 @@ top_httphead(); // TODO Replace with ID of template if (GETPOSTISSET('content')) { - $content = GETPOST('content'); + $content = filter_input(INPUT_POST, 'content', FILTER_UNSAFE_RAW); - if (!empty($selectedPosts)) { + $selectedPostsStr = GETPOST('selectedPosts', 'alpha'); + $selectedPosts = explode(',', $selectedPostsStr); + + if (is_array($selectedPosts) && !empty($selectedPosts)) { $newsList = ''; - foreach ($selectedPosts as $post) { + foreach ($selectedPosts as $postId) { + $post = getNewsDetailsById($postId); $newsList .= '

' . htmlentities($post['title']) . '

diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index d33f5f73f8f..d51d1177e68 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -499,7 +499,7 @@ class FormMail extends Form $modelmail_array = array(); if ($this->param['models'] != 'none') { - $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); // Fill $this->lines_model + $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); } @@ -1514,16 +1514,21 @@ class FormMail extends Form * Return HTML code for selection of email layout * * @param string $htmlContent HTML name of WYSIWYG field to fill - * @return string HTML for model email boxes + * @return string HTML for model email boxes */ public function getModelEmailTemplate($htmlContent = 'message') { - global $langs; + global $websitepage, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/emaillayout.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; - $out = '