*
 *   $Id$:
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$plugin_name = 'newsletter';
##################################
# Initialization
##################################
$oPage = new cPage();
$oMenu = new UI_Menu();
$oJobs = new cNewsletterJobCollection();
$oUser = new cApiUser($auth->auth["uid"]);
// Specify fields for search, sort and validation. Design makes enhancements
// using plugins possible (currently not implemented). If you are changing things here,
// remember to update include.newsletter_left_top.php, also.
// field:	Field name in the db
// caption:	Shown field name (-> user)
// base:	Elements from core code (other type may be: "plugin")
// sort: 	Element can be used to be sorted by
// search:	Element can be used to search in
$aFields = array();
$aFields["name"] = array("field" => "name", "caption" => i18n("Name", $plugin_name), "type" => "base,sort,search");
$aFields["created"] = array("field" => "created", "caption" => i18n("Created", $plugin_name), "type" => "base,sort");
$aFields["status"] = array("field" => "status", "caption" => i18n("Status", $plugin_name), "type" => "base,sort");
// Not needed, as no sort/search, but keep as memo: $aFields["cronjob"]	= array("field" => "use_cronjob", "caption" => i18n("Use cronjob", $plugin_name), "type" => "base");
##################################
# Check external input
 *   created 2007-01-01, Björn Behrens (HerrB)
 *   modified 2008-06-27, Dominik Ziegler, add security fix
 *
 *   $Id$:
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$plugin_name = 'newsletter';
##################################
# Initialization
##################################
$oPage = new cPage();
$oUser = new cApiUser($auth->auth["uid"]);
$oClientLang = new cApiClientLanguage(false, $client, $lang);
// Get idCatArt to check, if we may send a test newsletter
$lIDCatArt = (int) $oClientLang->getProperty("newsletter", "idcatart");
// Specify fields for search, sort and validation. Design makes enhancements
// using plugins possible (currently not implemented). If you are changing things here,
// remember to update include.newsletter_left_top.php, also.
// field:	Field name in the db
// caption:	Shown field name (-> user)
// base:	Elements from core code (other type may be: "plugin")
// sort: 	Element can be used to be sorted by
// search:	Element can be used to search in
$aFields = array();
$aFields["name"] = array("field" => "name", "caption" => i18n("Name", $plugin_name), "type" => "base,sort,search");
##################################
# Store settings/Get basic data
            foreach ($_REQUEST["deluser"] as $iRcpID) {
                if (is_numeric($iRcpID)) {
                    echo "yo: " . $iRcpID;
                    $oRGroupMembers->remove($_REQUEST["idrecipientgroup"], $iRcpID);
                }
            }
        }
        $sRefreshLeftTopScript = '<script type="text/javascript">top.content.left.left_top.refreshGroupOption(\'' . $_REQUEST["idrecipientgroup"] . '\', \'remove\');
									top.content.left.left_top.refreshGroupOption(\'' . $_REQUEST["idrecipientgroup"] . '\', \'add\', \'' . $sGroupName . '\');</script>';
        $oPage->addScript('refreshlefttop', $sRefreshLeftTopScript);
    }
    if (count($aMessages) > 0) {
        $sNotis = $notification->returnNotification("warning", implode("<br>", $aMessages)) . "<br>";
    }
    // Set default values
    $oUser = new cApiUser($auth->auth["uid"]);
    if (!isset($_REQUEST["member_elemperpage"]) || !is_numeric($_REQUEST["member_elemperpage"]) || $_REQUEST["member_elemperpage"] < 0) {
        $_REQUEST["member_elemperpage"] = $oUser->getProperty("itemsperpage", $area . "_edit_member");
    }
    if (!is_numeric($_REQUEST["member_elemperpage"])) {
        $_REQUEST["member_elemperpage"] = 25;
    }
    if ($_REQUEST["member_elemperpage"] > 0) {
        // -- All -- will not be stored, as it may be impossible to change this back to something more useful
        $oUser->setProperty("itemsperpage", $area . "_edit_member", $_REQUEST["member_elemperpage"]);
    }
    if (!isset($_REQUEST["outsider_elemperpage"]) || !is_numeric($_REQUEST["outsider_elemperpage"]) || $_REQUEST["outsider_elemperpage"] < 0) {
        $_REQUEST["outsider_elemperpage"] = $oUser->getProperty("itemsperpage", $area . "_edit_outsider");
    }
    if (!is_numeric($_REQUEST["outsider_elemperpage"])) {
        $_REQUEST["outsider_elemperpage"] = 25;
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$plugin_name = 'newsletter';
######################################
# Initialization
######################################
if (!is_object($oTpl)) {
    $oTpl = new Template();
}
if (!is_object($oDB)) {
    $oDB = new DB_Contenido();
    // We have really to send a special SQL statement - we need a DB object
}
$oUser = new cApiUser($auth->auth["uid"]);
$oClient = new cApiClient($client);
$oClientLang = new cApiClientLanguage(false, $client, $lang);
######################################
# 0. BUTTONS
######################################
// Newsletter
$sId = 'img_newsletter';
$oTpl->set('s', 'INEWSLETTER', $sId);
if ($perm->have_perm_area_action('news')) {
    $sButtonRow = '<a style="margin-right:5px;" href="javascript://" onclick="toggleContainer(\'' . $sId . '\');reloadLeftBottomAndTransportFormVars(document.newsletter_listoptionsform);">';
    $sButtonRow .= '<img onmouseover="hoverEffect(\'' . $sId . '\', \'in\')" onmouseout="hoverEffect(\'' . $sId . '\', \'out\')" alt="' . i18n("Newsletter", $plugin_name) . '" title="' . i18n("Newsletter", $plugin_name) . '" name="' . $sId . '" id="' . $sId . '" src="' . $cfg["path"]["images"] . 'newsletter_on.gif"/>';
    $sButtonRow .= '</a>';
}
// Job dispatch
$sId = 'img_dispatch';
 $oLogs = new cNewsletterLogCollection();
 // Remove recipient from a job
 if ($action == "news_job_detail_delete" && is_numeric($_REQUEST["idnewslog"]) && $perm->have_perm_area_action($area, "news_job_detail_delete")) {
     $oLogs->delete($_REQUEST["idnewslog"]);
 }
 // Initialize
 $iNextPage = Contenido_Security::toInteger($_GET['nextpage']);
 if ($iNextPage <= 0) {
     $iNextPage = 1;
 }
 if ($_REQUEST["sortmode"] !== "DESC") {
     $_REQUEST["sortmode"] = "ASC";
 }
 $sDateFormat = getEffectiveSetting("backend", "timeformat", "d.m.Y H:i");
 // Set default values
 $oUser = new cApiUser($auth->auth["uid"]);
 if (!isset($_REQUEST["elemperpage"]) || !is_numeric($_REQUEST["elemperpage"]) || $_REQUEST["elemperpage"] < 0) {
     $_REQUEST["elemperpage"] = $oUser->getProperty("itemsperpage", $area . "_job_details");
 }
 if (!is_numeric($_REQUEST["elemperpage"])) {
     $_REQUEST["elemperpage"] = 50;
 }
 if ($_REQUEST["elemperpage"] > 0) {
     // - All - will not be saved
     $oUser->setProperty("itemsperpage", $area . "_job_details", $_REQUEST["elemperpage"]);
 }
 $oFrmOptions = new UI_Table_Form("frmOptions");
 $oFrmOptions->setVar("contenido", $sess->id);
 $oFrmOptions->setVar("area", $area);
 $oFrmOptions->setVar("action", $action);
 $oFrmOptions->setVar("frame", $frame);