* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
* @since file available since contenido release <= 4.6
*
* {@internal
* created 2007-01-01, Bj�rn Behrens (HerrB)
* modified 2008-06-27, Dominik Ziegler, add security fix
*
* $Id: include.newsletter_edit_message.php 128 2019-07-03 11:58:28Z oldperl $:
* }}
*
*/
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
cInclude("includes", "functions.con.php"); // For conDeleteArt and conCopyArt
// Initialization
$oPage = new cPage;
$oClientLang = new cApiClientLanguage(false, $client, $lang);
// Include plugins
if (is_array($cfg['plugins']['newsletters'])) {
foreach ($cfg['plugins']['newsletters'] as $plugin) {
plugin_include("newsletters", $plugin . "/" . $plugin . ".php");
}
}
// Exec actions
$oNewsletter = new Newsletter;
$oNewsletter->loadByPrimaryKey($idnewsletter);
if ($oNewsletter->virgin == false && $oNewsletter->get("idclient") == $client && $oNewsletter->get("idlang") == $lang) {
// Check and set values
if (!is_numeric($_REQUEST["selTemplate"])) {
$_REQUEST["selTemplate"] = 0;
}
// Saving message changes; note, that if a user doesn't have the right to save the
// text message he may still have the right to change the html article. To prevent
// changing the html article, give the user only read access right for the newsletter
// article category - the article will be shown also, if he doesn't have any rights at all...
if ($action == "news_save" && $perm->have_perm_area_action("news", $action)) { // Don't use $area!
// Changing e.g. \' back to ' (magic_quotes)
$sMessage = Contenido_Security::unescapeDB($_REQUEST["txtMessage"]);
$oNewsletter->set("message", $sMessage);
if ($oNewsletter->get("template_idart") != $_REQUEST["selTemplate"]) {
if ($oNewsletter->get("idart") > 0) {
// Template has been changed: Delete old article
// (this discards the current html content as it deletes the existing newsletter article)
conDeleteArt($oNewsletter->get("idart"));
$iIDArt = 0;
}
if ($_REQUEST["selTemplate"] > 0) {
// Template has been changed, but specified: Store template article as new newsletter article
$iIDArt = conCopyArticle($_REQUEST["selTemplate"], $oClientLang->getProperty("newsletter", "html_newsletter_idcat"), sprintf(i18n("Newsletter: %s", "cl-newsletter"), $oNewsletter->get("name")));
conMakeOnline($iIDArt, $lang); // Article has to be online for sending...
}
$oNewsletter->set("idart", $iIDArt);
$oNewsletter->set("template_idart", $_REQUEST["selTemplate"]);
}
$oNewsletter->store();
} else if ($oNewsletter->get("idart") > 0) {
// Check, if html message article and template article are still available
$oArticles = new cApiArticleLanguageCollection;
$oArticles->setWhere("idlang", $lang);
$oArticles->setWhere("idart", $oNewsletter->get("idart"));
$oArticles->query();
if ($oArticles->count() == 0) {
// Ups, article lost, reset idart and template_idart for newsletter
$notis = $notification->returnNotification("error", sprintf(i18n("The html newsletter article has been deleted (idart: %s), the html message is lost", "cl-newsletter"), $oNewsletter->get("idart"))) . "
";
$oNewsletter->set("idart", 0);
$oNewsletter->set("template_idart", 0);
$oNewsletter->store();
} else {
$oArticles->resetQuery();
$oArticles->setWhere("idlang", $lang);
$oArticles->setWhere("idart", $oNewsletter->get("template_idart"));
$oArticles->query();
if ($oArticles->count() == 0) {
// Ups, template has been deleted: Restore from current newsletter message article
$notis = $notification->returnNotification("warning", i18n("The html newsletter template article has been deleted, it has been restored using the html message article of this newsletter", "cl-newsletter")) . "
";
$iIDArt = conCopyArticle($oNewsletter->get("idart"), $oClientLang->getProperty("newsletter", "html_template_idcat"), sprintf(i18n("%s (Template restored)", "cl-newsletter"), $oNewsletter->get("name")));
$oNewsletter->set("template_idart", $iIDArt);
$oNewsletter->store();
}
}
}
$oForm = new UI_Table_Form("frmNewsletterMsg");
$oForm->setVar("frame", $frame);
$oForm->setVar("area", $area);
$oForm->setVar("action", "news_save");
$oForm->setVar("idnewsletter", $idnewsletter);
$oForm->setWidth("100%");
$oForm->addHeader(sprintf(i18n("Edit newsletter message (%s)", "cl-newsletter"), $oNewsletter->get("name")));
$oForm->add(i18n("Subject"), $oNewsletter->get("subject"));
$sTagInfoText = '' . i18n("Tag information", "cl-newsletter") . '' .
'