* {@internal 
 *   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();
$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");
 * @since      file available since contenido release <= 4.6
 * 
 * {@internal 
 *   created 2004-08-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();
$oRGroups = new RecipientGroupCollection();
$oRGroupMembers = new RecipientGroupMemberCollection();
$oRGroup = new RecipientGroup();
$aFields = array();
$aFields["name"] = array("field" => "name", "caption" => i18n("Name", $plugin_name), "type" => "base,sort,search");
$aFields["email"] = array("field" => "email", "caption" => i18n("E-Mail", $plugin_name), "type" => "base,sort,search");
$aFields["confirmed"] = array("field" => "confirmed", "caption" => i18n("Confirmed", $plugin_name), "type" => "base");
$aFields["deactivated"] = array("field" => "deactivated", "caption" => i18n("Deactivated", $plugin_name), "type" => "base");
if ($action == "recipientgroup_create" && $perm->have_perm_area_action($area, $action)) {
    $oRGroup = $oRGroups->create(" " . i18n("-- new group --", $plugin_name));
    $_REQUEST["idrecipientgroup"] = $oRGroup->get("idnewsgroup");
    $oPage->setReload();
    $sRefreshLeftTopScript = '<script type="text/javascript">top.content.left.left_top.refreshGroupOption(\'' . $_REQUEST["idrecipientgroup"] . '\', \'add\')</script>';
    $oPage->addScript('refreshlefttop', $sRefreshLeftTopScript);
} elseif ($action == "recipientgroup_delete" && $perm->have_perm_area_action($area, $action)) {
 * @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$:
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$plugin_name = 'newsletter';
$oPage = new cPage();
$oRecipients = new RecipientCollection();
if (is_array($cfg['plugins']['recipients'])) {
    foreach ($cfg['plugins']['recipients'] as $plugin) {
        plugin_include("recipients", $plugin . "/" . $plugin . ".php");
    }
}
// Note, that the object name has to be $recipient for plugins
if ($action == "recipients_create" && $perm->have_perm_area_action($area, $action)) {
    $recipient = $oRecipients->create("*****@*****.**", " " . i18n("-- new recipient --", $plugin_name));
    $oPage->setReload();
} elseif ($action == "recipients_delete" && $perm->have_perm_area_action($area, $action)) {
    $oRecipients->delete($idrecipient);
    $recipient = new Recipient();
    $oPage->setReload();
} elseif ($action == "recipients_purge" && $perm->have_perm_area_action($area, "recipients_delete")) {
{
    if (!is_array($array)) {
        return false;
    }
    $result = array();
    foreach ($array as $value) {
        $result[] = str_replace("e", "", $value);
    }
    return $result;
}
// fetch idartlang for idart
$sql = "SELECT idartlang FROM " . $cfg['tab']['art_lang'] . " WHERE idart=" . Contenido_Security::toInteger($idart) . " AND idlang=" . Contenido_Security::toInteger($lang);
$db->query($sql);
$db->next_record();
$this_idartlang = $db->f('idartlang');
$oPage = new cPage();
$oPage->setMargin(10);
$oTree = new pApiContentAllocationComplexList('06bd456d-fe76-40cb-b041-b9ba90dc400a');
$oAlloc = new pApiContentAllocation();
if ($_POST['action'] == 'storeallocation') {
    $oAlloc->storeAllocations($this_idartlang, $_POST['allocation']);
}
if ($_GET['step'] == 'collapse') {
    $oTree->setTreeStatus($_GET['idpica_alloc']);
}
#build category path
$catString = '';
prCreateURLNameLocationString($idcat, '/', $catString);
$oArticle = new Article($idart, $client, $lang);
$sArticleTitle = $oArticle->getField('title');
$sLocationString = "<div class=\"categorypath\">" . $catString . '/' . htmlspecialchars($sArticleTitle) . "</div>";
 * @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$:
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$plugin_name = 'newsletter';
// Initialization
$oPage = new cPage();
if ($action == "news_job_run" && $perm->have_perm_area_action($area, $action) && is_numeric($_REQUEST["idnewsjob"])) {
    // Run job
    $oJob = new cNewsletterJob($_REQUEST["idnewsjob"]);
    $iSendCount = $oJob->runJob();
    if ($oJob->get("dispatch") == 1 && $oJob->get("sendcount") < $oJob->get("rcpcount")) {
        // Send in chunks
        $sPathNext = $sess->url("main.php?area={$area}&action=news_job_run&frame=4&idnewsjob=" . $_REQUEST["idnewsjob"]);
        // Calculating some statistics
        $iChunk = ceil($oJob->get("sendcount") / $oJob->get("dispatch_count"));
        $iChunks = ceil($oJob->get("rcpcount") / $oJob->get("dispatch_count"));
        // Dispatch count > send/recipient count, set values to 1, at least
        if ($iChunk == 0) {
            $iChunk = 1;
        }
        if ($iChunks == 0) {
    $db = new DB_Contenido();
}
if (isset($_REQUEST['treeItemPost']['idpica_alloc'])) {
    $aPostTreeItem['idpica_alloc'] = (int) $_REQUEST['treeItemPost']['idpica_alloc'];
}
if (isset($_REQUEST['treeItemPost']['parentid'])) {
    $aPostTreeItem['parentid'] = (int) $_REQUEST['treeItemPost']['parentid'];
}
if (isset($_REQUEST['treeItemPost']['name'])) {
    $sName = stripslashes($_REQUEST['treeItemPost']['name']);
    $sName = $db->escape($sName);
    $aPostTreeItem['name'] = $sName;
}
$_GET['idpica_alloc'] = (int) $_GET['idpica_alloc'];
#end added 24.06.08 timo.trautmann
$oPage = new cPage();
$oPage->setMargin(10);
$oPage->setMessageBox();
$oTree = new pApiContentAllocationTreeView('f7771624-4874-4745-8b7e-21a49a71a447');
// store item
if ($_POST['step'] == 'store') {
    $pNotify = '<div style="width:410px;margin-bottom:20px;">';
    $sMessage = sprintf(i18n("New Category %s successfully stored!", 'content_allocation'), $treeItem['name']);
    $notification->displayNotification("info", $sMessage);
    $pNotify .= '</div>';
    $oTree->storeItem($aPostTreeItem);
}
// rename item
if ($_POST['step'] == 'storeRename') {
    $pNotify = '<div style="width:410px;margin-bottom:20px;">';
    $sMessage = sprintf(i18n("Category %s successfully renamed!", 'content_allocation'), $treeItem['name']);
 * {@internal 
 *   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';
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;
    }
 * @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$:
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
$plugin_name = 'newsletter';
$oPage = new cPage();
$oRecipients = new RecipientCollection();
if (is_array($cfg['plugins']['recipients'])) {
    foreach ($cfg['plugins']['recipients'] as $plugin) {
        plugin_include("recipients", $plugin . "/" . $plugin . ".php");
    }
}
// Check form data
if ($_REQUEST["selDelimiter"] == "") {
    $_REQUEST["selDelimiter"] = "semikolon";
}
$aFields = array();
$aFieldDetails = array();
$aFields["name"] = strtolower(i18n("Name", $plugin_name));
$aFieldDetails["name"]["fieldtype"] = "field";
// field, plugin or group