// 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)) {
        // 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", $plugin_name), $oNewsletter->get("name")));
                conMakeOnline($iIDArt, $lang);
                // Article has to be online for sending...
            }
            $oNewsletter->set("idart", $iIDArt);
            $oNewsletter->set("template_idart", $_REQUEST["selTemplate"]);