Add files via upload
Dieser Commit ist enthalten in:
Ursprung
a185d2db52
Commit
faa2e43e37
34 geänderte Dateien mit 9581 neuen und 0 gelöschten Zeilen
17
includes/config.autoloader.php
Normale Datei
17
includes/config.autoloader.php
Normale Datei
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
$sAutoloadClassPath = strstr(dirname(dirname(__FILE__)), "conlite/plugins")."/classes/";
|
||||
return array(
|
||||
'RecipientGroupCollection' => $sAutoloadClassPath.'class.newsletter.groups.php',
|
||||
'RecipientGroup' => $sAutoloadClassPath.'class.newsletter.groups.php',
|
||||
'RecipientGroupMemberCollection' => $sAutoloadClassPath.'class.newsletter.groups.php',
|
||||
'RecipientGroupMember' => $sAutoloadClassPath.'class.newsletter.groups.php',
|
||||
'cNewsletterJobCollection' => $sAutoloadClassPath.'class.newsletter.jobs.php',
|
||||
'cNewsletterJob' => $sAutoloadClassPath.'class.newsletter.jobs.php',
|
||||
'cNewsletterLogCollection' => $sAutoloadClassPath.'class.newsletter.logs.php',
|
||||
'cNewsletterLog' => $sAutoloadClassPath.'class.newsletter.logs.php',
|
||||
'NewsletterCollection' => $sAutoloadClassPath.'class.newsletter.php',
|
||||
'Newsletter' => $sAutoloadClassPath.'class.newsletter.php',
|
||||
'RecipientCollection' => $sAutoloadClassPath.'class.newsletter.recipients.php',
|
||||
'Recipient' => $sAutoloadClassPath.'class.newsletter.recipients.php'
|
||||
);
|
||||
?>
|
||||
35
includes/config.plugin.php
Normale Datei
35
includes/config.plugin.php
Normale Datei
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* File:
|
||||
* plugin.conf.php.php
|
||||
*
|
||||
* @package Plugins
|
||||
* @subpackage Newsletter
|
||||
* @version $Rev: 128 $
|
||||
* @since 2.0
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
* @copyright 2012 CL-Team
|
||||
* @link http://www.conlite.org
|
||||
*
|
||||
* $Id: config.plugin.php 128 2019-07-03 11:58:28Z oldperl $
|
||||
*/
|
||||
|
||||
// security check
|
||||
defined('CON_FRAMEWORK') or die('Illegal call');
|
||||
|
||||
class nlHandler extends pluginHandlerAbstract {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
plugin_include(nlHandler::getName(), "includes/functions/demo1.php");
|
||||
plugin_include(nlHandler::getName(), "includes/functions/demo2.php");
|
||||
*/
|
||||
|
||||
|
||||
$cfg["tab"]["news"] = $cfg['sql']['sqlprefix']."_pi_news";
|
||||
$cfg["tab"]["news_rcp"] = $cfg['sql']['sqlprefix']."_pi_news_rcp";
|
||||
$cfg["tab"]["news_groups"] = $cfg['sql']['sqlprefix']."_pi_news_groups";
|
||||
$cfg["tab"]["news_groupmembers"] = $cfg['sql']['sqlprefix']."_pi_news_groupmembers";
|
||||
$cfg["tab"]["news_jobs"] = $cfg['sql']['sqlprefix']."_pi_news_jobs";
|
||||
$cfg["tab"]["news_log"] = $cfg['sql']['sqlprefix']."_pi_news_log";
|
||||
556
includes/include.newsletter_edit.php
Normale Datei
556
includes/include.newsletter_edit.php
Normale Datei
|
|
@ -0,0 +1,556 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Frontend user editor
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.1.7
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
* modified 2010-12-14, Dominik Ziegler, newsletter encoding is ignored due to wrong parameter values [#CON-374]
|
||||
*
|
||||
* $Id: include.newsletter_edit.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
// Initialization
|
||||
$oPage = new cPage();
|
||||
$oRcpGroups = new RecipientGroupCollection();
|
||||
$oClientLang = new cApiClientLanguage(false, $client, $lang);
|
||||
$oNewsletters = new NewsletterCollection();
|
||||
|
||||
// Include plugins
|
||||
if (is_array($cfg['plugins']['newsletters'])) {
|
||||
foreach ($cfg['plugins']['newsletters'] as $plugin) {
|
||||
plugin_include("newsletters", $plugin . "/" . $plugin . ".php");
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == "news_create" && $perm->have_perm_area_action($area, "news_create")) {
|
||||
// Create new newsletter
|
||||
$oNewsletter = $oNewsletters->create(i18n("-- new newsletter --", "cl_newsletter"));
|
||||
$idnewsletter = $oNewsletter->get("idnews");
|
||||
$oPage->setSubnav("idnewsletter=$idnewsletter", "news");
|
||||
$oPage->setReload();
|
||||
|
||||
// Populating default values
|
||||
$oNewsletter->set("newsfrom", $oClientLang->getProperty("newsletter", "newsfrom"));
|
||||
$oNewsletter->set("newsfromname", $oClientLang->getProperty("newsletter", "newsfromname"));
|
||||
|
||||
$sValue = $oClientLang->getProperty("newsletter", "sendto");
|
||||
if ($sValue == "") {
|
||||
$sValue = "all";
|
||||
}
|
||||
$oNewsletter->set("send_to", $sValue);
|
||||
|
||||
$oNewsletter->set("send_ids", $oClientLang->getProperty("newsletter", "sendids"));
|
||||
|
||||
$iValue = $oClientLang->getProperty("newsletter", "use_cronjob");
|
||||
if (!is_numeric($iValue)) {
|
||||
$iValue = 0;
|
||||
}
|
||||
$oNewsletter->set("use_cronjob", $iValue);
|
||||
|
||||
$iValue = $oClientLang->getProperty("newsletter", "dispatch");
|
||||
if (!is_numeric($iValue)) {
|
||||
$iValue = 0;
|
||||
}
|
||||
$oNewsletter->set("dispatch", $iValue);
|
||||
|
||||
$iValue = $oClientLang->getProperty("newsletter", "dispatchcount");
|
||||
if (!is_numeric($iValue)) {
|
||||
$iValue = 50;
|
||||
}
|
||||
$oNewsletter->set("dispatch_count", $iValue);
|
||||
|
||||
$iValue = $oClientLang->getProperty("newsletter", "dispatchdelay");
|
||||
if (!is_numeric($iValue)) {
|
||||
$iValue = 5;
|
||||
}
|
||||
$oNewsletter->set("dispatch_delay", $iValue);
|
||||
$oNewsletter->store();
|
||||
} else if ($action == "news_duplicate" && $perm->have_perm_area_action($area, "news_create")) {
|
||||
// Copy newsletter
|
||||
$oNewsletter = $oNewsletters->duplicate($idnewsletter);
|
||||
|
||||
// Update subnav with new ID
|
||||
$oPage->setSubnav("idnewsletter=" . $oNewsletter->get("idnews"), "news");
|
||||
$oPage->setReload();
|
||||
} else if ($action == "news_delete" && $perm->have_perm_area_action($area, "news_delete")) {
|
||||
// Delete newsletter
|
||||
// If it is an html newsletter, delete html message article, also
|
||||
$oNewsletter = new Newsletter($idnewsletter);
|
||||
|
||||
if ($oNewsletter->get("type") == "html" && $oNewsletter->get("idart") > 0) {
|
||||
conDeleteArt($oNewsletter->get("idart"));
|
||||
}
|
||||
|
||||
// Delete newsletter
|
||||
$oNewsletters->delete($idnewsletter);
|
||||
$oNewsletter = new Newsletter; // Generate empty newsletter object
|
||||
// Setting blank subnav - "blank" doesn't mean anything special, it just can't be empty
|
||||
// and must not contain "idnewsletter" as this is checked in the _subnav file.
|
||||
$oPage->setSubnav("blank", "news");
|
||||
$oPage->setReload();
|
||||
} else if ($action == "news_add_job" && $perm->have_perm_area_action($area, "news_add_job")) {
|
||||
// Create job
|
||||
$oJobs = new cNewsletterJobCollection;
|
||||
$oJob = $oJobs->create($idnewsletter, $oClientLang->getProperty("newsletter", "idcatart"));
|
||||
unset($oJobs);
|
||||
|
||||
if ($oJob) {
|
||||
$notis = $notification->returnNotification("info", i18n("Newsletter dispatch job has been added for this newsletter", "cl_newsletter")) . "<br>";
|
||||
} else {
|
||||
$notis = $notification->returnNotification("error", i18n("Newsletter dispatch job has been not been added! Please check newsletter details", "cl_newsletter")) . "<br>";
|
||||
}
|
||||
|
||||
$oNewsletter = new Newsletter($idnewsletter);
|
||||
} else if ($action == "news_send_test" &&
|
||||
($perm->have_perm_area_action($area, "news_create") ||
|
||||
$perm->have_perm_area_action($area, "news_save") ||
|
||||
$perm->have_perm_area_action($area, "news_add_job"))) {
|
||||
// Send test newsletter
|
||||
$oUser = new cApiUser($auth->auth["uid"]);
|
||||
|
||||
// Subnav gets not updated otherwise (no multilink from newsletter_menu)
|
||||
$oPage->setSubnav("idnewsletter=" . $idnewsletter, "news");
|
||||
|
||||
// Get test destination
|
||||
if ($perm->have_perm_area_action($area, "news_send_test")) {
|
||||
$iTestIDNewsGroup = (int) $oUser->getProperty("newsletter", "test_idnewsgrp_lang" . $lang);
|
||||
} else {
|
||||
$iTestIDNewsGroup = 0; // If user doesn't have the news_send_test right, just send to himself
|
||||
}
|
||||
|
||||
// Get encoding
|
||||
$oLang = new cApiLanguage($lang);
|
||||
$sEncoding = $oLang->get("encoding");
|
||||
unset($oLang);
|
||||
|
||||
// Send test newsletter
|
||||
$oNewsletter = new Newsletter($idnewsletter);
|
||||
$aRecipients = array();
|
||||
if ($iTestIDNewsGroup == 0) {
|
||||
// Send test newsletter to current user email address
|
||||
$sName = $oUser->get("realname");
|
||||
$sEMail = $oUser->get("email");
|
||||
|
||||
$bSend = $oNewsletter->sendEMail($oClientLang->getProperty("newsletter", "idcatart"), $sEMail, $sName, true, $sEncoding);
|
||||
if ($bSend) {
|
||||
$aRecipients[] = $sName . " (" . $sEMail . ")";
|
||||
} else {
|
||||
$aRecipients[] = i18n("None", "cl_newsletter");
|
||||
}
|
||||
} else {
|
||||
$bSend = $oNewsletter->sendDirect($oClientLang->getProperty("newsletter", "idcatart"), 0, $iTestIDNewsGroup, $aRecipients, $sEncoding);
|
||||
}
|
||||
unset($oUser);
|
||||
|
||||
if ($bSend) {
|
||||
$notis = $notification->returnNotification("info", i18n("Test newsletter has been sent to:", "cl_newsletter") . "<br />" . implode("<br />", $aRecipients) . "<br />");
|
||||
} else {
|
||||
$notis = $notification->returnNotification("warning", i18n("Test newsletter has not been sent (partly or completely):", "cl_newsletter") . "<br />" .
|
||||
i18n("Successful:", "cl_newsletter") . "<br />" . implode("<br />", $aRecipients) . "<br />" .
|
||||
i18n("Error messages:", "cl_newsletter") . "<br />" . $oNewsletter->_sError);
|
||||
}
|
||||
} else {
|
||||
// No action, just get selected newsletter
|
||||
$oNewsletter = new Newsletter($idnewsletter);
|
||||
}
|
||||
|
||||
if ($oNewsletter->virgin == false && $oNewsletter->get("idclient") == $client && $oNewsletter->get("idlang") == $lang) {
|
||||
// Check and set values
|
||||
if ($_REQUEST["optSendTo"] == "") {
|
||||
$_REQUEST["optSendTo"] = $oNewsletter->get("send_to");
|
||||
}
|
||||
|
||||
if (!is_numeric($_REQUEST["ckbWelcome"])) {
|
||||
$_REQUEST["ckbWelcome"] = 0;
|
||||
}
|
||||
|
||||
if (!is_numeric($_REQUEST["txtDispatchCount"]) || $_REQUEST["txtDispatchCount"] <= 0) {
|
||||
$_REQUEST["txtDispatchCount"] = $oNewsletter->get("dispatch_count");
|
||||
}
|
||||
|
||||
// Note, that for DispatchDelay 0 is possible (= send chunks manually)
|
||||
if (!is_numeric($_REQUEST["txtDispatchDelay"]) || $_REQUEST["txtDispatchDelay"] < 0) {
|
||||
$_REQUEST["txtDispatchDelay"] = $oNewsletter->get("dispatch_delay");
|
||||
}
|
||||
|
||||
// Only set template id to 0 if it has been specified (as something not useful).
|
||||
// This prevents deleting of the template id, if type setting is changed to "text"
|
||||
if (isset($_REQUEST["selTemplate"]) && !is_numeric($_REQUEST["selTemplate"])) {
|
||||
$_REQUEST["selTemplate"] = 0;
|
||||
}
|
||||
|
||||
if ($action == "news_save" && $perm->have_perm_area_action($area, $action)) {
|
||||
// Save changes
|
||||
$aMessages = array();
|
||||
|
||||
// Changing e.g. \' back to ' (magic_quotes)
|
||||
$sName = stripslashes($_REQUEST["txtName"]);
|
||||
$sFromEMail = stripslashes($_REQUEST["txtFromEMail"]);
|
||||
$sFromName = stripslashes($_REQUEST["txtFromName"]);
|
||||
$sSubject = stripslashes($_REQUEST["txtSubject"]);
|
||||
|
||||
if ($oNewsletter->get("name") != $sName ||
|
||||
$oNewsletter->get("welcome") != $_REQUEST["ckbWelcome"] ||
|
||||
!isValidMail($oNewsletter->get("newsfrom")) && isValidMail($sFromEMail)) {
|
||||
// Only reload, if something visible has changed
|
||||
$oPage->setReload();
|
||||
}
|
||||
|
||||
if ($oNewsletter->get("name") != $sName) {
|
||||
// Check, if item with same name exists
|
||||
$oNewsletters->setWhere("name", $sName);
|
||||
$oNewsletters->setWhere("idclient", $client);
|
||||
$oNewsletters->setWhere("idlang", $lang);
|
||||
$oNewsletters->setWhere($oNewsletter->primaryKey, $oNewsletter->get($oNewsletter->primaryKey), "!=");
|
||||
$oNewsletters->query();
|
||||
|
||||
if ($oNewsletters->next()) {
|
||||
$aMessages[] = i18n("Could not set new newsletter name: name already exists", "cl_newsletter");
|
||||
} else {
|
||||
$oNewsletter->set("name", $sName);
|
||||
if ($oNewsletter->get("idart") > 0) {
|
||||
// Update also HTML newsletter article title, if newsletter name has been changed
|
||||
$oArticles = new cApiArticleLanguageCollection;
|
||||
$oArticles->setWhere("idlang", $lang);
|
||||
$oArticles->setWhere("idart", $oNewsletter->get("idart"));
|
||||
$oArticles->query();
|
||||
|
||||
if ($oArticle = $oArticles->next()) {
|
||||
$oArticle->set("title", sprintf(i18n("Newsletter: %s", "cl_newsletter"), $oNewsletter->get("name")));
|
||||
$oArticle->store();
|
||||
}
|
||||
unset($oArticle);
|
||||
unset($oArticles);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($oClientLang->getProperty("newsletter", "html_newsletter") == "true") {
|
||||
$oNewsletter->set("type", $selType);
|
||||
} else {
|
||||
$oNewsletter->set("type", "text");
|
||||
}
|
||||
$oNewsletter->set("newsfrom", $sFromEMail);
|
||||
$oNewsletter->set("newsfromname", $sFromName);
|
||||
$oNewsletter->set("subject", $sSubject);
|
||||
|
||||
// Options
|
||||
$oNewsletter->set("welcome", $_REQUEST["ckbWelcome"]);
|
||||
|
||||
// Check out if there are any plugins
|
||||
if (is_array($cfg['plugins']['newsletters'])) {
|
||||
foreach ($cfg['plugins']['newsletters'] as $plugin) {
|
||||
if (function_exists("newsletters_" . $plugin . "_wantedVariables") && function_exists("newsletters_" . $plugin . "_store")) {
|
||||
$wantVariables = call_user_func("newsletters_" . $plugin . "_wantedVariables");
|
||||
|
||||
if (is_array($wantVariables)) {
|
||||
$varArray = array();
|
||||
|
||||
foreach ($wantVariables as $value) {
|
||||
$varArray[$value] = stripslashes($GLOBALS[$value]);
|
||||
}
|
||||
}
|
||||
$store = call_user_func("newsletters_" . $plugin . "_store", $varArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If "selected groups" have been selected and no group specified, set
|
||||
// selection to "all"
|
||||
if ($_REQUEST["optSendTo"] == "selection" && !is_array($_REQUEST["selGroup"])) {
|
||||
$aMessages[] = i18n("'Send to recipients in selected groups' has been selected, but no group has been specified. Selection has been set to 'Send to all recipients'", "cl_newsletter");
|
||||
$_REQUEST["optSendTo"] = "all";
|
||||
}
|
||||
$oNewsletter->set("send_to", $_REQUEST["optSendTo"]);
|
||||
$oNewsletter->set("send_ids", serialize($_REQUEST["selGroup"]));
|
||||
|
||||
if (getEffectiveSetting("newsletter", "option-cronjob-available", "false") == "true") {
|
||||
// Only store changes, if cronjob option is available
|
||||
if (isset($_REQUEST["ckbCronJob"])) {
|
||||
$oNewsletter->set("use_cronjob", 1);
|
||||
} else {
|
||||
$oNewsletter->set("use_cronjob", 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST["ckbDispatch"])) {
|
||||
$oNewsletter->set("dispatch", 1);
|
||||
} else {
|
||||
$oNewsletter->set("dispatch", 0);
|
||||
}
|
||||
|
||||
$oNewsletter->set("dispatch_count", $_REQUEST["txtDispatchCount"]);
|
||||
$oNewsletter->set("dispatch_delay", $_REQUEST["txtDispatchDelay"]);
|
||||
|
||||
$oNewsletter->store(); // Note, that the properties are stored, anyway
|
||||
// Storing from (e-mail), from (name) and options as default
|
||||
if ($_REQUEST["ckbSetDefault"]) {
|
||||
$oClientLang->setProperty("newsletter", "newsfrom", $sFromEMail);
|
||||
$oClientLang->setProperty("newsletter", "newsfromname", $sFromName);
|
||||
$oClientLang->setProperty("newsletter", "sendto", $_REQUEST["optSendTo"]);
|
||||
$oClientLang->setProperty("newsletter", "sendgroups", serialize($_REQUEST["selGroup"]));
|
||||
if (isset($_REQUEST["ckbCronJob"])) {
|
||||
$oClientLang->setProperty("newsletter", "use_cronjob", "1");
|
||||
} else {
|
||||
$oClientLang->setProperty("newsletter", "use_cronjob", "0");
|
||||
}
|
||||
if (isset($_REQUEST["ckbDispatch"])) {
|
||||
$oClientLang->setProperty("newsletter", "dispatch", "1");
|
||||
} else {
|
||||
$oClientLang->setProperty("newsletter", "dispatch", "0");
|
||||
}
|
||||
$oClientLang->setProperty("newsletter", "dispatchcount", $_REQUEST["txtDispatchCount"]);
|
||||
$oClientLang->setProperty("newsletter", "dispatchdelay", $_REQUEST["txtDispatchDelay"]);
|
||||
}
|
||||
|
||||
if (count($aMessages) > 0) {
|
||||
$notis .= $notification->returnNotification("warning", implode("<br>", $aMessages)) . "<br>";
|
||||
}
|
||||
} else {
|
||||
$_REQUEST["selGroup"] = unserialize($oNewsletter->get("send_ids"));
|
||||
if (!is_array($_REQUEST["selGroup"])) {
|
||||
$_REQUEST["selGroup"] = unserialize($oClientLang->getProperty("newsletter", "sendgroups"));
|
||||
if (!is_array($_REQUEST["selGroup"])) {
|
||||
$_REQUEST["selGroup"] = array();
|
||||
}
|
||||
}
|
||||
|
||||
$_REQUEST["ckbDispatch"] = false;
|
||||
if ($oNewsletter->get("dispatch") == 1) {
|
||||
$_REQUEST["ckbDispatch"] = true;
|
||||
} else if ($oNewsletter->get("dispatch") == "" && $oClientLang->getProperty("newsletter", "dispatch") == "true") {
|
||||
$_REQUEST["ckbDispatch"] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$oForm = new UI_Table_Form("properties");
|
||||
$oForm->setVar("frame", $frame);
|
||||
$oForm->setVar("area", $area);
|
||||
$oForm->setVar("action", "news_save");
|
||||
$oForm->setVar("idnewsletter", $oNewsletter->get("idnews"));
|
||||
|
||||
$oForm->addHeader(i18n("Edit newsletter", "cl_newsletter"));
|
||||
|
||||
$oTxtName = new cHTMLTextbox("txtName", $oNewsletter->get("name"), 40);
|
||||
$oForm->add(i18n("Name", "cl_newsletter"), $oTxtName->render());
|
||||
|
||||
$oSelType = new cHTMLSelectElement("selType");
|
||||
$aItems = array();
|
||||
$aItems[] = array("text", i18n("Text only", "cl_newsletter"));
|
||||
if ($oClientLang->getProperty("newsletter", "html_newsletter") == "true") {
|
||||
$aItems[] = array("html", i18n("HTML and text", "cl_newsletter"));
|
||||
} else {
|
||||
$oNewsletter->set("type", "text"); // just in case the global setting was switched off
|
||||
// TODO: Should this setting be stored?
|
||||
}
|
||||
$oSelType->autoFill($aItems);
|
||||
$oSelType->setDefault($oNewsletter->get("type"));
|
||||
|
||||
$oForm->add(i18n("Type", "cl_newsletter"), $oSelType->render());
|
||||
|
||||
$oTxtFromEMail = new cHTMLTextbox("txtFromEMail", $oNewsletter->get("newsfrom"), 40);
|
||||
$oTxtFromName = new cHTMLTextbox("txtFromName", $oNewsletter->get("newsfromname"), 40);
|
||||
$oTxtSubject = new cHTMLTextarea("txtSubject", $oNewsletter->get("subject"), 80, 2);
|
||||
|
||||
$oForm->add(i18n("From (E-Mail)", "cl_newsletter"), $oTxtFromEMail->render());
|
||||
$oForm->add(i18n("From (Name)", "cl_newsletter"), $oTxtFromName->render() . " " . i18n("optional", "cl_newsletter"));
|
||||
$oForm->add(i18n("Subject", "cl_newsletter"), $oTxtSubject->render());
|
||||
|
||||
// Send options
|
||||
$oSendToAll = new cHTMLRadiobutton("optSendTo", "all");
|
||||
$oSendToAll->setEvent("Click", "checkSelection(this.value)");
|
||||
$oSendToDefault = new cHTMLRadiobutton("optSendTo", "default");
|
||||
$oSendToDefault->setEvent("Click", "checkSelection(this.value)");
|
||||
$oSendToGroups = new cHTMLRadiobutton("optSendTo", "selection");
|
||||
$oSendToGroups->setEvent("Click", "checkSelection(this.value)");
|
||||
|
||||
$oRcpGroups->setWhere("idclient", $client);
|
||||
$oRcpGroups->setWhere("idlang", $lang);
|
||||
$oRcpGroups->setOrder("defaultgroup DESC, groupname ASC");
|
||||
$oRcpGroups->query();
|
||||
|
||||
$aItems = array();
|
||||
while ($oRcpGroup = $oRcpGroups->next()) {
|
||||
$sGroupName = $oRcpGroup->get("groupname");
|
||||
if ($oRcpGroup->get("defaultgroup")) {
|
||||
$sGroupName = $sGroupName . "*";
|
||||
}
|
||||
$aItems[] = array($oRcpGroup->get("idnewsgroup"), $sGroupName);
|
||||
}
|
||||
|
||||
$oSelGroup = new cHTMLSelectElement("selGroup[]", "", "groupselect");
|
||||
$oSelGroup->setSize(10);
|
||||
$oSelGroup->setStyle("width: 350px; margin-top: 5px; margin-bottom: 5px; margin-left: 25px;");
|
||||
$oSelGroup->setMultiSelect();
|
||||
$oSelGroup->setAlt(i18n("Note: Hold <Ctrl> to select multiple items.", "cl_newsletter"));
|
||||
$oSelGroup->autoFill($aItems);
|
||||
|
||||
// No groups in the list, sendToGroups and group listbox disabled
|
||||
if (count($aItems) == 0) {
|
||||
$oSendToGroups->setDisabled(true);
|
||||
if ($_REQUEST["optSendTo"] == "selection") {
|
||||
$_REQUEST["optSendTo"] == "all";
|
||||
}
|
||||
} else if (is_array($_REQUEST["selGroup"])) {
|
||||
foreach ($_REQUEST["selGroup"] as $sValue) {
|
||||
if (array_key_exists($sValue, $oSelGroup->_options)) {
|
||||
// only select, if item still exists
|
||||
$oSelGroup->_options[$sValue]->setSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($_REQUEST["optSendTo"]) {
|
||||
case "default":
|
||||
$oSendToDefault->setChecked(true);
|
||||
$oSelGroup->setDisabled(true);
|
||||
break;
|
||||
case "selection":
|
||||
$oSendToGroups->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
$oSendToAll->setChecked(true);
|
||||
$oSelGroup->setDisabled(true);
|
||||
}
|
||||
|
||||
// Recipients
|
||||
$oForm->add(i18n("Recipients", "cl_newsletter"), $oSendToAll->toHTML(false) . " " . i18n("Send newsletter to all recipients", "cl_newsletter") . "<br />" . chr(10) .
|
||||
$oSendToDefault->toHTML(false) . " " . i18n("Send newsletter to the members of the default group", "cl_newsletter") . "<br />" . chr(10) .
|
||||
$oSendToGroups->toHTML(false) . " " . i18n("Send newsletter to the members of the selected group(s):", "cl_newsletter") . "<br />" . chr(10) .
|
||||
$oSelGroup->render());
|
||||
|
||||
/* TODO: Work in progress
|
||||
// Files
|
||||
$oSelFiles = new cHTMLSelectElement("selFiles[]", "", "fileselect");
|
||||
$oSelFiles->setSize(5);
|
||||
//$oSelGroup->setStyle("width: 350px; margin-top: 5px; margin-bottom: 5px; margin-left: 25px;");
|
||||
$oSelFiles->setMultiSelect();
|
||||
$oSelFiles->setAlt(i18n("Note: Hold <Ctrl> to select multiple items."));
|
||||
//$oSelGroup->autoFill($aItems);
|
||||
$sFileSelScript = '<script type="text/javascript">
|
||||
var fb_handle;
|
||||
var fb_intervalhandle;
|
||||
|
||||
function fncShowImageBrowser()
|
||||
{
|
||||
fb_handle = window.open(\''.$cfg["path"]["contenido_fullhtml"] .'frameset.php?area=upl&contenido='.$sess->id.'&appendparameters=imagebrowser\', \'imagebrowser\', \'dialog=yes,resizable=yes\');
|
||||
fb_intervalhandle = window.setInterval("fncUpdateImageFilebrowser()", 250);
|
||||
}
|
||||
|
||||
function fncUpdateImageFilebrowser()
|
||||
{
|
||||
if (!fb_handle.left)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fb_handle.left.left_top)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fb_handle.left.left_top.document.getElementById("selectedfile"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (fb_handle.left.left_top.document.getElementById("selectedfile").value != "")
|
||||
{
|
||||
var oSelElement = document.forms[0].elements["selFiles[]"];
|
||||
var sValue = fb_handle.left.left_top.document.getElementById("selectedfile").value;
|
||||
|
||||
oSelElement.options[oSelElement.length] = new Option(sValue, sValue, false, false);
|
||||
|
||||
//fb_win.document.forms[0].elements[fb_fieldname].value = fb_handle.left.left_top.document.getElementById("selectedfile").value;
|
||||
|
||||
fb_handle.close();
|
||||
window.clearInterval(fb_intervalhandle);
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
$oPage->addScript('selFile', $sFileSelScript);
|
||||
$oForm->add(i18n("Attachments"), $oSelFiles->render().'<br /><span onclick="fncShowImageBrowser();">Test</span>');
|
||||
*/
|
||||
|
||||
// Options
|
||||
$ckbWelcome = new cHTMLCheckbox("ckbWelcome", "1");
|
||||
$ckbWelcome->setChecked($oNewsletter->get("welcome"));
|
||||
|
||||
// Generate disabled cronjob element
|
||||
// Provide only "Use cronjob" option, if it has been explicitely enabled
|
||||
// (and the admin knows, what he is doing - like using a real cronjob, not a simulated one...)
|
||||
// Note, that the run_newsletter_job.php file has not been added to the cronjob
|
||||
// list in the cronjobs folder - as it may be used, but not via cronjob simulation
|
||||
$ckbCronJob = new cHTMLCheckbox("ckbCronJob", "1", "", $oNewsletter->get("use_cronjob"), true);
|
||||
|
||||
if (getEffectiveSetting("newsletter", "option-cronjob-available", "false") == "true") {
|
||||
// Enable cronjob checkbox
|
||||
$ckbCronJob->setDisabled("");
|
||||
} else {
|
||||
// Give the user a hint
|
||||
$ckbCronJob->setAlt(i18n("Option has to be enabled as client setting - see techref for details", "cl_newsletter"));
|
||||
}
|
||||
|
||||
$oCkbDispatch = new cHTMLCheckbox("ckbDispatch", "enabled");
|
||||
$oCkbDispatch->setChecked($oNewsletter->get("dispatch"));
|
||||
$oTxtDispatchCount = new cHTMLTextbox("txtDispatchCount", $oNewsletter->get("dispatch_count"), 4);
|
||||
$oTxtDispatchDelay = new cHTMLTextbox("txtDispatchDelay", $oNewsletter->get("dispatch_delay"), 4);
|
||||
$oTxtDispatchDelay->setAlt(i18n("Note: Set to 0 to send chunks manually.", "cl_newsletter"));
|
||||
$oCkbSaveAsDefault = new cHTMLCheckbox("ckbSetDefault", "1");
|
||||
|
||||
$oForm->add(i18n("Options", "cl_newsletter"), $ckbWelcome->toHTML(false) . " " . i18n("Welcome-Newsletter", "cl_newsletter") . "<br />" .
|
||||
$ckbCronJob->toHTML(false) . " " . i18n("Use cronjob", "cl_newsletter") . "<br />" .
|
||||
$oCkbDispatch->toHTML(false) . " " . i18n("Send in blocks:", "cl_newsletter") . " " .
|
||||
i18n("Recipients per block:", "cl_newsletter") . " " . $oTxtDispatchCount->render() . " " .
|
||||
i18n("Delay between blocks:", "cl_newsletter") . " " . $oTxtDispatchDelay->render() . " " . i18n("sec.", "cl_newsletter") . "<br />" .
|
||||
$oCkbSaveAsDefault->toHTML(false) . " " . i18n("Save option settings as default", "cl_newsletter"));
|
||||
|
||||
$oForm->add(i18n("Author", "cl_newsletter"), $classuser->getUserName($oNewsletter->get("author")) . " (" . $oNewsletter->get("created") . ")");
|
||||
$oForm->add(i18n("Last modified by", "cl_newsletter"), $classuser->getUserName($oNewsletter->get("modifiedby")) . " (" . $oNewsletter->get("modified") . ")");
|
||||
|
||||
$sExecScript = '
|
||||
<script type="text/javascript">
|
||||
|
||||
// Enabled/Disable group box
|
||||
function checkSelection(strValue)
|
||||
{
|
||||
if (strValue == "selection") {
|
||||
document.getElementById("groupselect").disabled = false;
|
||||
} else {
|
||||
document.getElementById("groupselect").disabled = true;
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
$oPage->addScript('exec', $sExecScript);
|
||||
|
||||
$oPage->setContent($notis . $oForm->render(true));
|
||||
} else {
|
||||
$oPage->setContent($notis . "");
|
||||
}
|
||||
|
||||
$oPage->render();
|
||||
?>
|
||||
257
includes/include.newsletter_edit_message.php
Normale Datei
257
includes/include.newsletter_edit_message.php
Normale Datei
|
|
@ -0,0 +1,257 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Frontend user editor
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.0.0
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>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"))) . "<br>";
|
||||
|
||||
$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")) . "<br>";
|
||||
|
||||
$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 = '<a href="javascript:fncShowHide(\'idTagInfoText\');"><strong>' . i18n("Tag information", "cl_newsletter") . '</strong></a>' .
|
||||
'<div id="idTagInfoText" style="display: none"><br /><b>' . i18n("Special message tags (will be replaced when sending)", "cl_newsletter") . ':</b><br>' .
|
||||
'MAIL_NAME: ' . i18n("Name of the recipient", "cl_newsletter") . '<br />' .
|
||||
'MAIL_DATE: ' . i18n("Date, when the mail has been sent", "cl_newsletter") . '<br />' .
|
||||
'MAIL_TIME: ' . i18n("Time, when the mail has been sent", "cl_newsletter") . '<br />' .
|
||||
'MAIL_NUMBER: ' . i18n("Number of recipients", "cl_newsletter") . '<br />' .
|
||||
#'MAIL_CHANGE: '.i18n("Link to change the e-mail adress", "cl_newsletter").'<br />'.
|
||||
'MAIL_UNSUBSCRIBE: ' . i18n("Link to unsubscribe", "cl_newsletter") . '<br />' .
|
||||
'MAIL_STOP: ' . i18n("Link to pause the subscription", "cl_newsletter") . '<br />' .
|
||||
'MAIL_GOON: ' . i18n("Link to resume the subscription", "cl_newsletter");
|
||||
|
||||
$sTagInfoHTML = '<a href="javascript:fncShowHide(\'idTagInfoHTML\');"><strong>' . i18n("Tag information", "cl_newsletter") . '</strong></a>' .
|
||||
'<div id="idTagInfoHTML" style="display: none"><br /><b>' . i18n("Special message tags (will be replaced when sending, {..} = optional)", "cl_newsletter") . ":</b><br />" .
|
||||
'[mail name="name" type="text"]{text}MAIL_NAME{text}[/mail]: ' . i18n("Name of the recipient", "cl_newsletter") . "<br />" .
|
||||
'[mail name="date" type="text"]{text}MAIL_DATE{text}[/mail]: ' . i18n("Date, when the mail has been sent", "cl_newsletter") . "<br />" .
|
||||
'[mail name="time" type="text"]{text}MAIL_TIME{text}[/mail]: ' . i18n("Time, when the mail has been sent", "cl_newsletter") . "<br />" .
|
||||
'[mail name="number" type="text"]{text}MAIL_NUMBER{text}[/mail]: ' . i18n("Number of recipients", "cl_newsletter") . "<br />" .
|
||||
#'[mail name="change" type="link" {text="'.i18n("Link text", "cl_newsletter").'"}]{text}MAIL_CHANGE{text}[/mail]: '.i18n("Link to change the e-mail adress", "cl_newsletter")."<br />".
|
||||
'[mail name="unsubscribe" type="link" {text="' . i18n("Link text", "cl_newsletter") . '" }]{text}MAIL_UNSUBSCRIBE{text}[/mail]: ' . i18n("Link to unsubscribe", "cl_newsletter") . "<br />" .
|
||||
'[mail name="stop" type="link" {text="' . i18n("Link text", "cl_newsletter") . '" }]{text}MAIL_STOP{text}[/mail]: ' . i18n("Link to pause the subscription", "cl_newsletter") . "<br />" .
|
||||
'[mail name="goon" type="link" {text="' . i18n("Link text", "cl_newsletter") . '" }]{text}MAIL_GOON{text}[/mail]: ' . i18n("Link to resume the subscription", "cl_newsletter");
|
||||
|
||||
// Mention plugin interface
|
||||
if (getSystemProperty("newsletter", "newsletter-recipients-plugin") == "true") {
|
||||
$sTagInfoText .= "<br /><br /><strong>" . i18n("Additional message tags from recipients plugins:", "cl_newsletter") . "</strong><br />";
|
||||
$sTagInfoHTML .= "<br /><br /><strong>" . i18n("Additional message tags from recipients plugins:", "cl_newsletter") . "</strong><br />";
|
||||
|
||||
if (is_array($cfg['plugins']['recipients'])) {
|
||||
foreach ($cfg['plugins']['recipients'] as $plugin) {
|
||||
plugin_include("recipients", $plugin . "/" . $plugin . ".php");
|
||||
|
||||
if (function_exists("recipients_" . $plugin . "_wantedVariables")) {
|
||||
$aPluginVars = call_user_func("recipients_" . $plugin . "_wantedVariables");
|
||||
|
||||
foreach ($aPluginVars as $sPluginVar) {
|
||||
$sTagInfoText .= 'MAIL_' . strtoupper($sPluginVar) . '<br />';
|
||||
$sTagInfoHTML .= '[mail name="' . strtolower($sPluginVar) . '" type="text"][/mail]<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setSystemProperty("newsletter", "newsletter-recipients-plugin", "false"); // -> Property available in system settings
|
||||
}
|
||||
$sTagInfoText .= "</div>";
|
||||
$sTagInfoHTML .= "</div>";
|
||||
|
||||
$iTplIDArt = 0; // Used later for on change event
|
||||
if ($oNewsletter->get("type") == "html") {
|
||||
$iTplIDArt = $oNewsletter->get("template_idart");
|
||||
$oSelTemplate = new cHTMLSelectElement("selTemplate");
|
||||
$oSelTemplate->setEvent("change", "askSubmitOnTplChange(this);");
|
||||
$aOptions = array("idcat" => $oClientLang->getProperty("newsletter", "html_template_idcat"),
|
||||
"start" => true,
|
||||
"offline" => true,
|
||||
"order" => "title");
|
||||
$oTemplateArticles = new ArticleCollection($aOptions);
|
||||
|
||||
$aItems = array();
|
||||
$aItems[] = array(0, i18n("-- none --", "cl_newsletter"));
|
||||
while ($oArticle = $oTemplateArticles->nextArticle()) {
|
||||
$aItems[] = array($oArticle->get("idart"), $oArticle->get("title"));
|
||||
}
|
||||
|
||||
$oSelTemplate->autoFill($aItems);
|
||||
$oSelTemplate->setDefault($iTplIDArt);
|
||||
unset($aItems);
|
||||
unset($oArticles);
|
||||
unset($oTemplateArticles);
|
||||
|
||||
$oForm->add(i18n("HTML Template", "cl_newsletter"), $oSelTemplate->render() . " " . i18n("Note, that changing the template discards the current html message content", "cl_newsletter"));
|
||||
|
||||
if ($iTplIDArt != 0) {
|
||||
$sFrameSrc = $cfgClient[$client]["path"]["htmlpath"] . "front_content.php?changeview=edit&action=con_editart&idart=" . $oNewsletter->get("idart") . "&idcat=" . $oClientLang->getProperty("newsletter", "html_newsletter_idcat") . "&lang=" . $lang . "&contenido=" . $sess->id;
|
||||
$oForm->add(i18n("HTML Message", "cl_newsletter"), '<iframe width="100%" height="600" src="' . $sFrameSrc . '"></iframe><br />' . $sTagInfoHTML);
|
||||
} else {
|
||||
// Add a real note, that a template has to be specified
|
||||
$notis .= $notification->returnNotification("warning", i18n("Newsletter type has been set to HTML/text, please remember to select an html template", "cl_newsletter")) . "<br />";
|
||||
|
||||
$oForm->add(i18n("HTML Message", "cl_newsletter"), i18n("Please choose a template first", "cl_newsletter"));
|
||||
}
|
||||
}
|
||||
|
||||
$oTxtMessage = new cHTMLTextarea("txtMessage", $oNewsletter->get("message"), 80, 20);
|
||||
$oForm->add(i18n("Text Message", "cl_newsletter"), $oTxtMessage->render() . "<br />" . $sTagInfoText);
|
||||
|
||||
$sExecScript = '
|
||||
<script type="text/javascript">
|
||||
// Enabled/Disable group box
|
||||
function fncShowHide(strItemID) {
|
||||
objItem = document.getElementById(strItemID);
|
||||
|
||||
if (objItem.style.display == "none") {
|
||||
objItem.style.display = "inline";
|
||||
} else {
|
||||
objItem.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// Create messageBox instance
|
||||
box = new messageBox("", "", "", 0, 0);
|
||||
|
||||
// If html newsletter template selection has changed, ask user
|
||||
// if he/she may like to save this change (e.g. to get an html
|
||||
// newsletter immediately)
|
||||
function askSubmitOnTplChange(oSelectObject) {
|
||||
iOriginalTplIDArt = ' . $iTplIDArt . ';
|
||||
|
||||
if (iOriginalTplIDArt != oSelectObject.options[oSelectObject.selectedIndex].value) {
|
||||
if (iOriginalTplIDArt == 0) {
|
||||
// Everything fine: Just selecting a template for the first time
|
||||
submitForm();
|
||||
} else {
|
||||
// You may loose information, warn!
|
||||
box.confirm("' . i18n("HTML newsletter template changed", "cl_newsletter") . '", "' . i18n("HTML template has been changed. Do you like to save now to apply changes?<br /><br /><b>Note, that existing HTML newsletter content will get lost!</b>", "cl_newsletter") . '", "submitForm()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
document.frmNewsletterMsg.submit();
|
||||
}
|
||||
</script>';
|
||||
$oPage->addScript('messagebox', '<script type="text/javascript" src="scripts/messageBox.js.php?contenido=' . $sess->id . '"></script>');
|
||||
$oPage->addScript('execscript', $sExecScript);
|
||||
$oPage->setContent($notis . $oForm->render(true));
|
||||
} else {
|
||||
$oPage->setContent($notis . "");
|
||||
}
|
||||
|
||||
$oPage->render();
|
||||
?>
|
||||
379
includes/include.newsletter_jobs_details.php
Normale Datei
379
includes/include.newsletter_jobs_details.php
Normale Datei
|
|
@ -0,0 +1,379 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Shows job details
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.0.0
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: include.newsletter_jobs_details.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
// 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) {
|
||||
$iChunks = 1;
|
||||
}
|
||||
|
||||
if ($oJob->get("dispatch_delay") == 0) {
|
||||
// Send manually
|
||||
$oForm = new UI_Table_Form("properties", $sPathNext);
|
||||
$oForm->addHeader(i18n("Report:", "cl_newsletter"));
|
||||
$oForm->add("", "");
|
||||
|
||||
$oForm->add("", sprintf(i18n("Sending newsletter ... (chunk %s of %s, recipients: %s, sent: %s)", "cl_newsletter"), $iChunk, $iChunks, $oJob->get("rcpcount"), $oJob->get("sendcount")));
|
||||
|
||||
$oForm->setActionButton("cancel", $cfg['path']['contenido_fullhtml'] . "images/but_cancel.gif", i18n("Stop sending", "cl_newsletter"), "c");
|
||||
$oForm->setActionButton("submit", $cfg['path']['contenido_fullhtml'] . "images/but_ok.gif", i18n("Send next chunk", "cl_newsletter"), "s", "news_job_run");
|
||||
} else {
|
||||
// Send automatically
|
||||
$oForm = new UI_Table_Form("properties");
|
||||
$oForm->addHeader(i18n("Report:", "cl_newsletter"));
|
||||
$oForm->add("", "");
|
||||
|
||||
$oForm->add("", sprintf(i18n("Sending newsletter ... (chunk %s of %s, recipients: %s, sent: %s)", "cl_newsletter"), $iChunk, $iChunks, $oJob->get("rcpcount"), $oJob->get("sendcount")));
|
||||
|
||||
$oPage->addScript("Refresh", '<meta http-equiv="refresh" content="' . $oJob->get("dispatch_delay") . '; URL=' . $sPathNext . '">');
|
||||
$oForm->unsetActionButton("submit");
|
||||
$oForm->setActionButton("cancel", $cfg['path']['contenido_fullhtml'] . "images/but_cancel.gif", i18n("Stop sending", "cl_newsletter"), "c");
|
||||
}
|
||||
} else {
|
||||
// All newsletters should have been sent
|
||||
$oForm = new UI_Table_Form("properties");
|
||||
$oForm->addHeader(i18n("Report:", "cl_newsletter"));
|
||||
$oForm->add("", "");
|
||||
|
||||
$oForm->add("", sprintf(i18n("The newsletter has been sent to %s recipients", "cl_newsletter"), $oJob->get("sendcount")));
|
||||
$oPage->setReload();
|
||||
}
|
||||
|
||||
$oPage->setContent($notis . $oForm->render(true));
|
||||
} else if ($action == "news_job_delete" && $perm->have_perm_area_action($area, $action) && is_numeric($_REQUEST["idnewsjob"])) {
|
||||
$oJobs = new cNewsletterJobCollection;
|
||||
$oJobs->delete($_REQUEST["idnewsjob"]);
|
||||
|
||||
$oPage->setSubnav("blank", "news_jobs");
|
||||
$oPage->setReload();
|
||||
$oPage->setContent($notis);
|
||||
} else if ($action == "news_job_details" || $action == "news_job_detail_delete") {
|
||||
// Show job details (recipients)
|
||||
|
||||
$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);
|
||||
$oFrmOptions->setVar("sortmode", $_REQUEST["sortmode"]);
|
||||
$oFrmOptions->setVar("sortby", $_REQUEST["sortby"]);
|
||||
$oFrmOptions->setVar("idnewsjob", $_REQUEST["idnewsjob"]);
|
||||
//$oFrmOptions->setVar("startpage", $startpage);
|
||||
//$oFrmOptions->setVar("appendparameters", $appendparameters);
|
||||
$oFrmOptions->addHeader(i18n("List options", "cl_newsletter"));
|
||||
|
||||
$oSelElements = new cHTMLSelectElement("elemperpage");
|
||||
$oSelElements->setEvent("onchange", "document.forms.frmOptions.submit();");
|
||||
|
||||
$aData = Array("0" => i18n("-All-", "cl_newsletter"),
|
||||
"50" => "50",
|
||||
"100" => "100",
|
||||
"250" => "250",
|
||||
"500" => "500");
|
||||
|
||||
foreach ($aData as $sKey => $sValue) {
|
||||
$oOption = new cHTMLOptionElement($sValue, $sKey);
|
||||
$oSelElements->addOptionElement($sKey, $oOption);
|
||||
}
|
||||
|
||||
$oSelElements->setDefault($_REQUEST["elemperpage"]);
|
||||
|
||||
//$oSelElements->setStyle('border:1px;border-style:solid;border-color:black;');
|
||||
$oFrmOptions->add(i18n("Items per page:", "cl_newsletter"), $oSelElements->render());
|
||||
|
||||
// Ouput data
|
||||
$oList = new cScrollList(true, "news_job_details");
|
||||
$oList->setCustom("idnewsjob", $_REQUEST["idnewsjob"]);
|
||||
$oList->setCustom("nextpage", $iNextPage);
|
||||
$oList->setCustom("elemperpage", $_REQUEST["elemperpage"]);
|
||||
|
||||
$aCols = array("rcpname", "rcpemail", "", "status", "sent");
|
||||
$oList->setHeader(i18n("Recipient", "cl_newsletter"), i18n("E-Mail", "cl_newsletter"), i18n("Type", "cl_newsletter"), i18n("Status", "cl_newsletter"), i18n("Sent", "cl_newsletter"), i18n("Actions", "cl_newsletter"));
|
||||
$oList->setSortable(0, true);
|
||||
$oList->setSortable(1, true);
|
||||
$oList->setSortable(2, false);
|
||||
$oList->setSortable(3, true);
|
||||
$oList->setSortable(4, true);
|
||||
|
||||
// Get data
|
||||
$oLogs->resetQuery();
|
||||
$oLogs->setWhere("idnewsjob", $_REQUEST["idnewsjob"]);
|
||||
|
||||
$sBrowseLinks = "1";
|
||||
if ($_REQUEST["elemperpage"] > 0) {
|
||||
// First, get total data count
|
||||
$oLogs->query();
|
||||
$iRecipients = $oLogs->count(); // Getting item count without limit (for page function) - better idea anybody (performance)?
|
||||
|
||||
if ($iRecipients > 0 && $iRecipients > $_REQUEST["elemperpage"]) {
|
||||
$sBrowseLinks = "";
|
||||
for ($i = 1; $i <= ceil($iRecipients / $_REQUEST["elemperpage"]); $i++) {
|
||||
//$iNext = (($i - 1) * $_REQUEST["elemperpage"]) + 1;
|
||||
if ($sBrowseLinks !== "") {
|
||||
$sBrowseLinks .= " ";
|
||||
}
|
||||
if ($iNextPage == $i) {
|
||||
$sBrowseLinks .= $i . "\n"; // I'm on the current page, no link
|
||||
} else {
|
||||
$sBrowseLinks .= '<a href="' . $sess->url("main.php?area=$area&action=$action&frame=$frame&idnewsjob=" .
|
||||
$_REQUEST["idnewsjob"] . "&nextpage=$i&sortmode=" .
|
||||
$_REQUEST["sortmode"] . "&sortby=" . $_REQUEST["sortby"]) . '">' . $i . '</a>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oLogs->setLimit($_REQUEST["elemperpage"] * ($iNextPage - 1), $_REQUEST["elemperpage"]);
|
||||
}
|
||||
|
||||
if (!array_key_exists($_REQUEST["sortby"], $aCols)) {
|
||||
$_REQUEST["sortby"] = 0; // Sort by rcpname by default
|
||||
}
|
||||
$oLogs->setOrder($aCols[$_REQUEST["sortby"]] . " " . $_REQUEST["sortmode"]);
|
||||
$oLogs->query();
|
||||
|
||||
$oImgDelete = new cHTMLImage("images/delete.gif");
|
||||
$oImgDelete->setAlt(i18n("Delete item", "cl_newsletter"));
|
||||
$sImgDelete = $oImgDelete->render();
|
||||
unset($oImgDelete);
|
||||
|
||||
$iCount = 0;
|
||||
$aNewsType[] = array(); // Performance
|
||||
$aNewsType[0] = i18n("Text only", "cl_newsletter");
|
||||
$aNewsType[1] = i18n("HTML/Text", "cl_newsletter");
|
||||
while ($oLog = $oLogs->next()) {
|
||||
$sName = $oLog->get("rcpname");
|
||||
$sEMail = $oLog->get("rcpemail");
|
||||
|
||||
switch ($oLog->get("status")) {
|
||||
case "pending":
|
||||
$sStatus = i18n("Waiting for sending", "cl_newsletter");
|
||||
break;
|
||||
case "sending":
|
||||
$sStatus = i18n("Sending", "cl_newsletter");
|
||||
break;
|
||||
case "successful":
|
||||
$sStatus = i18n("Successful", "cl_newsletter");
|
||||
break;
|
||||
default:
|
||||
$sStatus = sprintf(i18n("Error: %s", "cl_newsletter"), $oLog->get("status"));
|
||||
}
|
||||
|
||||
if ($oLog->get("sent") == "0000-00-00 00:00:00") {
|
||||
$sSent = "-";
|
||||
} else {
|
||||
$sSent = date($sDateFormat, strtotime($oLog->get("sent")));
|
||||
}
|
||||
|
||||
$sLnkRemove = "";
|
||||
if ($oLog->get("status") == "pending" && $perm->have_perm_area_action($area, "news_job_detail_delete")) {
|
||||
$oLnkRemove = new cHTMLLink;
|
||||
$oLnkRemove->setCLink("news_jobs", 4, "news_job_detail_delete");
|
||||
$oLnkRemove->setCustom("idnewsjob", $_REQUEST["idnewsjob"]);
|
||||
$oLnkRemove->setCustom("idnewslog", $oLog->get($oLog->primaryKey));
|
||||
$oLnkRemove->setCustom("sortby", $_REQUEST["sortby"]);
|
||||
$oLnkRemove->setCustom("sortmode", $_REQUEST["sortmode"]);
|
||||
$oLnkRemove->setContent($sImgDelete);
|
||||
|
||||
$sLnkRemove = $oLnkRemove->render();
|
||||
}
|
||||
|
||||
$oList->setData($iCount, $sName, $sEMail, $aNewsType[$oLog->get("rcpnewstype")], $sStatus, $sSent, $sLnkRemove);
|
||||
|
||||
$iCount++;
|
||||
}
|
||||
|
||||
// A little bit senseless, as the data is already sorted, but
|
||||
// we need the sortmode in the header link
|
||||
$oList->sort($_REQUEST["sortby"], $_REQUEST["sortmode"]);
|
||||
|
||||
// HerrB: Hardcore UI for browsing elements ... sorry
|
||||
$sBrowseHTML = '<table width="100%" cellspacing="0" cellpadding="2" border="0">
|
||||
<tr>
|
||||
<td><img src="images/spacer.gif" width="1" height="10"></td>
|
||||
</tr>
|
||||
<tr class="text_medium" style="background-color: #ffffff;">
|
||||
<td style="border: 1px; border-color: #B3B3B3; border-style: solid; background-color: #E2E2E2; color:#666666"> ' .
|
||||
sprintf(i18n("Go to page: %s", "cl_newsletter"), $sBrowseLinks) . '</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
$oPage->setContent($oFrmOptions->render() . "<br />" . $oList->render() . $sBrowseHTML);
|
||||
} else {
|
||||
// Just show the job data
|
||||
$oJob = new cNewsletterJob($_REQUEST["idnewsjob"]);
|
||||
|
||||
$oForm = new UI_Table_Form("properties");
|
||||
$oForm->setVar("frame", $frame);
|
||||
$oForm->setVar("area", $area);
|
||||
$oForm->setVar("action", "");
|
||||
$oForm->setVar("idnewsjob", $idnewsjob);
|
||||
|
||||
$oForm->addHeader(i18n("Newsletter Dispatch Job", "cl_newsletter"));
|
||||
|
||||
$oForm->add(i18n("Name", "cl_newsletter"), $oJob->get("name"));
|
||||
|
||||
$sDateFormat = getEffectiveSetting("backend", "timeformat", "d.m.Y H:i");
|
||||
switch ($oJob->get("status")) {
|
||||
case 1:
|
||||
$oForm->add(i18n("Status", "cl_newsletter"), i18n("Pending", "cl_newsletter"));
|
||||
break;
|
||||
case 2:
|
||||
$oForm->add(i18n("Status", "cl_newsletter"), sprintf(i18n("Sending (started: %s)", "cl_newsletter"), date($sDateFormat, strtotime($oJob->get("started")))));
|
||||
break;
|
||||
case 9:
|
||||
$oForm->add(i18n("Status", "cl_newsletter"), sprintf(i18n("Finished (started: %s, finished: %s)", "cl_newsletter"), date($sDateFormat, strtotime($oJob->get("started"))), date($sDateFormat, strtotime($oJob->get("finished")))));
|
||||
break;
|
||||
}
|
||||
|
||||
$oForm->add(i18n("Statistics", "cl_newsletter"), sprintf(i18n("Planned: %s, Send: %s", "cl_newsletter"), $oJob->get("rcpcount"), $oJob->get("sendcount")));
|
||||
$oForm->add(i18n("From", "cl_newsletter"), $oJob->get("newsfrom") . " (" . $oJob->get("newsfromname") . ")");
|
||||
$oForm->add(i18n("Subject", "cl_newsletter"), $oJob->get("subject"));
|
||||
|
||||
if ($oJob->get("type") == "html") {
|
||||
$oForm->add(i18n("Type", "cl_newsletter"), i18n("HTML and text", "cl_newsletter"));
|
||||
|
||||
$txtMessageHTML = new cHTMLTextarea("txtMessageHTML", $oJob->get("message_html"), 80, 20);
|
||||
$txtMessageHTML->setDisabled("disabled");
|
||||
|
||||
$oForm->add(i18n("HTML Message", "cl_newsletter"), $txtMessageHTML->render());
|
||||
} else {
|
||||
$oForm->add(i18n("Type", "cl_newsletter"), i18n("Text only", "cl_newsletter"));
|
||||
}
|
||||
$txtMessageText = new cHTMLTextarea("txtMessageText", $oJob->get("message_text"), 80, 20);
|
||||
$txtMessageText->setDisabled("disabled");
|
||||
|
||||
$oForm->add(i18n("Text Message", "cl_newsletter"), $txtMessageText->render());
|
||||
|
||||
$aSendTo = unserialize($oJob->get("send_to"));
|
||||
switch ($aSendTo[0]) {
|
||||
case "all":
|
||||
$sSendToInfo = i18n("Send newsletter to all recipients", "cl_newsletter");
|
||||
break;
|
||||
case "default":
|
||||
$sSendToInfo = i18n("Send newsletter to the members of the default group", "cl_newsletter");
|
||||
break;
|
||||
case "selection":
|
||||
$sSendToInfo = i18n("Send newsletter to the members of the selected group(s):", "cl_newsletter");
|
||||
|
||||
unset($aSendTo[0]);
|
||||
foreach ($aSendTo as $sGroup) {
|
||||
$sSendToInfo .= "<br />" . $sGroup;
|
||||
}
|
||||
break;
|
||||
case "single":
|
||||
$sSendToInfo = i18n("Send newsletter to single recipient:", "cl_newsletter");
|
||||
$sSendToInfo .= "<br />" . $aSendTo[1] . " (" . $aSendTo[2] . ")";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
unset($aSendTo);
|
||||
|
||||
$oForm->add(i18n("Recipients", "cl_newsletter"), $sSendToInfo);
|
||||
|
||||
if ($oJob->get("use_cronjob") == 1) {
|
||||
$sOptionsInfo = i18n("Use cronjob: Enabled", "cl_newsletter");
|
||||
} else {
|
||||
$sOptionsInfo = i18n("Use cronjob: Not enabled", "cl_newsletter");
|
||||
}
|
||||
|
||||
if ($oJob->get("dispatch")) {
|
||||
$sOptionsInfo .= "<br />" . sprintf(i18n("Dispatch: Enabled (block size: %s, delay: %s sec.)", "cl_newsletter"), $oJob->get("dispatch_count"), $oJob->get("dispatch_delay"));
|
||||
} else {
|
||||
$sOptionsInfo .= "<br />" . i18n("Dispatch: Disabled", "cl_newsletter");
|
||||
}
|
||||
|
||||
$oForm->add(i18n("Options", "cl_newsletter"), $sOptionsInfo);
|
||||
|
||||
$oForm->add(i18n("Author", "cl_newsletter"), $oJob->get("authorname"));
|
||||
$oForm->add(i18n("Created", "cl_newsletter"), $oJob->get("created"));
|
||||
|
||||
// Just remove the "save changes" message (as it is not possible to remove the image completely in ui_table_form)
|
||||
$oForm->setActionButton("submit", $cfg['path']['contenido_fullhtml'] . "images/but_ok.gif", "", "s");
|
||||
|
||||
$oPage->setContent($oForm->render(true));
|
||||
}
|
||||
|
||||
$oPage->render();
|
||||
?>
|
||||
344
includes/include.newsletter_jobs_menu.php
Normale Datei
344
includes/include.newsletter_jobs_menu.php
Normale Datei
|
|
@ -0,0 +1,344 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Frontend user list
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.0.0
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: include.newsletter_jobs_menu.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
# 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", "cl_newsletter"), "type" => "base,sort,search");
|
||||
$aFields["created"] = array("field" => "created", "caption" => i18n("Created", "cl_newsletter"), "type" => "base,sort");
|
||||
$aFields["status"] = array("field" => "status", "caption" => i18n("Status", "cl_newsletter"), "type" => "base,sort");
|
||||
// Not needed, as no sort/search, but keep as memo: $aFields["cronjob"] = array("field" => "use_cronjob", "caption" => i18n("Use cronjob"), "type" => "base");
|
||||
|
||||
##################################
|
||||
# Check external input
|
||||
##################################
|
||||
// Items per page (value stored per area in user property)
|
||||
if (!isset($_REQUEST["elemperpage"]) || !is_numeric($_REQUEST["elemperpage"]) || $_REQUEST["elemperpage"] < 0) {
|
||||
$_REQUEST["elemperpage"] = $oUser->getProperty("itemsperpage", $area);
|
||||
}
|
||||
if (!is_numeric($_REQUEST["elemperpage"])) {
|
||||
// This is the case, if the user property has never been set (first time user)
|
||||
$_REQUEST["elemperpage"] = 25;
|
||||
}
|
||||
if ($_REQUEST["elemperpage"] > 0) {
|
||||
// -- All -- will not be stored, as it may be impossible to change this back to something more useful
|
||||
$oUser->setProperty("itemsperpage", $area, $_REQUEST["elemperpage"]);
|
||||
}
|
||||
unset ($oUser);
|
||||
|
||||
$_REQUEST["page"] = (int)$_REQUEST["page"];
|
||||
if ($_REQUEST["page"] <= 0 || $_REQUEST["elemperpage"] == 0) {
|
||||
$_REQUEST["page"] = 1;
|
||||
}
|
||||
// Sort order
|
||||
if ($_REQUEST["sortorder"] != "ASC") {
|
||||
$_REQUEST["sortorder"] = "DESC"; // Note, default is DESC (as default sortby is "created" date)
|
||||
}
|
||||
|
||||
// Check sort by and search in criteria
|
||||
$bSortByFound = false;
|
||||
$bSearchInFound = false;
|
||||
foreach ($aFields as $sKey => $aData)
|
||||
{
|
||||
if ($aData["field"] == $_REQUEST["sortby"] && strpos($aData["type"], "sort") !== false) {
|
||||
$bSortByFound = true;
|
||||
}
|
||||
if ($aData["field"] == $_REQUEST["searchin"] && strpos($aData["type"], "search") !== false) {
|
||||
$bSearchInFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bSortByFound) {
|
||||
$_REQUEST["sortby"] = "created"; // Default sort by field, possible values see above
|
||||
}
|
||||
if (!$bSearchInFound) {
|
||||
$_REQUEST["searchin"] = "--all--";
|
||||
}
|
||||
|
||||
// Author
|
||||
if ($_REQUEST["selAuthor"] == "") {
|
||||
$_REQUEST["selAuthor"] = $auth->auth["uid"];
|
||||
}
|
||||
|
||||
// Free memory
|
||||
unset($oUser);
|
||||
|
||||
##################################
|
||||
# Get data
|
||||
##################################
|
||||
|
||||
$oJobs->setWhere("idclient", $client);
|
||||
$oJobs->setWhere("idlang", $lang);
|
||||
$oJobs->setWhere("author", $_REQUEST["selAuthor"]);
|
||||
|
||||
if ($_REQUEST["filter"] != "")
|
||||
{
|
||||
if ($_REQUEST["searchin"] == "--all--" || $_REQUEST["searchin"] == "")
|
||||
{
|
||||
foreach ($aFields as $sKey => $aData)
|
||||
{
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oJobs->setWhereGroup("filter", $aData["field"], $_REQUEST["filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
$oJobs->setInnerGroupCondition("filter", "OR");
|
||||
} else {
|
||||
$oJobs->setWhere($_REQUEST["searchin"], $_REQUEST["filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST["elemperpage"] > 0)
|
||||
{
|
||||
$oJobs->query();
|
||||
|
||||
// Getting item count without limit (for page function) - better idea anyone (performance)?
|
||||
$iItemCount = $oJobs->count();
|
||||
|
||||
if ($_REQUEST["elemperpage"]*($_REQUEST["page"]) >= $iItemCount+$_REQUEST["elemperpage"] && $_REQUEST["page"] != 1) {
|
||||
$_REQUEST["page"]--;
|
||||
}
|
||||
$oJobs->setLimit($_REQUEST["elemperpage"] * ($_REQUEST["page"] - 1), $_REQUEST["elemperpage"]);
|
||||
} else {
|
||||
$iItemCount = 0;
|
||||
}
|
||||
|
||||
$oJobs->setOrder($_REQUEST["sortby"] . " " . $_REQUEST["sortorder"]);
|
||||
$oJobs->query();
|
||||
|
||||
// Output data
|
||||
$oMenu = new UI_Menu;
|
||||
$iMenu = 0;
|
||||
$sDateFormat = getEffectiveSetting("backend", "timeformat", "d.m.Y H:i");
|
||||
|
||||
// Store messages for repeated use (speeds performance, as i18n translation is only needed once)
|
||||
$aMsg = array();
|
||||
$aMsg["DelTitle"] = i18n("Delete dispatch job", "cl_newsletter");
|
||||
$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter dispatch job:<br>", "cl_newsletter");
|
||||
|
||||
$aMsg["SendTitle"] = i18n("Run job", "cl_newsletter");
|
||||
$aMsg["SendDescr"] = i18n("Do you really want to run the following job:<br>", "cl_newsletter");
|
||||
|
||||
// Prepare "send link" template
|
||||
$sTplSend = '<a title="'.$aMsg["SendTitle"].'" href="javascript://" onclick="showSendMsg(\'{ID}\',\'{NAME}\')"><img src="'.$cfg['path']['images'].'newsletter_16.gif" border="0" title="'.$aMsg["SendTitle"].'" alt="'.$aMsg["SendTitle"].'"></a>';
|
||||
|
||||
while ($oJob = $oJobs->next())
|
||||
{
|
||||
$iMenu++;
|
||||
$iID = $oJob->get("idnewsjob");
|
||||
$sName = $oJob->get("name") . " (" . date($sDateFormat, strtotime($oJob->get("created"))) .")";
|
||||
|
||||
$oLnk = new cHTMLLink;
|
||||
$oLnk->setMultiLink($area, "", $area, "");
|
||||
$oLnk->setCustom("idnewsjob", $iID);
|
||||
|
||||
// Is at present redundant
|
||||
// HerrB: No, it's just not used/set...
|
||||
//$oMenu->setImage($iMenu, "images/newsletter_16.gif");
|
||||
$oMenu->setTitle($iMenu, $sName);
|
||||
|
||||
switch ($oJob->get("status"))
|
||||
{
|
||||
case 1:
|
||||
// Pending
|
||||
if ($oJob->get("cronjob") == 0)
|
||||
{
|
||||
// Standard job can be run if user has the right to do so
|
||||
if ($perm->have_perm_area_action($area, "news_job_run"))
|
||||
{
|
||||
$sLnkSend = str_replace('{ID}', $iID, $sTplSend);
|
||||
$sLnkSend = str_replace('{NAME}', addslashes($sName), $sLnkSend);
|
||||
|
||||
$oMenu->setActions($iMenu, 'send', $sLnkSend);
|
||||
}
|
||||
} else if ($oJob->get("cronjob") == 1) {
|
||||
// It's a cronjob job - no manual sending, show it blue
|
||||
$oLnk->updateAttributes(array("style" => "color:#0000FF"));
|
||||
}
|
||||
|
||||
if ($perm->have_perm_area_action($area, "news_job_delete")) {
|
||||
// Job may be deleted, if user has the right to do so
|
||||
$oMenu->setActions($iMenu, 'delete', '<a title="'.$aMsg["DelTitle"].'" href="javascript://" onclick="showDelMsg('.$iID.',\''.addslashes($sName).'\')"><img src="'.$cfg['path']['images'].'delete.gif" border="0" title="'.$aMsg["DelTitle"].'" alt="'.$aMsg["DelTitle"].'"></a>');
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// Sending job
|
||||
if ($perm->have_perm_area_action($area, "news_job_run"))
|
||||
{
|
||||
// User may try to start sending, again - if he has the right to do so
|
||||
$sLnkSend = str_replace('{ID}', $iID, $sTplSend);
|
||||
$sLnkSend = str_replace('{NAME}', addslashes($sName), $sLnkSend);
|
||||
|
||||
$oMenu->setActions($iMenu, 'send', $sLnkSend);
|
||||
}
|
||||
|
||||
$oLnk->updateAttributes(array("style" => "color:#da8a00"));
|
||||
|
||||
$sDelete = '<img src="'.$cfg['path']['images'].'delete_inact.gif" border="0" title="'.$aMsg["DelTitle"].'" alt="'.$aMsg["DelTitle"].'">';
|
||||
break;
|
||||
case 9:
|
||||
// Job finished, don't do anything
|
||||
$oLnk->updateAttributes(array("style" => "color:#808080"));
|
||||
|
||||
if ($perm->have_perm_area_action($area, "news_job_delete")) {
|
||||
// You have the right, but you can't delete the job after sending
|
||||
$oMenu->setActions($iMenu, 'delete', '<img src="'.$cfg['path']['images'].'delete_inact.gif" border="0" title="'.$aMsg["DelTitle"].'" alt="'.$aMsg["DelTitle"].'">');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$oMenu->setLink($iMenu, $oLnk);
|
||||
}
|
||||
|
||||
$sExecScript = '
|
||||
<script type="text/javascript">
|
||||
// Session-ID
|
||||
var sid = "'.$sess->id.'";
|
||||
|
||||
// Create messageBox instance
|
||||
box = new messageBox("", "", "", 0, 0);
|
||||
|
||||
function showSendMsg(lngId, strElement) {
|
||||
box.confirm("'.$aMsg["SendTitle"].'", "'.$aMsg["SendDescr"].'<b>" + strElement + "</b>", "runJob(\'" + lngId + "\')");
|
||||
}
|
||||
|
||||
function showDelMsg(lngId, strElement) {
|
||||
box.confirm("'.$aMsg["DelTitle"].'", "'.$aMsg["DelDescr"].'<b>" + strElement + "</b>", "deleteJob(\'" + lngId + "\')");
|
||||
}
|
||||
|
||||
// Function for running job
|
||||
function runJob(idnewsjob)
|
||||
{
|
||||
oForm = parent.parent.left.left_top.document.getElementById("dispatch_listoptionsform");
|
||||
|
||||
url = "main.php?area=news_jobs";
|
||||
url += "&action=news_job_run";
|
||||
url += "&frame=4";
|
||||
url += "&idnewsjob=" + idnewsjob;
|
||||
url += "&contenido=" + sid;
|
||||
url += get_registered_parameters();
|
||||
url += "&selAuthor=" + oForm.selAuthor.value;
|
||||
url += "&sortby=" + oForm.sortby.value;
|
||||
url += "&sortorder=" + oForm.sortorder.value;
|
||||
url += "&filter=" + oForm.filter.value;
|
||||
url += "&elemperpage=" + oForm.elemperpage.value;
|
||||
|
||||
parent.parent.right.right_bottom.location.href = url;
|
||||
}
|
||||
|
||||
// Function for deleting job
|
||||
function deleteJob(idnewsjob)
|
||||
{
|
||||
oForm = parent.parent.left.left_top.document.getElementById("dispatch_listoptionsform");
|
||||
|
||||
url = "main.php?area=news_jobs";
|
||||
url += "&action=news_job_delete";
|
||||
url += "&frame=4";
|
||||
url += "&idnewsjob=" + idnewsjob;
|
||||
url += "&contenido=" + sid;
|
||||
url += get_registered_parameters();
|
||||
url += "&selAuthor=" + oForm.selAuthor.value;
|
||||
url += "&sortby=" + oForm.sortby.value;
|
||||
url += "&sortorder=" + oForm.sortorder.value;
|
||||
url += "&filter=" + oForm.filter.value;
|
||||
url += "&elemperpage=" + oForm.elemperpage.value;
|
||||
|
||||
parent.parent.right.right_bottom.location.href = url;
|
||||
}
|
||||
</script>';
|
||||
|
||||
$oPage->setMargin(0);
|
||||
// Messagebox JS has to be included before ExecScript!
|
||||
$oPage->addScript('messagebox', '<script type="text/javascript" src="scripts/messageBox.js.php?contenido='.$sess->id.'"></script>');
|
||||
$oPage->addScript('exec', $sExecScript);
|
||||
$oPage->addScript('parameterCollector.js', '<script language="JavaScript" src="scripts/parameterCollector.js"></script>');
|
||||
|
||||
//generate current content for Object Pager
|
||||
$sPagerId = '0ed6d632-6adf-4f09-a0c6-1e38ab60e303';
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setTargetFrame('left_bottom');
|
||||
$oPagerLink->setCustom("selAuthor", $_REQUEST["selAuthor"]);
|
||||
$oPagerLink->setCustom("elemperpage", $_REQUEST["elemperpage"]);
|
||||
$oPagerLink->setCustom("filter", $_REQUEST["filter"]);
|
||||
$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
|
||||
$oPagerLink->setCustom("sortby", $_REQUEST["sortby"]);
|
||||
$oPagerLink->setCustom("sortorder", $_REQUEST["sortorder"]);
|
||||
$oPagerLink->setCustom("searchin", $_REQUEST["searchin"]);
|
||||
$oPagerLink->setCustom("frame", $frame);
|
||||
$oPagerLink->setCustom("area", $area);
|
||||
$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
// Note, that after the "page" parameter no "pagerlink" parameter is specified -
|
||||
// it is not used, as the JS below only uses the INNER html and the "pagerlink" parameter is
|
||||
// set by ...left_top.html for the foldingrow itself
|
||||
$oPager = new cObjectPager($sPagerId, $iItemCount, $_REQUEST["elemperpage"], $_REQUEST["page"], $oPagerLink, "page");
|
||||
|
||||
// Add slashes, to insert in javascript
|
||||
$sPagerContent = $oPager->render(1);
|
||||
$sPagerContent = str_replace('\\', '\\\\', $sPagerContent);
|
||||
$sPagerContent = str_replace('\'', '\\\'', $sPagerContent);
|
||||
|
||||
// Send new object pager to left_top
|
||||
$oPage->addScript('setpager', '<script type="text/javascript" src="scripts/setPager.js"></script>');
|
||||
|
||||
$sRefreshPager = '
|
||||
<script type="text/javascript">
|
||||
var sNavigation = \''.$sPagerContent.'\';
|
||||
|
||||
// Activate time to refresh pager folding row in left top
|
||||
var oTimer = window.setInterval("fncSetPager(\'' . $sPagerId . '\',\'' . $_REQUEST["page"] . '\')", 200);
|
||||
</script>';
|
||||
|
||||
$oPage->addScript('refreshpager', $sRefreshPager);
|
||||
|
||||
//$oPage->setContent(array('<table border="0" cellspacing="0" cellpadding="0" width="100%">', $oListOptionRow, '</table>', $oMenu->render(false)));
|
||||
$oPage->setContent($oMenu->render(false));
|
||||
$oPage->render();
|
||||
|
||||
?>
|
||||
67
includes/include.newsletter_jobs_subnav.php
Normale Datei
67
includes/include.newsletter_jobs_subnav.php
Normale Datei
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Custom subnavigation for the newsletters
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.0.1
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
* modified 2010-05-20, Murat Purc, removed request check during processing ticket [#CON-307]
|
||||
*
|
||||
* $Id: include.newsletter_jobs_subnav.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['idnewsjob']) && (int)$_GET['idnewsjob'] > 0)
|
||||
{
|
||||
$sCaption = i18n("View", "cl_newsletter");
|
||||
$tmp_area = "foo2";
|
||||
|
||||
# Set template data
|
||||
$tpl->set("d", "ID", 'c_'.$tpl->dyn_cnt);
|
||||
$tpl->set("d", "CLASS", '');
|
||||
$tpl->set("d", "OPTIONS", '');
|
||||
$tpl->set("d", "CAPTION", '<a class="white" onclick="sub.clicked(this)" target="right_bottom" href="'.$sess->url("main.php?area=news_jobs&frame=4&idnewsjob=$idnewsjob").'">'.$sCaption.'</a>');
|
||||
$tpl->next();
|
||||
|
||||
$sCaption = i18n("Details", "cl_newsletter");
|
||||
$tmp_area = "foo2";
|
||||
|
||||
# Set template data
|
||||
$tpl->set("d", "ID", 'c_'.$tpl->dyn_cnt);
|
||||
$tpl->set("d", "CLASS", '');
|
||||
$tpl->set("d", "OPTIONS", '');
|
||||
$tpl->set("d", "CAPTION", '<a class="white" onclick="sub.clicked(this)" target="right_bottom" href="'.$sess->url("main.php?area=news_jobs&action=news_job_details&frame=4&idnewsjob=$idnewsjob").'">'.$sCaption.'</a>');
|
||||
$tpl->next();
|
||||
|
||||
$tpl->set('s', 'COLSPAN', ($tpl->dyn_cnt * 2) + 2);
|
||||
|
||||
# Generate the third navigation layer
|
||||
$tpl->generate($cfg["path"]["templates"] . $cfg["templates"]["subnav"]);
|
||||
} else {
|
||||
include ($cfg["path"]["contenido"].$cfg["path"]["templates"] . $cfg["templates"]["right_top_blank"]);
|
||||
}
|
||||
|
||||
?>
|
||||
960
includes/include.newsletter_left_top.php
Normale Datei
960
includes/include.newsletter_left_top.php
Normale Datei
|
|
@ -0,0 +1,960 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Left top pane
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.0.0
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
* modified 2008-08-03, Bj<EFBFBD>rn Behrens (HerrB), complete makeover to fix bugs and reduce memory waste
|
||||
*
|
||||
* $Id: include.newsletter_left_top.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
######################################
|
||||
# Initialization
|
||||
######################################
|
||||
if (!is_object($oTpl)) {
|
||||
$oTpl = new Template;
|
||||
}
|
||||
if (!is_object($oDB)) {
|
||||
$oDB = new DB_ConLite; // 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", "cl_newsletter").'" title="'.i18n("Newsletter", "cl_newsletter").'" name="'.$sId.'" id="'.$sId.'" src="'.$cfg["path"]["images"].'newsletter_on.gif"/>';
|
||||
$sButtonRow .= '</a>';
|
||||
}
|
||||
|
||||
// Job dispatch
|
||||
$sId = 'img_dispatch';
|
||||
$oTpl->set('s', 'IDISPATCH', $sId);
|
||||
if ($perm->have_perm_area_action('news_jobs')) {
|
||||
$sButtonRow .= '<a style="margin-right:5px;" href="javascript://" onclick="toggleContainer(\''.$sId.'\');reloadLeftBottomAndTransportFormVars(document.dispatch_listoptionsform);">';
|
||||
$sButtonRow .= '<img onmouseover="hoverEffect(\''.$sId.'\', \'in\')" onmouseout="hoverEffect(\''.$sId.'\', \'out\')" alt="'.i18n("Dispatch", "cl_newsletter").'" title="'.i18n("Dispatch", "cl_newsletter").'" name="'.$sId.'" id="'.$sId.'" src="'.$cfg["path"]["images"].'newsletter_dispatch_on.gif"/>';
|
||||
$sButtonRow .= '</a>';
|
||||
}
|
||||
|
||||
// Recipients
|
||||
$sId = 'img_recipient';
|
||||
$oTpl->set('s', 'IRECIPIENTS', $sId);
|
||||
if ($perm->have_perm_area_action('recipients')) {
|
||||
$sButtonRow .= '<a style="margin-right:5px;" href="javascript://" onclick="toggleContainer(\''.$sId.'\');reloadLeftBottomAndTransportFormVars(document.recipients_listoptionsform);">';
|
||||
$sButtonRow .= '<img onmouseover="hoverEffect(\''.$sId.'\', \'in\')" onmouseout="hoverEffect(\''.$sId.'\', \'out\')" alt="'.i18n("Recipients", "cl_newsletter").'" title="'.i18n("Recipients", "cl_newsletter").'" id="'.$sId.'" src="'.$cfg["path"]["images"].'newsletter_recipients_on.gif"/>';
|
||||
$sButtonRow .= '</a>';
|
||||
}
|
||||
|
||||
// Recipient groups
|
||||
$sId = 'img_recipientgroup';
|
||||
$oTpl->set('s', 'IRECIPIENTGROUP', $sId);
|
||||
if ($perm->have_perm_area_action('recipientgroups')) {
|
||||
$sButtonRow .= '<a style="margin-right:5px;" href="javascript://" onclick="toggleContainer(\''.$sId.'\');reloadLeftBottomAndTransportFormVars(groups_listoptionsform);">';
|
||||
$sButtonRow .= '<img onmouseover="hoverEffect(\''.$sId.'\', \'in\')" onmouseout="hoverEffect(\''.$sId.'\', \'out\')" alt="'.i18n("Recipient groups", "cl_newsletter").'" title="'.i18n("Recipient groups", "cl_newsletter").'" id="'.$sId.'" src="'.$cfg["path"]["images"].'newsletter_recipientgroups_on.gif"/>';
|
||||
$sButtonRow .= '</a>';
|
||||
}
|
||||
|
||||
$oTpl->set('s', 'BUTTONROW', $sButtonRow);
|
||||
unset($sButtonRow);
|
||||
|
||||
######################################
|
||||
# 1. NEWSLETTER
|
||||
######################################
|
||||
|
||||
######################################
|
||||
# 1.1 Newsletter: Actions folding row
|
||||
######################################
|
||||
$sLink = "actionlink"; // ID for HTML element
|
||||
$oActionsRow = new cFoldingRow("28cf9b31-e6d7-4657-a9a7-db31478e7a5c",i18n("Actions", "cl_newsletter"), $sLink);
|
||||
$oTpl->set('s', 'ACTIONLINK', $sLink);
|
||||
|
||||
if ($perm->have_perm_area_action("news", "news_create"))
|
||||
{
|
||||
// Create the link to add a newsletter
|
||||
$sContent = '<div style="padding: 4px; padding-left: 17px; margin-bottom:2px; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
|
||||
$oLink = new cHTMLLink;
|
||||
$oLink->setMultiLink("news", "", "news", "news_create");
|
||||
$oLink->setContent('<img style="margin-right: 4px;" src="'.$cfg["path"]["images"] . 'folder_new.gif" align="middle">'.i18n("Create newsletter", "cl_newsletter"));
|
||||
|
||||
$sContent .= $oLink->render() . '</div>'."\n";
|
||||
$oActionsRow->setContentData($sContent);
|
||||
} else {
|
||||
$oActionsRow->setContentData("");
|
||||
}
|
||||
|
||||
######################################
|
||||
# 1.2 Newsletter: Settings folding row
|
||||
######################################
|
||||
$sLink = "settingslink";
|
||||
$oSettingsRow = new cFoldingRow("d64baf0a-aea9-47b3-8490-54a00fce02b5",i18n("Settings", "cl_newsletter"), $sLink);
|
||||
$oTpl->set('s', 'SETTINGSLINK', $sLink);
|
||||
|
||||
// HTML Newsletter: Template and newsletter category
|
||||
// Note, that in PHP 5 it is not possible to have a truely working copy of an object
|
||||
// so, we are filling two almost identical objects with the same data ("clone" may work, but is not available in PHP4 ...)
|
||||
$oSelHTMLTemplateIDCat = new cHTMLSelectElement("selHTMLTemplateCat");
|
||||
$oSelHTMLTemplateIDCat->setStyle("width: 220px;");
|
||||
|
||||
$oSelHTMLNewsletterIDCat = new cHTMLSelectElement("selHTMLNewsletterCat");
|
||||
$oSelHTMLNewsletterIDCat->setStyle("width: 220px;");
|
||||
|
||||
$oOptionTemplate = new cHTMLOptionElement("--".i18n("Please select", "cl_newsletter")."--", 0);
|
||||
$oSelHTMLTemplateIDCat->addOptionElement(0, $oOptionTemplate);
|
||||
$oOptionNewsletter = new cHTMLOptionElement("--".i18n("Please select", "cl_newsletter")."--", 0);
|
||||
$oSelHTMLNewsletterIDCat->addOptionElement(0, $oOptionNewsletter);
|
||||
|
||||
$sSQL = "SELECT tblCat.idcat AS idcat, tblCatLang.name AS name, tblCatTree.level AS level, ";
|
||||
$sSQL .= "tblCatLang.visible AS visible, tblCatLang.public AS public FROM ";
|
||||
$sSQL .= $cfg["tab"]["cat"]." AS tblCat, ".$cfg["tab"]["cat_lang"]." AS tblCatLang, ";
|
||||
$sSQL .= $cfg["tab"]["cat_tree"]." AS tblCatTree ";
|
||||
$sSQL .= "WHERE tblCat.idclient = '".Contenido_Security::toInteger($client)."' AND tblCatLang.idlang = '".Contenido_Security::toInteger($lang)."' AND ";
|
||||
$sSQL .= "tblCatLang.idcat = tblCat.idcat AND tblCatTree.idcat = tblCat.idcat ";
|
||||
$sSQL .= "ORDER BY tblCatTree.idtree";
|
||||
|
||||
$oDB->query($sSQL);
|
||||
|
||||
while ($oDB->next_record()) {
|
||||
$sSpaces = " ";
|
||||
|
||||
for ($i = 0; $i < $oDB->f("level"); $i ++) {
|
||||
$sSpaces .= " ";
|
||||
}
|
||||
|
||||
$oOptionTemplate = new cHTMLOptionElement($sSpaces.$oDB->f("name"), $oDB->f("idcat"));
|
||||
$oOptionNewsletter = new cHTMLOptionElement($sSpaces.$oDB->f("name"), $oDB->f("idcat"));
|
||||
if ($oDB->f("visible") == 0 || $oDB->f("public") == 0) {
|
||||
$oOptionTemplate->setStyle("color: #666666;");
|
||||
$oOptionNewsletter->setStyle("color: #666666;");
|
||||
}
|
||||
|
||||
$oSelHTMLTemplateIDCat->addOptionElement($oDB->f("idcat"), $oOptionTemplate);
|
||||
$oSelHTMLNewsletterIDCat->addOptionElement($oDB->f("idcat"), $oOptionNewsletter);
|
||||
}
|
||||
|
||||
// Get html template category
|
||||
$iHTMLTemplateIDCat = (int)$oClientLang->getProperty("newsletter", "html_template_idcat");
|
||||
if ($iHTMLTemplateIDCat < 0) {
|
||||
$iHTMLTemplateIDCat = 0;
|
||||
}
|
||||
$oSelHTMLTemplateIDCat->setDefault($iHTMLTemplateIDCat);
|
||||
|
||||
// Get html newsletter article category
|
||||
$iHTMLNewsletterIDCat = (int)$oClientLang->getProperty("newsletter", "html_newsletter_idcat");
|
||||
if ($iHTMLNewsletterIDCat < 0) {
|
||||
$iHTMLNewsletterIDCat = 0;
|
||||
}
|
||||
$oSelHTMLNewsletterIDCat->setDefault($iHTMLNewsletterIDCat);
|
||||
|
||||
// Global HTML newsletter option
|
||||
$bHTMLNewsletter = false;
|
||||
if ($iHTMLTemplateIDCat > 0 && $iHTMLNewsletterIDCat > 0 && $oClientLang->getProperty("newsletter", "html_newsletter") == "true") {
|
||||
// If necessary idcats are not specified or the option is disabled,
|
||||
// then HTML are not used
|
||||
$bHTMLNewsletter = true;
|
||||
}
|
||||
$oCkbHTMLNewsletter = new cHTMLCheckbox("ckbHTMLNewsletter", "enabled", "", $bHTMLNewsletter);
|
||||
|
||||
// Disable HTML options, if user has no rights
|
||||
if (!$perm->have_perm_area_action($area, "news_html_settings"))
|
||||
{
|
||||
$oSelHTMLTemplateIDCat->setDisabled("disabled");
|
||||
$oSelHTMLNewsletterIDCat->setDisabled("disabled");
|
||||
$oCkbHTMLNewsletter->setDisabled("disabled");
|
||||
}
|
||||
|
||||
// Destination for sending test newsletter
|
||||
$oSelTestDestination = new cHTMLSelectElement("selTestDestination");
|
||||
$oSelTestDestination->setStyle("width: 220px;");
|
||||
|
||||
$oOption = new cHTMLOptionElement(i18n("My mail address", "cl_newsletter"), 0);
|
||||
$oSelTestDestination->addOptionElement(0, $oOption);
|
||||
|
||||
$oRcpGroups = new RecipientGroupCollection;
|
||||
$oRcpGroups->setWhere("idclient", (int)$client);
|
||||
$oRcpGroups->setWhere("idlang", (int)$lang);
|
||||
$oRcpGroups->setOrder("groupname");
|
||||
$oRcpGroups->query();
|
||||
|
||||
$bTestTargetFound = false;
|
||||
// Get client and language specific test destination. As lang is client specific, lang is sufficient
|
||||
$iTestDestination = (int)$oUser->getProperty("newsletter", "test_idnewsgrp_lang" . $lang);
|
||||
while ($oRcpGroup = $oRcpGroups->next())
|
||||
{
|
||||
$iID = $oRcpGroup->get($oRcpGroup->primaryKey);
|
||||
|
||||
if ($iTestDestination == $iID) {
|
||||
$bTestTargetFound = true;
|
||||
}
|
||||
|
||||
$oOption = new cHTMLOptionElement($oRcpGroup->get("groupname"), $iID);
|
||||
$oSelTestDestination->addOptionElement($iID, $oOption);
|
||||
}
|
||||
unset($oRcpGroups);
|
||||
|
||||
if (!$bTestTargetFound) {
|
||||
// Currently specified test target doesn't exist anymore, get back to "my mail"
|
||||
$iTestDestination = 0;
|
||||
}
|
||||
if (!$perm->have_perm_area_action($area, "news_send_test"))
|
||||
{
|
||||
// No right to send somewhere else than to yourself
|
||||
$iTestDestination = 0;
|
||||
$oSelTestDestination->setDisabled("disabled");
|
||||
}
|
||||
$oSelTestDestination->setDefault($iTestDestination);
|
||||
|
||||
$oBtnSave = new cHTMLButton("submit", i18n("Save", "cl_newsletter"));
|
||||
|
||||
$sContent = '<div style="border-bottom: 0px solid #B3B3B3; padding-left:17px; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
$sContent .= ' <form target="left_bottom" onsubmit="append_registered_parameters(this);" id="htmlnewsletter" name="htmlnewsletter" method="get" action="main.php?1">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="area" value="'.$area.'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="frame" value="2">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="contenido" value="'.$sess->id.'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="elemperpage" value="'.$_REQUEST["elemperpage"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="sortby" value="'.$_REQUEST["sortby"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="sortorder" value="'.$_REQUEST["sortorder"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="restrictgroup" value="'.$_REQUEST["restrictgroup"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="filter" value="'.$_REQUEST["filter"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="searchin" value="'.$_REQUEST["searchin"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="action_html" value="save_newsletter_properties">'."\n";
|
||||
$sContent .= ' <table>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'.$oCkbHTMLNewsletter->toHTML(false).' '.i18n("Enable HTML Newsletter", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'.i18n("HTML Template Category:", "cl_newsletter").'<br />'.$oSelHTMLTemplateIDCat->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'.i18n("HTML Newsletter Category:", "cl_newsletter").'<br />'.$oSelHTMLNewsletterIDCat->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'.i18n("Send test destination:", "cl_newsletter").'<br />'.$oSelTestDestination->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td style="text-align: right;">'.$oBtnSave->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' </table>'."\n";
|
||||
$sContent .= ' </form>'."\n";
|
||||
$sContent .= '</div>'."\n";
|
||||
$oSettingsRow->setContentData($sContent);
|
||||
|
||||
######################################
|
||||
# 1.3 Newsletter: List options folding row
|
||||
######################################
|
||||
// Items per Page
|
||||
$iItemsPerPage = (int)$oUser->getProperty("itemsperpage", "news"); // Also used in query below
|
||||
if ($iItemsPerPage == 0) {
|
||||
$iItemsPerPage = 25; // All can't be saved
|
||||
}
|
||||
|
||||
$oSelItemsPerPage = new cHTMLSelectElement("elemperpage");
|
||||
$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100));
|
||||
$oSelItemsPerPage->setDefault($iItemsPerPage);
|
||||
// Sort By
|
||||
$oSelSortBy = new cHTMLSelectElement("sortby");
|
||||
$oOption = new cHTMLOptionElement("Name", "name");
|
||||
$oSelSortBy->addOptionElement($sKey, $oOption);
|
||||
$oSelSortBy->setDefault("name");
|
||||
// Sort Order
|
||||
$oSelSortOrder = new cHTMLSelectElement("sortorder");
|
||||
$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter")));
|
||||
$oSelSortOrder->setDefault("ASC");
|
||||
// Search For
|
||||
$oTextboxFilter = new cHTMLTextbox("filter", "", 16);
|
||||
// Search In
|
||||
$oSelSearchIn = new cHTMLSelectElement("searchin");
|
||||
$oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--");
|
||||
$oSelSearchIn->addOptionElement("all", $oOption);
|
||||
$oOption = new cHTMLOptionElement("Name", "name");
|
||||
$oSelSearchIn->addOptionElement($sKey, $oOption);
|
||||
$oSelSearchIn->setDefault("name");
|
||||
// Apply button
|
||||
$oBtnApply = new cHTMLButton("submit", i18n("Apply", "cl_newsletter"));
|
||||
|
||||
$sContent = '<div style="border-bottom: 0px solid #B3B3B3; padding-left: 17px; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
$sContent .= '<form target="left_bottom" onsubmit="reloadLeftBottomAndTransportFormVars(this);" id="newsletter_listoptionsform" name="newsletter_listoptionsform" method="get" action="">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="area" value="news">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="frame" value="2">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="contenido" value="'.$sess->id.'">'."\n";
|
||||
$sContent .= ' <table>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Items / page", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelItemsPerPage->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Sort by", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSortBy->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Sort order", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSortOrder->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Search for", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oTextboxFilter->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Search in", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSearchIn->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td> </td>'."\n";
|
||||
$sContent .= ' <td>'.$oBtnApply->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' </table>'."\n";
|
||||
$sContent .= '</form>'."\n";
|
||||
$sContent .= '</div>'."\n";
|
||||
|
||||
// To template
|
||||
$sLink = "listoption";
|
||||
$oListOptionsRow = new cFoldingRow("9d0968be-601d-44f8-a666-99d51c9c777d",i18n("List options", "cl_newsletter"), $sLink);
|
||||
$oListOptionsRow->setContentData($sContent);
|
||||
$oTpl->set('s', 'LISTOPTIONLINK', $sLink);
|
||||
|
||||
######################################
|
||||
# 1.4 Newsletter: Paging folding row
|
||||
######################################
|
||||
|
||||
// Add paging folding row (current page = 1) to get HTML paging container (later on updated by ...menu.php)
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setTargetFrame("left_bottom");
|
||||
$oPagerLink->setCustom("elemperpage", $iItemsPerPage);
|
||||
$oPagerLink->setCustom("filter", "");
|
||||
//$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
|
||||
$oPagerLink->setCustom("sortby", "name");
|
||||
$oPagerLink->setCustom("sortorder", "ASC");
|
||||
$oPagerLink->setCustom("searchin", "name");
|
||||
$oPagerLink->setCustom("frame", "2");
|
||||
$oPagerLink->setCustom("area", "news");
|
||||
$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
|
||||
$sLink = "pagerlink";
|
||||
$oTpl->set('s', 'PAGINGLINK', $sLink);
|
||||
//$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e302", $iItemCount, $iItemsPerPage, 1, $oPagerLink, 'page', $sLink);
|
||||
$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e302", 0, 1, 1, $oPagerLink, 'page', $sLink);
|
||||
|
||||
######################################
|
||||
# Newsletter: Container
|
||||
######################################
|
||||
$sContainerId = 'cont_newsletter';
|
||||
$sContainer = '<div id="'.$sContainerId.'">';
|
||||
$sContainer .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
|
||||
if ($perm->have_perm_area_action("news", "news_create")) {
|
||||
$sContainer .= $oActionsRow->render();
|
||||
}
|
||||
if ($perm->have_perm_area_action("news", "news_html_settings")) {
|
||||
$sContainer .= $oSettingsRow->render();
|
||||
}
|
||||
$sContainer .= $oListOptionsRow->render();
|
||||
$sContainer .= $oPagerRow->render();
|
||||
$sContainer .= '</table>';
|
||||
$sContainer .= '</div>';
|
||||
$oTpl->set('s', 'CNEWSLETTER', $sContainer);
|
||||
$oTpl->set('s', 'ID_CNEWSLETTER', $sContainerId);
|
||||
|
||||
######################################
|
||||
# 2. Job dispatch
|
||||
######################################
|
||||
// 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. ... menu.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", "cl_newsletter"), "type" => "base,sort,search");
|
||||
$aFields["created"] = array("field" => "created", "caption" => i18n("Created", "cl_newsletter"), "type" => "base,sort");
|
||||
$aFields["status"] = array("field" => "status", "caption" => i18n("Status", "cl_newsletter"), "type" => "base,sort");
|
||||
$aFields["cronjob"] = array("field" => "use_cronjob", "caption" => i18n("Use cronjob", "cl_newsletter"), "type" => "base");
|
||||
|
||||
######################################
|
||||
# 2.1 Job dispatch: List options folding row
|
||||
######################################
|
||||
// Author
|
||||
$oSelAuthor = new cHTMLSelectElement("selAuthor");
|
||||
|
||||
// Get possible authors/users from available jobs
|
||||
// For this query genericdb can't be used, as the class id is always included (distinct won't work)
|
||||
$sSQL = "SELECT DISTINCT author, authorname FROM ".$cfg["tab"]["news_jobs"]." ORDER BY authorname";
|
||||
$oDB->query($sSQL);
|
||||
|
||||
$aItems = array();
|
||||
$bUserInList = false;
|
||||
while ($oDB->next_record())
|
||||
{
|
||||
if ($oDB->f("author") == $auth->auth["uid"]) {
|
||||
$bUserInList = true;
|
||||
}
|
||||
$aItems[] = array($oDB->f("author"), urldecode($oDB->f("authorname")));
|
||||
}
|
||||
$oSelAuthor->autoFill($aItems);
|
||||
|
||||
if (!$bUserInList) {
|
||||
// Current ser hasn't sent newsletter jobs, yet - add him to the list (it's the default author)
|
||||
$oOption = new cHTMLOptionElement($auth->auth["uname"], $auth->auth["uid"]);
|
||||
$oSelAuthor->addOptionElement($auth->auth["uid"], $oOption);
|
||||
}
|
||||
$oSelAuthor->setDefault($auth->auth["uid"]);
|
||||
|
||||
// Items per page
|
||||
$iItemsPerPage = (int)$oUser->getProperty("itemsperpage", "news_jobs"); // Used also below in query
|
||||
if ($iItemsPerPage == 0) {
|
||||
$iItemsPerPage = 25; // All can't be saved
|
||||
}
|
||||
|
||||
$oSelItemsPerPage = new cHTMLSelectElement("elemperpage");
|
||||
$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100));
|
||||
$oSelItemsPerPage->setDefault($iItemsPerPage);
|
||||
|
||||
// Sort by
|
||||
$oSelSortBy = new cHTMLSelectElement("sortby");
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "sort") !== false)
|
||||
{
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $sKey);
|
||||
$oSelSortBy->addOptionElement($sKey, $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSortBy->setDefault("created");
|
||||
|
||||
// Sort order
|
||||
$oSelSortOrder = new cHTMLSelectElement("sortorder");
|
||||
$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter")));
|
||||
$oSelSortOrder->setDefault("DESC");
|
||||
|
||||
// Filter
|
||||
$oTxtFilter = new cHTMLTextbox("filter", "", 16);
|
||||
|
||||
//Search in
|
||||
$oSelSearchIn = new cHTMLSelectElement("searchin");
|
||||
$oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--");
|
||||
$oSelSearchIn->addOptionElement("all", $oOption);
|
||||
|
||||
foreach ($aFields as $sKey => $aData)
|
||||
{
|
||||
if (strpos($aData["type"], "search") !== false)
|
||||
{
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $sKey);
|
||||
$oSelSearchIn->addOptionElement($sKey, $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSearchIn->setDefault("--all--");
|
||||
|
||||
$oBtnApply = new cHTMLButton("submit", i18n("Apply", "cl_newsletter"));
|
||||
|
||||
$sContent = '<div style="border-bottom: 0px solid #B3B3B3; padding-left: 17px; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
$sContent .= '<form target="left_bottom" onsubmit="reloadLeftBottomAndTransportFormVars(this);" id="dispatch_listoptionsform" name="dispatch_listoptionsform" method="get" action="">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="area" value="news_jobs">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="frame" value="2">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="contenido" value="'.$sess->id.'">'."\n";
|
||||
$sContent .= ' <table>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Author", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelAuthor->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Items / page", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelItemsPerPage->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Sort by", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSortBy->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Sort order", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSortOrder->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Search for", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oTxtFilter->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Search in", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSearchIn->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td> </td>'."\n";
|
||||
$sContent .= ' <td>'.$oBtnApply->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' </table>'."\n";
|
||||
$sContent .= '</form>'."\n";
|
||||
$sContent .= '</div>'."\n";
|
||||
|
||||
// To template
|
||||
$sLink = "listoptiondisp";
|
||||
$oListOptionsRow = new cFoldingRow("dfa6cc00-0acf-11db-9cd8-0800200c9a66",i18n("List options", "cl_newsletter"), $sLink);
|
||||
$oListOptionsRow->setContentData($sContent);
|
||||
$oTpl->set('s', 'LISTOPTIONLINKDISP', $sLink);
|
||||
|
||||
######################################
|
||||
# 2.2 Job dispatch: Paging folding row
|
||||
######################################
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setTargetFrame('left_bottom');
|
||||
$oPagerLink->setCustom("selAuthor", $auth->auth["uid"]);
|
||||
$oPagerLink->setCustom("elemperpage", $iItemsPerPage);
|
||||
$oPagerLink->setCustom("filter", "");
|
||||
//$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
|
||||
$oPagerLink->setCustom("sortby", "created");
|
||||
$oPagerLink->setCustom("sortorder", "DESC");
|
||||
$oPagerLink->setCustom("searchin", "--all--");
|
||||
$oPagerLink->setCustom("frame", "2"); // HIER!!! Stimmt das?
|
||||
$oPagerLink->setCustom("area", "news_jobs");
|
||||
$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
|
||||
$sLink = "pagerlinkdisp";
|
||||
$oTpl->set('s', 'PAGINGLINKDISP', $sLink);
|
||||
//$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e303", $iItemCount, $iItemsPerPage, 1, $oPagerLink, "page", $sLink);
|
||||
$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e303", 0, 1, 1, $oPagerLink, 'page', $sLink);
|
||||
|
||||
######################################
|
||||
# Job dispatch: Container
|
||||
######################################
|
||||
$sContainerId = 'cont_dispatch';
|
||||
$sContainer = '<div id="'.$sContainerId.'">';
|
||||
$sContainer .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
|
||||
$sContainer .= $oListOptionsRow->render();
|
||||
$sContainer .= $oPagerRow->render();
|
||||
$sContainer .= '</table>';
|
||||
$sContainer .= '</div>';
|
||||
$oTpl->set('s', 'CDISPATCH', $sContainer);
|
||||
$oTpl->set('s', 'ID_CDISPATCH', $sContainerId);
|
||||
|
||||
######################################
|
||||
# 3. Recipients
|
||||
######################################
|
||||
// See comment at 2. Job dispatch
|
||||
$aFields = array();
|
||||
$aFields["name"] = array("field" => "name", "caption" => i18n("Name", "cl_newsletter"),"type" => "base,sort,search");
|
||||
$aFields["email"] = array("field" => "email", "caption" => i18n("E-Mail", "cl_newsletter"),"type" => "base,sort,search");
|
||||
$aFields["confirmed"] = array("field" => "confirmed", "caption" => i18n("Confirmed", "cl_newsletter"), "type" => "base");
|
||||
$aFields["deactivated"] = array("field" => "deactivated", "caption" => i18n("Deactivated", "cl_newsletter"), "type" => "base");
|
||||
|
||||
######################################
|
||||
# 3.1 Recipients: Actions folding row
|
||||
######################################
|
||||
$sContent = '<div style="padding: 4px; padding-left: 17px; border-bottom: 0px solid black; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
|
||||
// Create a link to add a recipient
|
||||
if ($perm->have_perm_area_action("recipients", "recipients_create"))
|
||||
{
|
||||
$oLink = new cHTMLLink;
|
||||
$oLink->setMultiLink("recipients","","recipients","recipients_create");
|
||||
$oLink->setContent('<img style="margin-right: 4px;" src="'.$cfg["path"]["images"] . 'folder_new.gif" align="middle">'.i18n("Create recipient", "cl_newsletter").'</a>');
|
||||
|
||||
$sContent .= $oLink->render().'<br />'."\n";
|
||||
}
|
||||
|
||||
// Create a link to import recipients
|
||||
if ($perm->have_perm_area_action("recipients", "recipients_create"))
|
||||
{
|
||||
$oLink = new cHTMLLink;
|
||||
$oLink->setMultiLink("recipients", "", "recipients_import", "recipients_import");
|
||||
$oLink->setContent('<img style="margin-right: 4px;" src="'.$cfg["path"]["images"] . 'importieren.gif" align="middle">'.i18n("Import recipients", "cl_newsletter").'</a>');
|
||||
|
||||
$sContent .= $oLink->render().'<br />'."\n";
|
||||
}
|
||||
|
||||
// Create a link to purge subscribed but not confirmed recipients
|
||||
$iTimeframe = (int)$oClient->getProperty("newsletter", "purgetimeframe");
|
||||
if ($iTimeframe <= 0) {
|
||||
$iTimeframe = 30;
|
||||
}
|
||||
|
||||
if ($perm->have_perm_area_action("recipients", "recipients_delete"))
|
||||
{
|
||||
$oLink = new cHTMLLink;
|
||||
$oLink->setLink('javascript:showPurgeMsg("'.i18n('Purge recipients', "cl_newsletter").'", "'.sprintf(i18n("Do you really want to remove recipients, that have not been confirmed since %s days and over?", "cl_newsletter"), '"+purgetimeframe+"').'")');
|
||||
|
||||
$oLink->setContent('<img style="margin-right: 4px;" src="'.$cfg["path"]["images"] . 'delete.gif" align="middle">'.i18n("Purge recipients", "cl_newsletter").'</a>');
|
||||
|
||||
$sContent .= $oLink->render();
|
||||
}
|
||||
$sContent .= '</div>'."\n";
|
||||
$oTpl->set('s', 'VALUE_PURGETIMEFRAME', $iTimeframe);
|
||||
|
||||
// To template
|
||||
$sLink = "actionrec";
|
||||
$oListActionsRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a66", i18n("Actions", "cl_newsletter"), $sLink);
|
||||
$oListActionsRow->setContentData($sContent);
|
||||
$oTpl->set('s', 'ACTIONLINKREC', $sLink);
|
||||
|
||||
######################################
|
||||
# 3.2 Recipients: Settings folding row
|
||||
######################################
|
||||
$oTxtTimeframe = new cHTMLTextbox("txtPurgeTimeframe", $iTimeframe, 5);
|
||||
$oBtnSave = new cHTMLButton("submit", i18n("Save", "cl_newsletter"));
|
||||
|
||||
$sContent = '<div style="border-bottom: 0px solid #B3B3B3; padding-left: 17px; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
$sContent .= '<form target="left_bottom" onsubmit="purgetimeframe = document.options.txtPurgeTimeframe.value; append_registered_parameters(this);" id="options" name="options" method="get" action="main.php?1">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="area" value="recipients">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="frame" value="2">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="contenido" value="'.$sess->id.'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="elemperpage" value="'.$_REQUEST["elemperpage"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="sortby" value="'.$_REQUEST["sortby"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="sortorder" value="'.$_REQUEST["sortorder"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="restrictgroup" value="'.$_REQUEST["restrictgroup"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="filter" value="'.$_REQUEST["filter"].'">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="searchin" value="'.$_REQUEST["searchin"].'">'."\n";
|
||||
$sContent .= ' <table>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Purge timeframe", "cl_newsletter").':</td>'."\n";
|
||||
$sContent .= ' <td>'.$oTxtTimeframe->render().' '.i18n("days", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td> </td>'."\n";
|
||||
$sContent .= ' <td>'.$oBtnSave->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' </table>'."\n";
|
||||
$sContent .= '</form>'."\n";
|
||||
$sContent .= '</div>'."\n";
|
||||
|
||||
// To template
|
||||
$sLink = "settingsrec";
|
||||
$oSettingsRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a69",i18n("Settings", "cl_newsletter"), $sLink);
|
||||
$oSettingsRow->setContentData($sContent);
|
||||
$oTpl->set('s', 'SETTINGSLINKREC', $sLink);
|
||||
|
||||
######################################
|
||||
# 3.3 Recipients: List options folding row
|
||||
######################################
|
||||
$iItemsPerPage = (int)$oUser->getProperty("itemsperpage", "recipients");
|
||||
if ($iItemsPerPage == 0) {
|
||||
$iItemsPerPage = 25; // All can't be saved
|
||||
}
|
||||
|
||||
$oSelItemsPerPage = new cHTMLSelectElement("elemperpage");
|
||||
$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100));
|
||||
$oSelItemsPerPage->setDefault($iItemsPerPage);
|
||||
|
||||
$oSelSortBy = new cHTMLSelectElement("sortby");
|
||||
foreach ($aFields as $sKey => $aData)
|
||||
{
|
||||
if (strpos($aData["type"], "sort") !== false) {
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]);
|
||||
$oSelSortBy->addOptionElement($aData["field"], $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSortBy->setDefault("name");
|
||||
|
||||
$oSelSortOrder = new cHTMLSelectElement("sortorder");
|
||||
$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter")));
|
||||
$oSelSortOrder->setDefault("ASC");
|
||||
|
||||
$oSelRestrictGroup = new cHTMLSelectElement("restrictgroup");
|
||||
$oOption = new cHTMLOptionElement(i18n("-- All groups --", "cl_newsletter"), "--all--");
|
||||
$oSelRestrictGroup->addOptionElement("all", $oOption);
|
||||
|
||||
// Fetch recipient groups
|
||||
$oRGroups = new RecipientGroupCollection;
|
||||
$oRGroups->setWhere("idclient", $client);
|
||||
$oRGroups->setWhere("idlang", $lang);
|
||||
$oRGroups->setOrder("defaultgroup DESC, groupname ASC");
|
||||
$oRGroups->query();
|
||||
|
||||
$i = 1;
|
||||
while ($oRGroup = $oRGroups->next())
|
||||
{
|
||||
if ($oRGroup->get("defaultgroup") == 1) {
|
||||
$sGroupname = $oRGroup->get("groupname") . "*";
|
||||
} else {
|
||||
$sGroupname = $oRGroup->get("groupname");
|
||||
}
|
||||
$oOption = new cHTMLOptionElement($sGroupname, $oRGroup->get("idnewsgroup"));
|
||||
$oSelRestrictGroup->addOptionElement($i, $oOption);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$oSelRestrictGroup->setDefault("--all--");
|
||||
|
||||
$oTxtFilter = new cHTMLTextbox("filter", "", 16);
|
||||
|
||||
$oSelSearchIn = new cHTMLSelectElement("searchin");
|
||||
$oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--");
|
||||
$oSelSearchIn->addOptionElement("all", $oOption);
|
||||
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]);
|
||||
$oSelSearchIn->addOptionElement($aData["field"], $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSearchIn->setDefault("--all--");
|
||||
|
||||
$oBtnApply = new cHTMLButton("submit", i18n("Apply"));
|
||||
|
||||
$sContent = '<div style="border-bottom: 0px solid #B3B3B3; padding-left: 17px; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
$sContent .= '<form target="left_bottom" onsubmit="reloadLeftBottomAndTransportFormVars(this);" id="recipients_listoptionsform" name="recipients_listoptionsform" method="get" action="">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="area" value="recipients">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="frame" value="2">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="contenido" value="'.$sess->id.'">'."\n";
|
||||
$sContent .= ' <table>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Items / page", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelItemsPerPage->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Sort by", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSortBy->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Sort order", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSortOrder->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Show group", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelRestrictGroup->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Search for", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oTxtFilter->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Search in", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSearchIn->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td> </td>'."\n";
|
||||
$sContent .= ' <td>'.$oBtnApply->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' </table>'."\n";
|
||||
$sContent .= '</form>'."\n";
|
||||
$sContent .= '</div>'."\n";
|
||||
|
||||
// To template
|
||||
$sLink = "listoptionsrec";
|
||||
$oListOptionsRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a66",i18n("List options", "cl_newsletter"), $sLink);
|
||||
$oListOptionsRow->setContentData($sContent);
|
||||
$oTpl->set('s', 'LISTOPTIONLINKREC', $sLink);
|
||||
|
||||
######################################
|
||||
# 3.4 Recipients: Paging
|
||||
######################################
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setTargetFrame('left_bottom');
|
||||
$oPagerLink->setCustom("elemperpage", $iItemsPerPage);
|
||||
$oPagerLink->setCustom("filter", "");
|
||||
$oPagerLink->setCustom("restrictgroup", "--all--");
|
||||
$oPagerLink->setCustom("sortby", "name");
|
||||
$oPagerLink->setCustom("sortorder", "ASC");
|
||||
$oPagerLink->setCustom("searchin", "--all--");
|
||||
$oPagerLink->setCustom("frame", "2");
|
||||
$oPagerLink->setCustom("area", "recipients");
|
||||
$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
|
||||
// To template
|
||||
$sLink = "pagingrec";
|
||||
$oTpl->set('s', 'PAGINGLINKREC', $sLink);
|
||||
//$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e304", $iItemCount, $iItemsPerPage, 1, $oPagerLink, "page", $sLink);
|
||||
$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e304", 0, 1, 1, $oPagerLink, 'page', $sLink);
|
||||
|
||||
######################################
|
||||
# Recipients: Container
|
||||
######################################
|
||||
$sContainerId = 'cont_recipients';
|
||||
$sContainer = '<div id="' . $sContainerId . '">';
|
||||
$sContainer .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
|
||||
if ($perm->have_perm_area_action('recipients', "recipients_delete") || $perm->have_perm_area_action("recipients", "recipients_create")) {
|
||||
$sContainer .= $oListActionsRow->render();
|
||||
}
|
||||
$sContainer .= $oSettingsRow->render();
|
||||
$sContainer .= $oListOptionsRow->render();
|
||||
$sContainer .= $oPagerRow->render();
|
||||
$sContainer .= '</table>';
|
||||
$sContainer .= '</div>';
|
||||
$oTpl->set('s', 'CRECIPIENTS', $sContainer);
|
||||
$oTpl->set('s', 'ID_CRECIPIENTS', $sContainerId);
|
||||
|
||||
######################################
|
||||
# 4 Recipient groups
|
||||
######################################
|
||||
// See comment at 2. Job dispatch
|
||||
$aFields = array();
|
||||
$aFields["name"] = array("field" => "groupname", "caption" => i18n("Name", "cl_newsletter"), "type" => "base,sort,search");
|
||||
|
||||
######################################
|
||||
# 4.1 Recipient groups: Actions
|
||||
######################################
|
||||
$sContent = '<div style="padding: 4px; padding-left: 17px; border-bottom: 0px solid black; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
|
||||
// Create a link to add a group
|
||||
if ($perm->have_perm_area_action("recipientgroups", "recipientgroup_create"))
|
||||
{
|
||||
$oLnk = new cHTMLLink;
|
||||
$oLnk->setMultiLink("recipientgroups","","recipientgroups","recipientgroup_create");
|
||||
$oLnk->setContent('<img style="margin-right: 4px;" src="'.$cfg["path"]["images"] . 'folder_new.gif" align="middle">'.i18n("Create group", "cl_newsletter").'</a>');
|
||||
$sContent .= $oLnk->render().'<br />'."\n";
|
||||
}
|
||||
|
||||
$sContent .= '</div>'."\n";
|
||||
|
||||
$sLink = "actiongroup";
|
||||
$oListActionsRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a67",i18n("Actions", "cl_newsletter"), $sLink);
|
||||
$oListActionsRow->setContentData($sContent);
|
||||
$oTpl->set('s', 'ACTIONLINKGROUP', $sLink);
|
||||
|
||||
######################################
|
||||
# 4.2 Recipient groups: List Options
|
||||
######################################
|
||||
$iItemsPerPage = (int)$oUser->getProperty("itemsperpage", "recipientgroups");
|
||||
if ($iItemsPerPage == 0) {
|
||||
$iItemsPerPage = 25; // All can't be saved
|
||||
}
|
||||
|
||||
$oSelItemsPerPage = new cHTMLSelectElement("elemperpage");
|
||||
$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100));
|
||||
$oSelItemsPerPage->setDefault($iItemsPerPage);
|
||||
|
||||
$oSelSortBy = new cHTMLSelectElement("sortby");
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "sort") !== false) {
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]);
|
||||
$oSelSortBy->addOptionElement($aData["field"], $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSortBy->setDefault("name");
|
||||
|
||||
$oSelSortOrder = new cHTMLSelectElement("sortorder");
|
||||
$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter")));
|
||||
$oSelSortOrder->setDefault("ASC");
|
||||
|
||||
$oTxtFilter = new cHTMLTextbox("filter", "", 16);
|
||||
|
||||
$oSelSearchIn = new cHTMLSelectElement("searchin");
|
||||
$oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--");
|
||||
$oSelSearchIn->addOptionElement("all", $oOption);
|
||||
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]);
|
||||
$oSelSearchIn->addOptionElement($aData["field"], $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSearchIn->setDefault("--all--");
|
||||
|
||||
$oBtnApply = new cHTMLButton("submit", i18n("Apply", "cl_newsletter"));
|
||||
|
||||
$sContent = '<div style="border-bottom: 0px solid #B3B3B3; padding-left: 17px; background: '.$cfg['color']['table_dark'].';">'."\n";
|
||||
$sContent .= '<form target="left_bottom" onsubmit="reloadLeftBottomAndTransportFormVars(this);" id="groups_listoptionsform" name="groups_listoptionsform" method="get" action="">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="area" value="recipientgroups">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="frame" value="2">'."\n";
|
||||
$sContent .= ' <input type="hidden" name="contenido" value="'.$sess->id.'">'."\n";
|
||||
$sContent .= ' <table>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Items / page", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelItemsPerPage->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Sort by", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSortBy->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Sort order", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSortOrder->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Search for", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oTxtFilter->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td>'. i18n("Search in", "cl_newsletter").'</td>'."\n";
|
||||
$sContent .= ' <td>'.$oSelSearchIn->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' <tr>'."\n";
|
||||
$sContent .= ' <td> </td>'."\n";
|
||||
$sContent .= ' <td>'.$oBtnApply->render().'</td>'."\n";
|
||||
$sContent .= ' </tr>'."\n";
|
||||
$sContent .= ' </table>'."\n";
|
||||
$sContent .= '</form>'."\n";
|
||||
$sContent .= '</div>'."\n";
|
||||
|
||||
// To template
|
||||
$sLink = "listoptionsgroup";
|
||||
$oListOptionsRow = new cFoldingRow("79efc1fc-111d-11dc-8314-0800200c9a66",i18n("List options", "cl_newsletter"), $sLink);
|
||||
$oListOptionsRow->setContentData($sContent);
|
||||
$oTpl->set('s', 'LISTOPTIONLINKGROUP', $sLink);
|
||||
|
||||
######################################
|
||||
# 4.3 Recipient groups: Paging
|
||||
######################################
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setTargetFrame('left_bottom');
|
||||
$oPagerLink->setCustom("elemperpage", $iItemsPerPage);
|
||||
$oPagerLink->setCustom("filter", "");
|
||||
$oPagerLink->setCustom("sortby", "name");
|
||||
$oPagerLink->setCustom("sortorder", "ASC");
|
||||
$oPagerLink->setCustom("searchin", "--all--");
|
||||
$oPagerLink->setCustom("frame", "2");
|
||||
$oPagerLink->setCustom("area", "recipientgroups");
|
||||
$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
|
||||
// To template
|
||||
$sLink = "paginggroup";
|
||||
$oTpl->set('s', 'PAGINGLINKGROUP', $sLink);
|
||||
//$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e305", $iItemCount, $iItemsPerPage, 1, $oPagerLink, "page", $sLink);
|
||||
$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e305", 0, 1, 1, $oPagerLink, 'page', $sLink);
|
||||
|
||||
######################################
|
||||
# Recipient Groups: Container
|
||||
######################################
|
||||
$sContainerId = 'cont_recipientgroup';
|
||||
$sContainer = '<div id="' . $sContainerId . '">';
|
||||
$sContainer .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
|
||||
if ($perm->have_perm_area_action("recipientgroups", "recipientgroup_create")) {
|
||||
$sContainer .= $oListActionsRow->render();
|
||||
}
|
||||
$sContainer .= $oListOptionsRow->render();
|
||||
$sContainer .= $oPagerRow->render();
|
||||
$sContainer .= '</table>';
|
||||
$sContainer .= '</div>';
|
||||
$oTpl->set('s', 'CRECIPIENTGROUP', $sContainer);
|
||||
$oTpl->set('s', 'ID_CRECIPIENTGROUP', $sContainerId);
|
||||
|
||||
$oTpl->set('s', 'SESSID', $sess->id);
|
||||
$oTpl->generate($cfg['path']['templates'] . $cfg['templates']['newsletter_left_top']);
|
||||
|
||||
?>
|
||||
367
includes/include.newsletter_menu.php
Normale Datei
367
includes/include.newsletter_menu.php
Normale Datei
|
|
@ -0,0 +1,367 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Frontend user list
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.2.0
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: include.newsletter_menu.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
# 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", "cl_newsletter"), "type" => "base,sort,search");
|
||||
|
||||
##################################
|
||||
# Store settings/Get basic data
|
||||
##################################
|
||||
if (isset($_REQUEST['action_html']) && $_REQUEST['action_html'] == 'save_newsletter_properties' && $perm->have_perm_area_action($area, "news_html_settings")) {
|
||||
// Storing settings
|
||||
if (isset($_REQUEST["ckbHTMLNewsletter"])) {
|
||||
$oClientLang->setProperty("newsletter", "html_newsletter", "true");
|
||||
} else {
|
||||
$oClientLang->setProperty("newsletter", "html_newsletter", "false");
|
||||
}
|
||||
$oClientLang->setProperty("newsletter", "html_template_idcat", (int) $_REQUEST["selHTMLTemplateCat"]);
|
||||
$oClientLang->setProperty("newsletter", "html_newsletter_idcat", (int) $_REQUEST["selHTMLNewsletterCat"]);
|
||||
$oUser->setProperty("newsletter", "test_idnewsgrp_lang" . $lang, (int) $_REQUEST["selTestDestination"]);
|
||||
} else {
|
||||
// No settings to be stored, get current settings (language sepcific, as lang is client specific, lang is sufficient)
|
||||
$_REQUEST["selTestDestination"] = (int) $oUser->getProperty("newsletter", "test_idnewsgrp_lang" . $lang);
|
||||
}
|
||||
// Default value: Current user mail
|
||||
$sSendTestTarget = $oUser->get("realname") . " (" . $oUser->get("email") . ")";
|
||||
|
||||
##################################
|
||||
# Check external input
|
||||
##################################
|
||||
// Items per page (value stored per area in user property)
|
||||
if (!isset($_REQUEST["elemperpage"]) || !is_numeric($_REQUEST["elemperpage"]) || $_REQUEST["elemperpage"] < 0) {
|
||||
$_REQUEST["elemperpage"] = $oUser->getProperty("itemsperpage", $area);
|
||||
}
|
||||
if (!is_numeric($_REQUEST["elemperpage"])) {
|
||||
// This is the case, if the user property has never been set (first time user)
|
||||
$_REQUEST["elemperpage"] = 25;
|
||||
}
|
||||
if ($_REQUEST["elemperpage"] > 0) {
|
||||
// -- All -- will not be stored, as it may be impossible to change this back to something more useful
|
||||
$oUser->setProperty("itemsperpage", $area, $_REQUEST["elemperpage"]);
|
||||
}
|
||||
$_REQUEST["page"] = (int) $_REQUEST["page"];
|
||||
if ($_REQUEST["page"] <= 0 || $_REQUEST["elemperpage"] == 0) {
|
||||
$_REQUEST["page"] = 1;
|
||||
}
|
||||
// Sort order
|
||||
if ($_REQUEST["sortorder"] != "DESC") {
|
||||
$_REQUEST["sortorder"] = "ASC";
|
||||
}
|
||||
|
||||
// Check sort by and search in criteria
|
||||
$bSortByFound = false;
|
||||
$bSearchInFound = false;
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if ($aData["field"] == $_REQUEST["sortby"] && strpos($aData["type"], "sort") !== false) {
|
||||
$bSortByFound = true;
|
||||
}
|
||||
if ($aData["field"] == $_REQUEST["searchin"] && strpos($aData["type"], "search") !== false) {
|
||||
$bSearchInFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bSortByFound) {
|
||||
$_REQUEST["sortby"] = "name"; // Default sort by field, possible values see above
|
||||
}
|
||||
if (!$bSearchInFound) {
|
||||
$_REQUEST["searchin"] = "--all--";
|
||||
}
|
||||
|
||||
// Free memory
|
||||
unset($oClientLang);
|
||||
unset($oUser);
|
||||
|
||||
##################################
|
||||
# Get data
|
||||
##################################
|
||||
$oNewsletters = new NewsletterCollection;
|
||||
$oNewsletters->setWhere("idclient", $client);
|
||||
$oNewsletters->setWhere("idlang", $lang);
|
||||
|
||||
if ($_REQUEST["filter"] != "") {
|
||||
if ($_REQUEST["searchin"] == "--all--" || $_REQUEST["searchin"] == "") {
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oNewsletters->setWhereGroup("filter", $aData["field"], $_REQUEST["filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
$oNewsletters->setInnerGroupCondition("filter", "OR");
|
||||
} else {
|
||||
$oNewsletters->setWhere($_REQUEST["searchin"], $_REQUEST["filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST["elemperpage"] > 0) {
|
||||
// Getting item count without limit (for page function) - better idea anyone (performance)?
|
||||
$oNewsletters->query();
|
||||
$iItemCount = $oNewsletters->count();
|
||||
|
||||
if ($_REQUEST["elemperpage"] * ($_REQUEST["page"]) >= $iItemCount + $_REQUEST["elemperpage"] && $_REQUEST["page"] != 1) {
|
||||
$_REQUEST["page"] --;
|
||||
}
|
||||
|
||||
$oNewsletters->setLimit($_REQUEST["elemperpage"] * ($_REQUEST["page"] - 1), $_REQUEST["elemperpage"]);
|
||||
} else {
|
||||
$iItemCount = 0;
|
||||
}
|
||||
|
||||
$oNewsletters->setOrder("welcome DESC, " . $_REQUEST["sortby"] . " " . $_REQUEST["sortorder"]);
|
||||
$oNewsletters->query();
|
||||
|
||||
// Output data
|
||||
$oMenu = new UI_Menu;
|
||||
$iMenu = 0;
|
||||
|
||||
// Store messages for repeated use (speeds performance, as i18n translation is only needed once)
|
||||
$aMsg = array();
|
||||
$aMsg["DelTitle"] = i18n("Delete newsletter", "cl_newsletter");
|
||||
$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter:<br>", "cl_newsletter");
|
||||
|
||||
$aMsg["SendTestTitle"] = i18n("Send test newsletter", "cl_newsletter");
|
||||
$aMsg["SendTestTitleOff"] = i18n("Send test newsletter (disabled, check newsletter sender e-mail address and handler article selection)", "cl_newsletter");
|
||||
$aMsg["AddJobTitle"] = i18n("Add newsletter dispatch job", "cl_newsletter");
|
||||
$aMsg["AddJobTitleOff"] = i18n("Add newsletter dispatch job (disabled, check newsletter sender e-mail address and handler article selection)", "cl_newsletter");
|
||||
$aMsg["CopyTitle"] = i18n("Duplicate newsletter", "cl_newsletter");
|
||||
|
||||
while ($oNewsletter = $oNewsletters->next()) {
|
||||
$idnewsletter = $oNewsletter->get("idnews");
|
||||
$iMenu++;
|
||||
|
||||
$sName = $oNewsletter->get("name");
|
||||
if ($oNewsletter->get("welcome")) {
|
||||
$sName = $sName . "*";
|
||||
}
|
||||
|
||||
// Create the link to show/edit the newsletter
|
||||
$oLnk = new cHTMLLink;
|
||||
$oLnk->setMultiLink($area, "", $area, "");
|
||||
$oLnk->setCustom("idnewsletter", $idnewsletter);
|
||||
|
||||
$oMenu->setTitle($iMenu, $sName);
|
||||
$oMenu->setLink($iMenu, $oLnk);
|
||||
|
||||
if ($perm->have_perm_area_action($area, "news_add_job") ||
|
||||
$perm->have_perm_area_action($area, "news_create") ||
|
||||
$perm->have_perm_area_action($area, "news_save")) {
|
||||
// Rights: If you are able to add a job, you should be able to test it
|
||||
// If you are able to add or change a newsletter, you should be able to test it
|
||||
// Usability: If no e-mail has been specified, you can't send a test newsletter
|
||||
if (isValidMail($oNewsletter->get("newsfrom")) && $lIDCatArt > 0) {
|
||||
$sLnkSendTest = '<a title="' . $aMsg["SendTestTitle"] . '" href="javascript://" onclick="showSendTestMsg(' . $idnewsletter . ')"><img src="' . $cfg['path']['images'] . 'newsletter_sendtest_16.gif" border="0" title="' . $aMsg["SendTestTitle"] . '" alt="' . $aMsg["SendTestTitle"] . '" /></a>';
|
||||
} else {
|
||||
$sLnkSendTest = '<img src="' . $cfg['path']['images'] . 'newsletter_sendtest_16_off.gif" border="0" title="' . $aMsg["SendTestTitleOff"] . '" alt="' . $aMsg["SendTestTitleOff"] . '" />';
|
||||
}
|
||||
$oMenu->setActions($iMenu, 'test', $sLnkSendTest);
|
||||
}
|
||||
|
||||
if ($perm->have_perm_area_action($area, "news_add_job")) {
|
||||
if (isValidMail($oNewsletter->get("newsfrom")) && $lIDCatArt > 0) {
|
||||
$oLnkAddJob = new Link;
|
||||
$oLnkAddJob->setMultiLink("news", "", "news", "news_add_job");
|
||||
$oLnkAddJob->setCustom("idnewsletter", $idnewsletter);
|
||||
$oLnkAddJob->setAlt($aMsg["AddJobTitle"]);
|
||||
$oLnkAddJob->setContent('<img src="' . $cfg['path']['images'] . 'newsletter_dispatch_16.gif" border="0" title="' . $aMsg["AddJobTitle"] . '" alt="' . $aMsg["AddJobTitle"] . '">');
|
||||
|
||||
$sLnkAddJob = $oLnkAddJob->render();
|
||||
} else {
|
||||
$sLnkAddJob = '<img src="' . $cfg['path']['images'] . 'newsletter_dispatch_16_off.gif" border="0" title="' . $aMsg["AddJobTitleOff"] . '" alt="' . $aMsg["AddJobTitleOff"] . '" />';
|
||||
}
|
||||
|
||||
$oMenu->setActions($iMenu, 'dispatch', $sLnkAddJob);
|
||||
}
|
||||
|
||||
if ($perm->have_perm_area_action($area, "news_create")) {
|
||||
$oLnkCopy = new Link;
|
||||
$oLnkCopy->setMultiLink("news", "", "news", "news_duplicate");
|
||||
$oLnkCopy->setCustom("idnewsletter", $idnewsletter);
|
||||
$oLnkCopy->setAlt($aMsg["CopyTitle"]);
|
||||
$oLnkCopy->setContent('<img src="' . $cfg['path']['images'] . 'but_copy.gif" border="0" title="' . $aMsg["CopyTitle"] . '" alt="' . $aMsg["CopyTitle"] . '">');
|
||||
|
||||
$oMenu->setActions($iMenu, 'copy', $oLnkCopy->render());
|
||||
}
|
||||
|
||||
if ($perm->have_perm_area_action($area, "news_delete")) {
|
||||
$sDelete = '<a title="' . $aMsg["DelTitle"] . '" href="javascript://" onclick="showDelMsg(' . $idnewsletter . ',\'' . addslashes($sName) . '\')"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . $aMsg["DelTitle"] . '" alt="' . $aMsg["DelTitle"] . '"></a>';
|
||||
$oMenu->setActions($iMenu, 'delete', $sDelete);
|
||||
}
|
||||
}
|
||||
|
||||
// Check destination for sending test newsletter
|
||||
if ($_REQUEST["selTestDestination"] > 0 && $perm->have_perm_area_action($area, "news_send_test")) {
|
||||
$oRcpGroups = new RecipientGroupCollection;
|
||||
$oRcpGroups->setWhere("idclient", $client);
|
||||
$oRcpGroups->setWhere("idlang", $lang);
|
||||
$oRcpGroups->setWhere($oRcpGroups->primaryKey, $_REQUEST["selTestDestination"]);
|
||||
$oRcpGroups->query();
|
||||
|
||||
if ($oRcpGroup = $oRcpGroups->next()) {
|
||||
$sSendTestTarget = sprintf(i18n("Recipient group: %s", "cl_newsletter"), $oRcpGroup->get("groupname"));
|
||||
}
|
||||
unset($oRcpGroups);
|
||||
}
|
||||
|
||||
$aMsg["SendTestDescr"] = sprintf(i18n("Do you really want to send the newsletter to:<br><strong>%s</strong>", "cl_newsletter"), $sSendTestTarget);
|
||||
|
||||
$sExecScript = '
|
||||
<script type="text/javascript">
|
||||
var sid = "' . $sess->id . '";
|
||||
|
||||
// Create messageBox instance
|
||||
box = new messageBox("", "", "", 0, 0);
|
||||
|
||||
function showSendTestMsg(lngId) {
|
||||
box.confirm("' . $aMsg["SendTestTitle"] . '", "' . $aMsg["SendTestDescr"] . '", "sendTestNewsletter(\'" + lngId + "\')");
|
||||
}
|
||||
|
||||
function showDelMsg(lngId, strElement) {
|
||||
box.confirm("' . $aMsg["DelTitle"] . '", "' . $aMsg["DelDescr"] . '<b>" + strElement + "</b>", "deleteNewsletter(\'" + lngId + "\')");
|
||||
}
|
||||
|
||||
//
|
||||
function checkSelection(strValue)
|
||||
{
|
||||
if (strValue == "selection") {
|
||||
document.getElementById("groupselect").disabled = false;
|
||||
} else {
|
||||
document.getElementById("groupselect").disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Function for sending test newsletter
|
||||
function sendTestNewsletter(idnewsletter)
|
||||
{
|
||||
oForm = top.content.left.left_top.document.getElementById("newsletter_listoptionsform");
|
||||
|
||||
url = "main.php?area=news";
|
||||
url += "&action=news_send_test";
|
||||
url += "&frame=4";
|
||||
url += "&idnewsletter=" + idnewsletter;
|
||||
url += "&contenido=" + sid;
|
||||
url += get_registered_parameters();
|
||||
url += "&sortby=" + oForm.sortby.value;
|
||||
url += "&sortorder=" + oForm.sortorder.value;
|
||||
url += "&filter=" + oForm.filter.value;
|
||||
url += "&elemperpage=" + oForm.elemperpage.value;
|
||||
|
||||
parent.parent.right.right_bottom.location.href = url;
|
||||
}
|
||||
|
||||
// Function for deleting newsletters
|
||||
function deleteNewsletter(idnewsletter)
|
||||
{
|
||||
oForm = top.content.left.left_top.document.getElementById("newsletter_listoptionsform");
|
||||
|
||||
url = "main.php?area=news";
|
||||
url += "&action=news_delete";
|
||||
url += "&frame=4";
|
||||
url += "&idnewsletter=" + idnewsletter;
|
||||
url += "&contenido=" + sid;
|
||||
url += get_registered_parameters();
|
||||
url += "&sortby=" + oForm.sortby.value;
|
||||
url += "&sortorder=" + oForm.sortorder.value;
|
||||
url += "&filter=" + oForm.filter.value;
|
||||
url += "&elemperpage=" + oForm.elemperpage.value;
|
||||
|
||||
parent.parent.right.right_bottom.location.href = url;
|
||||
}
|
||||
</script>';
|
||||
|
||||
$oPage->setMargin(0);
|
||||
|
||||
// Messagebox JS has to be included before ExecScript!
|
||||
$oPage->addScript('messagebox', '<script type="text/javascript" src="scripts/messageBox.js.php?contenido=' . $sess->id . '"></script>');
|
||||
$oPage->addScript('exec', $sExecScript);
|
||||
$oPage->addScript('parameterCollector.js', '<script language="JavaScript" src="scripts/parameterCollector.js"></script>');
|
||||
|
||||
// Generate current content for Object Pager
|
||||
$sPagerId = "0ed6d632-6adf-4f09-a0c6-1e38ab60e302";
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setTargetFrame('left_bottom');
|
||||
$oPagerLink->setCustom("elemperpage", $_REQUEST["elemperpage"]);
|
||||
$oPagerLink->setCustom("filter", $_REQUEST["filter"]);
|
||||
$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
|
||||
$oPagerLink->setCustom("sortby", $_REQUEST["sortby"]);
|
||||
$oPagerLink->setCustom("sortorder", $_REQUEST["sortorder"]);
|
||||
$oPagerLink->setCustom("searchin", $_REQUEST["searchin"]);
|
||||
$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
|
||||
$oPagerLink->setCustom("frame", 2);
|
||||
$oPagerLink->setCustom("area", $area);
|
||||
$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
// Note, that after the "page" parameter no "pagerlink" parameter is specified -
|
||||
// it is not used, as the JS below only uses the INNER html and the "pagerlink" parameter is
|
||||
// set by ...left_top.html for the foldingrow itself
|
||||
$oPager = new cObjectPager($sPagerId, $iItemCount, $_REQUEST["elemperpage"], $_REQUEST["page"], $oPagerLink, "page");
|
||||
|
||||
// Add slashes, to insert in javascript
|
||||
$sPagerContent = $oPager->render(1);
|
||||
$sPagerContent = str_replace('\\', '\\\\', $sPagerContent);
|
||||
$sPagerContent = str_replace('\'', '\\\'', $sPagerContent);
|
||||
|
||||
// Send new object pager to left_top
|
||||
$oPage->addScript('setpager', '<script type="text/javascript" src="scripts/setPager.js"></script>');
|
||||
|
||||
$sRefreshPager = '
|
||||
<script type="text/javascript">
|
||||
var sNavigation = \'' . $sPagerContent . '\';
|
||||
|
||||
// Activate time to refresh pager folding row in left top
|
||||
var oTimer = window.setInterval("fncSetPager(\'' . $sPagerId . '\',\'' . $_REQUEST["page"] . '\')", 200);
|
||||
</script>';
|
||||
|
||||
$oPage->addScript('refreshpager', $sRefreshPager);
|
||||
|
||||
$oPage->setContent($oMenu->render(false));
|
||||
$oPage->render();
|
||||
?>
|
||||
65
includes/include.newsletter_subnav.php
Normale Datei
65
includes/include.newsletter_subnav.php
Normale Datei
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Custom subnavigation for the newsletters
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.0.1
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
* modified 2010-05-20, Murat Purc, removed request check during processing ticket [#CON-307]
|
||||
*
|
||||
* $Id: include.newsletter_subnav.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['idnewsletter']))
|
||||
{
|
||||
# Set template data
|
||||
$sCaption = i18n("Edit", "cl_newsletter");
|
||||
|
||||
$tpl->set("d", "ID", 'c_'.$tpl->dyn_cnt);
|
||||
$tpl->set("d", "CLASS", '');
|
||||
$tpl->set("d", "OPTIONS", '');
|
||||
$tpl->set("d", "CAPTION", '<a class="white" onclick="sub.clicked(this)" target="right_bottom" href="'.$sess->url("main.php?area=news&frame=4&idnewsletter=$idnewsletter").'">'.$sCaption.'</a>');
|
||||
$tpl->next();
|
||||
|
||||
# Set template data
|
||||
$sCaption = i18n("Edit Message", "cl_newsletter");
|
||||
|
||||
$tpl->set("d", "ID", 'c_'.$tpl->dyn_cnt);
|
||||
$tpl->set("d", "CLASS", '');
|
||||
$tpl->set("d", "OPTIONS", '');
|
||||
$tpl->set("d", "CAPTION", '<a class="white" onclick="sub.clicked(this)" target="right_bottom" href="'.$sess->url("main.php?area=news_edit&frame=4&idnewsletter=$idnewsletter").'">'.$sCaption.'</a>');
|
||||
$tpl->next();
|
||||
|
||||
$tpl->set('s', 'COLSPAN', ($tpl->dyn_cnt * 2) + 2);
|
||||
|
||||
# Generate the third navigation layer
|
||||
$tpl->generate($cfg["path"]["templates"] . $cfg["templates"]["subnav"]);
|
||||
} else {
|
||||
include ($cfg["path"]["contenido"].$cfg["path"]["templates"] . $cfg["templates"]["right_top_blank"]);
|
||||
}
|
||||
|
||||
?>
|
||||
72
includes/include.recipients.group.subnav.php
Normale Datei
72
includes/include.recipients.group.subnav.php
Normale Datei
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Custom subnavigation for the newsletter recipient groups
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.0.1
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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 2004-08-01, Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
* modified 2010-05-20, Murat Purc, removed request check during processing ticket [#CON-307]
|
||||
*
|
||||
* $Id: include.recipients.group.subnav.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['idrecipientgroup']) && (int) $_GET['idrecipientgroup'] > 0) {
|
||||
$caption = i18n("Overview", "cl_newsletter");
|
||||
$tmp_area = "foo2";
|
||||
|
||||
# Set template data
|
||||
$tpl->set("d", "ID", 'c_' . $tpl->dyn_cnt);
|
||||
$tpl->set("d", "CLASS", '');
|
||||
$tpl->set("d", "OPTIONS", '');
|
||||
$tpl->set("d", "CAPTION", '<a class="white" onclick="sub.clicked(this)" target="right_bottom" href="' . $sess->url("main.php?area=$area&frame=4&idrecipientgroup=$idrecipientgroup") . '">' . $caption . '</a>');
|
||||
$tpl->next();
|
||||
|
||||
if (is_array($cfg['plugins']['recipientslogic'])) {
|
||||
foreach ($cfg['plugins']['recipientslogic'] as $plugin) {
|
||||
cInclude("plugins", "recipientslogic/$plugin/" . $plugin . ".php");
|
||||
|
||||
$className = "recipientslogic_" . $plugin;
|
||||
$class = new $className;
|
||||
|
||||
$caption = $class->getFriendlyName();
|
||||
$tmp_area = "foo2";
|
||||
$tpl->set("d", "ID", 'c_' . $tpl->dyn_cnt);
|
||||
$tpl->set("d", "CLASS", '');
|
||||
$tpl->set("d", "OPTIONS", '');
|
||||
$tpl->set("d", "CAPTION", '<a class="white" onclick="sub.clicked(this)" target="right_bottom" href="' . $sess->url("main.php?area=recipientgroup_rights&frame=4&useplugin=$plugin&idrecipientgroup=$idrecipientgroup") . '">' . $caption . '</a>');
|
||||
$tpl->next();
|
||||
}
|
||||
}
|
||||
|
||||
$tpl->set('s', 'COLSPAN', ($tpl->dyn_cnt * 2) + 2);
|
||||
|
||||
# Generate the third navigation layer
|
||||
$tpl->generate($cfg["path"]["templates"] . $cfg["templates"]["subnav"]);
|
||||
} else {
|
||||
include ($cfg["path"]["contenido"] . $cfg["path"]["templates"] . $cfg["templates"]["right_top_blank"]);
|
||||
}
|
||||
?>
|
||||
568
includes/include.recipients.group_edit.php
Normale Datei
568
includes/include.recipients.group_edit.php
Normale Datei
|
|
@ -0,0 +1,568 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Recipient group editor
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.1.1
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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 2004-08-01, Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: include.recipients.group_edit.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
// Initialization
|
||||
$oPage = new cPage;
|
||||
$oRGroups = new RecipientGroupCollection;
|
||||
$oRGroupMembers = new RecipientGroupMemberCollection;
|
||||
$oRGroup = new RecipientGroup;
|
||||
|
||||
$aFields = array();
|
||||
$aFields["name"] = array("field" => "name", "caption" => i18n("Name", "cl_newsletter"), "type" => "base,sort,search");
|
||||
$aFields["email"] = array("field" => "email", "caption" => i18n("E-Mail", "cl_newsletter"), "type" => "base,sort,search");
|
||||
$aFields["confirmed"] = array("field" => "confirmed", "caption" => i18n("Confirmed", "cl_newsletter"), "type" => "base");
|
||||
$aFields["deactivated"] = array("field" => "deactivated", "caption" => i18n("Deactivated", "cl_newsletter"), "type" => "base");
|
||||
|
||||
if ($action == "recipientgroup_create" && $perm->have_perm_area_action($area, $action)) {
|
||||
$oRGroup = $oRGroups->create(" " . i18n("-- new group --", "cl_newsletter"));
|
||||
$_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)) {
|
||||
$oRGroups->delete($_REQUEST["idrecipientgroup"]);
|
||||
$sRefreshLeftTopScript = '<script type="text/javascript">top.content.left.left_top.refreshGroupOption(\'' . $_REQUEST["idrecipientgroup"] . '\', \'remove\')</script>';
|
||||
$oPage->addScript('refreshlefttop', $sRefreshLeftTopScript);
|
||||
|
||||
$_REQUEST["idrecipientgroup"] = 0;
|
||||
$oRGroup = new RecipientGroup;
|
||||
$oPage->setReload();
|
||||
} else {
|
||||
$oRGroup->loadByPrimaryKey($_REQUEST["idrecipientgroup"]);
|
||||
}
|
||||
|
||||
if ($oRGroup->virgin == false && $oRGroup->get("idclient") == $client && $oRGroup->get("idlang") == $lang) {
|
||||
if ($action == "recipientgroup_save_group" && $perm->have_perm_area_action($area, $action)) {
|
||||
// Saving changes
|
||||
$aMessages = array();
|
||||
$bReload = false;
|
||||
|
||||
$sGroupName = stripslashes($_REQUEST["groupname"]);
|
||||
if ($oRGroup->get("groupname") != $sGroupName) {
|
||||
$oRGroups->resetQuery();
|
||||
$oRGroups->setWhere("groupname", $sGroupName);
|
||||
$oRGroups->setWhere("idclient", $client);
|
||||
$oRGroups->setWhere("idlang", $lang);
|
||||
$oRGroups->setWhere($oRGroup->primaryKey, $oRGroup->get($oRGroup->primaryKey), "!=");
|
||||
$oRGroups->query();
|
||||
|
||||
if ($oRGroups->next()) {
|
||||
$aMessages[] = i18n("Could not set new group name: Group already exists", "cl_newsletter");
|
||||
} else {
|
||||
$bReload = true;
|
||||
|
||||
$oRGroup->set("groupname", $sGroupName);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($_REQUEST["adduser"]) > 0) {
|
||||
foreach ($_REQUEST["adduser"] as $iRcpID) {
|
||||
if (is_numeric($iRcpID)) {
|
||||
$oRGroupMembers->create($_REQUEST["idrecipientgroup"], $iRcpID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oRGroup->get("defaultgroup") != (int) $_REQUEST["defaultgroup"]) {
|
||||
$bReload = true;
|
||||
$oRGroup->set("defaultgroup", $_REQUEST["defaultgroup"]);
|
||||
}
|
||||
|
||||
$oRGroup->store();
|
||||
|
||||
if ($bReload) {
|
||||
$oPage->setReload();
|
||||
}
|
||||
|
||||
// Removing users from group (if specified)
|
||||
//print_r ($_REQUEST["deluser"]);
|
||||
if ($perm->have_perm_area_action($area, "recipientgroup_recipient_delete") && is_array($_REQUEST["deluser"])) {
|
||||
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 ($_REQUEST["outsider_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_outsider", $_REQUEST["outsider_elemperpage"]);
|
||||
}
|
||||
unset($oUser);
|
||||
|
||||
if (!isset($_REQUEST["member_page"]) || !is_numeric($_REQUEST["member_page"]) || $_REQUEST["member_page"] <= 0 || $_REQUEST["member_elemperpage"] == 0) {
|
||||
$_REQUEST["member_page"] = 1;
|
||||
}
|
||||
if ($_REQUEST["member_sortorder"] != "DESC") {
|
||||
$_REQUEST["member_sortorder"] = "ASC";
|
||||
}
|
||||
if (!isset($_REQUEST["outsider_page"]) || !is_numeric($_REQUEST["outsider_page"]) || $_REQUEST["outsider_page"] <= 0 || $_REQUEST["outsider_elemperpage"] == 0) {
|
||||
$_REQUEST["outsider_page"] = 1;
|
||||
}
|
||||
if ($_REQUEST["outsider_sortorder"] != "DESC") {
|
||||
$_REQUEST["outsider_sortorder"] = "ASC";
|
||||
}
|
||||
|
||||
// Output form
|
||||
$oForm = new UI_Table_Form("properties", "main.php?1", "get"); // Use "get" for folding rows...
|
||||
$oForm->setVar("frame", $frame);
|
||||
$oForm->setVar("area", $area);
|
||||
$oForm->setVar("action", "recipientgroup_save_group");
|
||||
$oForm->setVar("idrecipientgroup", $_REQUEST["idrecipientgroup"]);
|
||||
$oForm->setSubmitJS("append_registered_parameters(this);");
|
||||
|
||||
$oForm->addHeader(i18n("Edit group", "cl_newsletter"));
|
||||
|
||||
$oTxtGroupName = new cHTMLTextbox("groupname", $oRGroup->get("groupname"), 40);
|
||||
$oForm->add(i18n("Group name", "cl_newsletter"), $oTxtGroupName->render());
|
||||
|
||||
$oCkbDefault = new cHTMLCheckbox("defaultgroup", "1");
|
||||
$oCkbDefault->setChecked($oRGroup->get("defaultgroup"));
|
||||
$oForm->add(i18n("Default group", "cl_newsletter"), $oCkbDefault->toHTML(false));
|
||||
|
||||
// Member list options folding row
|
||||
$oMemberListOptionRow = new cFoldingRow("a91f5540-52db-11db-b0de-0800200c9a66", i18n("Member list options", "cl_newsletter"));
|
||||
|
||||
$oSelItemsPerPage = new cHTMLSelectElement("member_elemperpage");
|
||||
$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100));
|
||||
$oSelItemsPerPage->setDefault($_REQUEST["member_elemperpage"]);
|
||||
|
||||
$oSelSortBy = new cHTMLSelectElement("member_sortby");
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "sort") !== false) {
|
||||
if ($_REQUEST["member_sortby"] == "") {
|
||||
$_REQUEST["member_sortby"] = $aData["field"];
|
||||
}
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]);
|
||||
$oSelSortBy->addOptionElement($aData["field"], $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSortBy->setDefault($_REQUEST["member_sortby"]);
|
||||
|
||||
$oSelSortOrder = new cHTMLSelectElement("member_sortorder");
|
||||
$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter")));
|
||||
$oSelSortOrder->setDefault($_REQUEST["member_sortorder"]);
|
||||
|
||||
$oTxtFilter = new cHTMLTextbox("member_filter", $_REQUEST["member_filter"], 16);
|
||||
|
||||
$oSelSearchIn = new cHTMLSelectElement("member_searchin");
|
||||
$oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--");
|
||||
$oSelSearchIn->addOptionElement("all", $oOption);
|
||||
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]);
|
||||
$oSelSearchIn->addOptionElement($aData["field"], $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSearchIn->setDefault($_REQUEST["member_searchin"]);
|
||||
|
||||
$oSubmit = new cHTMLButton("submit", i18n("Apply", "cl_newsletter"));
|
||||
|
||||
$sContent = '<div style="border-bottom: 1px solid black; background: ' . $cfg['color']['table_dark'] . ';">' . chr(10);
|
||||
$sContent .= ' <table>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Items / page", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSelItemsPerPage->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Sort by", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSelSortBy->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Sort order", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSelSortOrder->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Search for", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oTxtFilter->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Search in", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSelSearchIn->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td> </td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSubmit->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' </table>' . chr(10);
|
||||
$sContent .= '</div>' . chr(10);
|
||||
$oMemberListOptionRow->setContentData($sContent);
|
||||
|
||||
// Members
|
||||
$oAddedRecipientList = new UI_List;
|
||||
$oAddedRecipientList->setWidth("100%");
|
||||
$oAddedRecipientList->setBorder(1);
|
||||
|
||||
$oAddedRecipientList->setCell(0, 1, "<strong>" . i18n("Name", "cl_newsletter") . "</strong>");
|
||||
$oImgDel = new cHTMLImage("images/but_invert_selection.gif");
|
||||
$sLnkDelIcon = '<a title="' . i18n("Check all", "cl_newsletter") . '" href="javascript://" onclick="fncCheckDel(\'deluser[]\');">' . $oImgDel->render() . '</a>';
|
||||
$oAddedRecipientList->setCell(0, 2, $sLnkDelIcon);
|
||||
$oAddedRecipientList->setCellAlignment(0, 2, "right");
|
||||
|
||||
$oInsiders = new RecipientCollection;
|
||||
|
||||
$oInsiders->link("RecipientGroupMemberCollection");
|
||||
$oInsiders->setWhere("recipientcollection.idclient", $client);
|
||||
$oInsiders->setWhere("recipientcollection.idlang", $lang);
|
||||
$oInsiders->setWhere("RecipientGroupMemberCollection.idnewsgroup", $_REQUEST["idrecipientgroup"]);
|
||||
|
||||
// Get insiders for outsiders list (*sigh!*)
|
||||
// TODO: Ask user to have at least mySQL 4.1...
|
||||
$oInsiders->query();
|
||||
|
||||
$aInsiders = array();
|
||||
if ($oInsiders->count() > 0) {
|
||||
while ($oInsider = $oInsiders->next()) {
|
||||
$aInsiders[] = $oInsider->get($oInsider->primaryKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter
|
||||
if ($_REQUEST["member_filter"] != "") {
|
||||
if ($_REQUEST["member_searchin"] == "--all--" || $_REQUEST["member_searchin"] == "") {
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oInsiders->setWhereGroup("filter", "recipientcollection." . $aData["field"], $_REQUEST["member_filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
$oInsiders->setInnerGroupCondition("filter", "OR");
|
||||
} else {
|
||||
$oInsiders->setWhere("recipientcollection." . $_REQUEST["member_searchin"], $_REQUEST["member_filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
|
||||
// If elemperpage is something else than "all", get item count based on filters
|
||||
if ($_REQUEST["member_elemperpage"] > 0) {
|
||||
$oInsiders->query();
|
||||
$iMembers = $oInsiders->count(); // Getting item count without limit (for page function) - better idea anybody (performance)?
|
||||
|
||||
$oInsiders->setLimit($_REQUEST["member_elemperpage"] * ($_REQUEST["member_page"] - 1), $_REQUEST["member_elemperpage"]);
|
||||
} else {
|
||||
$iMembers = 0;
|
||||
}
|
||||
|
||||
// Get data
|
||||
$sSortSQL = "recipientcollection." . $_REQUEST["member_sortby"] . " " . $_REQUEST["member_sortorder"];
|
||||
if ($_REQUEST["member_sortby"] == "name") {
|
||||
// Name field may be empty, add email as sort criteria
|
||||
$sSortSQL .= ", email " . $_REQUEST["member_sortorder"];
|
||||
}
|
||||
|
||||
$oInsiders->setOrder($sSortSQL);
|
||||
$oInsiders->query();
|
||||
|
||||
$iItems = $oInsiders->count();
|
||||
if ($iItems == 0 && $_REQUEST["member_filter"] == "" && ($_REQUEST["member_elemperpage"] == 0 || $iMembers == 0)) {
|
||||
$oAddedRecipientList->setCell(1, 1, i18n("No recipients are added to this group yet", "cl_newsletter"));
|
||||
$oAddedRecipientList->setCell(1, 2, ' ');
|
||||
} else if ($iItems == 0) {
|
||||
$oAddedRecipientList->setCell(1, 1, i18n("No recipients found", "cl_newsletter"));
|
||||
$oAddedRecipientList->setCell(1, 2, ' ');
|
||||
} else {
|
||||
while ($oRcp = $oInsiders->next()) {
|
||||
$iID = $oRcp->get("idnewsrcp");
|
||||
|
||||
$sName = $oRcp->get("name");
|
||||
$sEMail = $oRcp->get("email");
|
||||
if (empty($sName)) {
|
||||
$sName = $sEMail;
|
||||
}
|
||||
$oAddedRecipientList->setCell($iID, 1, $sName . " (" . $sEMail . ")");
|
||||
|
||||
if ($perm->have_perm_area_action($area, "recipientgroup_recipient_delete")) {
|
||||
$oCkbDel = new cHTMLCheckbox("deluser[]", $iID);
|
||||
$oAddedRecipientList->setCell($iID, 2, $oCkbDel->toHTML(false));
|
||||
} else {
|
||||
$oAddedRecipientList->setCell($iID, 2, " ");
|
||||
}
|
||||
$oAddedRecipientList->setCellAlignment($iID, 2, "right");
|
||||
}
|
||||
}
|
||||
|
||||
// Member list pager (-> below data, as iMembers is needed)
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setCustom("member_elemperpage", $_REQUEST["member_elemperpage"]);
|
||||
$oPagerLink->setCustom("member_filter", $_REQUEST["member_filter"]);
|
||||
$oPagerLink->setCustom("member_sortby", $_REQUEST["member_sortby"]);
|
||||
$oPagerLink->setCustom("member_sortorder", $_REQUEST["member_sortorder"]);
|
||||
$oPagerLink->setCustom("member_searchin", $_REQUEST["member_searchin"]);
|
||||
$oPagerLink->setCustom("outsider_elemperpage", $_REQUEST["outsider_elemperpage"]);
|
||||
$oPagerLink->setCustom("outsider_filter", $_REQUEST["outsider_filter"]);
|
||||
$oPagerLink->setCustom("outsider_sortby", $_REQUEST["outsider_sortby"]);
|
||||
$oPagerLink->setCustom("outsider_sortorder", $_REQUEST["outsider_sortorder"]);
|
||||
$oPagerLink->setCustom("outsider_searchin", $_REQUEST["outsider_searchin"]);
|
||||
$oPagerLink->setCustom("idrecipientgroup", $_REQUEST["idrecipientgroup"]);
|
||||
$oPagerLink->setCustom("frame", $frame);
|
||||
$oPagerLink->setCustom("area", $area);
|
||||
#$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
|
||||
$oMemberPager = new cObjectPager("d82a3ff0-52d9-11db-b0de-0800200c9a66", $iMembers, $_REQUEST["member_elemperpage"], $_REQUEST["member_page"], $oPagerLink, "member_page");
|
||||
$oMemberPager->setCaption(i18n("Member navigation", "cl_newsletter"));
|
||||
|
||||
$oForm->add(i18n("Recipients in group", "cl_newsletter"), '<table border="0" cellspacing="0" cellpadding="0" width="100%">' .
|
||||
$oMemberListOptionRow->render() .
|
||||
$oMemberPager->render() .
|
||||
'<tr><td>' . $oAddedRecipientList->render() . '</td></tr></table>');
|
||||
unset($oInsiders);
|
||||
unset($oMemberListOptionRow);
|
||||
unset($oMemberPager);
|
||||
unset($oAddedRecipientList);
|
||||
|
||||
// Outsiders
|
||||
// Outsider list options folding row
|
||||
$oOutsiderListOptionRow = new cFoldingRow("ca633b00-52e9-11db-b0de-0800200c9a66", i18n("Outsider list options", "cl_newsletter"));
|
||||
|
||||
$oSelItemsPerPage = new cHTMLSelectElement("outsider_elemperpage");
|
||||
$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100));
|
||||
$oSelItemsPerPage->setDefault($_REQUEST["outsider_elemperpage"]);
|
||||
|
||||
$oSelSortBy = new cHTMLSelectElement("outsider_sortby");
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "sort") !== false) {
|
||||
if ($_REQUEST["outsider_sortby"] == "") {
|
||||
$_REQUEST["outsider_sortby"] = $aData["field"];
|
||||
}
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]);
|
||||
$oSelSortBy->addOptionElement($aData["field"], $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSortBy->setDefault($_REQUEST["outsider_sortby"]);
|
||||
|
||||
$oSelSortOrder = new cHTMLSelectElement("outsider_sortorder");
|
||||
$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter")));
|
||||
$oSelSortOrder->setDefault($_REQUEST["outsider_sortorder"]);
|
||||
|
||||
$oTxtFilter = new cHTMLTextbox("outsider_filter", $_REQUEST["outsider_filter"], 16);
|
||||
|
||||
$oSelSearchIn = new cHTMLSelectElement("outsider_searchin");
|
||||
$oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--");
|
||||
$oSelSearchIn->addOptionElement("all", $oOption);
|
||||
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]);
|
||||
$oSelSearchIn->addOptionElement($aData["field"], $oOption);
|
||||
}
|
||||
}
|
||||
$oSelSearchIn->setDefault($_REQUEST["outsider_searchin"]);
|
||||
|
||||
$oSubmit = new cHTMLButton("submit", i18n("Apply", "cl_newsletter"));
|
||||
|
||||
$sContent = '<div style="border-bottom: 1px solid black; background: ' . $cfg['color']['table_dark'] . ';">' . chr(10);
|
||||
$sContent .= ' <table>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Items / page", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSelItemsPerPage->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Sort by", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSelSortBy->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Sort order", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSelSortOrder->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Search for", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oTxtFilter->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td>' . i18n("Search in", "cl_newsletter") . '</td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSelSearchIn->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' <tr>' . chr(10);
|
||||
$sContent .= ' <td> </td>' . chr(10);
|
||||
$sContent .= ' <td>' . $oSubmit->render() . '</td>' . chr(10);
|
||||
$sContent .= ' </tr>' . chr(10);
|
||||
$sContent .= ' </table>' . chr(10);
|
||||
$sContent .= '</div>' . chr(10);
|
||||
$oOutsiderListOptionRow->setContentData($sContent);
|
||||
|
||||
// TODO: Try to enhance genericdb to get this working with the usual objects...
|
||||
$oOutsiders = new RecipientCollection;
|
||||
|
||||
# This requires mySQL V4.1, at least...
|
||||
# TODO: Add mySQL server version switch
|
||||
#$sSQL = "idclient = '".$client."' AND idlang = '".$lang."' AND ".
|
||||
# "idnewsrcp NOT IN (SELECT idnewsrcp FROM ".$cfg["tab"]["news_groupmembers"]." WHERE idnewsgroup = '".$_REQUEST["idrecipientgroup"]."')";
|
||||
// TODO: This works with every mySQL version but may be problematic, if a group
|
||||
// contains a lot of members (e.g. Oracle can't handle more than 1000 items in the brackets)
|
||||
$sSQL = "idclient = '" . $client . "' AND idlang = '" . $lang . "' AND " .
|
||||
"idnewsrcp NOT IN ('" . implode("','", $aInsiders) . "')";
|
||||
|
||||
if ($_REQUEST["outsider_filter"] != "") {
|
||||
$sSQLSearchIn = "";
|
||||
if ($_REQUEST["outsider_searchin"] == "--all--" || $_REQUEST["outsider_searchin"] == "") {
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
if ($sSQLSearchIn !== "") {
|
||||
$sSQLSearchIn .= " OR ";
|
||||
}
|
||||
$sSQLSearchIn .= $aData["field"] . " LIKE '%" . urlencode($_REQUEST["outsider_filter"]) . "%'";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sSQLSearchIn .= urlencode($_REQUEST["outsider_searchin"]) . " LIKE '%" . urlencode($_REQUEST["outsider_filter"]) . "%'";
|
||||
}
|
||||
$sSQL .= " AND (" . $sSQLSearchIn . ")";
|
||||
}
|
||||
|
||||
// If elemperpage is something else than "all", get item count based on filters
|
||||
if ($_REQUEST["outsider_elemperpage"] > 0) {
|
||||
$oOutsiders->flexSelect("", "", $sSQL, "");
|
||||
$iOutsiders = $oOutsiders->count(); // Getting item count without limit (for page function) - better idea anyone (performance)?
|
||||
|
||||
$sSQLLimit = " LIMIT " . $_REQUEST["outsider_elemperpage"] * ($_REQUEST["outsider_page"] - 1) . ", " . $_REQUEST["outsider_elemperpage"];
|
||||
} else {
|
||||
$iMembers = 0;
|
||||
$sSQLLimit = "";
|
||||
}
|
||||
|
||||
// Get data
|
||||
$sSQLSort = " ORDER BY " . urlencode($_REQUEST["outsider_sortby"]) . " " . $_REQUEST["outsider_sortorder"];
|
||||
if ($_REQUEST["outsider_sortby"] == "name") {
|
||||
// Name field may be empty, add email as sort criteria
|
||||
$sSQLSort .= ", email " . $_REQUEST["outsider_sortorder"];
|
||||
}
|
||||
|
||||
$sSQL .= $sSQLSort . $sSQLLimit;
|
||||
$oOutsiders->flexSelect("", "", $sSQL, "");
|
||||
|
||||
$aItems = array();
|
||||
while ($oRecipient = $oOutsiders->next()) {
|
||||
$sName = $oRecipient->get("name");
|
||||
$sEMail = $oRecipient->get("email");
|
||||
|
||||
if (empty($sName)) {
|
||||
$sName = $sEMail;
|
||||
}
|
||||
$aItems[] = array($oRecipient->get("idnewsrcp"), $sName . " (" . $sEMail . ")");
|
||||
}
|
||||
|
||||
$oSelUser = new cHTMLSelectElement("adduser[]");
|
||||
$oSelUser->setSize(25);
|
||||
$oSelUser->setStyle("width: 100%;");
|
||||
$oSelUser->setMultiSelect();
|
||||
$oSelUser->autoFill($aItems);
|
||||
|
||||
// Outsider list pager (-> below data, as iOutsiders is needed)
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setCustom("member_elemperpage", $_REQUEST["member_elemperpage"]);
|
||||
$oPagerLink->setCustom("member_filter", $_REQUEST["member_filter"]);
|
||||
$oPagerLink->setCustom("member_sortby", $_REQUEST["member_sortby"]);
|
||||
$oPagerLink->setCustom("member_sortorder", $_REQUEST["member_sortorder"]);
|
||||
$oPagerLink->setCustom("member_searchin", $_REQUEST["member_searchin"]);
|
||||
$oPagerLink->setCustom("outsider_elemperpage", $_REQUEST["outsider_elemperpage"]);
|
||||
$oPagerLink->setCustom("outsider_filter", $_REQUEST["outsider_filter"]);
|
||||
$oPagerLink->setCustom("outsider_sortby", $_REQUEST["outsider_sortby"]);
|
||||
$oPagerLink->setCustom("outsider_sortorder", $_REQUEST["outsider_sortorder"]);
|
||||
$oPagerLink->setCustom("outsider_searchin", $_REQUEST["outsider_searchin"]);
|
||||
$oPagerLink->setCustom("idrecipientgroup", $_REQUEST["idrecipientgroup"]);
|
||||
$oPagerLink->setCustom("frame", $frame);
|
||||
$oPagerLink->setCustom("area", $area);
|
||||
#$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
|
||||
$oOutsiderPager = new cObjectPager("4d3a7330-52eb-11db-b0de-0800200c9a66", $iOutsiders, $_REQUEST["outsider_elemperpage"], $_REQUEST["outsider_page"], $oPagerLink, "outsider_page");
|
||||
$oOutsiderPager->setCaption(i18n("Outsider navigation", "cl_newsletter"));
|
||||
|
||||
$oForm->add(i18n("Add recipients", "cl_newsletter"), '<table border="0" cellspacing="0" cellpadding="0" width="100%">' .
|
||||
$oOutsiderListOptionRow->render() .
|
||||
$oOutsiderPager->render() .
|
||||
'<tr><td>' . $oSelUser->render() . '<br />' . i18n("Note: Hold <Ctrl> to<br>select multiple items.", "cl_newsletter") . '</td></tr></table>');
|
||||
unset($oOutsiders);
|
||||
unset($oOutsiderListOptionRow);
|
||||
unset($oOutsiderPager);
|
||||
|
||||
$sDelMarkScript = ' <script type="text/javascript">
|
||||
/* Function to select all ckbDel boxes */
|
||||
function fncCheckDel(elementname) {
|
||||
var aBoxes = document.getElementsByName(elementname);
|
||||
|
||||
if (aBoxes.length > 0) {
|
||||
for (var i = 0; i < aBoxes.length; i++) {
|
||||
if (aBoxes[i].checked) {
|
||||
aBoxes[i].checked = false;
|
||||
} else {
|
||||
aBoxes[i].checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
$oPage->addScript('DelMarkScript', $sDelMarkScript);
|
||||
$oPage->addScript('cfoldingrow.js', '<script language="JavaScript" src="scripts/cfoldingrow.js"></script>');
|
||||
$oPage->addScript('parameterCollector.js', '<script language="JavaScript" src="scripts/parameterCollector.js"></script>');
|
||||
|
||||
$oPage->setContent($sNotis . $oForm->render(true));
|
||||
} else {
|
||||
$oPage->setContent($sNotis . "");
|
||||
}
|
||||
$oPage->render();
|
||||
?>
|
||||
234
includes/include.recipients.group_menu.php
Normale Datei
234
includes/include.recipients.group_menu.php
Normale Datei
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Frontend group list
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.6.0
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: include.recipients.group_menu.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
# Initialization
|
||||
##################################
|
||||
$oPage = new cPage;
|
||||
$oMenu = new UI_Menu;
|
||||
$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" => "groupname", "caption" => i18n("Name", "cl_newsletter"), "type" => "base,sort,search");
|
||||
|
||||
##################################
|
||||
# Check external input
|
||||
##################################
|
||||
// Items per page (value stored per area in user property)
|
||||
if (!isset($_REQUEST["elemperpage"]) || !is_numeric($_REQUEST["elemperpage"]) || $_REQUEST["elemperpage"] < 0) {
|
||||
$_REQUEST["elemperpage"] = $oUser->getProperty("itemsperpage", $area);
|
||||
}
|
||||
if (!is_numeric($_REQUEST["elemperpage"])) {
|
||||
// This is the case, if the user property has never been set (first time user)
|
||||
$_REQUEST["elemperpage"] = 25;
|
||||
}
|
||||
if ($_REQUEST["elemperpage"] > 0) {
|
||||
// -- All -- will not be stored, as it may be impossible to change this back to something more useful
|
||||
$oUser->setProperty("itemsperpage", $area, $_REQUEST["elemperpage"]);
|
||||
}
|
||||
$_REQUEST["page"] = (int) $_REQUEST["page"];
|
||||
if ($_REQUEST["page"] <= 0 || $_REQUEST["elemperpage"] == 0) {
|
||||
$_REQUEST["page"] = 1;
|
||||
}
|
||||
// Sort order
|
||||
if ($_REQUEST["sortorder"] != "DESC") {
|
||||
$_REQUEST["sortorder"] = "ASC";
|
||||
}
|
||||
|
||||
// Don't need to check sort by and search in criteria - just set it
|
||||
$_REQUEST["sortby"] = "groupname"; // Default sort by field, possible values see above
|
||||
$_REQUEST["searchin"] = "--all--";
|
||||
|
||||
// Free memory
|
||||
unset($oUser);
|
||||
unset($oClient);
|
||||
|
||||
##################################
|
||||
# Get data
|
||||
##################################
|
||||
$oRcpGroups = new RecipientGroupCollection;
|
||||
$oRcpGroups->setWhere("idclient", $client);
|
||||
$oRcpGroups->setWhere("idlang", $lang);
|
||||
|
||||
if ($_REQUEST["filter"] != "") {
|
||||
if ($_REQUEST["searchin"] == "--all--" || $_REQUEST["searchin"] == "") {
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oRcpGroups->setWhereGroup("filter", $aData["field"], $_REQUEST["filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
$oRcpGroups->setInnerGroupCondition("filter", "OR");
|
||||
} else {
|
||||
$oRcpGroups->setWhere($_REQUEST["searchin"], $_REQUEST["filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST["elemperpage"] > 0) {
|
||||
// Getting item count without limit (for page function) - better idea anyone (performance)?
|
||||
$oRcpGroups->query();
|
||||
$iItemCount = $oRcpGroups->count();
|
||||
|
||||
if ($_REQUEST["elemperpage"] * ($_REQUEST["page"]) >= $iItemCount + $_REQUEST["elemperpage"] && $_REQUEST["page"] != 1) {
|
||||
$_REQUEST["page"] --;
|
||||
}
|
||||
|
||||
$oRcpGroups->setLimit($_REQUEST["elemperpage"] * ($_REQUEST["page"] - 1), $_REQUEST["elemperpage"]);
|
||||
} else {
|
||||
$iItemCount = 0;
|
||||
}
|
||||
|
||||
$oRcpGroups->setOrder("defaultgroup DESC, " . $_REQUEST["sortby"] . " " . $_REQUEST["sortorder"]);
|
||||
$oRcpGroups->query();
|
||||
|
||||
// Output data
|
||||
$oMenu = new UI_Menu;
|
||||
$iMenu = 0;
|
||||
|
||||
// Store messages for repeated use (speeds performance, as i18n translation is only needed once)
|
||||
$aMsg = array();
|
||||
$aMsg["DelTitle"] = i18n("Delete recipient group", "cl_newsletter");
|
||||
$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter recipient group:<br>", "cl_newsletter");
|
||||
|
||||
while ($oRcpGroup = $oRcpGroups->next()) {
|
||||
$iMenu++;
|
||||
$iIDGroup = $oRcpGroup->get("idnewsgroup");
|
||||
|
||||
$sName = $oRcpGroup->get("groupname");
|
||||
if ($oRcpGroup->get("defaultgroup")) {
|
||||
$sName = $sName . "*";
|
||||
}
|
||||
|
||||
// Create the link to show/edit the recipient group
|
||||
$oLnk = new cHTMLLink;
|
||||
$oLnk->setMultiLink("recipientgroups", "", "recipientgroups", "");
|
||||
$oLnk->setCustom("idrecipientgroup", $iIDGroup);
|
||||
|
||||
#$oMenu->setImage($iMenu, $cfg["path"]["images"] . "groups.gif");
|
||||
$oMenu->setTitle($iMenu, $sName);
|
||||
$oMenu->setLink($iMenu, $oLnk);
|
||||
|
||||
if ($perm->have_perm_area_action($area, recipientgroup_delete)) {
|
||||
$oMenu->setActions($iMenu, 'delete', '<a title="' . $aMsg["DelTitle"] . '" href="javascript://" onclick="showDelMsg(' . $iIDGroup . ',\'' . addslashes($sName) . '\')"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . $aMsg["DelTitle"] . '" alt="' . $aMsg["DelTitle"] . '"></a>');
|
||||
}
|
||||
}
|
||||
|
||||
$sExecScript = '
|
||||
<script type="text/javascript">
|
||||
// Session-ID
|
||||
var sid = "' . $sess->id . '";
|
||||
|
||||
// Create messageBox instance
|
||||
box = new messageBox("", "", "", 0, 0);
|
||||
|
||||
function showDelMsg(lngId, strElement) {
|
||||
box.confirm("' . $aMsg["DelTitle"] . '", "' . $aMsg["DelDescr"] . '<b>" + strElement + "</b>", "deleteRecipientGroup(\'" + lngId + "\')");
|
||||
}
|
||||
|
||||
// Function for deleting recipient groups
|
||||
function deleteRecipientGroup(idrecipientgroup) {
|
||||
oForm = top.content.left.left_top.document.getElementById("groups_listoptionsform");
|
||||
|
||||
url = "main.php?area=recipientgroups";
|
||||
url += "&action=recipientgroup_delete";
|
||||
url += "&frame=4";
|
||||
url += "&idrecipientgroup=" + idrecipientgroup;
|
||||
url += "&contenido=" + sid;
|
||||
url += get_registered_parameters();
|
||||
url += "&sortby=" + oForm.sortby.value;
|
||||
url += "&sortorder=" + oForm.sortorder.value;
|
||||
url += "&filter=" + oForm.filter.value;
|
||||
url += "&elemperpage=" + oForm.elemperpage.value;
|
||||
|
||||
parent.parent.right.right_bottom.location.href = url;
|
||||
}
|
||||
|
||||
</script>';
|
||||
|
||||
$oPage->setMargin(0);
|
||||
$oPage->addScript('messagebox', '<script type="text/javascript" src="scripts/messageBox.js.php?contenido=' . $sess->id . '"></script>');
|
||||
$oPage->addScript('delete', $sExecScript);
|
||||
//$oPage->addScript('cfoldingrow.js', '<script language="JavaScript" src="scripts/cfoldingrow.js"></script>');
|
||||
$oPage->addScript('parameterCollector.js', '<script language="JavaScript" src="scripts/parameterCollector.js"></script>');
|
||||
|
||||
// Generate current content for Object Pager
|
||||
$sPagerId = "0ed6d632-6adf-4f09-a0c6-1e38ab60e305";
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setTargetFrame('left_bottom');
|
||||
$oPagerLink->setCustom("elemperpage", $_REQUEST["elemperpage"]);
|
||||
$oPagerLink->setCustom("filter", $_REQUEST["filter"]);
|
||||
$oPagerLink->setCustom("sortby", $_REQUEST["sortby"]);
|
||||
$oPagerLink->setCustom("sortorder", $_REQUEST["sortorder"]);
|
||||
$oPagerLink->setCustom("searchin", $_REQUEST["searchin"]);
|
||||
$oPagerLink->setCustom("frame", $frame);
|
||||
$oPagerLink->setCustom("area", $area);
|
||||
$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
// Note, that after the "page" parameter no "pagerlink" parameter is specified -
|
||||
// it is not used, as the JS below only uses the INNER html and the "pagerlink" parameter is
|
||||
// set by ...left_top.html for the foldingrow itself
|
||||
$oPager = new cObjectPager($sPagerId, $iItemCount, $_REQUEST["elemperpage"], $_REQUEST["page"], $oPagerLink, "page");
|
||||
|
||||
// Add slashes, to insert in javascript
|
||||
$sPagerContent = $oPager->render(1);
|
||||
$sPagerContent = str_replace('\\', '\\\\', $sPagerContent);
|
||||
$sPagerContent = str_replace('\'', '\\\'', $sPagerContent);
|
||||
|
||||
// Send new object pager to left_top
|
||||
// Send new object pager to left_top
|
||||
$oPage->addScript('setpager', '<script type="text/javascript" src="scripts/setPager.js"></script>');
|
||||
|
||||
$sRefreshPager = '
|
||||
<script type="text/javascript">
|
||||
var sNavigation = \'' . $sPagerContent . '\';
|
||||
|
||||
// Activate time to refresh pager folding row in left top
|
||||
var oTimer = window.setInterval("fncSetPager(\'' . $sPagerId . '\',\'' . $_REQUEST["page"] . '\')", 200);
|
||||
</script>';
|
||||
|
||||
$oPage->addScript('refreshpager', $sRefreshPager);
|
||||
|
||||
//$oPage->setContent(array('<table border="0" cellspacing="0" cellpadding="0" width="100%">', '</table>', $oMenu->render(false)));
|
||||
$oPage->setContent($oMenu->render(false));
|
||||
$oPage->render();
|
||||
?>
|
||||
246
includes/include.recipients_edit.php
Normale Datei
246
includes/include.recipients_edit.php
Normale Datei
|
|
@ -0,0 +1,246 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Frontend user editor
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.1.7
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: include.recipients_edit.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
$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("mail@domain.tld", " " . i18n("-- new recipient --", "cl_newsletter"));
|
||||
$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")) {
|
||||
$oClient = new cApiClient($client);
|
||||
$timeframe = $oClient->getProperty("newsletter", "purgetimeframe");
|
||||
if (!$timeframe) {
|
||||
$timeframe = 30;
|
||||
}
|
||||
$purgedrecipients = $oRecipients->purge($timeframe);
|
||||
/* backslashdollar: There is a problem translating \$ - it is either not recognized or translated correctly (using poEdit) */
|
||||
if ($purgedrecipients > 0) {
|
||||
$sNotis = $notification->messageBox("info", sprintf(str_replace("backslashdollar", "\$", i18n("%1backslashdollard recipients, which hasn't been confirmed since more than %2backslashdollard days has been removed.", "cl_newsletter")), $purgedrecipients, $timeframe), 0);
|
||||
} else {
|
||||
$sNotis = $notification->messageBox("info", sprintf(str_replace("backslashdollar", "\$", i18n("There are no recipients, which hasn't been confirmed since more than %2backslashdollard days has been removed.", "cl_newsletter")), 0, $timeframe), 0);
|
||||
}
|
||||
|
||||
$recipient = new Recipient;
|
||||
$oPage->setReload();
|
||||
} else {
|
||||
$recipient = new Recipient($idrecipient);
|
||||
}
|
||||
|
||||
if ($recipient->virgin == false && $recipient->get("idclient") == $client && $recipient->get("idlang") == $lang) {
|
||||
if ($action == "recipients_save" && $perm->have_perm_area_action($area, $action)) {
|
||||
$oPage->setReload();
|
||||
$aMessages = array();
|
||||
|
||||
$name = stripslashes($name);
|
||||
$email = stripslashes($email);
|
||||
$confirmed = (int) $confirmed;
|
||||
$deactivated = (int) $deactivated;
|
||||
$newstype = (int) $newstype;
|
||||
|
||||
$recipient->set("name", $name);
|
||||
|
||||
if (!isValidMail($email)) {
|
||||
$aMessages[] = i18n("Please specify a valid e-mail address", "cl_newsletter");
|
||||
} else {
|
||||
$email = strtolower($email); // e-mail always in lower case
|
||||
if ($recipient->get("email") != $email) {
|
||||
$oRecipients->resetQuery();
|
||||
$oRecipients->setWhere("email", $email);
|
||||
$oRecipients->setWhere("idclient", $client);
|
||||
$oRecipients->setWhere("idlang", $lang);
|
||||
$oRecipients->setWhere($recipient->primaryKey, $recipient->get($recipient->primaryKey), "!=");
|
||||
$oRecipients->query();
|
||||
|
||||
if ($oRecipients->next()) {
|
||||
$aMessages[] = i18n("Could not set new e-mail adress: Other recipient with same e-mail address already exists", "cl_newsletter");
|
||||
} else {
|
||||
$recipient->set("email", $email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($recipient->get("confirmed") != $confirmed && $confirmed) {
|
||||
$recipient->set("confirmeddate", date("Y-m-d H:i:s"), false);
|
||||
} elseif (!$confirmed) {
|
||||
$recipient->set("confirmeddate", "0000-00-00 00:00:00", false);
|
||||
}
|
||||
$recipient->set("confirmed", $confirmed);
|
||||
$recipient->set("deactivated", $deactivated);
|
||||
$recipient->set("news_type", $newstype);
|
||||
|
||||
// Check out if there are any plugins
|
||||
if (is_array($cfg['plugins']['recipients'])) {
|
||||
foreach ($cfg['plugins']['recipients'] as $plugin) {
|
||||
if (function_exists("recipients_" . $plugin . "_wantedVariables") && function_exists("recipients_" . $plugin . "_store")) {
|
||||
$wantVariables = call_user_func("recipients_" . $plugin . "_wantedVariables");
|
||||
|
||||
if (is_array($wantVariables)) {
|
||||
$varArray = array();
|
||||
|
||||
foreach ($wantVariables as $value) {
|
||||
$varArray[$value] = stripslashes($GLOBALS[$value]);
|
||||
}
|
||||
}
|
||||
$store = call_user_func("recipients_" . $plugin . "_store", $varArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$recipient->store();
|
||||
|
||||
// Remove group associations
|
||||
if (isset($_REQUEST["ckbRemove"])) {
|
||||
$oGroupMembers = new RecipientGroupMemberCollection;
|
||||
|
||||
foreach ($_REQUEST["ckbRemove"] as $iGroupMemberID) {
|
||||
if (is_numeric($iGroupMemberID)) {
|
||||
$oGroupMembers->delete($iGroupMemberID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($aMessages) > 0) {
|
||||
$sNotis = $notification->returnNotification("warning", implode("<br>", $aMessages)) . "<br>";
|
||||
}
|
||||
|
||||
$oForm = new UI_Table_Form("properties");
|
||||
$oForm->setVar("frame", $frame);
|
||||
$oForm->setVar("area", $area);
|
||||
$oForm->setVar("action", "recipients_save");
|
||||
$oForm->setVar("idrecipient", $recipient->get("idnewsrcp"));
|
||||
|
||||
$oForm->addHeader(i18n("Edit recipient", "cl_newsletter"));
|
||||
|
||||
$oTxtName = new cHTMLTextbox("name", $recipient->get("name"), 40);
|
||||
$oTxtEMail = new cHTMLTextbox("email", $recipient->get("email"), 40);
|
||||
$oCkbConfirmed = new cHTMLCheckbox("confirmed", "1");
|
||||
$oCkbConfirmed->setChecked($recipient->get("confirmed"));
|
||||
$oCkbDeactivated = new cHTMLCheckbox("deactivated", "1");
|
||||
$oCkbDeactivated->setChecked($recipient->get("deactivated"));
|
||||
|
||||
$oSelNewsType = new cHTMLSelectElement("newstype");
|
||||
$oOption = new cHTMLOptionElement(i18n("Text only", "cl_newsletter"), "0");
|
||||
$oSelNewsType->addOptionElement(0, $oOption);
|
||||
$oOption = new cHTMLOptionElement(i18n("HTML and text", "cl_newsletter"), "1");
|
||||
$oSelNewsType->addOptionElement(1, $oOption);
|
||||
$oSelNewsType->setDefault($recipient->get("news_type"));
|
||||
|
||||
$oForm->add(i18n("Name", "cl_newsletter"), $oTxtName->render());
|
||||
$oForm->add(i18n("E-Mail", "cl_newsletter"), $oTxtEMail->render());
|
||||
$oForm->add(i18n("Confirmed", "cl_newsletter"), $oCkbConfirmed->toHTML(false) . " (" . $recipient->get("confirmeddate") . ")");
|
||||
$oForm->add(i18n("Deactivated", "cl_newsletter"), $oCkbDeactivated->toHTML(false));
|
||||
$oForm->add(i18n("Message type", "cl_newsletter"), $oSelNewsType->render());
|
||||
|
||||
$aPluginOrder = trim_array(explode(",", getSystemProperty("plugin", "recipients-pluginorder")));
|
||||
|
||||
// Check out if there are any plugins
|
||||
if (is_array($aPluginOrder)) {
|
||||
foreach ($aPluginOrder as $sPlugin) {
|
||||
if (function_exists("recipients_" . $sPlugin . "_getTitle") &&
|
||||
function_exists("recipients_" . $sPlugin . "_display")) {
|
||||
$aPluginTitle = call_user_func("recipients_" . $sPlugin . "_getTitle");
|
||||
$aPluginDisplay = call_user_func("recipients_" . $sPlugin . "_display", $recipient);
|
||||
|
||||
if (is_array($aPluginTitle) && is_array($aPluginDisplay)) {
|
||||
foreach ($aPluginTitle as $sKey => $sValue) {
|
||||
$oForm->add($sValue, $aPluginDisplay[$sKey]);
|
||||
}
|
||||
} else {
|
||||
if (is_array($aPluginTitle) || is_array($aPluginDisplay)) {
|
||||
$oForm->add(i18n("WARNING", "cl_newsletter"), sprintf(i18n("The plugin %s delivered an array for the displayed titles, but did not return an array for the contents.", "cl_newsletter"), $sPlugin));
|
||||
} else {
|
||||
$oForm->add($aPluginTitle, $aPluginDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oGroupList = new UI_List;
|
||||
$oGroupList->setWidth("100%");
|
||||
$oGroupList->setBorder(1);
|
||||
|
||||
$oAssocGroups = new RecipientGroupMemberCollection;
|
||||
$oAssocGroups->link("RecipientGroupCollection");
|
||||
$oAssocGroups->setWhere("recipientgroupmembercollection.idnewsrcp", $recipient->get("idnewsrcp"));
|
||||
$oAssocGroups->setOrder("recipientgroupcollection.groupname");
|
||||
$oAssocGroups->query();
|
||||
|
||||
if ($oAssocGroups->count() == 0) {
|
||||
$oGroupList->setCell(0, 1, i18n("Recipient is not member of any group", "cl_newsletter"));
|
||||
} else {
|
||||
// Headline
|
||||
$oGroupList->setCell(0, 1, "<strong>" . i18n("Groupname", "cl_newsletter") . "</strong>");
|
||||
$oImgDel = new cHTMLImage("images/delete.gif");
|
||||
$oGroupList->setCell(0, 2, $oImgDel->render());
|
||||
$oGroupList->setCellAlignment(0, 2, "right");
|
||||
|
||||
// Data
|
||||
while ($oAssocGroup = $oAssocGroups->next()) {
|
||||
$oGroup = $oAssocGroups->fetchObject("RecipientGroupCollection");
|
||||
|
||||
$oCkbRemove = new cHTMLCheckbox("ckbRemove[]", $oAssocGroup->get("idnewsgroupmember"));
|
||||
echo ($oGroup->get("idnewsgroupmember"));
|
||||
$oGroupList->setCell($oAssocGroup->get("idnewsgroupmember"), 1, $oGroup->get("groupname"));
|
||||
$oGroupList->setCell($oAssocGroup->get("idnewsgroupmember"), 2, $oCkbRemove->toHTML(false));
|
||||
$oGroupList->setCellAlignment($oAssocGroup->get("idnewsgroupmember"), 2, "right");
|
||||
}
|
||||
}
|
||||
|
||||
$oForm->add(i18n("Associated Groups", "cl_newsletter"), $oGroupList->render());
|
||||
|
||||
$oForm->add(i18n("Author", "cl_newsletter"), $classuser->getUserName($recipient->get("author")) . " (" . $recipient->get("created") . ")");
|
||||
$oForm->add(i18n("Last modified by", "cl_newsletter"), $classuser->getUserName($recipient->get("modifiedby")) . " (" . $recipient->get("lastmodified") . ")");
|
||||
|
||||
$oPage->setContent($sNotis . $oForm->render(true));
|
||||
} else {
|
||||
$oPage->setContent($sNotis . "");
|
||||
}
|
||||
|
||||
$oPage->render();
|
||||
?>
|
||||
360
includes/include.recipients_import.php
Normale Datei
360
includes/include.recipients_import.php
Normale Datei
|
|
@ -0,0 +1,360 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Frontend user editor
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.0.0
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: include.recipients_import.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
$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"] = "tab";
|
||||
}
|
||||
|
||||
$aFields = array();
|
||||
$aFieldDetails = array();
|
||||
$aFields["name"] = strtolower(i18n("Name", "cl_newsletter"));
|
||||
$aFieldDetails["name"]["fieldtype"] = "field"; // field, plugin or group
|
||||
$aFieldDetails["name"]["mandatory"] = false; // true or false
|
||||
$aFieldDetails["name"]["type"] = "string"; // string, boolean or date
|
||||
$aFieldDetails["name"]["link"] = false; // plugin name for plugins, recipient group id for groups
|
||||
$aFieldDetails["name"]["col"] = -1; // Stores column index where this field has been found
|
||||
$aFields["email"] = strtolower(i18n("Mail", "cl_newsletter"));
|
||||
$aFieldDetails["email"]["fieldtype"] = "field";
|
||||
$aFieldDetails["email"]["mandatory"] = true;
|
||||
$aFieldDetails["email"]["type"] = "string";
|
||||
$aFieldDetails["email"]["link"] = false;
|
||||
$aFieldDetails["email"]["col"] = -1;
|
||||
$aFields["deactivated"] = strtolower(i18n("Deactivated", "cl_newsletter"));
|
||||
$aFieldDetails["deactivated"]["fieldtype"] = "field";
|
||||
$aFieldDetails["deactivated"]["mandatory"] = false;
|
||||
$aFieldDetails["deactivated"]["type"] = "boolean";
|
||||
$aFieldDetails["deactivated"]["link"] = false;
|
||||
$aFieldDetails["deactivated"]["col"] = -1;
|
||||
$aFields["confirmed"] = strtolower(i18n("Confirmed", "cl_newsletter"));
|
||||
$aFieldDetails["confirmed"]["fieldtype"] = "field";
|
||||
$aFieldDetails["confirmed"]["mandatory"] = false;
|
||||
$aFieldDetails["confirmed"]["type"] = "boolean";
|
||||
$aFieldDetails["confirmed"]["link"] = false;
|
||||
$aFieldDetails["confirmed"]["col"] = -1;
|
||||
$aFields["confirmeddate"] = strtolower(i18n("Confirmed Date", "cl_newsletter"));
|
||||
$aFieldDetails["confirmeddate"]["fieldtype"] = "field";
|
||||
$aFieldDetails["confirmeddate"]["mandatory"] = false;
|
||||
$aFieldDetails["confirmeddate"]["type"] = "date";
|
||||
$aFieldDetails["confirmeddate"]["link"] = false;
|
||||
$aFieldDetails["confirmeddate"]["col"] = -1;
|
||||
$aFields["news_type"] = strtolower(i18n("Message type", "cl_newsletter"));
|
||||
$aFieldDetails["news_type"]["fieldtype"] = "field";
|
||||
$aFieldDetails["news_type"]["mandatory"] = false;
|
||||
$aFieldDetails["news_type"]["type"] = "boolean";
|
||||
$aFieldDetails["news_type"]["link"] = false;
|
||||
$aFieldDetails["news_type"]["col"] = -1;
|
||||
|
||||
// Check out if there are any plugins
|
||||
if (is_array($cfg['plugins']['recipients'])) {
|
||||
foreach ($cfg['plugins']['recipients'] as $sPlugin) {
|
||||
if (function_exists("recipients_" . $sPlugin . "_wantedVariables") && function_exists("recipients_" . $sPlugin . "_canonicalVariables")) {
|
||||
$aPluginTitles = call_user_func("recipients_" . $sPlugin . "_canonicalVariables");
|
||||
$aPluginFields = call_user_func("recipients_" . $sPlugin . "_wantedVariables");
|
||||
foreach ($aPluginFields as $sField) {
|
||||
//if ($_REQUEST["ckb".$sField]) {
|
||||
$aFields[$sField] = strtolower(str_replace(" ", "", $aPluginTitles[$sField]));
|
||||
$aFieldDetails[$sField]["fieldtype"] = "plugin";
|
||||
$aFieldDetails[$sField]["mandatory"] = false;
|
||||
$aFieldDetails[$sField]["type"] = "string";
|
||||
$aFieldDetails[$sField]["link"] = $sPlugin;
|
||||
$aFieldDetails[$sField]["col"] = -1;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get groups
|
||||
$oRcpGroups = new RecipientGroupCollection;
|
||||
$oRcpGroups->setWhere("idclient", $client);
|
||||
$oRcpGroups->setWhere("idlang", $lang);
|
||||
$oRcpGroups->setOrder("groupname");
|
||||
$oRcpGroups->query();
|
||||
|
||||
while ($oRcpGroup = $oRcpGroups->next()) {
|
||||
$sField = "g" . $oRcpGroup->get($oRcpGroup->primaryKey);
|
||||
|
||||
$sGroupName = $oRcpGroup->get("groupname");
|
||||
$sGroupName = str_replace(" ", "", $sGroupName);
|
||||
$sGroupName = str_replace("\t", "", $sGroupName);
|
||||
$sGroupName = str_replace("\n", "", $sGroupName);
|
||||
$sGroupName = str_replace("\r", "", $sGroupName);
|
||||
$sGroupName = str_replace("\0", "", $sGroupName);
|
||||
$sGroupName = str_replace("\x0B;", "", $sGroupName);
|
||||
|
||||
// Only PHP5!
|
||||
//$sGroupName = str_replace(str_split(" \t\n\r\0\x0B;"), "", $oRcpGroup->get("groupname"));
|
||||
|
||||
$aFields[$sField] = strtolower(clHtmlEntities(trim(i18n("Group", "cl_newsletter") . "_" . $sGroupName)));
|
||||
$aFieldDetails[$sField]["fieldtype"] = "group";
|
||||
$aFieldDetails[$sField]["mandatory"] = false;
|
||||
$aFieldDetails[$sField]["type"] = "string";
|
||||
$aFieldDetails[$sField]["link"] = $oRcpGroup->get($oRcpGroup->primaryKey);
|
||||
$aFieldDetails[$sField]["col"] = -1;
|
||||
}
|
||||
|
||||
if ($action == "recipients_import_exec" && $perm->have_perm_area_action("recipients", "recipients_create")) {
|
||||
$_REQUEST["txtData"] = trim(stripslashes($_REQUEST["txtData"]));
|
||||
|
||||
if ($_REQUEST["txtData"]) {
|
||||
switch ($_REQUEST["selDelimiter"]) {
|
||||
case "semicolon":
|
||||
$sDelimiter = ";";
|
||||
break;
|
||||
default:
|
||||
$sDelimiter = "\t"; //chr(9);
|
||||
}
|
||||
|
||||
//echo "<pre>".nl2br(stripslashes($_REQUEST["txtData"]))."</pre>";
|
||||
$aLines = explode("\n", stripslashes($_REQUEST["txtData"]));
|
||||
$iAdded = 0;
|
||||
$iDublettes = 0;
|
||||
$iInvalid = 0;
|
||||
$iRow = 0;
|
||||
$iCol = 0;
|
||||
$bStop = false;
|
||||
$sMessage = "";
|
||||
$aMessage = array();
|
||||
$aInvalidLines = array();
|
||||
$oGroupMembers = new RecipientGroupMemberCollection;
|
||||
|
||||
foreach ($aLines as $sLine) {
|
||||
$iRow++;
|
||||
|
||||
$aParts = explode($sDelimiter, trim($sLine));
|
||||
|
||||
if ($iRow == 1) {
|
||||
$aInvalidLines[] = $sLine;
|
||||
|
||||
foreach ($aParts as $sHeader) {
|
||||
$sKey = array_search(strtolower(clHtmlEntities(trim($sHeader))), $aFields);
|
||||
if ($sKey === false) {
|
||||
$aMessage[] = sprintf(i18n("Given column header '%s' unknown, column ignored", "cl_newsletter"), $sHeader);
|
||||
} else {
|
||||
$aFieldDetails[$sKey]["col"] = $iCol;
|
||||
$iCol++;
|
||||
}
|
||||
}
|
||||
foreach ($aFieldDetails as $sKey => $aDetails) {
|
||||
if ($aDetails["mandatory"] && $aDetails["col"] == -1) {
|
||||
$aMessage[] = sprintf(i18n("Mandatory column '%s' wasn't found, import stopped", "cl_newsletter"), $aDetails[$sKey]);
|
||||
$bStop = true;
|
||||
}
|
||||
}
|
||||
if ($bStop) {
|
||||
exit;
|
||||
} else {
|
||||
$_REQUEST["txtData"] = "";
|
||||
}
|
||||
} else {
|
||||
$sEMail = trim($aParts[$aFieldDetails["email"]["col"]]);
|
||||
if ($aFieldDetails["name"]["col"] > -1) {
|
||||
$sName = trim($aParts[$aFieldDetails["name"]["col"]]);
|
||||
if ($sName == "") {
|
||||
$sName = $sEMail;
|
||||
}
|
||||
} else {
|
||||
$sName = $sEMail;
|
||||
}
|
||||
if ($sEMail == "") {
|
||||
$aMessage[] = sprintf(i18n("Item with empty mail address found, item ignored (name: %s, row: %s)", "cl_newsletter"), $sName, $iRow);
|
||||
$aInvalidLines[] = $sLine;
|
||||
$iInvalid++;
|
||||
} else if (!isValidMail($sEMail)) {
|
||||
$aMessage[] = sprintf(i18n("Mail address '%s' is invalid, item ignored (row: %s)", "cl_newsletter"), $sEMail, $iRow);
|
||||
$aInvalidLines[] = $sLine;
|
||||
$iInvalid++;
|
||||
} else if ($oRecipients->emailExists($sEMail)) {
|
||||
$aMessage[] = sprintf(i18n("Recipient with mail address '%s' already exists, item skipped (row: %s)", "cl_newsletter"), $sEMail, $iRow);
|
||||
$aInvalidLines[] = $sLine;
|
||||
$iDublettes++;
|
||||
} else {
|
||||
unset($sLine);
|
||||
|
||||
// Must be $recipient for plugins
|
||||
if ($recipient = $oRecipients->create($sEMail, $sName)) {
|
||||
$iID = $recipient->get($recipient->primaryKey);
|
||||
$iAdded++;
|
||||
|
||||
unset($aPluginValue);
|
||||
$aPluginValue = array();
|
||||
|
||||
foreach ($aFieldDetails as $sKey => $aDetails) {
|
||||
if ($aDetails["col"] > -1) {
|
||||
switch ($aDetails["fieldtype"]) {
|
||||
case "field":
|
||||
switch ($aDetails["type"]) {
|
||||
case "boolean":
|
||||
$sValue = strtolower(trim($aParts[$aDetails["col"]]));
|
||||
|
||||
// html is only treated as "true", to get html messages for recipients
|
||||
// - quick and dirty...
|
||||
if ($sValue == "yes" || $sValue == i18n("yes", "cl_newsletter") || $sValue == "true" ||
|
||||
(is_numeric($sValue) && $sValue > 0) ||
|
||||
$sValue == "html") {
|
||||
$recipient->set($sKey, 1);
|
||||
|
||||
if ($sKey == "confirmed") {
|
||||
// Ensure, that if a recipient is confirmed, a confirmed date
|
||||
// is available. As "confirmeddate" will be set after "confirmed"
|
||||
// a specified confirmeddate will overwrite this default
|
||||
$recipient->set("confirmeddate", date("Y-m-d H:i:s"), false);
|
||||
}
|
||||
} else {
|
||||
$recipient->set($sKey, 0);
|
||||
}
|
||||
break;
|
||||
case "date":
|
||||
// TODO: Check conversion: Result may be unpredictable...
|
||||
$sValue = trim($aParts[$aDetails["col"]]);
|
||||
$recipient->set($sKey, date("Y-m-d H:i:s", strtotime($sValue)), false);
|
||||
break;
|
||||
default:
|
||||
$sValue = trim($aParts[$aDetails["col"]]);
|
||||
$recipient->set($sKey, $sValue);
|
||||
}
|
||||
break;
|
||||
case "plugin":
|
||||
// type may be mentioned here, also, but as plugins currently can't
|
||||
// specify the type, just treat everything as string
|
||||
// There may be plugins which store more than one value per plugin_store-
|
||||
// function. As the plugin_store parameter is an array of values, collect
|
||||
// all values in an array for later storing... unfortunately, that means,
|
||||
// that we have to go through the fields array second time per item *sigh*
|
||||
$aPluginValue[$aDetails["link"]][$sKey] = trim($aParts[$aDetails["col"]]);
|
||||
break;
|
||||
case "group":
|
||||
// Add recipient to group
|
||||
$sValue = strtolower(trim($aParts[$aDetails["col"]]));
|
||||
|
||||
if ($sValue == "yes" || $sValue == i18n("yes", "cl_newsletter") ||
|
||||
$sValue == "true" || (is_numeric($sValue) && $sValue > 0)) {
|
||||
$oGroupMembers->create($aDetails["link"], $iID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Store all base data
|
||||
$recipient->store();
|
||||
|
||||
// Store plugin data (to store plugin data, only, where the column has been found in the data
|
||||
// should be faster than going through all plugins and store mostly empty arrays)
|
||||
$sCurrentPlugin = "";
|
||||
foreach ($aFieldDetails as $sKey => $aDetails) {
|
||||
if ($aDetails["col"] > -1 &&
|
||||
$aDetails["fieldtype"] == "plugin" &&
|
||||
$aDetails["link"] !== $sCurrentPlugin) {
|
||||
$sCurrentPlugin = $aDetails["link"];
|
||||
|
||||
call_user_func("recipients_" . $sCurrentPlugin . "_store", $aPluginValue[$sCurrentPlugin]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($aInvalidLines) > 1) {
|
||||
$_REQUEST["txtData"] = implode("\n", $aInvalidLines);
|
||||
}
|
||||
if (count($aMessage) > 0) {
|
||||
$sMessage = $notification->returnNotification("warning", implode("<br />", $aMessage)) . "<br />";
|
||||
}
|
||||
$sMessage .= $notification->returnNotification("info", sprintf(i18n("%d recipients added, %d recipients skipped (email already exists) and %d invalid recipients/e-mail adresses ignored. Invalid recipients are shown (if any).", "cl_newsletter"), $iAdded, $iDublettes, $iInvalid));
|
||||
if ($iAdded > 0) {
|
||||
$oPage->setReload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oForm = new UI_Table_Form("properties");
|
||||
$oForm->setVar("frame", $frame);
|
||||
$oForm->setVar("area", $area);
|
||||
$oForm->setVar("action", "recipients_import_exec");
|
||||
|
||||
$oForm->addHeader(i18n("Import recipients", "cl_newsletter"));
|
||||
|
||||
$oSelDelimiter = new cHTMLSelectElement("selDelimiter");
|
||||
$aItems = array();
|
||||
$aItems[] = array("tab", i18n("Tab", "cl_newsletter"));
|
||||
$aItems[] = array("semicolon", i18n("Semicolon", "cl_newsletter"));
|
||||
$oSelDelimiter->autoFill($aItems);
|
||||
$oSelDelimiter->setDefault($_REQUEST["selDelimiter"]);
|
||||
$oForm->add(i18n("Delimiter", "cl_newsletter"), $oSelDelimiter->render());
|
||||
|
||||
$oAreaData = new cHTMLTextarea("txtData", $_REQUEST["txtData"], 80, 20);
|
||||
|
||||
$sInfo = '<a href="javascript:fncShowHide(\'idInfoText\');"><strong>' . i18n("Import information", "cl_newsletter") . '</strong></a>' .
|
||||
'<div id="idInfoText" style="display: none">' .
|
||||
'<br /><br /><strong>' . i18n("Specify colum types:", "cl_newsletter") . '</strong>' .
|
||||
i18n("<br />The first line must contain the column names; this specifies the column order.<br /><column name>[delimiter]<column name>...", "cl_newsletter") .
|
||||
'<br /><br /><strong>' . i18n("Data structure:", "cl_newsletter") . '</strong><br />' .
|
||||
i18n("The recipients have to be entered using the following format:<br /><data>[Delimiter]<data>... - each recipient in a new line.", "cl_newsletter") .
|
||||
'<br /><br /><strong>' . i18n("Example:", "cl_newsletter") . '</strong>' .
|
||||
i18n("<br />name;mail;confirmed<br />Smith;jon.smith@example.org;1", "cl_newsletter") .
|
||||
'<br /><br /><strong>' . i18n("The following column names will be recognized:", "cl_newsletter") . '</strong><br />' .
|
||||
implode("<br />\n", $aFields);
|
||||
|
||||
$oForm->add(i18n("Recipients", "cl_newsletter"), $oAreaData->render() . "<br />" . $sInfo);
|
||||
unset($sInfo);
|
||||
|
||||
$sExecScript = '
|
||||
<script type="text/javascript">
|
||||
/* Enabled/Disable group box */
|
||||
function fncShowHide(strItemID) {
|
||||
objItem = document.getElementById(strItemID);
|
||||
|
||||
if (objItem.style.display == "none") {
|
||||
objItem.style.display = "inline";
|
||||
} else {
|
||||
objItem.style.display = "none";
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
$oPage->addScript('execscript', $sExecScript);
|
||||
$oPage->setContent($sMessage . $oForm->render(true));
|
||||
$oPage->render();
|
||||
?>
|
||||
288
includes/include.recipients_menu.php
Normale Datei
288
includes/include.recipients_menu.php
Normale Datei
|
|
@ -0,0 +1,288 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Recipient user list
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend includes
|
||||
* @version 1.2.2
|
||||
* @author Bj<EFBFBD>rn Behrens (HerrB)
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @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<EFBFBD>rn Behrens (HerrB)
|
||||
* modified 2008-06-27, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: include.recipients_menu.php 128 2019-07-03 11:58:28Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
# Initialization
|
||||
##################################
|
||||
$oPage = new cPage;
|
||||
$oMenu = new UI_Menu;
|
||||
$oClient = new cApiClient($client);
|
||||
$oUser = new cApiUser($auth->auth["uid"]);
|
||||
//$sLocation = $sess->url("main.php?area=$area&frame=$frame");
|
||||
// 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", "cl_newsletter"), "type" => "base,sort,search");
|
||||
$aFields["email"] = array("field" => "email", "caption" => i18n("E-Mail", "cl_newsletter"), "type" => "base,sort,search");
|
||||
$aFields["confirmed"] = array("field" => "confirmed", "caption" => i18n("Confirmed", "cl_newsletter"), "type" => "base");
|
||||
$aFields["deactivated"] = array("field" => "deactivated", "caption" => i18n("Deactivated", "cl_newsletter"), "type" => "base");
|
||||
|
||||
##################################
|
||||
# Store settings
|
||||
##################################
|
||||
//Update purgetimeframe if submitted
|
||||
//$sRefreshTop = '';
|
||||
$iTimeframe = $oClient->getProperty("newsletter", "purgetimeframe");
|
||||
if (isset($_REQUEST["txtPurgeTimeframe"]) && $_REQUEST["txtPurgeTimeframe"] > 0 && $_REQUEST["txtPurgeTimeframe"] != $iTimeframe && $perm->have_perm_area_action($area, "recipients_delete")) {
|
||||
$oClient->setProperty("newsletter", "purgetimeframe", $_REQUEST["txtPurgeTimeframe"]);
|
||||
//$sRefreshTop = '<script language="JavaScript">parent.left_top.purgetimeframe = '.$_REQUEST["txtPurgeTimeframe"].'</script>';
|
||||
}
|
||||
|
||||
##################################
|
||||
# Check external input
|
||||
##################################
|
||||
// Items per page (value stored per area in user property)
|
||||
if (!isset($_REQUEST["elemperpage"]) || !is_numeric($_REQUEST["elemperpage"]) || $_REQUEST["elemperpage"] < 0) {
|
||||
$_REQUEST["elemperpage"] = $oUser->getProperty("itemsperpage", $area);
|
||||
}
|
||||
if (!is_numeric($_REQUEST["elemperpage"])) {
|
||||
// This is the case, if the user property has never been set (first time user)
|
||||
$_REQUEST["elemperpage"] = 25;
|
||||
}
|
||||
if ($_REQUEST["elemperpage"] > 0) {
|
||||
// -- All -- will not be stored, as it may be impossible to change this back to something more useful
|
||||
$oUser->setProperty("itemsperpage", $area, $_REQUEST["elemperpage"]);
|
||||
}
|
||||
|
||||
$_REQUEST["restrictgroup"] = (int) $_REQUEST["restrictgroup"];
|
||||
if ($_REQUEST["restrictgroup"] == 0) {
|
||||
$_REQUEST["restrictgroup"] = "--all--";
|
||||
}
|
||||
$_REQUEST["page"] = (int) $_REQUEST["page"];
|
||||
if ($_REQUEST["page"] <= 0 || $_REQUEST["elemperpage"] == 0) {
|
||||
$_REQUEST["page"] = 1;
|
||||
}
|
||||
// Sort order
|
||||
if ($_REQUEST["sortorder"] != "DESC") {
|
||||
$_REQUEST["sortorder"] = "ASC";
|
||||
}
|
||||
|
||||
// Check sort by and search in criteria
|
||||
$bSortByFound = false;
|
||||
$bSearchInFound = false;
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if ($aData["field"] == $_REQUEST["sortby"] && strpos($aData["type"], "sort") !== false) {
|
||||
$bSortByFound = true;
|
||||
}
|
||||
if ($aData["field"] == $_REQUEST["searchin"] && strpos($aData["type"], "search") !== false) {
|
||||
$bSearchInFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bSortByFound) {
|
||||
$_REQUEST["sortby"] = "name"; // Default sort by field, possible values see above
|
||||
}
|
||||
if (!$bSearchInFound) {
|
||||
$_REQUEST["searchin"] = "--all--";
|
||||
}
|
||||
|
||||
// Free memory
|
||||
unset($oUser);
|
||||
unset($oClient);
|
||||
|
||||
##################################
|
||||
# Get data
|
||||
##################################
|
||||
$oRecipients = new RecipientCollection;
|
||||
|
||||
// Updating keys, if activated; all recipients of all clients!
|
||||
$sMsg = "";
|
||||
if (getSystemProperty("newsletter", "updatekeys")) {
|
||||
$iUpdatedRecipients = $oRecipients->updateKeys();
|
||||
$sMsg = $notification->returnNotification("info", sprintf(i18n("%d recipients, with no or incompatible key has been updated. Deactivate update function.", "cl_newsletter"), $iUpdatedRecipients));
|
||||
}
|
||||
|
||||
$oRecipients->setWhere("recipientcollection.idclient", $client);
|
||||
$oRecipients->setWhere("recipientcollection.idlang", $lang);
|
||||
|
||||
// sort by and sort order
|
||||
$oRecipients->setOrder("recipientcollection." . $_REQUEST["sortby"] . " " . $_REQUEST["sortorder"]);
|
||||
|
||||
// Show group
|
||||
if ($_REQUEST["restrictgroup"] != "--all--") {
|
||||
$oRecipients->link("RecipientGroupMemberCollection");
|
||||
$oRecipients->setWhere("RecipientGroupMemberCollection.idnewsgroup", $_REQUEST["restrictgroup"]);
|
||||
}
|
||||
// Search for
|
||||
if ($_REQUEST["filter"] != "") {
|
||||
if ($_REQUEST["searchin"] == "--all--" || $_REQUEST["searchin"] == "") {
|
||||
foreach ($aFields as $sKey => $aData) {
|
||||
if (strpos($aData["type"], "search") !== false) {
|
||||
$oRecipients->setWhereGroup("filter", "recipientcollection." . $aData["field"], $_REQUEST["filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
$oRecipients->setInnerGroupCondition("filter", "OR");
|
||||
} else {
|
||||
$oRecipients->setWhere("recipientcollection." . $_REQUEST["searchin"], $_REQUEST["filter"], "LIKE");
|
||||
}
|
||||
}
|
||||
|
||||
// Items / page
|
||||
if ($_REQUEST["elemperpage"] > 0) {
|
||||
// Getting item count without limit (for page function) - better idea anyone (performance)?
|
||||
$oRecipients->query();
|
||||
$iItemCount = $oRecipients->count();
|
||||
|
||||
if ($_REQUEST["elemperpage"] * ($_REQUEST["page"]) >= $iItemCount + $_REQUEST["elemperpage"] && $_REQUEST["page"] != 1) {
|
||||
$_REQUEST["page"] --;
|
||||
}
|
||||
|
||||
$oRecipients->setLimit($_REQUEST["elemperpage"] * ($_REQUEST["page"] - 1), $_REQUEST["elemperpage"]);
|
||||
} else {
|
||||
$iItemCount = 0;
|
||||
}
|
||||
|
||||
$oRecipients->query();
|
||||
|
||||
// Output data
|
||||
$oMenu = new UI_Menu;
|
||||
$iMenu = 0;
|
||||
|
||||
// Store messages for repeated use (speeds performance, as i18n translation is only needed once)
|
||||
$aMsg = array();
|
||||
$aMsg["DelTitle"] = i18n("Delete recipient", "cl_newsletter");
|
||||
$aMsg["DelDescr"] = i18n("Do you really want to delete the following recipient:<br>", "cl_newsletter");
|
||||
|
||||
while ($oRecipient = $oRecipients->next()) {
|
||||
$iMenu++;
|
||||
$idnewsrcp = $oRecipient->get("idnewsrcp");
|
||||
|
||||
$sName = $oRecipient->get("name");
|
||||
if (empty($sName)) {
|
||||
$sName = $oRecipient->get("email");
|
||||
}
|
||||
|
||||
$oLnk = new cHTMLLink;
|
||||
$oLnk->setMultiLink($area, "", $area, "");
|
||||
$oLnk->setCustom("idrecipient", $idnewsrcp);
|
||||
|
||||
if ($oRecipient->get("deactivated") == 1 || $oRecipient->get("confirmed") == 0) {
|
||||
$oLnk->updateAttributes(array("style" => "color:#A20000"));
|
||||
}
|
||||
|
||||
$oMenu->setTitle($iMenu, $sName);
|
||||
$oMenu->setLink($iMenu, $oLnk);
|
||||
|
||||
if ($perm->have_perm_area_action("recipients", "recipients_delete")) {
|
||||
$oMenu->setActions($iMenu, "delete", '<a title="' . $aMsg["DelTitle"] . '" href="javascript://" onclick="showDelMsg(' . $idnewsrcp . ',\'' . addslashes($sName) . '\')"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . $aMsg["DelTitle"] . '" alt="' . $aMsg["DelTitle"] . '"></a>');
|
||||
}
|
||||
}
|
||||
|
||||
$sExecScript = '
|
||||
<script type="text/javascript">
|
||||
// Session-ID
|
||||
var sid = "' . $sess->id . '";
|
||||
|
||||
// Create messageBox instance
|
||||
box = new messageBox("", "", "", 0, 0);
|
||||
|
||||
function showDelMsg(lngId, strElement) {
|
||||
box.confirm("' . $aMsg["DelTitle"] . '", "' . $aMsg["DelDescr"] . '<b>" + strElement + "</b>", "deleteRecipient(\'" + lngId + "\')");
|
||||
}
|
||||
|
||||
// Function for deleting recipients
|
||||
function deleteRecipient(idrecipient) {
|
||||
oForm = top.content.left.left_top.document.getElementById("options");
|
||||
|
||||
url = "main.php?area=recipients";
|
||||
url += "&action=recipients_delete";
|
||||
url += "&frame=4";
|
||||
url += "&idrecipient=" + idrecipient;
|
||||
url += "&contenido=" + sid;
|
||||
url += get_registered_parameters();
|
||||
url += "&restrictgroup=" + oForm.restrictgroup.value;
|
||||
url += "&sortby=" + oForm.sortby.value;
|
||||
url += "&sortorder=" + oForm.sortorder.value;
|
||||
url += "&filter=" + oForm.filter.value;
|
||||
url += "&elemperpage=" + oForm.elemperpage.value;
|
||||
|
||||
parent.parent.right.right_bottom.location.href = url;
|
||||
}
|
||||
</script>';
|
||||
|
||||
$oPage->setMargin(0);
|
||||
$oPage->addScript('messagebox', '<script type="text/javascript" src="scripts/messageBox.js.php?contenido=' . $sess->id . '"></script>');
|
||||
$oPage->addScript('exec', $sExecScript);
|
||||
//$oPage->addScript('cfoldingrow.js', '<script language="JavaScript" src="scripts/cfoldingrow.js"></script>');
|
||||
$oPage->addScript('parameterCollector.js', '<script language="JavaScript" src="scripts/parameterCollector.js"></script>');
|
||||
//$oPage->addScript('refreshTop', $sRefreshTop);
|
||||
//generate current content for Object Pager<65>
|
||||
$sPagerId = '0ed6d632-6adf-4f09-a0c6-1e38ab60e304';
|
||||
$oPagerLink = new cHTMLLink;
|
||||
$oPagerLink->setLink("main.php");
|
||||
$oPagerLink->setTargetFrame('left_bottom');
|
||||
$oPagerLink->setCustom("elemperpage", $_REQUEST["elemperpage"]);
|
||||
$oPagerLink->setCustom("filter", $_REQUEST["filter"]);
|
||||
$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
|
||||
$oPagerLink->setCustom("sortby", $_REQUEST["sortby"]);
|
||||
$oPagerLink->setCustom("sortorder", $_REQUEST["sortorder"]);
|
||||
$oPagerLink->setCustom("searchin", $_REQUEST["searchin"]);
|
||||
$oPagerLink->setCustom("frame", $frame);
|
||||
$oPagerLink->setCustom("area", $area);
|
||||
$oPagerLink->enableAutomaticParameterAppend();
|
||||
$oPagerLink->setCustom("contenido", $sess->id);
|
||||
// Note, that after the "page" parameter no "pagerlink" parameter is specified -
|
||||
// it is not used, as the JS below only uses the INNER html and the "pagerlink" parameter is
|
||||
// set by ...left_top.html for the foldingrow itself
|
||||
$oPager = new cObjectPager($sPagerId, $iItemCount, $_REQUEST["elemperpage"], $_REQUEST["page"], $oPagerLink, "page");
|
||||
|
||||
//add slashes, to insert in javascript
|
||||
$sPagerContent = $oPager->render(1);
|
||||
$sPagerContent = str_replace('\\', '\\\\', $sPagerContent);
|
||||
$sPagerContent = str_replace('\'', '\\\'', $sPagerContent);
|
||||
|
||||
// Send new object pager to left_top
|
||||
$oPage->addScript('setpager', '<script type="text/javascript" src="scripts/setPager.js"></script>');
|
||||
|
||||
$sRefreshPager = '
|
||||
<script type="text/javascript">
|
||||
var sNavigation = \'' . $sPagerContent . '\';
|
||||
|
||||
// Activate time to refresh pager folding row in left top
|
||||
var oTimer = window.setInterval("fncSetPager(\'' . $sPagerId . '\',\'' . $_REQUEST["page"] . '\')", 200);
|
||||
</script>';
|
||||
|
||||
$oPage->addScript('refreshpager', $sRefreshPager);
|
||||
|
||||
//$oPage->setContent(array('<table border="0" cellspacing="0" cellpadding="0" width="100%">', '</table>', $sMsg . $oMenu->render(false)));
|
||||
$oPage->setContent($sMsg . $oMenu->render(false));
|
||||
$oPage->render();
|
||||
?>
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren