From 07c09452f90328a9e438c61f0234d30c490f951b Mon Sep 17 00:00:00 2001 From: Oldperl <44996956+oldperl@users.noreply.github.com> Date: Tue, 1 Aug 2017 12:52:06 +0000 Subject: [PATCH] localization FS#172 --- .../classes/class.newsletter.groups.php | 89 +- .../classes/class.newsletter.jobs.php | 153 +-- .../classes/class.newsletter.logs.php | 104 +- .../newsletter/classes/class.newsletter.php | 20 +- .../classes/class.newsletter.recipients.php | 63 +- .../includes/include.newsletter_edit.php | 974 +++++++------- .../include.newsletter_edit_message.php | 359 +++-- .../include.newsletter_jobs_details.php | 665 +++++----- .../includes/include.newsletter_jobs_menu.php | 14 +- .../include.newsletter_jobs_subnav.php | 4 +- .../includes/include.newsletter_left_top.php | 154 +-- .../includes/include.newsletter_menu.php | 295 ++--- .../includes/include.newsletter_subnav.php | 4 +- .../include.recipients.group.subnav.php | 64 +- .../include.recipients.group_edit.php | 1020 +++++++-------- .../include.recipients.group_menu.php | 148 +-- .../includes/include.recipients_edit.php | 384 +++--- .../includes/include.recipients_import.php | 559 ++++---- .../includes/include.recipients_menu.php | 219 ++-- .../locale/de_DE/LC_MESSAGES/newsletter.mo | Bin 0 -> 19176 bytes .../locale/de_DE/LC_MESSAGES/newsletter.po | 1161 +++++++++++++++++ .../plugins/newsletter/locale/newsletter.pot | 1055 +++++++++++++++ .../plugins/newsletter/locale/potfiles.txt | 21 + 23 files changed, 4792 insertions(+), 2737 deletions(-) create mode 100644 conlite/plugins/newsletter/locale/de_DE/LC_MESSAGES/newsletter.mo create mode 100644 conlite/plugins/newsletter/locale/de_DE/LC_MESSAGES/newsletter.po create mode 100644 conlite/plugins/newsletter/locale/newsletter.pot create mode 100644 conlite/plugins/newsletter/locale/potfiles.txt diff --git a/conlite/plugins/newsletter/classes/class.newsletter.groups.php b/conlite/plugins/newsletter/classes/class.newsletter.groups.php index 2d4fa94..f9b1a7a 100644 --- a/conlite/plugins/newsletter/classes/class.newsletter.groups.php +++ b/conlite/plugins/newsletter/classes/class.newsletter.groups.php @@ -1,4 +1,5 @@ _setItemClass("RecipientGroup"); } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function RecipientGroupCollection() - { + public function RecipientGroupCollection() { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct(); } @@ -61,12 +59,11 @@ class RecipientGroupCollection extends ItemCollection * @param $groupname string Specifies the groupname * @param $defaultgroup integer Specfies, if group is default group (optional) */ - public function create($groupname, $defaultgroup = 0) - { + public function create($groupname, $defaultgroup = 0) { global $client, $lang; $client = Contenido_Security::toInteger($client); - $lang = Contenido_Security::toInteger($lang); + $lang = Contenido_Security::toInteger($lang); $group = new RecipientGroup(); @@ -74,7 +71,7 @@ class RecipientGroupCollection extends ItemCollection $mangledGroupName = $group->_inFilter($groupname); $this->setWhere("idclient", $client); - $this->setWhere("idlang", $lang); + $this->setWhere("idlang", $lang); $this->setWhere("groupname", $mangledGroupName); $this->query(); @@ -99,8 +96,7 @@ class RecipientGroupCollection extends ItemCollection * * @param $itemID int specifies the newsletter recipient group */ - public function delete($itemID) - { + public function delete($itemID) { $oAssociations = new RecipientGroupMemberCollection; $oAssociations->setWhere("idnewsgroup", $itemID); $oAssociations->query(); @@ -110,20 +106,19 @@ class RecipientGroupCollection extends ItemCollection } parent::delete($itemID); } -} +} /** * Single RecipientGroup Item */ -class RecipientGroup extends Item -{ +class RecipientGroup extends Item { + /** * Constructor Function * @param mixed $mId Specifies the ID of item to load */ - public function __construct($mId = false) - { + public function __construct($mId = false) { global $cfg; parent::__construct($cfg["tab"]["news_groups"], "idnewsgroup"); if ($mId !== false) { @@ -132,21 +127,19 @@ class RecipientGroup extends Item } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function RecipientGroup($mId = false) - { + public function RecipientGroup($mId = false) { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct($mId); } /** * Overriden store() method to ensure, that there is only one default group - **/ - public function store() - { + * */ + public function store() { global $client, $lang; $client = Contenido_Security::toInteger($client); - $lang = Contenido_Security::toInteger($lang); + $lang = Contenido_Security::toInteger($lang); if ($this->get("defaultgroup") == 1) { $oItems = new RecipientGroupCollection(); @@ -163,30 +156,28 @@ class RecipientGroup extends Item } parent::store(); } -} +} /** * Recipient group member management class */ -class RecipientGroupMemberCollection extends ItemCollection -{ +class RecipientGroupMemberCollection extends ItemCollection { + /** * Constructor Function * @param none */ - public function __construct() - { + public function __construct() { global $cfg; parent::__construct($cfg["tab"]["news_groupmembers"], "idnewsgroupmember"); - $this->_setJoinPartner ('RecipientGroupCollection'); - $this->_setJoinPartner ('RecipientCollection'); + $this->_setJoinPartner('RecipientGroupCollection'); + $this->_setJoinPartner('RecipientCollection'); $this->_setItemClass("RecipientGroupMember"); } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function RecipientGroupMemberCollection() - { + public function RecipientGroupMemberCollection() { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct(); } @@ -196,10 +187,9 @@ class RecipientGroupMemberCollection extends ItemCollection * @param $idrecipientgroup int specifies the newsletter group * @param $idrecipient int specifies the newsletter user */ - public function create($idrecipientgroup, $idrecipient) - { + public function create($idrecipientgroup, $idrecipient) { $idrecipientgroup = Contenido_Security::toInteger($idrecipientgroup); - $idrecipient = Contenido_Security::toInteger($idrecipient); + $idrecipient = Contenido_Security::toInteger($idrecipient); $this->setWhere("idnewsgroup", $idrecipientgroup); $this->setWhere("idnewsrcp", $idrecipient); @@ -223,10 +213,9 @@ class RecipientGroupMemberCollection extends ItemCollection * @param $idrecipientgroup int specifies the newsletter group * @param $idrecipient int specifies the newsletter user */ - public function remove($idrecipientgroup, $idrecipient) - { + public function remove($idrecipientgroup, $idrecipient) { $idrecipientgroup = Contenido_Security::toInteger($idrecipientgroup); - $idrecipient = Contenido_Security::toInteger($idrecipient); + $idrecipient = Contenido_Security::toInteger($idrecipient); $this->setWhere("idnewsgroup", $idrecipientgroup); $this->setWhere("idnewsrcp", $idrecipient); @@ -241,8 +230,7 @@ class RecipientGroupMemberCollection extends ItemCollection * Removes all associations from any newsletter group * @param $idrecipient int specifies the newsletter recipient */ - public function removeRecipientFromGroups($idrecipient) - { + public function removeRecipientFromGroups($idrecipient) { $idrecipient = Contenido_Security::toInteger($idrecipient); $this->setWhere("idnewsrcp", $idrecipient); @@ -257,8 +245,7 @@ class RecipientGroupMemberCollection extends ItemCollection * Removes all associations of a newsletter group * @param $idgroup int specifies the newsletter recipient group */ - public function removeGroup($idgroup) - { + public function removeGroup($idgroup) { $idgroup = Contenido_Security::toInteger($idgroup); $this->setWhere("idnewsgroup", $idgroup); @@ -275,8 +262,7 @@ class RecipientGroupMemberCollection extends ItemCollection * @param $asObjects boolean specifies if the function should return objects * @return array RecipientRecipient items */ - public function getRecipientsInGroup($idrecipientgroup, $asObjects = true) - { + public function getRecipientsInGroup($idrecipientgroup, $asObjects = true) { $idrecipientgroup = Contenido_Security::toInteger($idrecipientgroup); $this->setWhere("idnewsgroup", $idrecipientgroup); @@ -297,20 +283,19 @@ class RecipientGroupMemberCollection extends ItemCollection return ($aObjects); } -} +} /** * Single RecipientGroup Item */ -class RecipientGroupMember extends Item -{ +class RecipientGroupMember extends Item { + /** * Constructor Function * @param mixed $mId Specifies the ID of item to load */ - public function __construct($mId = false) - { + public function __construct($mId = false) { global $cfg; parent::__construct($cfg["tab"]["news_groupmembers"], "idnewsgroupmember"); if ($mId !== false) { @@ -319,11 +304,11 @@ class RecipientGroupMember extends Item } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function RecipientGroupMember($mId = false) - { + public function RecipientGroupMember($mId = false) { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct($mId); } + } ?> \ No newline at end of file diff --git a/conlite/plugins/newsletter/classes/class.newsletter.jobs.php b/conlite/plugins/newsletter/classes/class.newsletter.jobs.php index 439cd7b..7301275 100644 --- a/conlite/plugins/newsletter/classes/class.newsletter.jobs.php +++ b/conlite/plugins/newsletter/classes/class.newsletter.jobs.php @@ -1,4 +1,5 @@ _setItemClass("cNewsletterJob"); } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cNewsletterJobCollection() - { + public function cNewsletterJobCollection() { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct(); } @@ -62,17 +59,16 @@ class cNewsletterJobCollection extends ItemCollection * @param $name string Specifies the name of the newsletter, the same name may be used more than once * @param $idnews integer Newsletter id */ - public function create($iIDNews, $iIDCatArt, $sName = "") - { + public function create($iIDNews, $iIDCatArt, $sName = "") { global $client, $lang, $cfg, $cfgClient, $auth; $oNewsletter = new Newsletter; if ($oNewsletter->loadByPrimaryKey($iIDNews)) { - $iIDNews = Contenido_Security::toInteger($iIDNews); + $iIDNews = Contenido_Security::toInteger($iIDNews); $iIDCatArt = Contenido_Security::toInteger($iIDCatArt); - $lang = Contenido_Security::toInteger($lang); - $client = Contenido_Security::toInteger($client); - $sName = Contenido_Security::escapeDB($sName, null); + $lang = Contenido_Security::toInteger($lang); + $client = Contenido_Security::toInteger($client); + $sName = Contenido_Security::escapeDB($sName, null); $oItem = parent::createNewItem(); @@ -90,13 +86,13 @@ class cNewsletterJobCollection extends ItemCollection $oLang = new cApiLanguage($lang); $oItem->set("encoding", $oLang->get("encoding")); - unset ($oLang); + unset($oLang); $oItem->set("idart", $oNewsletter->get("idart")); $oItem->set("subject", $oNewsletter->get("subject")); // Precompile messages - $sPath = $cfgClient[$client]["path"]["htmlpath"]."front_content.php?changelang=".$lang."&idcatart=".$iIDCatArt."&"; + $sPath = $cfgClient[$client]["path"]["htmlpath"] . "front_content.php?changelang=" . $lang . "&idcatart=" . $iIDCatArt . "&"; $sMessageText = $oNewsletter->get("message"); @@ -105,10 +101,10 @@ class cNewsletterJobCollection extends ItemCollection $sMessageText = str_replace("\r\n", "\n", $sMessageText); } - $oNewsletter->_replaceTag($sMessageText, false, "unsubscribe", $sPath."unsubscribe={KEY}"); - $oNewsletter->_replaceTag($sMessageText, false, "change", $sPath."change={KEY}"); - $oNewsletter->_replaceTag($sMessageText, false, "stop", $sPath."stop={KEY}"); - $oNewsletter->_replaceTag($sMessageText, false, "goon", $sPath."goon={KEY}"); + $oNewsletter->_replaceTag($sMessageText, false, "unsubscribe", $sPath . "unsubscribe={KEY}"); + $oNewsletter->_replaceTag($sMessageText, false, "change", $sPath . "change={KEY}"); + $oNewsletter->_replaceTag($sMessageText, false, "stop", $sPath . "stop={KEY}"); + $oNewsletter->_replaceTag($sMessageText, false, "goon", $sPath . "goon={KEY}"); $oItem->set("message_text", $sMessageText); @@ -125,22 +121,22 @@ class cNewsletterJobCollection extends ItemCollection $oNewsletter->_replaceTag($sMessageHTML, true, "date", "MAIL_DATE"); $oNewsletter->_replaceTag($sMessageHTML, true, "time", "MAIL_TIME"); - $oNewsletter->_replaceTag($sMessageHTML, true, "unsubscribe", $sPath."unsubscribe={KEY}"); - $oNewsletter->_replaceTag($sMessageHTML, true, "change", $sPath."change={KEY}"); - $oNewsletter->_replaceTag($sMessageHTML, true, "stop", $sPath."stop={KEY}"); - $oNewsletter->_replaceTag($sMessageHTML, true, "goon", $sPath."goon={KEY}"); + $oNewsletter->_replaceTag($sMessageHTML, true, "unsubscribe", $sPath . "unsubscribe={KEY}"); + $oNewsletter->_replaceTag($sMessageHTML, true, "change", $sPath . "change={KEY}"); + $oNewsletter->_replaceTag($sMessageHTML, true, "stop", $sPath . "stop={KEY}"); + $oNewsletter->_replaceTag($sMessageHTML, true, "goon", $sPath . "goon={KEY}"); // Replace plugin tags by simple MAIL_ tags if (getSystemProperty("newsletter", "newsletter-recipients-plugin") == "true") { if (is_array($cfg['plugins']['recipients'])) { foreach ($cfg['plugins']['recipients'] as $sPlugin) { - plugin_include("recipients", $sPlugin."/".$sPlugin.".php"); - if (function_exists("recipients_".$sPlugin."_wantedVariables")) { + plugin_include("recipients", $sPlugin . "/" . $sPlugin . ".php"); + if (function_exists("recipients_" . $sPlugin . "_wantedVariables")) { $aPluginVars = array(); - $aPluginVars = call_user_func("recipients_".$sPlugin."_wantedVariables"); + $aPluginVars = call_user_func("recipients_" . $sPlugin . "_wantedVariables"); foreach ($aPluginVars as $sPluginVar) { - $oNewsletter->_replaceTag($sMessageHTML, true, $sPluginVar, "MAIL_".strtoupper($sPluginVar)); + $oNewsletter->_replaceTag($sMessageHTML, true, $sPluginVar, "MAIL_" . strtoupper($sPluginVar)); } } } @@ -167,7 +163,7 @@ class cNewsletterJobCollection extends ItemCollection $oItem->set("dispatch_delay", $oNewsletter->get("dispatch_delay")); // Store "send to" info in serialized array (just info) - $aSendInfo = array(); + $aSendInfo = array(); $aSendInfo[] = $oNewsletter->get("send_to"); switch ($oNewsletter->get("send_to")) { @@ -182,8 +178,8 @@ class cNewsletterJobCollection extends ItemCollection $aSendInfo[] = $oGroup->get("groupname"); } - unset ($oGroup); - unset ($oGroups); + unset($oGroup); + unset($oGroups); break; case "single": if (is_numeric($oNewsletter->get("send_ids"))) { @@ -206,12 +202,11 @@ class cNewsletterJobCollection extends ItemCollection $oItem->set("created", date("Y-m-d H:i:s"), false); $oItem->set("author", $auth->auth["uid"]); $oItem->set("authorname", $auth->auth["uname"]); - unset ($oNewsletter); // Not needed anymore - + unset($oNewsletter); // Not needed anymore // Adds log items for all recipients and returns recipient count $oLogs = new cNewsletterLogCollection(); $iRecipientCount = $oLogs->initializeJob($oItem->get($oItem->primaryKey), $iIDNews); - unset ($oLogs); + unset($oLogs); $oItem->set("rcpcount", $iRecipientCount); $oItem->set("sendcount", 0); @@ -231,27 +226,25 @@ class cNewsletterJobCollection extends ItemCollection * * @param $iItemID int specifies the frontend user group */ - public function delete($iItemID) - { + public function delete($iItemID) { $oLogs = new cNewsletterLogCollection(); $oLogs->delete($iItemID); parent::delete($iItemID); } -} +} /** * Single NewsletterJob Item */ -class cNewsletterJob extends Item -{ +class cNewsletterJob extends Item { + /** * Constructor Function * @param mixed $mId Specifies the ID of item to load */ - public function __construct($mId = false) - { + public function __construct($mId = false) { global $cfg; parent::__construct($cfg["tab"]["news_jobs"], "idnewsjob"); if ($mId !== false) { @@ -260,14 +253,12 @@ class cNewsletterJob extends Item } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cNewsletterJob($mId = false) - { + public function cNewsletterJob($mId = false) { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct($mId); } - public function runJob() - { + public function runJob() { global $cfg, $recipient; $iCount = 0; @@ -275,7 +266,7 @@ class cNewsletterJob extends Item // Job is currently running, check start time and restart if // started 5 minutes ago $dStart = strtotime($this->get("started")); - $dNow = time(); + $dNow = time(); if (($dNow - $dStart) > (5 * 60)) { $this->set("status", 1); @@ -296,7 +287,7 @@ class cNewsletterJob extends Item if ($this->get("status") == 1) { // Job waiting for sending $this->set("status", 2); - $this->set("started", date("Y-m-d H:i:s"), false); + $this->set("started", date("Y-m-d H:i:s"), false); $this->store(); // Initialization @@ -305,7 +296,7 @@ class cNewsletterJob extends Item $oLanguage = new cApiLanguage($this->get("idlang")); $sFormatDate = $oLanguage->getProperty("dateformat", "date"); $sFormatTime = $oLanguage->getProperty("dateformat", "time"); - unset ($oLanguage); + unset($oLanguage); if ($sFormatDate == "") { $sFormatDate = "%d.%m.%Y"; @@ -315,14 +306,14 @@ class cNewsletterJob extends Item } // Get newsletter data - $sFrom = $this->get("newsfrom"); - $sFromName = $this->get("newsfromname"); - $sSubject = $this->get("subject"); - $sMessageText = $this->get("message_text"); - $sMessageHTML = $this->get("message_html"); - $dNewsDate = strtotime($this->get("newsdate")); - $sEncoding = $this->get("encoding"); - $bIsHTML = false; + $sFrom = $this->get("newsfrom"); + $sFromName = $this->get("newsfromname"); + $sSubject = $this->get("subject"); + $sMessageText = $this->get("message_text"); + $sMessageHTML = $this->get("message_html"); + $dNewsDate = strtotime($this->get("newsdate")); + $sEncoding = $this->get("encoding"); + $bIsHTML = false; if ($this->get("type") == "html" && $sMessageHTML != "") { $bIsHTML = true; } @@ -349,13 +340,13 @@ class cNewsletterJob extends Item $bPluginEnabled = false; if (getSystemProperty("newsletter", "newsletter-recipients-plugin") == "true") { $bPluginEnabled = true; - $aPlugins = array(); + $aPlugins = array(); if (is_array($cfg['plugins']['recipients'])) { foreach ($cfg['plugins']['recipients'] as $sPlugin) { - plugin_include("recipients", $sPlugin."/".$sPlugin.".php"); - if (function_exists("recipients_".$sPlugin."_wantedVariables")) { - $aPlugins[$sPlugin] = call_user_func("recipients_".$sPlugin."_wantedVariables"); + plugin_include("recipients", $sPlugin . "/" . $sPlugin . ".php"); + if (function_exists("recipients_" . $sPlugin . "_wantedVariables")) { + $aPlugins[$sPlugin] = call_user_func("recipients_" . $sPlugin . "_wantedVariables"); } } } @@ -383,21 +374,21 @@ class cNewsletterJob extends Item $sRcpMsgText = $sMessageText; $sRcpMsgHTML = $sMessageHTML; - $sKey = $oLog->get("rcphash"); + $sKey = $oLog->get("rcphash"); $sEMail = $oLog->get("rcpemail"); - $bSendHTML = false; + $bSendHTML = false; if ($oLog->get("rcpnewstype") == 1) { $bSendHTML = true; // Recipient accepts html newsletter } if (strlen($sKey) == 30) { // Prevents sending without having a key - $sRcpMsgText = str_replace("{KEY}", $sKey, $sRcpMsgText); + $sRcpMsgText = str_replace("{KEY}", $sKey, $sRcpMsgText); $sRcpMsgText = str_replace("MAIL_MAIL", $sEMail, $sRcpMsgText); $sRcpMsgText = str_replace("MAIL_NAME", $oLog->get("rcpname"), $sRcpMsgText); // Replace message tags (html message) if ($bIsHTML && $bSendHTML) { - $sRcpMsgHTML = str_replace("{KEY}", $sKey, $sRcpMsgHTML); + $sRcpMsgHTML = str_replace("{KEY}", $sKey, $sRcpMsgHTML); $sRcpMsgHTML = str_replace("MAIL_MAIL", $sEMail, $sRcpMsgHTML); $sRcpMsgHTML = str_replace("MAIL_NAME", $oLog->get("rcpname"), $sRcpMsgHTML); } @@ -410,11 +401,11 @@ class cNewsletterJob extends Item foreach ($aPlugins as $sPlugin => $aPluginVar) { foreach ($aPluginVar as $sPluginVar) { // Replace tags in text message - $sRcpMsgText = str_replace("MAIL_".strtoupper($sPluginVar), call_user_func("recipients_".$sPlugin."_getvalue", $sPluginVar), $sRcpMsgText); + $sRcpMsgText = str_replace("MAIL_" . strtoupper($sPluginVar), call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar), $sRcpMsgText); // Replace tags in html message if ($bIsHTML && $bSendHTML) { - $sRcpMsgHTML = str_replace("MAIL_".strtoupper($sPluginVar), call_user_func("recipients_".$sPlugin."_getvalue", $sPluginVar), $sRcpMsgHTML); + $sRcpMsgHTML = str_replace("MAIL_" . strtoupper($sPluginVar), call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar), $sRcpMsgHTML); } } } @@ -422,24 +413,24 @@ class cNewsletterJob extends Item } $oMail = new PHPMailer(); - $oMail->CharSet = $sEncoding; + $oMail->CharSet = $sEncoding; $oMail->IsHTML($bIsHTML && $bSendHTML); - $oMail->From = $sFrom; - $oMail->FromName = $sFromName; + $oMail->From = $sFrom; + $oMail->FromName = $sFromName; $oMail->AddAddress($sEMail); - $oMail->Mailer = "mail"; - $oMail->Subject = $sSubject; + $oMail->Mailer = "mail"; + $oMail->Subject = $sSubject; if ($bIsHTML && $bSendHTML) { - $oMail->Body = $sRcpMsgHTML; - $oMail->AltBody = $sRcpMsgText."\n\n"; + $oMail->Body = $sRcpMsgHTML; + $oMail->AltBody = $sRcpMsgText . "\n\n"; } else { - $oMail->Body = $sRcpMsgText."\n\n"; + $oMail->Body = $sRcpMsgText . "\n\n"; } if ($oMail->Send()) { $oLog->set("status", "successful"); - $oLog->set("sent", date("Y-m-d H:i:s"), false); + $oLog->set("sent", date("Y-m-d H:i:s"), false); } else { $oLog->set("status", "error (sending)"); } @@ -466,7 +457,7 @@ class cNewsletterJob extends Item If ($oLogs->next()) { // Remaining recipients found, set job back to pending $this->set("status", 1); - $this->set("started", "0000-00-00 00:00:00", false); + $this->set("started", "0000-00-00 00:00:00", false); } else { // No remaining recipients, job finished $this->set("status", 9); @@ -475,7 +466,7 @@ class cNewsletterJob extends Item } else { // Set job back to pending $this->set("status", 1); - $this->set("started", "0000-00-00 00:00:00", false); + $this->set("started", "0000-00-00 00:00:00", false); } $this->store(); } @@ -486,19 +477,19 @@ class cNewsletterJob extends Item /** * Overriden store() method to set status to finished if rcpcount is 0 */ - public function store() - { + public function store() { if ($this->get("rcpcount") == 0) { // No recipients, job finished - $this->set("status", 9); + $this->set("status", 9); if ($this->get("started") == "0000-00-00 00:00:00") { $this->set("started", date("Y-m-d H:i:s"), false); } - $this->set("finished", date("Y-m-d H:i:s"), false); + $this->set("finished", date("Y-m-d H:i:s"), false); } parent::store(); } + } ?> \ No newline at end of file diff --git a/conlite/plugins/newsletter/classes/class.newsletter.logs.php b/conlite/plugins/newsletter/classes/class.newsletter.logs.php index 79210e8..3b00f2d 100644 --- a/conlite/plugins/newsletter/classes/class.newsletter.logs.php +++ b/conlite/plugins/newsletter/classes/class.newsletter.logs.php @@ -1,4 +1,5 @@ _setItemClass("cNewsletterLog"); } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cNewsletterLogCollection() - { + public function cNewsletterLogCollection() { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct(); } @@ -64,14 +61,13 @@ class cNewsletterLogCollection extends ItemCollection * @param $rcp_name string Name of the recipient (-> recipient may be deleted) * @param $rcp_email string E-Mail of the recipient (-> recipient may be deleted) */ - public function create($idnewsjob, $idnewsrcp) - { + public function create($idnewsjob, $idnewsrcp) { global $client, $lang, $auth; - $idnewsjob = Contenido_Security::toInteger($idnewsjob); - $idnewsrcp = Contenido_Security::toInteger($idnewsrcp); - $client = Contenido_Security::toInteger($client); - $lang = Contenido_Security::toInteger($lang); + $idnewsjob = Contenido_Security::toInteger($idnewsjob); + $idnewsrcp = Contenido_Security::toInteger($idnewsrcp); + $client = Contenido_Security::toInteger($client); + $lang = Contenido_Security::toInteger($lang); $this->resetQuery(); $this->setWhere("idnewsjob", $idnewsjob); @@ -90,7 +86,7 @@ class cNewsletterLogCollection extends ItemCollection $oItem->set("idnewsrcp", $idnewsrcp); $sEMail = $oRecipient->get("email"); - $sName = $oRecipient->get("name"); + $sName = $oRecipient->get("name"); if ($sName == "") { $oItem->set("rcpname", $sEMail); @@ -118,51 +114,50 @@ class cNewsletterLogCollection extends ItemCollection * @param integer $idnews ID of newsletter * @return integer Recipient count */ - public function initializeJob($idnewsjob, $idnews) - { + public function initializeJob($idnewsjob, $idnews) { global $cfg; $idnewsjob = Contenido_Security::toInteger($idnewsjob); - $idnews = Contenido_Security::toInteger($idnews); + $idnews = Contenido_Security::toInteger($idnews); $oNewsletter = new Newsletter(); if ($oNewsletter->loadByPrimaryKey($idnews)) { $sDestination = $oNewsletter->get("send_to"); - $iIDClient = $oNewsletter->get("idclient"); - $iIDLang = $oNewsletter->get("idlang"); + $iIDClient = $oNewsletter->get("idclient"); + $iIDLang = $oNewsletter->get("idlang"); switch ($sDestination) { case "all" : $sDistinct = ""; - $sFrom = ""; - $sSQL = "deactivated='0' AND confirmed='1' AND idclient='".$iIDClient."' AND idlang='".$iIDLang."'"; + $sFrom = ""; + $sSQL = "deactivated='0' AND confirmed='1' AND idclient='" . $iIDClient . "' AND idlang='" . $iIDLang . "'"; break; case "default" : $sDistinct = "distinct"; - $sFrom = $cfg["tab"]["news_groups"]." AS groups, ".$cfg["tab"]["news_groupmembers"]." AS groupmembers "; - $sSQL = "recipientcollection.idclient = '".$iIDClient."' AND ". - "recipientcollection.idlang = '".$iIDLang."' AND ". - "recipientcollection.deactivated = '0' AND ". - "recipientcollection.confirmed = '1' AND ". - "recipientcollection.idnewsrcp = groupmembers.idnewsrcp AND ". - "groupmembers.idnewsgroup = groups.idnewsgroup AND ". - "groups.defaultgroup = '1' AND groups.idclient = '".$iIDClient."' AND ". - "groups.idlang = '".$iIDLang."'"; + $sFrom = $cfg["tab"]["news_groups"] . " AS groups, " . $cfg["tab"]["news_groupmembers"] . " AS groupmembers "; + $sSQL = "recipientcollection.idclient = '" . $iIDClient . "' AND " . + "recipientcollection.idlang = '" . $iIDLang . "' AND " . + "recipientcollection.deactivated = '0' AND " . + "recipientcollection.confirmed = '1' AND " . + "recipientcollection.idnewsrcp = groupmembers.idnewsrcp AND " . + "groupmembers.idnewsgroup = groups.idnewsgroup AND " . + "groups.defaultgroup = '1' AND groups.idclient = '" . $iIDClient . "' AND " . + "groups.idlang = '" . $iIDLang . "'"; break; case "selection" : - $aGroups = unserialize ($oNewsletter->get("send_ids")); + $aGroups = unserialize($oNewsletter->get("send_ids")); if (is_array($aGroups) && count($aGroups) > 0) { - $sGroups = "'" . implode("','", $aGroups) . "'"; + $sGroups = "'" . implode("','", $aGroups) . "'"; - $sDistinct = "distinct"; - $sFrom = $cfg["tab"]["news_groupmembers"]." AS groupmembers "; - $sSQL = "recipientcollection.idclient = '".$iIDClient."' AND ". - "recipientcollection.idlang = '".$iIDLang."' AND ". - "recipientcollection.deactivated = '0' AND ". - "recipientcollection.confirmed = '1' AND ". - "recipientcollection.idnewsrcp = groupmembers.idnewsrcp AND ". - "groupmembers.idnewsgroup IN (".$sGroups.")"; + $sDistinct = "distinct"; + $sFrom = $cfg["tab"]["news_groupmembers"] . " AS groupmembers "; + $sSQL = "recipientcollection.idclient = '" . $iIDClient . "' AND " . + "recipientcollection.idlang = '" . $iIDLang . "' AND " . + "recipientcollection.deactivated = '0' AND " . + "recipientcollection.confirmed = '1' AND " . + "recipientcollection.idnewsrcp = groupmembers.idnewsrcp AND " . + "groupmembers.idnewsgroup IN (" . $sGroups . ")"; } else { $sDestination = "unknown"; } @@ -171,8 +166,8 @@ class cNewsletterLogCollection extends ItemCollection $iID = $oNewsletter->get("send_ids"); if (is_numeric($iID)) { $sDistinct = ""; - $sFrom = ""; - $sSQL = "idnewsrcp = '".$iID."'"; + $sFrom = ""; + $sSQL = "idnewsrcp = '" . $iID . "'"; } else { $sDestination = "unknown"; } @@ -180,7 +175,7 @@ class cNewsletterLogCollection extends ItemCollection default: $sDestination = "unknown"; } - unset ($oNewsletter); + unset($oNewsletter); if ($sDestination == "unknown") { return 0; @@ -205,8 +200,7 @@ class cNewsletterLogCollection extends ItemCollection * Overriden delete function to update recipient count if removing recipient from the list * @param integer $idnewslog ID */ - public function delete($idnewslog) - { + public function delete($idnewslog) { $idnewslog = Contenido_Security::toInteger($idnewslog); $oLog = new cNewsletterLog($idnewslog); @@ -216,13 +210,12 @@ class cNewsletterLogCollection extends ItemCollection $oJob = new cNewsletterJob($iIDNewsJob); $oJob->set("rcpcount", $oJob->get("rcpcount") - 1); $oJob->store(); - unset ($oJob); + unset($oJob); parent::delete($idnewslog); } - public function deleteJob($idnewsjob) - { + public function deleteJob($idnewsjob) { $idnewsjob = Contenido_Security::toInteger($idnewsjob); $this->setWhere("idnewsjob", $idnewsjob); $this->query(); @@ -233,20 +226,19 @@ class cNewsletterLogCollection extends ItemCollection return true; } -} +} /** * Single NewsletterLog Item */ -class cNewsletterLog extends Item -{ +class cNewsletterLog extends Item { + /** * Constructor Function * @param mixed $mId Specifies the ID of item to load */ - public function __construct($mId = false) - { + public function __construct($mId = false) { global $cfg; parent::__construct($cfg["tab"]["news_log"], "idnewslog"); if ($mId !== false) { @@ -255,11 +247,11 @@ class cNewsletterLog extends Item } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function cNewsletterLog($mId = false) - { + public function cNewsletterLog($mId = false) { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct($mId); } + } ?> \ No newline at end of file diff --git a/conlite/plugins/newsletter/classes/class.newsletter.php b/conlite/plugins/newsletter/classes/class.newsletter.php index 0e5b643..dd3a47e 100644 --- a/conlite/plugins/newsletter/classes/class.newsletter.php +++ b/conlite/plugins/newsletter/classes/class.newsletter.php @@ -118,7 +118,7 @@ class NewsletterCollection extends ItemCollection if ($oClientLang->getProperty("newsletter", "html_newsletter") == "true") { $iIDArt = conCopyArticle($oBaseItem->get("idart"), $oClientLang->getProperty("newsletter", "html_newsletter_idcat"), - sprintf(i18n("Newsletter: %s"), $oItem->get("name"))); + sprintf(i18n("Newsletter: %s", "newsletter"), $oItem->get("name"))); conMakeOnline($iIDArt, $lang); // Article has to be online for sending... } unset ($oClientLang); @@ -564,7 +564,7 @@ class Newsletter extends Item $sReturn = $sHTML; } else { if ($contenido) { // Use i18n only in backend - $sErrorText = i18n("There was a problem getting the newsletter article using http. Error: %s (%s)"); + $sErrorText = i18n("There was a problem getting the newsletter article using http. Error: %s (%s)", "newsletter"); } else { $sErrorText = "There was a problem getting the newsletter article using http. Error: %s (%s)"; } @@ -671,7 +671,7 @@ class Newsletter extends Item // deleted). Exit with error instead of sending as text message only if ($contenido) { // Use i18n only in backend - $sError = i18n("Newsletter to %s could not be sent: No html message available"); + $sError = i18n("Newsletter to %s could not be sent: No html message available", "newsletter"); } else { $sError = "Newsletter to %s could not be sent: No html message available"; } @@ -742,7 +742,7 @@ class Newsletter extends Item if (!isValidMail($sEMail) || strtolower($sEMail) == "sysadmin@ihresite.de") { // No valid destination mail address specified if ($contenido) { // Use i18n only in backend - $sError = i18n("Newsletter to %s could not be sent: No valid e-mail address"); + $sError = i18n("Newsletter to %s could not be sent: No valid e-mail address", "newsletter"); } else { $sError = "Newsletter to %s could not be sent: No valid e-mail address"; } @@ -767,7 +767,7 @@ class Newsletter extends Item if (!$oMail->Send()) { if ($contenido) { // Use i18n only in backend - $sError = i18n("Newsletter to %s could not be sent"); + $sError = i18n("Newsletter to %s could not be sent", "newsletter"); } else { $sError = "Newsletter to %s could not be sent"; } @@ -830,7 +830,7 @@ class Newsletter extends Item // deleted). Exit with error instead of sending as text message only if ($contenido) { // Use i18n only in backend - $sError = i18n("Newsletter could not be sent: No html message available"); + $sError = i18n("Newsletter could not be sent: No html message available", "newsletter"); } else { $sError = "Newsletter could not be sent: No html message available"; } @@ -942,14 +942,14 @@ class Newsletter extends Item if (strlen($sKey) != 30) { // Prevents sending without having a key if ($contenido) { // Use i18n only in backend - $sError = i18n("Newsletter to %s could not be sent: Recipient has an incompatible or empty key"); + $sError = i18n("Newsletter to %s could not be sent: Recipient has an incompatible or empty key", "newsletter"); } else { $sError = "Newsletter to %s could not be sent: Recipient has an incompatible or empty key"; } $aMessages[] = $sName." (".$sEMail."): ".sprintf($sError, $sEMail); } else if (!isValidMail($sEMail)) { if ($contenido) { // Use i18n only in backend - $sError = i18n("Newsletter to %s could not be sent: No valid e-mail address specified"); + $sError = i18n("Newsletter to %s could not be sent: No valid e-mail address specified", "newsletter"); } else { $sError = "Newsletter to %s could not be sent: No valid e-mail address specified"; } @@ -975,7 +975,7 @@ class Newsletter extends Item $aSendRcps[] = $sName." (".$sEMail.")"; } else { if ($contenido) { // Use i18n only in backend - $sError = i18n("Newsletter to %s could not be sent"); + $sError = i18n("Newsletter to %s could not be sent", "newsletter"); } else { $sError = "Newsletter to %s could not be sent"; } @@ -985,7 +985,7 @@ class Newsletter extends Item } } else { if ($contenido) { // Use i18n only in backend - $sError = i18n("No recipient with specified recipient/group id %s/%s found"); + $sError = i18n("No recipient with specified recipient/group id %s/%s found", "newsletter"); } else { $sError = "No recipient with specified recpient/group id %s/%s found"; } diff --git a/conlite/plugins/newsletter/classes/class.newsletter.recipients.php b/conlite/plugins/newsletter/classes/class.newsletter.recipients.php index 59ecc6f..75e4da3 100644 --- a/conlite/plugins/newsletter/classes/class.newsletter.recipients.php +++ b/conlite/plugins/newsletter/classes/class.newsletter.recipients.php @@ -1,4 +1,5 @@ _setItemClass("Recipient"); } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function RecipientCollection() - { + public function RecipientCollection() { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct(); } @@ -65,12 +62,11 @@ class RecipientCollection extends ItemCollection * @param string $sJoinID Specifies additional recipient group ids to join (optional, e.g. 47,12,...) * @param int $iMessageType Specifies the message type for the recipient (0 = text, 1 = html) */ - public function create($sEMail, $sName = "", $iConfirmed = 0, $sJoinID = "", $iMessageType = 0) - { + public function create($sEMail, $sName = "", $iConfirmed = 0, $sJoinID = "", $iMessageType = 0) { global $client, $lang, $auth; - $iConfirmed = (int)$iConfirmed; - $iMessageType = (int)$iMessageType; + $iConfirmed = (int) $iConfirmed; + $iMessageType = (int) $iMessageType; /* Check if the e-mail adress already exists */ $email = strtolower($email); // e-mail always lower case @@ -80,14 +76,14 @@ class RecipientCollection extends ItemCollection $this->query(); if ($this->next()) { - return $this->create($sEMail."_".substr(md5(rand()),0,10), $sName, 0, $sJoinID, $iMessageType); // 0: Deactivate 'confirmed' + return $this->create($sEMail . "_" . substr(md5(rand()), 0, 10), $sName, 0, $sJoinID, $iMessageType); // 0: Deactivate 'confirmed' } $oItem = parent::createNewItem(); $oItem->set("idclient", $client); $oItem->set("idlang", $lang); $oItem->set("name", $sName); $oItem->set("email", $sEMail); - $oItem->set("hash", substr(md5(rand()),0,17) . uniqid("")); // Generating UID, 30 characters + $oItem->set("hash", substr(md5(rand()), 0, 17) . uniqid("")); // Generating UID, 30 characters $oItem->set("confirmed", $iConfirmed); $oItem->set("news_type", $iMessageType); @@ -100,9 +96,8 @@ class RecipientCollection extends ItemCollection $oItem->store(); $iIDRcp = $oItem->get("idnewsrcp"); // Getting internal id of new recipient - // Add this recipient to the default recipient group (if available) - $oGroups = new RecipientGroupCollection(); + $oGroups = new RecipientGroupCollection(); $oGroupMembers = new RecipientGroupMemberCollection(); $oGroups->setWhere("idclient", $client); @@ -135,8 +130,7 @@ class RecipientCollection extends ItemCollection * * @param $itemID int specifies the recipient */ - public function delete($itemID) - { + public function delete($itemID) { $oAssociations = new RecipientGroupMemberCollection(); $oAssociations->setWhere("idnewsrcp", $itemID); $oAssociations->query(); @@ -152,8 +146,7 @@ class RecipientCollection extends ItemCollection * @param $timeframe int Days after creation a not confirmed recipient will be removed * @return int Count of deleted recipients */ - public function purge($timeframe) - { + public function purge($timeframe) { global $client, $lang; $oRecipientCollection = new RecipientCollection(); @@ -172,14 +165,12 @@ class RecipientCollection extends ItemCollection return $oRecipientCollection->count(); } - /** * checkEMail returns true, if there is no recipient with the same e-mail address; otherwise false * @param $email string e-mail * @return recpient item if item with e-mail exists, false otherwise */ - public function emailExists($sEmail) - { + public function emailExists($sEmail) { global $client, $lang; $oRecipientCollection = new RecipientCollection(); @@ -200,33 +191,31 @@ class RecipientCollection extends ItemCollection * Sets a key for all recipients without key or an old key (len(key) <> 30) * @param none */ - public function updateKeys() - { + public function updateKeys() { $this->setWhere("LENGTH(hash)", 30, "<>"); $this->query(); $iUpdated = $this->count(); while ($oItem = $this->next()) { - $oItem->set("hash", substr(md5(rand()),0,17) . uniqid("")); /* Generating UID, 30 characters */ + $oItem->set("hash", substr(md5(rand()), 0, 17) . uniqid("")); /* Generating UID, 30 characters */ $oItem->store(); } return $iUpdated; } -} +} /** * Single Recipient Item */ -class Recipient extends Item -{ +class Recipient extends Item { + /** * Constructor Function * @param mixed $mId Specifies the ID of item to load */ - public function __construct($mId = false) - { + public function __construct($mId = false) { global $cfg; parent::__construct($cfg["tab"]["news_rcp"], "idnewsrcp"); if ($mId !== false) { @@ -235,8 +224,7 @@ class Recipient extends Item } /** @deprecated [2011-03-15] Old constructor function for downwards compatibility */ - public function Recipient($mId = false) - { + public function Recipient($mId = false) { cWarning(__FILE__, __LINE__, "Deprecated method call, use __construct()"); $this->__construct($mId); } @@ -247,8 +235,7 @@ class Recipient extends Item * @return boolean True if the hash matches, false otherwise * @deprecated 4.6.15 - 10.08.2006 */ - public function checkMD5Email($md5email) - { + public function checkMD5Email($md5email) { if ($md5email == md5($this->get("email"))) { return true; } else { @@ -256,8 +243,7 @@ class Recipient extends Item } } - public function store() - { + public function store() { global $auth; $this->set("lastmodified", date("Y-m-d H:i:s"), false); @@ -265,7 +251,7 @@ class Recipient extends Item parent::store(); // Update name, email and newsletter type for recipients in pending newsletter jobs - $sName = $this->get("name"); + $sName = $this->get("name"); $sEmail = $this->get("email"); if ($sName == "") { $sName = $sEmail; @@ -284,6 +270,7 @@ class Recipient extends Item $oLog->store(); } } + } ?> \ No newline at end of file diff --git a/conlite/plugins/newsletter/includes/include.newsletter_edit.php b/conlite/plugins/newsletter/includes/include.newsletter_edit.php index bd9a616..8457ca0 100644 --- a/conlite/plugins/newsletter/includes/include.newsletter_edit.php +++ b/conlite/plugins/newsletter/includes/include.newsletter_edit.php @@ -1,4 +1,5 @@ have_perm_area_action($area, "news_create")) -{ - // Create new newsletter - $oNewsletter = $oNewsletters->create(i18n("-- new 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")); +if ($action == "news_create" && $perm->have_perm_area_action($area, "news_create")) { + // Create new newsletter + $oNewsletter = $oNewsletters->create(i18n("-- new newsletter --", "newsletter")); + $idnewsletter = $oNewsletter->get("idnews"); + $oPage->setSubnav("idnewsletter=$idnewsletter", "news"); + $oPage->setReload(); - $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(); + // 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")) . "
"; - } else { - $notis = $notification->returnNotification("error", i18n("Newsletter dispatch job has been not been added! Please check newsletter details")) . "
"; - } - - $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"); + // Copy newsletter + $oNewsletter = $oNewsletters->duplicate($idnewsletter); - $bSend = $oNewsletter->sendEMail($oClientLang->getProperty("newsletter", "idcatart"), $sEMail, $sName, true, $sEncoding); - if ($bSend) { - $aRecipients[] = $sName . " (" . $sEMail . ")"; - } else { - $aRecipients[] = i18n("None"); - } - } 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:") . "
" . implode("
", $aRecipients) . "
"); - } else { - $notis = $notification->returnNotification("warning", i18n("Test newsletter has not been sent (partly or completely):") . "
" . - i18n("Successful:") . "
" . implode("
", $aRecipients) . "
" . - i18n("Error messages:") . "
" . $oNewsletter->_sError); - } + // 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", "newsletter")) . "
"; + } else { + $notis = $notification->returnNotification("error", i18n("Newsletter dispatch job has been not been added! Please check newsletter details", "newsletter")) . "
"; + } + + $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", "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:", "newsletter") . "
" . implode("
", $aRecipients) . "
"); + } else { + $notis = $notification->returnNotification("warning", i18n("Test newsletter has not been sent (partly or completely):", "newsletter") . "
" . + i18n("Successful:", "newsletter") . "
" . implode("
", $aRecipients) . "
" . + i18n("Error messages:", "newsletter") . "
" . $oNewsletter->_sError); + } } else { - // No action, just get selected newsletter - $oNewsletter = new Newsletter($idnewsletter); + // 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 ($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["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(); + if (!is_numeric($_REQUEST["txtDispatchCount"]) || $_REQUEST["txtDispatchCount"] <= 0) { + $_REQUEST["txtDispatchCount"] = $oNewsletter->get("dispatch_count"); + } - // 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"); - } 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"), $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'"); - $_REQUEST["optSendTo"] = "all"; - } - $oNewsletter->set("send_to", $_REQUEST["optSendTo"]); - $oNewsletter->set("send_ids", serialize($_REQUEST["selGroup"])); + // Note, that for DispatchDelay 0 is possible (= send chunks manually) + if (!is_numeric($_REQUEST["txtDispatchDelay"]) || $_REQUEST["txtDispatchDelay"] < 0) { + $_REQUEST["txtDispatchDelay"] = $oNewsletter->get("dispatch_delay"); + } - 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("
", $aMessages)) . "
"; - } - } 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(); - } - } + // 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; + } - $_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")); + if ($action == "news_save" && $perm->have_perm_area_action($area, $action)) { + // Save changes + $aMessages = array(); - $oForm->addHeader(i18n("Edit newsletter")); + // Changing e.g. \' back to ' (magic_quotes) + $sName = stripslashes($_REQUEST["txtName"]); + $sFromEMail = stripslashes($_REQUEST["txtFromEMail"]); + $sFromName = stripslashes($_REQUEST["txtFromName"]); + $sSubject = stripslashes($_REQUEST["txtSubject"]); - $oTxtName = new cHTMLTextbox("txtName", $oNewsletter->get("name"),40); - $oForm->add(i18n("Name"), $oTxtName->render()); - - $oSelType = new cHTMLSelectElement("selType"); - $aItems = array(); - $aItems[] = array("text", i18n("Text only")); - if ($oClientLang->getProperty("newsletter", "html_newsletter") == "true") { - $aItems[] = array("html", i18n("HTML and text")); - } 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"), $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); + 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(); + } - $oForm->add(i18n("From (E-Mail)"), $oTxtFromEMail->render()); - $oForm->add(i18n("From (Name)"), $oTxtFromName->render()." ".i18n("optional")); - $oForm->add(i18n("Subject"), $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)"); + 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(); - $oRcpGroups->setWhere("idclient", $client); - $oRcpGroups->setWhere("idlang", $lang); - $oRcpGroups->setOrder("defaultgroup DESC, groupname ASC"); - $oRcpGroups->query(); + if ($oNewsletters->next()) { + $aMessages[] = i18n("Could not set new newsletter name: name already exists", "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(); - $aItems = array(); - while ($oRcpGroup = $oRcpGroups->next()) - { - $sGroupName = $oRcpGroup->get("groupname"); - if ($oRcpGroup->get("defaultgroup")) { - $sGroupName = $sGroupName . "*"; - } - $aItems[] = array($oRcpGroup->get("idnewsgroup"), $sGroupName); - } + if ($oArticle = $oArticles->next()) { + $oArticle->set("title", sprintf(i18n("Newsletter: %s", "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); - $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 to select multiple items.")); - $oSelGroup->autoFill($aItems); + // Options + $oNewsletter->set("welcome", $_REQUEST["ckbWelcome"]); - // 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); - } - } - } + // 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"); - 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); - } + if (is_array($wantVariables)) { + $varArray = array(); - // Recipients - $oForm->add(i18n("Recipients"), - $oSendToAll->toHTML(false)." ".i18n("Send newsletter to all recipients")."
".chr(10). - $oSendToDefault->toHTML(false)." ".i18n("Send newsletter to the members of the default group")."
".chr(10). - $oSendToGroups->toHTML(false)." ".i18n("Send newsletter to the members of the selected group(s):")."
".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 to select multiple items.")); - //$oSelGroup->autoFill($aItems); - $sFileSelScript = ''; - $oPage->addScript('selFile', $sFileSelScript); - $oForm->add(i18n("Attachments"), $oSelFiles->render().'
Test'); - */ - - // Options - $ckbWelcome = new cHTMLCheckbox("ckbWelcome", "1"); - $ckbWelcome->setChecked($oNewsletter->get("welcome")); + $oNewsletter->set("dispatch_count", $_REQUEST["txtDispatchCount"]); + $oNewsletter->set("dispatch_delay", $_REQUEST["txtDispatchDelay"]); - // 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")); - } - - $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.")); - $oCkbSaveAsDefault = new cHTMLCheckbox("ckbSetDefault", "1"); - - $oForm->add(i18n("Options"), - $ckbWelcome->toHTML(false)." ".i18n("Welcome-Newsletter")."
". - $ckbCronJob->toHTML(false)." ".i18n("Use cronjob")."
". - $oCkbDispatch->toHTML(false)." ".i18n("Send in blocks:")."   ". - i18n("Recipients per block:")." ".$oTxtDispatchCount->render()." ". - i18n("Delay between blocks:")." ".$oTxtDispatchDelay->render()." ".i18n("sec.")."
". - $oCkbSaveAsDefault->toHTML(false)." ".i18n("Save option settings as default")); - - $oForm->add(i18n("Author"), $classuser->getUserName($oNewsletter->get("author")) . " (". $oNewsletter->get("created").")" ); - $oForm->add(i18n("Last modified by"), $classuser->getUserName($oNewsletter->get("modifiedby")). " (". $oNewsletter->get("modified").")" ); + $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"]); + } - $sExecScript = ' + if (count($aMessages) > 0) { + $notis .= $notification->returnNotification("warning", implode("
", $aMessages)) . "
"; + } + } 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", "newsletter")); + + $oTxtName = new cHTMLTextbox("txtName", $oNewsletter->get("name"), 40); + $oForm->add(i18n("Name", "newsletter"), $oTxtName->render()); + + $oSelType = new cHTMLSelectElement("selType"); + $aItems = array(); + $aItems[] = array("text", i18n("Text only", "newsletter")); + if ($oClientLang->getProperty("newsletter", "html_newsletter") == "true") { + $aItems[] = array("html", i18n("HTML and text", "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", "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)", "newsletter"), $oTxtFromEMail->render()); + $oForm->add(i18n("From (Name)", "newsletter"), $oTxtFromName->render() . " " . i18n("optional", "newsletter")); + $oForm->add(i18n("Subject", "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 to select multiple items.", "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", "newsletter"), $oSendToAll->toHTML(false) . " " . i18n("Send newsletter to all recipients", "newsletter") . "
" . chr(10) . + $oSendToDefault->toHTML(false) . " " . i18n("Send newsletter to the members of the default group", "newsletter") . "
" . chr(10) . + $oSendToGroups->toHTML(false) . " " . i18n("Send newsletter to the members of the selected group(s):", "newsletter") . "
" . 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 to select multiple items.")); + //$oSelGroup->autoFill($aItems); + $sFileSelScript = ''; + $oPage->addScript('selFile', $sFileSelScript); + $oForm->add(i18n("Attachments"), $oSelFiles->render().'
Test'); + */ + + // 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", "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.", "newsletter")); + $oCkbSaveAsDefault = new cHTMLCheckbox("ckbSetDefault", "1"); + + $oForm->add(i18n("Options", "newsletter"), $ckbWelcome->toHTML(false) . " " . i18n("Welcome-Newsletter", "newsletter") . "
" . + $ckbCronJob->toHTML(false) . " " . i18n("Use cronjob", "newsletter") . "
" . + $oCkbDispatch->toHTML(false) . " " . i18n("Send in blocks:", "newsletter") . "   " . + i18n("Recipients per block:", "newsletter") . " " . $oTxtDispatchCount->render() . " " . + i18n("Delay between blocks:", "newsletter") . " " . $oTxtDispatchDelay->render() . " " . i18n("sec.", "newsletter") . "
" . + $oCkbSaveAsDefault->toHTML(false) . " " . i18n("Save option settings as default", "newsletter")); + + $oForm->add(i18n("Author", "newsletter"), $classuser->getUserName($oNewsletter->get("author")) . " (" . $oNewsletter->get("created") . ")"); + $oForm->add(i18n("Last modified by", "newsletter"), $classuser->getUserName($oNewsletter->get("modifiedby")) . " (" . $oNewsletter->get("modified") . ")"); + + $sExecScript = ' '; - $oPage->addScript('exec', $sExecScript); - - $oPage->setContent($notis . $oForm->render(true)); + $oPage->addScript('exec', $sExecScript); + + $oPage->setContent($notis . $oForm->render(true)); } else { - $oPage->setContent($notis . ""); + $oPage->setContent($notis . ""); } $oPage->render(); - ?> \ No newline at end of file diff --git a/conlite/plugins/newsletter/includes/include.newsletter_edit_message.php b/conlite/plugins/newsletter/includes/include.newsletter_edit_message.php index b151196..d6c3f41 100644 --- a/conlite/plugins/newsletter/includes/include.newsletter_edit_message.php +++ b/conlite/plugins/newsletter/includes/include.newsletter_edit_message.php @@ -1,4 +1,5 @@ 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"), $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"), $oNewsletter->get("idart"))) . "
"; - - $oNewsletter->set("idart", 0); - $oNewsletter->set("template_idart", 0); - $oNewsletter->store(); - } else { - $oArticles->resetQuery(); - $oArticles->setWhere("idlang", $lang); - $oArticles->setWhere("idart", $oNewsletter->get("template_idart")); - $oArticles->query(); - - if ($oArticles->count() == 0) - { - // Ups, template has been deleted: Restore from current newsletter message article - $notis = $notification->returnNotification("warning", i18n("The html newsletter template article has been deleted, it has been restored using the html message article of this newsletter")) . "
"; - - $iIDArt = conCopyArticle($oNewsletter->get("idart"), - $oClientLang->getProperty("newsletter", "html_template_idcat"), - sprintf(i18n("%s (Template restored)"), $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%"); + // Check and set values + if (!is_numeric($_REQUEST["selTemplate"])) { + $_REQUEST["selTemplate"] = 0; + } - $oForm->addHeader(sprintf(i18n("Edit newsletter message (%s)"), $oNewsletter->get("name"))); - $oForm->add(i18n("Subject"), $oNewsletter->get("subject")); - - $sTagInfoText = ''.i18n("Tag information").''. - '"; + $oNewsletter->set("idart", $iIDArt); + $oNewsletter->set("template_idart", $_REQUEST["selTemplate"]); + } - $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 --")); - 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"), $oSelTemplate->render()." ".i18n("Note, that changing the template discards the current html message content")); - - 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"), '
'.$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")) . "
"; - - $oForm->add(i18n("HTML Message"), i18n("Please choose a template first")); - } - } + $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(); - $oTxtMessage = new cHTMLTextarea("txtMessage", $oNewsletter->get("message"), 80, 20); - $oForm->add(i18n("Text Message"), $oTxtMessage->render()."
".$sTagInfoText); - - $sExecScript = ' + 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", "newsletter"), $oNewsletter->get("idart"))) . "
"; + + $oNewsletter->set("idart", 0); + $oNewsletter->set("template_idart", 0); + $oNewsletter->store(); + } else { + $oArticles->resetQuery(); + $oArticles->setWhere("idlang", $lang); + $oArticles->setWhere("idart", $oNewsletter->get("template_idart")); + $oArticles->query(); + + if ($oArticles->count() == 0) { + // Ups, template has been deleted: Restore from current newsletter message article + $notis = $notification->returnNotification("warning", i18n("The html newsletter template article has been deleted, it has been restored using the html message article of this newsletter", "newsletter")) . "
"; + + $iIDArt = conCopyArticle($oNewsletter->get("idart"), $oClientLang->getProperty("newsletter", "html_template_idcat"), sprintf(i18n("%s (Template restored)", "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)", "newsletter"), $oNewsletter->get("name"))); + $oForm->add(i18n("Subject"), $oNewsletter->get("subject")); + + $sTagInfoText = '' . i18n("Tag information", "newsletter") . '' . + '"; + + $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 --", "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", "newsletter"), $oSelTemplate->render() . " " . i18n("Note, that changing the template discards the current html message content", "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", "newsletter"), '
' . $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", "newsletter")) . "
"; + + $oForm->add(i18n("HTML Message", "newsletter"), i18n("Please choose a template first", "newsletter")); + } + } + + $oTxtMessage = new cHTMLTextarea("txtMessage", $oNewsletter->get("message"), 80, 20); + $oForm->add(i18n("Text Message", "newsletter"), $oTxtMessage->render() . "
" . $sTagInfoText); + + $sExecScript = ' '; - $oPage->addScript('messagebox', ''); - $oPage->addScript('execscript', $sExecScript); - $oPage->setContent($notis . $oForm->render(true)); + $oPage->addScript('messagebox', ''); + $oPage->addScript('execscript', $sExecScript); + $oPage->setContent($notis . $oForm->render(true)); } else { - $oPage->setContent($notis . ""); + $oPage->setContent($notis . ""); } $oPage->render(); diff --git a/conlite/plugins/newsletter/includes/include.newsletter_jobs_details.php b/conlite/plugins/newsletter/includes/include.newsletter_jobs_details.php index 4327e97..e768b18 100644 --- a/conlite/plugins/newsletter/includes/include.newsletter_jobs_details.php +++ b/conlite/plugins/newsletter/includes/include.newsletter_jobs_details.php @@ -1,4 +1,5 @@ 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:")); - $oForm->add("", ""); - - $oForm->add("", sprintf(i18n("Sending newsletter ... (chunk %s of %s, recipients: %s, sent: %s)"), - $iChunk, $iChunks, $oJob->get("rcpcount"), $oJob->get("sendcount"))); + // Run job + $oJob = new cNewsletterJob($_REQUEST["idnewsjob"]); + $iSendCount = $oJob->runJob(); - $oForm->setActionButton("cancel", $cfg['path']['contenido_fullhtml']."images/but_cancel.gif", i18n("Stop sending"), "c"); - $oForm->setActionButton("submit", $cfg['path']['contenido_fullhtml']."images/but_ok.gif", i18n("Send next chunk"), "s", "news_job_run"); - } else { - // Send automatically - $oForm = new UI_Table_Form("properties"); - $oForm->addHeader(i18n("Report:")); - $oForm->add("", ""); - - $oForm->add("", sprintf(i18n("Sending newsletter ... (chunk %s of %s, recipients: %s, sent: %s)"), - $iChunk, $iChunks, $oJob->get("rcpcount"), $oJob->get("sendcount"))); + 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"]); - $oPage->addScript("Refresh", ''); - $oForm->unsetActionButton("submit"); - $oForm->setActionButton("cancel", $cfg['path']['contenido_fullhtml']."images/but_cancel.gif", i18n("Stop sending"), "c"); - } - } else { - // All newsletters should have been sent - $oForm = new UI_Table_Form("properties"); - $oForm->addHeader(i18n("Report:")); - $oForm->add("", ""); - - $oForm->add("", sprintf(i18n("The newsletter has been sent to %s recipients"), $oJob->get("sendcount"))); - $oPage->setReload(); - } - - $oPage->setContent($notis . $oForm->render(true)); + // 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:", "newsletter")); + $oForm->add("", ""); + + $oForm->add("", sprintf(i18n("Sending newsletter ... (chunk %s of %s, recipients: %s, sent: %s)", "newsletter"), $iChunk, $iChunks, $oJob->get("rcpcount"), $oJob->get("sendcount"))); + + $oForm->setActionButton("cancel", $cfg['path']['contenido_fullhtml'] . "images/but_cancel.gif", i18n("Stop sending", "newsletter"), "c"); + $oForm->setActionButton("submit", $cfg['path']['contenido_fullhtml'] . "images/but_ok.gif", i18n("Send next chunk", "newsletter"), "s", "news_job_run"); + } else { + // Send automatically + $oForm = new UI_Table_Form("properties"); + $oForm->addHeader(i18n("Report:", "newsletter")); + $oForm->add("", ""); + + $oForm->add("", sprintf(i18n("Sending newsletter ... (chunk %s of %s, recipients: %s, sent: %s)", "newsletter"), $iChunk, $iChunks, $oJob->get("rcpcount"), $oJob->get("sendcount"))); + + $oPage->addScript("Refresh", ''); + $oForm->unsetActionButton("submit"); + $oForm->setActionButton("cancel", $cfg['path']['contenido_fullhtml'] . "images/but_cancel.gif", i18n("Stop sending", "newsletter"), "c"); + } + } else { + // All newsletters should have been sent + $oForm = new UI_Table_Form("properties"); + $oForm->addHeader(i18n("Report:", "newsletter")); + $oForm->add("", ""); + + $oForm->add("", sprintf(i18n("The newsletter has been sent to %s recipients", "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); + $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")); + // Show job details (recipients) - $oSelElements = new cHTMLSelectElement("elemperpage"); - $oSelElements->setEvent("onchange", "document.forms.frmOptions.submit();"); - - $aData = Array("0" => i18n("-All-"), - "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:"), $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"), i18n("E-Mail"), i18n("Type"), i18n("Status"), i18n("Sent"), i18n("Actions")); - $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 .= ''.$i.''."\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")); - $sImgDelete = $oImgDelete->render(); - unset ($oImgDelete); - - $iCount = 0; - $aNewsType[] = array(); // Performance - $aNewsType[0] = i18n("Text only"); - $aNewsType[1] = i18n("HTML/Text"); - while ($oLog = $oLogs->next()) - { - $sName = $oLog->get("rcpname"); - $sEMail = $oLog->get("rcpemail"); - - switch ($oLog->get("status")) - { - case "pending": - $sStatus = i18n("Waiting for sending"); - break; - case "sending": - $sStatus = i18n("Sending"); - break; - case "successful": - $sStatus = i18n("Successful"); - break; - default: - $sStatus = sprintf(i18n("Error: %s"), $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); + $oLogs = new cNewsletterLogCollection; - $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 = ' + // 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", "newsletter")); + + $oSelElements = new cHTMLSelectElement("elemperpage"); + $oSelElements->setEvent("onchange", "document.forms.frmOptions.submit();"); + + $aData = Array("0" => i18n("-All-", "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:", "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", "newsletter"), i18n("E-Mail", "newsletter"), i18n("Type", "newsletter"), i18n("Status", "newsletter"), i18n("Sent", "newsletter"), i18n("Actions", "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 .= '' . $i . '' . "\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", "newsletter")); + $sImgDelete = $oImgDelete->render(); + unset($oImgDelete); + + $iCount = 0; + $aNewsType[] = array(); // Performance + $aNewsType[0] = i18n("Text only", "newsletter"); + $aNewsType[1] = i18n("HTML/Text", "newsletter"); + while ($oLog = $oLogs->next()) { + $sName = $oLog->get("rcpname"); + $sEMail = $oLog->get("rcpemail"); + + switch ($oLog->get("status")) { + case "pending": + $sStatus = i18n("Waiting for sending", "newsletter"); + break; + case "sending": + $sStatus = i18n("Sending", "newsletter"); + break; + case "successful": + $sStatus = i18n("Successful", "newsletter"); + break; + default: + $sStatus = sprintf(i18n("Error: %s", "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 = '
+ sprintf(i18n("Go to page: %s", "newsletter"), $sBrowseLinks) . '
' . - sprintf(i18n("Go to page: %s"), $sBrowseLinks) . '
'; - $oPage->setContent($oFrmOptions->render() . "
" . $oList->render() . $sBrowseHTML); + $oPage->setContent($oFrmOptions->render() . "
" . $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); + // Just show the job data + $oJob = new cNewsletterJob($_REQUEST["idnewsjob"]); - $oForm->addHeader(i18n("Newsletter Dispatch Job")); - - $oForm->add(i18n("Name"), $oJob->get("name")); - - $sDateFormat = getEffectiveSetting("backend", "timeformat", "d.m.Y H:i"); - switch ($oJob->get("status")) - { - case 1: - $oForm->add(i18n("Status"), i18n("Pending")); - break; - case 2: - $oForm->add(i18n("Status"), sprintf(i18n("Sending (started: %s)"), - date($sDateFormat, strtotime($oJob->get("started"))))); - break; - case 9: - $oForm->add(i18n("Status"), sprintf(i18n("Finished (started: %s, finished: %s)"), - date($sDateFormat, strtotime($oJob->get("started"))), - date($sDateFormat, strtotime($oJob->get("finished"))))); - break; - } - - $oForm->add(i18n("Statistics"), sprintf(i18n("Planned: %s, Send: %s"), $oJob->get("rcpcount"), $oJob->get("sendcount"))); - $oForm->add(i18n("From"), $oJob->get("newsfrom") . " (" . $oJob->get("newsfromname") . ")"); - $oForm->add(i18n("Subject"), $oJob->get("subject")); + $oForm = new UI_Table_Form("properties"); + $oForm->setVar("frame", $frame); + $oForm->setVar("area", $area); + $oForm->setVar("action", ""); + $oForm->setVar("idnewsjob", $idnewsjob); - if ($oJob->get("type") == "html") - { - $oForm->add(i18n("Type"), i18n("HTML and text")); - - $txtMessageHTML = new cHTMLTextarea("txtMessageHTML", $oJob->get("message_html"), 80, 20); - $txtMessageHTML->setDisabled("disabled"); - - $oForm->add(i18n("HTML Message"), $txtMessageHTML->render()); - } else { - $oForm->add(i18n("Type"), i18n("Text only")); - } - $txtMessageText = new cHTMLTextarea("txtMessageText", $oJob->get("message_text"), 80, 20); - $txtMessageText->setDisabled("disabled"); - - $oForm->add(i18n("Text Message"), $txtMessageText->render()); - - $aSendTo = unserialize($oJob->get("send_to")); - switch ($aSendTo[0]) - { - case "all": - $sSendToInfo = i18n("Send newsletter to all recipients"); - break; - case "default": - $sSendToInfo = i18n("Send newsletter to the members of the default group"); - break; - case "selection": - $sSendToInfo = i18n("Send newsletter to the members of the selected group(s):"); - - unset ($aSendTo[0]); - foreach ($aSendTo as $sGroup) - { - $sSendToInfo .= "
" . $sGroup; - } - break; - case "single": - $sSendToInfo = i18n("Send newsletter to single recipient:"); - $sSendToInfo .= "
" . $aSendTo[1] . " (" . $aSendTo[2] . ")"; - break; - default: - } - unset ($aSendTo); - - $oForm->add(i18n("Recipients"), $sSendToInfo); - - if ($oJob->get("use_cronjob") == 1) { - $sOptionsInfo = i18n("Use cronjob: Enabled"); - } else { - $sOptionsInfo = i18n("Use cronjob: Not enabled"); - } - - if ($oJob->get("dispatch")) { - $sOptionsInfo .= "
" . sprintf(i18n("Dispatch: Enabled (block size: %s, delay: %s sec.)"), $oJob->get("dispatch_count"), $oJob->get("dispatch_delay")); - } else { - $sOptionsInfo .= "
" . i18n("Dispatch: Disabled"); - } - - $oForm->add(i18n("Options"), $sOptionsInfo); - - $oForm->add(i18n("Author"), $oJob->get("authorname")); - $oForm->add(i18n("Created"), $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)); + $oForm->addHeader(i18n("Newsletter Dispatch Job", "newsletter")); + + $oForm->add(i18n("Name", "newsletter"), $oJob->get("name")); + + $sDateFormat = getEffectiveSetting("backend", "timeformat", "d.m.Y H:i"); + switch ($oJob->get("status")) { + case 1: + $oForm->add(i18n("Status", "newsletter"), i18n("Pending", "newsletter")); + break; + case 2: + $oForm->add(i18n("Status", "newsletter"), sprintf(i18n("Sending (started: %s)", "newsletter"), date($sDateFormat, strtotime($oJob->get("started"))))); + break; + case 9: + $oForm->add(i18n("Status", "newsletter"), sprintf(i18n("Finished (started: %s, finished: %s)", "newsletter"), date($sDateFormat, strtotime($oJob->get("started"))), date($sDateFormat, strtotime($oJob->get("finished"))))); + break; + } + + $oForm->add(i18n("Statistics", "newsletter"), sprintf(i18n("Planned: %s, Send: %s", "newsletter"), $oJob->get("rcpcount"), $oJob->get("sendcount"))); + $oForm->add(i18n("From", "newsletter"), $oJob->get("newsfrom") . " (" . $oJob->get("newsfromname") . ")"); + $oForm->add(i18n("Subject", "newsletter"), $oJob->get("subject")); + + if ($oJob->get("type") == "html") { + $oForm->add(i18n("Type", "newsletter"), i18n("HTML and text", "newsletter")); + + $txtMessageHTML = new cHTMLTextarea("txtMessageHTML", $oJob->get("message_html"), 80, 20); + $txtMessageHTML->setDisabled("disabled"); + + $oForm->add(i18n("HTML Message", "newsletter"), $txtMessageHTML->render()); + } else { + $oForm->add(i18n("Type", "newsletter"), i18n("Text only", "newsletter")); + } + $txtMessageText = new cHTMLTextarea("txtMessageText", $oJob->get("message_text"), 80, 20); + $txtMessageText->setDisabled("disabled"); + + $oForm->add(i18n("Text Message", "newsletter"), $txtMessageText->render()); + + $aSendTo = unserialize($oJob->get("send_to")); + switch ($aSendTo[0]) { + case "all": + $sSendToInfo = i18n("Send newsletter to all recipients", "newsletter"); + break; + case "default": + $sSendToInfo = i18n("Send newsletter to the members of the default group", "newsletter"); + break; + case "selection": + $sSendToInfo = i18n("Send newsletter to the members of the selected group(s):", "newsletter"); + + unset($aSendTo[0]); + foreach ($aSendTo as $sGroup) { + $sSendToInfo .= "
" . $sGroup; + } + break; + case "single": + $sSendToInfo = i18n("Send newsletter to single recipient:", "newsletter"); + $sSendToInfo .= "
" . $aSendTo[1] . " (" . $aSendTo[2] . ")"; + break; + default: + } + unset($aSendTo); + + $oForm->add(i18n("Recipients", "newsletter"), $sSendToInfo); + + if ($oJob->get("use_cronjob") == 1) { + $sOptionsInfo = i18n("Use cronjob: Enabled", "newsletter"); + } else { + $sOptionsInfo = i18n("Use cronjob: Not enabled", "newsletter"); + } + + if ($oJob->get("dispatch")) { + $sOptionsInfo .= "
" . sprintf(i18n("Dispatch: Enabled (block size: %s, delay: %s sec.)", "newsletter"), $oJob->get("dispatch_count"), $oJob->get("dispatch_delay")); + } else { + $sOptionsInfo .= "
" . i18n("Dispatch: Disabled", "newsletter"); + } + + $oForm->add(i18n("Options", "newsletter"), $sOptionsInfo); + + $oForm->add(i18n("Author", "newsletter"), $oJob->get("authorname")); + $oForm->add(i18n("Created", "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(); - ?> \ No newline at end of file diff --git a/conlite/plugins/newsletter/includes/include.newsletter_jobs_menu.php b/conlite/plugins/newsletter/includes/include.newsletter_jobs_menu.php index 0b16dd2..f6e9b6d 100644 --- a/conlite/plugins/newsletter/includes/include.newsletter_jobs_menu.php +++ b/conlite/plugins/newsletter/includes/include.newsletter_jobs_menu.php @@ -50,9 +50,9 @@ $oUser = new cApiUser($auth->auth["uid"]); // 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"), "type" => "base,sort,search"); -$aFields["created"] = array("field" => "created", "caption" => i18n("Created"), "type" => "base,sort"); -$aFields["status"] = array("field" => "status", "caption" => i18n("Status"), "type" => "base,sort"); +$aFields["name"] = array("field" => "name", "caption" => i18n("Name", "newsletter"), "type" => "base,sort,search"); +$aFields["created"] = array("field" => "created", "caption" => i18n("Created", "newsletter"), "type" => "base,sort"); +$aFields["status"] = array("field" => "status", "caption" => i18n("Status", "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"); ################################## @@ -158,11 +158,11 @@ $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"); -$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter dispatch job:
"); +$aMsg["DelTitle"] = i18n("Delete dispatch job", "newsletter"); +$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter dispatch job:
", "newsletter"); -$aMsg["SendTitle"] = i18n("Run job"); -$aMsg["SendDescr"] = i18n("Do you really want to run the following job:
"); +$aMsg["SendTitle"] = i18n("Run job", "newsletter"); +$aMsg["SendDescr"] = i18n("Do you really want to run the following job:
", "newsletter"); // Prepare "send link" template $sTplSend = ''.$aMsg['; diff --git a/conlite/plugins/newsletter/includes/include.newsletter_jobs_subnav.php b/conlite/plugins/newsletter/includes/include.newsletter_jobs_subnav.php index 065add9..1b6d692 100644 --- a/conlite/plugins/newsletter/includes/include.newsletter_jobs_subnav.php +++ b/conlite/plugins/newsletter/includes/include.newsletter_jobs_subnav.php @@ -36,7 +36,7 @@ if (!defined('CON_FRAMEWORK')) { if (isset($_GET['idnewsjob']) && (int)$_GET['idnewsjob'] > 0) { - $sCaption = i18n("View"); + $sCaption = i18n("View", "newsletter"); $tmp_area = "foo2"; # Set template data @@ -46,7 +46,7 @@ if (isset($_GET['idnewsjob']) && (int)$_GET['idnewsjob'] > 0) $tpl->set("d", "CAPTION", ''.$sCaption.''); $tpl->next(); - $sCaption = i18n("Details"); + $sCaption = i18n("Details", "newsletter"); $tmp_area = "foo2"; # Set template data diff --git a/conlite/plugins/newsletter/includes/include.newsletter_left_top.php b/conlite/plugins/newsletter/includes/include.newsletter_left_top.php index 3d89512..d29d417 100644 --- a/conlite/plugins/newsletter/includes/include.newsletter_left_top.php +++ b/conlite/plugins/newsletter/includes/include.newsletter_left_top.php @@ -56,7 +56,7 @@ $sId = 'img_newsletter'; $oTpl->set('s', 'INEWSLETTER', $sId); if ($perm->have_perm_area_action('news')) { $sButtonRow = ''; - $sButtonRow .= ''.i18n('; + $sButtonRow .= ''. i18n('; $sButtonRow .= ''; } @@ -65,7 +65,7 @@ $sId = 'img_dispatch'; $oTpl->set('s', 'IDISPATCH', $sId); if ($perm->have_perm_area_action('news_jobs')) { $sButtonRow .= ''; - $sButtonRow .= ''.i18n('; + $sButtonRow .= ''.i18n('; $sButtonRow .= ''; } @@ -74,7 +74,7 @@ $sId = 'img_recipient'; $oTpl->set('s', 'IRECIPIENTS', $sId); if ($perm->have_perm_area_action('recipients')) { $sButtonRow .= ''; - $sButtonRow .= ''.i18n('; + $sButtonRow .= ''.i18n('; $sButtonRow .= ''; } @@ -83,7 +83,7 @@ $sId = 'img_recipientgroup'; $oTpl->set('s', 'IRECIPIENTGROUP', $sId); if ($perm->have_perm_area_action('recipientgroups')) { $sButtonRow .= ''; - $sButtonRow .= ''.i18n('; + $sButtonRow .= ''.i18n('; $sButtonRow .= ''; } @@ -98,7 +98,7 @@ unset($sButtonRow); # 1.1 Newsletter: Actions folding row ###################################### $sLink = "actionlink"; // ID for HTML element -$oActionsRow = new cFoldingRow("28cf9b31-e6d7-4657-a9a7-db31478e7a5c",i18n("Actions"), $sLink); +$oActionsRow = new cFoldingRow("28cf9b31-e6d7-4657-a9a7-db31478e7a5c",i18n("Actions", "newsletter"), $sLink); $oTpl->set('s', 'ACTIONLINK', $sLink); if ($perm->have_perm_area_action("news", "news_create")) @@ -108,7 +108,7 @@ if ($perm->have_perm_area_action("news", "news_create")) $oLink = new cHTMLLink; $oLink->setMultiLink("news", "", "news", "news_create"); - $oLink->setContent(''.i18n("Create newsletter")); + $oLink->setContent(''.i18n("Create newsletter", "newsletter")); $sContent .= $oLink->render() . ''."\n"; $oActionsRow->setContentData($sContent); @@ -120,7 +120,7 @@ if ($perm->have_perm_area_action("news", "news_create")) # 1.2 Newsletter: Settings folding row ###################################### $sLink = "settingslink"; -$oSettingsRow = new cFoldingRow("d64baf0a-aea9-47b3-8490-54a00fce02b5",i18n("Settings"), $sLink); +$oSettingsRow = new cFoldingRow("d64baf0a-aea9-47b3-8490-54a00fce02b5",i18n("Settings", "newsletter"), $sLink); $oTpl->set('s', 'SETTINGSLINK', $sLink); // HTML Newsletter: Template and newsletter category @@ -132,9 +132,9 @@ $oSelHTMLTemplateIDCat->setStyle("width: 220px;"); $oSelHTMLNewsletterIDCat = new cHTMLSelectElement("selHTMLNewsletterCat"); $oSelHTMLNewsletterIDCat->setStyle("width: 220px;"); -$oOptionTemplate = new cHTMLOptionElement("--".i18n("Please select")."--", 0); +$oOptionTemplate = new cHTMLOptionElement("--".i18n("Please select", "newsletter")."--", 0); $oSelHTMLTemplateIDCat->addOptionElement(0, $oOptionTemplate); -$oOptionNewsletter = new cHTMLOptionElement("--".i18n("Please select")."--", 0); +$oOptionNewsletter = new cHTMLOptionElement("--".i18n("Please select", "newsletter")."--", 0); $oSelHTMLNewsletterIDCat->addOptionElement(0, $oOptionNewsletter); $sSQL = "SELECT tblCat.idcat AS idcat, tblCatLang.name AS name, tblCatTree.level AS level, "; @@ -200,7 +200,7 @@ if (!$perm->have_perm_area_action($area, "news_html_settings")) $oSelTestDestination = new cHTMLSelectElement("selTestDestination"); $oSelTestDestination->setStyle("width: 220px;"); -$oOption = new cHTMLOptionElement(i18n("My mail address"), 0); +$oOption = new cHTMLOptionElement(i18n("My mail address", "newsletter"), 0); $oSelTestDestination->addOptionElement(0, $oOption); $oRcpGroups = new RecipientGroupCollection; @@ -237,7 +237,7 @@ if (!$perm->have_perm_area_action($area, "news_send_test")) } $oSelTestDestination->setDefault($iTestDestination); -$oBtnSave = new cHTMLButton("submit", i18n("Save")); +$oBtnSave = new cHTMLButton("submit", i18n("Save", "newsletter")); $sContent = '
'."\n"; $sContent .= '
'."\n"; @@ -253,16 +253,16 @@ $sContent .= ' toHTML(false).' '.i18n("Enable HTML Newsletter").''."\n"; +$sContent .= ' '.$oCkbHTMLNewsletter->toHTML(false).' '.i18n("Enable HTML Newsletter", "newsletter").''."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '.i18n("HTML Template Category:").'
'.$oSelHTMLTemplateIDCat->render().''."\n"; +$sContent .= ' '.i18n("HTML Template Category:", "newsletter").'
'.$oSelHTMLTemplateIDCat->render().''."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '.i18n("HTML Newsletter Category:").'
'.$oSelHTMLNewsletterIDCat->render().''."\n"; +$sContent .= ' '.i18n("HTML Newsletter Category:", "newsletter").'
'.$oSelHTMLNewsletterIDCat->render().''."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '.i18n("Send test destination:").'
'.$oSelTestDestination->render().''."\n"; +$sContent .= ' '.i18n("Send test destination:", "newsletter").'
'.$oSelTestDestination->render().''."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '.$oBtnSave->render().''."\n"; @@ -282,7 +282,7 @@ if ($iItemsPerPage == 0) { } $oSelItemsPerPage = new cHTMLSelectElement("elemperpage"); -$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); +$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); $oSelItemsPerPage->setDefault($iItemsPerPage); // Sort By $oSelSortBy = new cHTMLSelectElement("sortby"); @@ -291,19 +291,19 @@ $oSelSortBy->addOptionElement($sKey, $oOption); $oSelSortBy->setDefault("name"); // Sort Order $oSelSortOrder = new cHTMLSelectElement("sortorder"); -$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending"), "DESC" => i18n("Descending"))); +$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "newsletter"), "DESC" => i18n("Descending", "newsletter"))); $oSelSortOrder->setDefault("ASC"); // Search For $oTextboxFilter = new cHTMLTextbox("filter", "", 16); // Search In $oSelSearchIn = new cHTMLSelectElement("searchin"); -$oOption = new cHTMLOptionElement(i18n("-- All fields --"), "--all--"); +$oOption = new cHTMLOptionElement(i18n("-- All fields --", "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")); +$oBtnApply = new cHTMLButton("submit", i18n("Apply", "newsletter")); $sContent = '
'."\n"; $sContent .= ''."\n"; @@ -312,23 +312,23 @@ $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; @@ -341,7 +341,7 @@ $sContent .= ''."\n"; // To template $sLink = "listoption"; -$oListOptionsRow = new cFoldingRow("9d0968be-601d-44f8-a666-99d51c9c777d",i18n("List options"), $sLink); +$oListOptionsRow = new cFoldingRow("9d0968be-601d-44f8-a666-99d51c9c777d",i18n("List options", "newsletter"), $sLink); $oListOptionsRow->setContentData($sContent); $oTpl->set('s', 'LISTOPTIONLINK', $sLink); @@ -400,10 +400,10 @@ $oTpl->set('s', 'ID_CNEWSLETTER', $sContainerId); // 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"), "type" => "base,sort,search"); -$aFields["created"] = array("field" => "created", "caption" => i18n("Created"), "type" => "base,sort"); -$aFields["status"] = array("field" => "status", "caption" => i18n("Status"), "type" => "base,sort"); -$aFields["cronjob"] = array("field" => "use_cronjob", "caption" => i18n("Use cronjob"), "type" => "base"); +$aFields["name"] = array("field" => "name", "caption" => i18n("Name", "newsletter"), "type" => "base,sort,search"); +$aFields["created"] = array("field" => "created", "caption" => i18n("Created", "newsletter"), "type" => "base,sort"); +$aFields["status"] = array("field" => "status", "caption" => i18n("Status", "newsletter"), "type" => "base,sort"); +$aFields["cronjob"] = array("field" => "use_cronjob", "caption" => i18n("Use cronjob", "newsletter"), "type" => "base"); ###################################### # 2.1 Job dispatch: List options folding row @@ -441,7 +441,7 @@ if ($iItemsPerPage == 0) { } $oSelItemsPerPage = new cHTMLSelectElement("elemperpage"); -$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); +$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); $oSelItemsPerPage->setDefault($iItemsPerPage); // Sort by @@ -457,7 +457,7 @@ $oSelSortBy->setDefault("created"); // Sort order $oSelSortOrder = new cHTMLSelectElement("sortorder"); -$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending"), "DESC" => i18n("Descending"))); +$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "newsletter"), "DESC" => i18n("Descending", "newsletter"))); $oSelSortOrder->setDefault("DESC"); // Filter @@ -465,7 +465,7 @@ $oTxtFilter = new cHTMLTextbox("filter", "", 16); //Search in $oSelSearchIn = new cHTMLSelectElement("searchin"); -$oOption = new cHTMLOptionElement(i18n("-- All fields --"), "--all--"); +$oOption = new cHTMLOptionElement(i18n("-- All fields --", "newsletter"), "--all--"); $oSelSearchIn->addOptionElement("all", $oOption); foreach ($aFields as $sKey => $aData) @@ -478,7 +478,7 @@ foreach ($aFields as $sKey => $aData) } $oSelSearchIn->setDefault("--all--"); -$oBtnApply = new cHTMLButton("submit", i18n("Apply")); +$oBtnApply = new cHTMLButton("submit", i18n("Apply", "newsletter")); $sContent = '
'."\n"; $sContent .= ''."\n"; @@ -487,27 +487,27 @@ $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= '
'. i18n("Items / page").''. i18n("Items / page", "newsletter").''.$oSelItemsPerPage->render().'
'. i18n("Sort by").''. i18n("Sort by", "newsletter").''.$oSelSortBy->render().'
'. i18n("Sort order").''. i18n("Sort order", "newsletter").''.$oSelSortOrder->render().'
'. i18n("Search for").''. i18n("Search for", "newsletter").''.$oTextboxFilter->render().'
'. i18n("Search in").''. i18n("Search in", "newsletter").''.$oSelSearchIn->render().'
'."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; @@ -520,7 +520,7 @@ $sContent .= ''."\n"; // To template $sLink = "listoptiondisp"; -$oListOptionsRow = new cFoldingRow("dfa6cc00-0acf-11db-9cd8-0800200c9a66",i18n("List options"), $sLink); +$oListOptionsRow = new cFoldingRow("dfa6cc00-0acf-11db-9cd8-0800200c9a66",i18n("List options", "newsletter"), $sLink); $oListOptionsRow->setContentData($sContent); $oTpl->set('s', 'LISTOPTIONLINKDISP', $sLink); @@ -565,10 +565,10 @@ $oTpl->set('s', 'ID_CDISPATCH', $sContainerId); ###################################### // See comment at 2. Job dispatch $aFields = array(); -$aFields["name"] = array("field" => "name", "caption" => i18n("Name"), "type" => "base,sort,search"); -$aFields["email"] = array("field" => "email", "caption" => i18n("E-Mail"), "type" => "base,sort,search"); -$aFields["confirmed"] = array("field" => "confirmed", "caption" => i18n("Confirmed"), "type" => "base"); -$aFields["deactivated"] = array("field" => "deactivated", "caption" => i18n("Deactivated"), "type" => "base"); +$aFields["name"] = array("field" => "name", "caption" => i18n("Name", "newsletter"),"type" => "base,sort,search"); +$aFields["email"] = array("field" => "email", "caption" => i18n("E-Mail", "newsletter"),"type" => "base,sort,search"); +$aFields["confirmed"] = array("field" => "confirmed", "caption" => i18n("Confirmed", "newsletter"), "type" => "base"); +$aFields["deactivated"] = array("field" => "deactivated", "caption" => i18n("Deactivated", "newsletter"), "type" => "base"); ###################################### # 3.1 Recipients: Actions folding row @@ -580,7 +580,7 @@ if ($perm->have_perm_area_action("recipients", "recipients_create")) { $oLink = new cHTMLLink; $oLink->setMultiLink("recipients","","recipients","recipients_create"); - $oLink->setContent(''.i18n("Create recipient").''); + $oLink->setContent(''.i18n("Create recipient", "newsletter").''); $sContent .= $oLink->render().'
'."\n"; } @@ -590,7 +590,7 @@ if ($perm->have_perm_area_action("recipients", "recipients_create")) { $oLink = new cHTMLLink; $oLink->setMultiLink("recipients", "", "recipients_import", "recipients_import"); - $oLink->setContent(''.i18n("Import recipients").''); + $oLink->setContent(''.i18n("Import recipients", "newsletter").''); $sContent .= $oLink->render().'
'."\n"; } @@ -604,9 +604,9 @@ if ($iTimeframe <= 0) { if ($perm->have_perm_area_action("recipients", "recipients_delete")) { $oLink = new cHTMLLink; - $oLink->setLink('javascript:showPurgeMsg("'.i18n('Purge recipients').'", "'.sprintf(i18n("Do you really want to remove recipients, that have not been confirmed since %s days and over?"), '"+purgetimeframe+"').'")'); + $oLink->setLink('javascript:showPurgeMsg("'.i18n('Purge recipients', "newsletter").'", "'.sprintf(i18n("Do you really want to remove recipients, that have not been confirmed since %s days and over?", "newsletter"), '"+purgetimeframe+"').'")'); - $oLink->setContent(''.i18n("Purge recipients").''); + $oLink->setContent(''.i18n("Purge recipients", "newsletter").''); $sContent .= $oLink->render(); } @@ -615,7 +615,7 @@ $oTpl->set('s', 'VALUE_PURGETIMEFRAME', $iTimeframe); // To template $sLink = "actionrec"; -$oListActionsRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a66", i18n("Actions"), $sLink); +$oListActionsRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a66", i18n("Actions", "newsletter"), $sLink); $oListActionsRow->setContentData($sContent); $oTpl->set('s', 'ACTIONLINKREC', $sLink); @@ -623,7 +623,7 @@ $oTpl->set('s', 'ACTIONLINKREC', $sLink); # 3.2 Recipients: Settings folding row ###################################### $oTxtTimeframe = new cHTMLTextbox("txtPurgeTimeframe", $iTimeframe, 5); -$oBtnSave = new cHTMLButton("submit", i18n("Save")); +$oBtnSave = new cHTMLButton("submit", i18n("Save", "newsletter")); $sContent = '
'."\n"; $sContent .= ''."\n"; @@ -638,8 +638,8 @@ $sContent .= ' '."\n"; $sContent .= '
'. i18n("Author").''. i18n("Author", "newsletter").''.$oSelAuthor->render().'
'. i18n("Items / page").''. i18n("Items / page", "newsletter").''.$oSelItemsPerPage->render().'
'. i18n("Sort by").''. i18n("Sort by", "newsletter").''.$oSelSortBy->render().'
'. i18n("Sort order").''. i18n("Sort order", "newsletter").''.$oSelSortOrder->render().'
'. i18n("Search for").''. i18n("Search for", "newsletter").''.$oTxtFilter->render().'
'. i18n("Search in").''. i18n("Search in", "newsletter").''.$oSelSearchIn->render().'
'."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; @@ -651,7 +651,7 @@ $sContent .= ''."\n"; // To template $sLink = "settingsrec"; -$oSettingsRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a69",i18n("Settings"), $sLink); +$oSettingsRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a69",i18n("Settings", "newsletter"), $sLink); $oSettingsRow->setContentData($sContent); $oTpl->set('s', 'SETTINGSLINKREC', $sLink); @@ -664,7 +664,7 @@ if ($iItemsPerPage == 0) { } $oSelItemsPerPage = new cHTMLSelectElement("elemperpage"); -$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); +$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); $oSelItemsPerPage->setDefault($iItemsPerPage); $oSelSortBy = new cHTMLSelectElement("sortby"); @@ -678,11 +678,11 @@ foreach ($aFields as $sKey => $aData) $oSelSortBy->setDefault("name"); $oSelSortOrder = new cHTMLSelectElement("sortorder"); -$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending"), "DESC" => i18n("Descending"))); +$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "newsletter"), "DESC" => i18n("Descending", "newsletter"))); $oSelSortOrder->setDefault("ASC"); $oSelRestrictGroup = new cHTMLSelectElement("restrictgroup"); -$oOption = new cHTMLOptionElement(i18n("-- All groups --"), "--all--"); +$oOption = new cHTMLOptionElement(i18n("-- All groups --", "newsletter"), "--all--"); $oSelRestrictGroup->addOptionElement("all", $oOption); // Fetch recipient groups @@ -710,7 +710,7 @@ $oSelRestrictGroup->setDefault("--all--"); $oTxtFilter = new cHTMLTextbox("filter", "", 16); $oSelSearchIn = new cHTMLSelectElement("searchin"); -$oOption = new cHTMLOptionElement(i18n("-- All fields --"), "--all--"); +$oOption = new cHTMLOptionElement(i18n("-- All fields --", "newsletter"), "--all--"); $oSelSearchIn->addOptionElement("all", $oOption); foreach ($aFields as $sKey => $aData) { @@ -730,27 +730,27 @@ $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= '
'. i18n("Purge timeframe").':'.$oTxtTimeframe->render().' '.i18n("days").''. i18n("Purge timeframe", "newsletter").':'.$oTxtTimeframe->render().' '.i18n("days", "newsletter").'
 
'."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; @@ -763,7 +763,7 @@ $sContent .= ''."\n"; // To template $sLink = "listoptionsrec"; -$oListOptionsRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a66",i18n("List options"), $sLink); +$oListOptionsRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a66",i18n("List options", "newsletter"), $sLink); $oListOptionsRow->setContentData($sContent); $oTpl->set('s', 'LISTOPTIONLINKREC', $sLink); @@ -812,7 +812,7 @@ $oTpl->set('s', 'ID_CRECIPIENTS', $sContainerId); ###################################### // See comment at 2. Job dispatch $aFields = array(); -$aFields["name"] = array("field" => "groupname", "caption" => i18n("Name"), "type" => "base,sort,search"); +$aFields["name"] = array("field" => "groupname", "caption" => i18n("Name", "newsletter"), "type" => "base,sort,search"); ###################################### # 4.1 Recipient groups: Actions @@ -824,14 +824,14 @@ if ($perm->have_perm_area_action("recipientgroups", "recipientgroup_create")) { $oLnk = new cHTMLLink; $oLnk->setMultiLink("recipientgroups","","recipientgroups","recipientgroup_create"); - $oLnk->setContent(''.i18n("Create group").''); + $oLnk->setContent(''.i18n("Create group", "newsletter").''); $sContent .= $oLnk->render().'
'."\n"; } $sContent .= ''."\n"; $sLink = "actiongroup"; -$oListActionsRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a67",i18n("Actions"), $sLink); +$oListActionsRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a67",i18n("Actions", "newsletter"), $sLink); $oListActionsRow->setContentData($sContent); $oTpl->set('s', 'ACTIONLINKGROUP', $sLink); @@ -844,7 +844,7 @@ if ($iItemsPerPage == 0) { } $oSelItemsPerPage = new cHTMLSelectElement("elemperpage"); -$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); +$oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); $oSelItemsPerPage->setDefault($iItemsPerPage); $oSelSortBy = new cHTMLSelectElement("sortby"); @@ -857,13 +857,13 @@ foreach ($aFields as $sKey => $aData) { $oSelSortBy->setDefault("name"); $oSelSortOrder = new cHTMLSelectElement("sortorder"); -$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending"), "DESC" => i18n("Descending"))); +$oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "newsletter"), "DESC" => i18n("Descending", "newsletter"))); $oSelSortOrder->setDefault("ASC"); $oTxtFilter = new cHTMLTextbox("filter", "", 16); $oSelSearchIn = new cHTMLSelectElement("searchin"); -$oOption = new cHTMLOptionElement(i18n("-- All fields --"), "--all--"); +$oOption = new cHTMLOptionElement(i18n("-- All fields --", "newsletter"), "--all--"); $oSelSearchIn->addOptionElement("all", $oOption); foreach ($aFields as $sKey => $aData) { @@ -874,7 +874,7 @@ foreach ($aFields as $sKey => $aData) { } $oSelSearchIn->setDefault("--all--"); -$oBtnApply = new cHTMLButton("submit", i18n("Apply")); +$oBtnApply = new cHTMLButton("submit", i18n("Apply", "newsletter")); $sContent = '
'."\n"; $sContent .= ''."\n"; @@ -883,23 +883,23 @@ $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= '
'. i18n("Items / page").''. i18n("Items / page", "newsletter").''.$oSelItemsPerPage->render().'
'. i18n("Sort by").''. i18n("Sort by", "newsletter").''.$oSelSortBy->render().'
'. i18n("Sort order").''. i18n("Sort order", "newsletter").''.$oSelSortOrder->render().'
'. i18n("Show group").''. i18n("Show group", "newsletter").''.$oSelRestrictGroup->render().'
'. i18n("Search for").''. i18n("Search for", "newsletter").''.$oTxtFilter->render().'
'. i18n("Search in").''. i18n("Search in", "newsletter").''.$oSelSearchIn->render().'
'."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; -$sContent .= ' '."\n"; +$sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; @@ -912,7 +912,7 @@ $sContent .= ''."\n"; // To template $sLink = "listoptionsgroup"; -$oListOptionsRow = new cFoldingRow("79efc1fc-111d-11dc-8314-0800200c9a66",i18n("List options"), $sLink); +$oListOptionsRow = new cFoldingRow("79efc1fc-111d-11dc-8314-0800200c9a66",i18n("List options", "newsletter"), $sLink); $oListOptionsRow->setContentData($sContent); $oTpl->set('s', 'LISTOPTIONLINKGROUP', $sLink); diff --git a/conlite/plugins/newsletter/includes/include.newsletter_menu.php b/conlite/plugins/newsletter/includes/include.newsletter_menu.php index fb03ebf..5693be6 100644 --- a/conlite/plugins/newsletter/includes/include.newsletter_menu.php +++ b/conlite/plugins/newsletter/includes/include.newsletter_menu.php @@ -1,4 +1,5 @@ auth["uid"]); -$oClientLang = new cApiClientLanguage(false, $client, $lang); +$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"); +$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, @@ -52,75 +52,74 @@ $lIDCatArt = (int)$oClientLang->getProperty("newsletter", "idcatart"); // 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"), "type" => "base,sort,search"); +$aFields["name"] = array("field" => "name", "caption" => i18n("Name", "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 + // 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"]); + $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); + // 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") . ")"; +$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); + $_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; + // 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"]); + // -- 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"]; +$_REQUEST["page"] = (int) $_REQUEST["page"]; if ($_REQUEST["page"] <= 0 || $_REQUEST["elemperpage"] == 0) { - $_REQUEST["page"] = 1; + $_REQUEST["page"] = 1; } // Sort order if ($_REQUEST["sortorder"] != "DESC") { - $_REQUEST["sortorder"] = "ASC"; + $_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; - } +$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 + $_REQUEST["sortby"] = "name"; // Default sort by field, possible values see above } if (!$bSearchInFound) { - $_REQUEST["searchin"] = "--all--"; + $_REQUEST["searchin"] = "--all--"; } // Free memory -unset ($oClientLang); -unset ($oUser); +unset($oClientLang); +unset($oUser); ################################## # Get data @@ -129,154 +128,143 @@ $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["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(); +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"]--; + + if ($_REQUEST["elemperpage"] * ($_REQUEST["page"]) >= $iItemCount + $_REQUEST["elemperpage"] && $_REQUEST["page"] != 1) { + $_REQUEST["page"] --; } - $oNewsletters->setLimit($_REQUEST["elemperpage"] * ($_REQUEST["page"] - 1), $_REQUEST["elemperpage"]); + $oNewsletters->setLimit($_REQUEST["elemperpage"] * ($_REQUEST["page"] - 1), $_REQUEST["elemperpage"]); } else { - $iItemCount = 0; + $iItemCount = 0; } $oNewsletters->setOrder("welcome DESC, " . $_REQUEST["sortby"] . " " . $_REQUEST["sortorder"]); $oNewsletters->query(); // Output data -$oMenu = new UI_Menu; -$iMenu = 0; +$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"); -$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter:
"); +$aMsg["DelTitle"] = i18n("Delete newsletter", "newsletter"); +$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter:
", "newsletter"); -$aMsg["SendTestTitle"] = i18n("Send test newsletter"); -$aMsg["SendTestTitleOff"] = i18n("Send test newsletter (disabled, check newsletter sender e-mail address and handler article selection)"); -$aMsg["AddJobTitle"] = i18n("Add newsletter dispatch job"); -$aMsg["AddJobTitleOff"] = i18n("Add newsletter dispatch job (disabled, check newsletter sender e-mail address and handler article selection)"); -$aMsg["CopyTitle"] = i18n("Duplicate newsletter"); +$aMsg["SendTestTitle"] = i18n("Send test newsletter", "newsletter"); +$aMsg["SendTestTitleOff"] = i18n("Send test newsletter (disabled, check newsletter sender e-mail address and handler article selection)", "newsletter"); +$aMsg["AddJobTitle"] = i18n("Add newsletter dispatch job", "newsletter"); +$aMsg["AddJobTitleOff"] = i18n("Add newsletter dispatch job (disabled, check newsletter sender e-mail address and handler article selection)", "newsletter"); +$aMsg["CopyTitle"] = i18n("Duplicate newsletter", "newsletter"); -while ($oNewsletter = $oNewsletters->next()) -{ - $idnewsletter = $oNewsletter->get("idnews"); - $iMenu++; - - $sName = $oNewsletter->get("name"); - if ($oNewsletter->get("welcome")) { - $sName = $sName . "*"; - } +while ($oNewsletter = $oNewsletters->next()) { + $idnewsletter = $oNewsletter->get("idnews"); + $iMenu++; - // 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 = ''.$aMsg['; - } else { - $sLnkSendTest = ''.$aMsg['; - } - $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(''.$aMsg['); - - $sLnkAddJob = $oLnkAddJob->render(); - } else { - $sLnkAddJob = ''.$aMsg['; - } - - $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(''.$aMsg['); - - $oMenu->setActions($iMenu, 'copy', $oLnkCopy->render()); - } - - if ($perm->have_perm_area_action($area, "news_delete")) - { - $sDelete = ''.$aMsg['; - $oMenu->setActions($iMenu, 'delete', $sDelete); - } + $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 = '' . $aMsg['; + } else { + $sLnkSendTest = '' . $aMsg['; + } + $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('' . $aMsg['); + + $sLnkAddJob = $oLnkAddJob->render(); + } else { + $sLnkAddJob = '' . $aMsg['; + } + + $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('' . $aMsg['); + + $oMenu->setActions($iMenu, 'copy', $oLnkCopy->render()); + } + + if ($perm->have_perm_area_action($area, "news_delete")) { + $sDelete = '' . $aMsg['; + $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 ($_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"), $oRcpGroup->get("groupname")); - } - unset ($oRcpGroups); + if ($oRcpGroup = $oRcpGroups->next()) { + $sSendTestTarget = sprintf(i18n("Recipient group: %s", "newsletter"), $oRcpGroup->get("groupname")); + } + unset($oRcpGroups); } -$aMsg["SendTestDescr"] = sprintf(i18n("Do you really want to send the newsletter to:
%s"), $sSendTestTarget); +$aMsg["SendTestDescr"] = sprintf(i18n("Do you really want to send the newsletter to:
%s", "newsletter"), $sSendTestTarget); $sExecScript = ' '); +$oPage->addScript('messagebox', ''); $oPage->addScript('exec', $sExecScript); $oPage->addScript('parameterCollector.js', ''); // Generate current content for Object Pager -$sPagerId = "0ed6d632-6adf-4f09-a0c6-1e38ab60e302"; +$sPagerId = "0ed6d632-6adf-4f09-a0c6-1e38ab60e302"; $oPagerLink = new cHTMLLink; $oPagerLink->setLink("main.php"); $oPagerLink->setTargetFrame('left_bottom'); @@ -366,7 +354,7 @@ $oPage->addScript('setpager', ''; - $oPage->addScript('refreshlefttop', $sRefreshLeftTopScript); +if ($action == "recipientgroup_create" && $perm->have_perm_area_action($area, $action)) { + $oRGroup = $oRGroups->create(" " . i18n("-- new group --", "newsletter")); + $_REQUEST["idrecipientgroup"] = $oRGroup->get("idnewsgroup"); + $oPage->setReload(); + $sRefreshLeftTopScript = ''; + $oPage->addScript('refreshlefttop', $sRefreshLeftTopScript); } elseif ($action == "recipientgroup_delete" && $perm->have_perm_area_action($area, $action)) { - $oRGroups->delete($_REQUEST["idrecipientgroup"]); - $sRefreshLeftTopScript = ''; - $oPage->addScript('refreshlefttop', $sRefreshLeftTopScript); - - $_REQUEST["idrecipientgroup"] = 0; - $oRGroup = new RecipientGroup; - $oPage->setReload(); + $oRGroups->delete($_REQUEST["idrecipientgroup"]); + $sRefreshLeftTopScript = ''; + $oPage->addScript('refreshlefttop', $sRefreshLeftTopScript); + + $_REQUEST["idrecipientgroup"] = 0; + $oRGroup = new RecipientGroup; + $oPage->setReload(); } else { - $oRGroup->loadByPrimaryKey($_REQUEST["idrecipientgroup"]); + $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"); - } 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(); - } +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; - // 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 = ''; - $oPage->addScript('refreshlefttop', $sRefreshLeftTopScript); - } - - if (count($aMessages) > 0) { - $sNotis = $notification->returnNotification("warning", implode("
", $aMessages)) . "
"; - } - - // 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); + $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 (!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);"); + if ($oRGroups->next()) { + $aMessages[] = i18n("Could not set new group name: Group already exists", "newsletter"); + } else { + $bReload = true; - $oForm->addHeader(i18n("Edit group")); - - $oTxtGroupName = new cHTMLTextbox("groupname", $oRGroup->get("groupname"),40); - $oForm->add(i18n("Group name"), $oTxtGroupName->render()); - - $oCkbDefault = new cHTMLCheckbox("defaultgroup", "1"); - $oCkbDefault->setChecked($oRGroup->get("defaultgroup")); - $oForm->add(i18n("Default group"), $oCkbDefault->toHTML(false)); - - // Member list options folding row - $oMemberListOptionRow = new cFoldingRow("a91f5540-52db-11db-b0de-0800200c9a66",i18n("Member list options")); - - $oSelItemsPerPage = new cHTMLSelectElement("member_elemperpage"); - $oSelItemsPerPage->autoFill(array(0 => i18n("-- All --"), 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"), "DESC" => i18n("Descending"))); - $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 --"), "--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")); - - $sContent = '
'.chr(10); - $sContent .= '
'. i18n("Items / page").''. i18n("Items / page", "newsletter").''.$oSelItemsPerPage->render().'
'. i18n("Sort by").''. i18n("Sort by", "newsletter").''.$oSelSortBy->render().'
'. i18n("Sort order").''. i18n("Sort order", "newsletter").''.$oSelSortOrder->render().'
'. i18n("Search for").''. i18n("Search for", "newsletter").''.$oTxtFilter->render().'
'. i18n("Search in").''. i18n("Search in", "newsletter").''.$oSelSearchIn->render().'
'.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= '
'. i18n("Items / page").''.$oSelItemsPerPage->render().'
'. i18n("Sort by").''.$oSelSortBy->render().'
'. i18n("Sort order").''.$oSelSortOrder->render().'
'. i18n("Search for").''.$oTxtFilter->render().'
'. i18n("Search in").''.$oSelSearchIn->render().'
 '.$oSubmit->render().'
'.chr(10); - $sContent .= '
'.chr(10); - $oMemberListOptionRow->setContentData($sContent); - - // Members - $oAddedRecipientList = new UI_List; - $oAddedRecipientList->setWidth("100%"); - $oAddedRecipientList->setBorder(1); + $oRGroup->set("groupname", $sGroupName); + } + } - $oAddedRecipientList->setCell(0, 1, "".i18n("Name").""); - $oImgDel = new cHTMLImage("images/but_invert_selection.gif"); - $sLnkDelIcon = ''.$oImgDel->render().''; - $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"]); + if (count($_REQUEST["adduser"]) > 0) { + foreach ($_REQUEST["adduser"] as $iRcpID) { + if (is_numeric($iRcpID)) { + $oRGroupMembers->create($_REQUEST["idrecipientgroup"], $iRcpID); + } + } + } - // 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); - } - } + if ($oRGroup->get("defaultgroup") != (int) $_REQUEST["defaultgroup"]) { + $bReload = true; + $oRGroup->set("defaultgroup", $_REQUEST["defaultgroup"]); + } - // 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"); - } - } + $oRGroup->store(); - // 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")); - $oAddedRecipientList->setCell(1, 2, ' '); - } else if ($iItems == 0) { - $oAddedRecipientList->setCell(1, 1, i18n("No recipients found")); - $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")); - - $oForm->add(i18n("Recipients in group"), ''. - $oMemberListOptionRow->render(). - $oMemberPager->render(). - '
'.$oAddedRecipientList->render().'
'); - 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")); - - $oSelItemsPerPage = new cHTMLSelectElement("outsider_elemperpage"); - $oSelItemsPerPage->autoFill(array(0 => i18n("-- All --"), 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"), "DESC" => i18n("Descending"))); - $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 --"), "--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")); - - $sContent = '
'.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= ' '.chr(10); - $sContent .= '
'. i18n("Items / page").''.$oSelItemsPerPage->render().'
'. i18n("Sort by").''.$oSelSortBy->render().'
'. i18n("Sort order").''.$oSelSortOrder->render().'
'. i18n("Search for").''.$oTxtFilter->render().'
'. i18n("Search in").''.$oSelSearchIn->render().'
 '.$oSubmit->render().'
'.chr(10); - $sContent .= '
'.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 ($bReload) { + $oPage->setReload(); + } - // 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"); + // 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); + } + } + } - 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")); - - $oForm->add(i18n("Add recipients"), ''. - $oOutsiderListOptionRow->render(). - $oOutsiderPager->render(). - '
'.$oSelUser->render().'
'.i18n("Note: Hold <Ctrl> to
select multiple items.").'
'); - unset ($oOutsiders); - unset ($oOutsiderListOptionRow); - unset ($oOutsiderPager); - - $sDelMarkScript = ' '; + $oPage->addScript('refreshlefttop', $sRefreshLeftTopScript); + } + + if (count($aMessages) > 0) { + $sNotis = $notification->returnNotification("warning", implode("
", $aMessages)) . "
"; + } + + // 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", "newsletter")); + + $oTxtGroupName = new cHTMLTextbox("groupname", $oRGroup->get("groupname"), 40); + $oForm->add(i18n("Group name", "newsletter"), $oTxtGroupName->render()); + + $oCkbDefault = new cHTMLCheckbox("defaultgroup", "1"); + $oCkbDefault->setChecked($oRGroup->get("defaultgroup")); + $oForm->add(i18n("Default group", "newsletter"), $oCkbDefault->toHTML(false)); + + // Member list options folding row + $oMemberListOptionRow = new cFoldingRow("a91f5540-52db-11db-b0de-0800200c9a66", i18n("Member list options", "newsletter")); + + $oSelItemsPerPage = new cHTMLSelectElement("member_elemperpage"); + $oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "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", "newsletter"), "DESC" => i18n("Descending", "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 --", "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", "newsletter")); + + $sContent = '
' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= '
' . i18n("Items / page", "newsletter") . '' . $oSelItemsPerPage->render() . '
' . i18n("Sort by", "newsletter") . '' . $oSelSortBy->render() . '
' . i18n("Sort order", "newsletter") . '' . $oSelSortOrder->render() . '
' . i18n("Search for", "newsletter") . '' . $oTxtFilter->render() . '
' . i18n("Search in", "newsletter") . '' . $oSelSearchIn->render() . '
 ' . $oSubmit->render() . '
' . chr(10); + $sContent .= '
' . chr(10); + $oMemberListOptionRow->setContentData($sContent); + + // Members + $oAddedRecipientList = new UI_List; + $oAddedRecipientList->setWidth("100%"); + $oAddedRecipientList->setBorder(1); + + $oAddedRecipientList->setCell(0, 1, "" . i18n("Name", "newsletter") . ""); + $oImgDel = new cHTMLImage("images/but_invert_selection.gif"); + $sLnkDelIcon = '' . $oImgDel->render() . ''; + $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", "newsletter")); + $oAddedRecipientList->setCell(1, 2, ' '); + } else if ($iItems == 0) { + $oAddedRecipientList->setCell(1, 1, i18n("No recipients found", "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", "newsletter")); + + $oForm->add(i18n("Recipients in group", "newsletter"), '' . + $oMemberListOptionRow->render() . + $oMemberPager->render() . + '
' . $oAddedRecipientList->render() . '
'); + 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", "newsletter")); + + $oSelItemsPerPage = new cHTMLSelectElement("outsider_elemperpage"); + $oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "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", "newsletter"), "DESC" => i18n("Descending", "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 --", "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", "newsletter")); + + $sContent = '
' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= ' ' . chr(10); + $sContent .= '
' . i18n("Items / page", "newsletter") . '' . $oSelItemsPerPage->render() . '
' . i18n("Sort by", "newsletter") . '' . $oSelSortBy->render() . '
' . i18n("Sort order", "newsletter") . '' . $oSelSortOrder->render() . '
' . i18n("Search for", "newsletter") . '' . $oTxtFilter->render() . '
' . i18n("Search in", "newsletter") . '' . $oSelSearchIn->render() . '
 ' . $oSubmit->render() . '
' . chr(10); + $sContent .= '
' . 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", "newsletter")); + + $oForm->add(i18n("Add recipients", "newsletter"), '' . + $oOutsiderListOptionRow->render() . + $oOutsiderPager->render() . + '
' . $oSelUser->render() . '
' . i18n("Note: Hold <Ctrl> to
select multiple items.", "newsletter") . '
'); + unset($oOutsiders); + unset($oOutsiderListOptionRow); + unset($oOutsiderPager); + + $sDelMarkScript = ' '; - - $oPage->addScript('DelMarkScript', $sDelMarkScript); - $oPage->addScript('cfoldingrow.js', ''); - $oPage->addScript('parameterCollector.js', ''); - - $oPage->setContent($sNotis.$oForm->render(true)); + '; + + $oPage->addScript('DelMarkScript', $sDelMarkScript); + $oPage->addScript('cfoldingrow.js', ''); + $oPage->addScript('parameterCollector.js', ''); + + $oPage->setContent($sNotis . $oForm->render(true)); } else { - $oPage->setContent($sNotis.""); + $oPage->setContent($sNotis . ""); } $oPage->render(); - ?> \ No newline at end of file diff --git a/conlite/plugins/newsletter/includes/include.recipients.group_menu.php b/conlite/plugins/newsletter/includes/include.recipients.group_menu.php index 142eb2a..0417683 100644 --- a/conlite/plugins/newsletter/includes/include.recipients.group_menu.php +++ b/conlite/plugins/newsletter/includes/include.recipients.group_menu.php @@ -1,4 +1,5 @@ auth["uid"]); +$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, @@ -48,125 +48,120 @@ $oUser = new cApiUser($auth->auth["uid"]); // 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"), "type" => "base,sort,search"); +$aFields = array(); +$aFields["name"] = array("field" => "groupname", "caption" => i18n("Name", "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); + $_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; + // 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"]); +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"]; +$_REQUEST["page"] = (int) $_REQUEST["page"]; if ($_REQUEST["page"] <= 0 || $_REQUEST["elemperpage"] == 0) { - $_REQUEST["page"] = 1; + $_REQUEST["page"] = 1; } // Sort order if ($_REQUEST["sortorder"] != "DESC") { - $_REQUEST["sortorder"] = "ASC"; + $_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--"; +$_REQUEST["sortby"] = "groupname"; // Default sort by field, possible values see above +$_REQUEST["searchin"] = "--all--"; // Free memory -unset ($oUser); -unset ($oClient); +unset($oUser); +unset($oClient); ################################## # Get data ################################## $oRcpGroups = new RecipientGroupCollection; -$oRcpGroups->setWhere("idclient", $client); -$oRcpGroups->setWhere("idlang", $lang); +$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["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)? +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"]--; + 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->setOrder("defaultgroup DESC, " . $_REQUEST["sortby"] . " " . $_REQUEST["sortorder"]); $oRcpGroups->query(); // Output data -$oMenu = new UI_Menu; -$iMenu = 0; +$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"); -$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter recipient group:
"); +$aMsg["DelTitle"] = i18n("Delete recipient group", "newsletter"); +$aMsg["DelDescr"] = i18n("Do you really want to delete the following newsletter recipient group:
", "newsletter"); -while ($oRcpGroup = $oRcpGroups->next()) -{ - $iMenu++; - $iIDGroup = $oRcpGroup->get("idnewsgroup"); - - $sName = $oRcpGroup->get("groupname"); - if ($oRcpGroup->get("defaultgroup")) { - $sName = $sName . "*"; - } +while ($oRcpGroup = $oRcpGroups->next()) { + $iMenu++; + $iIDGroup = $oRcpGroup->get("idnewsgroup"); - // Create the link to show/edit the recipient group - $oLnk = new cHTMLLink; - $oLnk->setMultiLink("recipientgroups","","recipientgroups",""); - $oLnk->setCustom("idrecipientgroup", $iIDGroup); + $sName = $oRcpGroup->get("groupname"); + if ($oRcpGroup->get("defaultgroup")) { + $sName = $sName . "*"; + } - #$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', ''.$aMsg['); - } + // 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', '' . $aMsg['); + } } $sExecScript = ' '; + '; $oPage->setMargin(0); -$oPage->addScript('messagebox', ''); +$oPage->addScript('messagebox', ''); $oPage->addScript('delete', $sExecScript); //$oPage->addScript('cfoldingrow.js', ''); $oPage->addScript('parameterCollector.js', ''); // Generate current content for Object Pager -$sPagerId = "0ed6d632-6adf-4f09-a0c6-1e38ab60e305"; +$sPagerId = "0ed6d632-6adf-4f09-a0c6-1e38ab60e305"; $oPagerLink = new cHTMLLink; $oPagerLink->setLink("main.php"); $oPagerLink->setTargetFrame('left_bottom'); @@ -225,16 +220,15 @@ $oPage->addScript('setpager', ''; -$oPage->addScript('refreshpager', $sRefreshPager); +$oPage->addScript('refreshpager', $sRefreshPager); //$oPage->setContent(array('', '
', $oMenu->render(false))); $oPage->setContent($oMenu->render(false)); $oPage->render(); - ?> \ No newline at end of file diff --git a/conlite/plugins/newsletter/includes/include.recipients_edit.php b/conlite/plugins/newsletter/includes/include.recipients_edit.php index 865c6b4..e54709b 100644 --- a/conlite/plugins/newsletter/includes/include.recipients_edit.php +++ b/conlite/plugins/newsletter/includes/include.recipients_edit.php @@ -1,4 +1,5 @@ have_perm_area_action($area, $action)) { - $recipient = $oRecipients->create("mail@domain.tld"," ".i18n("-- new recipient --")); - $oPage->setReload(); + $recipient = $oRecipients->create("mail@domain.tld", " " . i18n("-- new recipient --", "newsletter")); + $oPage->setReload(); } elseif ($action == "recipients_delete" && $perm->have_perm_area_action($area, $action)) { - $oRecipients->delete($idrecipient); - $recipient = new Recipient; - $oPage->setReload(); + $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.")),$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.")), 0, $timeframe),0); - } - - $recipient = new Recipient; - $oPage->setReload(); + 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.", "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.", "newsletter")), 0, $timeframe), 0); + } + + $recipient = new Recipient; + $oPage->setReload(); } else { - $recipient = new Recipient($idrecipient); + $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(); + 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); + $name = stripslashes($name); + $email = stripslashes($email); + $confirmed = (int) $confirmed; + $deactivated = (int) $deactivated; + $newstype = (int) $newstype; - if (!isValidMail($email)) - { - $aMessages[] = i18n("Please specify a valid e-mail address"); - } 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"); - } 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("
", $aMessages)) . "
"; - } - - $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")); + $recipient->set("name", $name); - $oForm->addHeader(i18n("Edit recipient")); + if (!isValidMail($email)) { + $aMessages[] = i18n("Please specify a valid e-mail address", "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(); - $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"), "0"); - $oSelNewsType->addOptionElement(0, $oOption); - $oOption = new cHTMLOptionElement(i18n("HTML and text"), "1"); - $oSelNewsType->addOptionElement(1, $oOption); - $oSelNewsType->setDefault($recipient->get("news_type")); - - $oForm->add(i18n("Name"), $oTxtName->render()); - $oForm->add(i18n("E-Mail"), $oTxtEMail->render()); - $oForm->add(i18n("Confirmed"), $oCkbConfirmed->toHTML(false) . " (" . $recipient->get("confirmeddate") . ")"); - $oForm->add(i18n("Deactivated"), $oCkbDeactivated->toHTML(false)); - $oForm->add(i18n("Message type"), $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"), sprintf(i18n("The plugin %s delivered an array for the displayed titles, but did not return an array for the contents."), $sPlugin)); - } else { - $oForm->add($aPluginTitle, $aPluginDisplay); - } - } - } - } - } - - $oGroupList = new UI_List; - $oGroupList->setWidth("100%"); - $oGroupList->setBorder(1); + if ($oRecipients->next()) { + $aMessages[] = i18n("Could not set new e-mail adress: Other recipient with same e-mail address already exists", "newsletter"); + } else { + $recipient->set("email", $email); + } + } + } - $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")); - } else { - // Headline - $oGroupList->setCell(0, 1, "".i18n("Groupname").""); - $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"), $oGroupList->render()); - - $oForm->add(i18n("Author"), $classuser->getUserName($recipient->get("author")) . " (". $recipient->get("created").")" ); - $oForm->add(i18n("Last modified by"), $classuser->getUserName($recipient->get("modifiedby")). " (". $recipient->get("lastmodified").")" ); - - $oPage->setContent($sNotis . $oForm->render(true)); + 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("
", $aMessages)) . "
"; + } + + $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", "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", "newsletter"), "0"); + $oSelNewsType->addOptionElement(0, $oOption); + $oOption = new cHTMLOptionElement(i18n("HTML and text", "newsletter"), "1"); + $oSelNewsType->addOptionElement(1, $oOption); + $oSelNewsType->setDefault($recipient->get("news_type")); + + $oForm->add(i18n("Name", "newsletter"), $oTxtName->render()); + $oForm->add(i18n("E-Mail", "newsletter"), $oTxtEMail->render()); + $oForm->add(i18n("Confirmed", "newsletter"), $oCkbConfirmed->toHTML(false) . " (" . $recipient->get("confirmeddate") . ")"); + $oForm->add(i18n("Deactivated", "newsletter"), $oCkbDeactivated->toHTML(false)); + $oForm->add(i18n("Message type", "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", "newsletter"), sprintf(i18n("The plugin %s delivered an array for the displayed titles, but did not return an array for the contents.", "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", "newsletter")); + } else { + // Headline + $oGroupList->setCell(0, 1, "" . i18n("Groupname", "newsletter") . ""); + $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", "newsletter"), $oGroupList->render()); + + $oForm->add(i18n("Author", "newsletter"), $classuser->getUserName($recipient->get("author")) . " (" . $recipient->get("created") . ")"); + $oForm->add(i18n("Last modified by", "newsletter"), $classuser->getUserName($recipient->get("modifiedby")) . " (" . $recipient->get("lastmodified") . ")"); + + $oPage->setContent($sNotis . $oForm->render(true)); } else { - $oPage->setContent($sNotis . ""); + $oPage->setContent($sNotis . ""); } $oPage->render(); - ?> diff --git a/conlite/plugins/newsletter/includes/include.recipients_import.php b/conlite/plugins/newsletter/includes/include.recipients_import.php index a430346..a60702e 100644 --- a/conlite/plugins/newsletter/includes/include.recipients_import.php +++ b/conlite/plugins/newsletter/includes/include.recipients_import.php @@ -1,4 +1,5 @@ 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") . "_" . $sGroupName))); - $aFieldDetails[$sField]["fieldtype"]= "group"; - $aFieldDetails[$sField]["mandatory"]= false; - $aFieldDetails[$sField]["type"] = "string"; - $aFieldDetails[$sField]["link"] = $oRcpGroup->get($oRcpGroup->primaryKey); - $aFieldDetails[$sField]["col"] = -1; +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", "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 ($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 "
".nl2br(stripslashes($_REQUEST["txtData"]))."
"; - $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; + if ($_REQUEST["txtData"]) { + switch ($_REQUEST["selDelimiter"]) { + case "semicolon": + $sDelimiter = ";"; + break; + default: + $sDelimiter = "\t"; //chr(9); + } - foreach($aLines as $sLine) { - $iRow++; + //echo "
".nl2br(stripslashes($_REQUEST["txtData"]))."
"; + $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; - $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"), $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"), $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)"), $sName, $iRow); - $aInvalidLines[] = $sLine; - $iInvalid++; - } else if (!isValidMail($sEMail)) { - $aMessage[] = sprintf(i18n("Mail address '%s' is invalid, item ignored (row: %s)"), $sEMail, $iRow); - $aInvalidLines[] = $sLine; - $iInvalid++; - } else if ($oRecipients->emailExists($sEMail)) { - $aMessage[] = sprintf(i18n("Recipient with mail address '%s' already exists, item skipped (row: %s)"), $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") || $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") || - $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("
", $aMessage))."
"; - } - $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)."), $iAdded, $iDublettes, $iInvalid)); - if ($iAdded > 0) { - $oPage->setReload(); - } - } + 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", "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", "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)", "newsletter"), $sName, $iRow); + $aInvalidLines[] = $sLine; + $iInvalid++; + } else if (!isValidMail($sEMail)) { + $aMessage[] = sprintf(i18n("Mail address '%s' is invalid, item ignored (row: %s)", "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)", "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", "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", "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("
", $aMessage)) . "
"; + } + $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).", "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")); +$oForm->addHeader(i18n("Import recipients", "newsletter")); $oSelDelimiter = new cHTMLSelectElement("selDelimiter"); $aItems = array(); -$aItems[] = array("tab", i18n("Tab")); -$aItems[] = array("semicolon", i18n("Semicolon")); +$aItems[] = array("tab", i18n("Tab", "newsletter")); +$aItems[] = array("semicolon", i18n("Semicolon", "newsletter")); $oSelDelimiter->autoFill($aItems); $oSelDelimiter->setDefault($_REQUEST["selDelimiter"]); -$oForm->add(i18n("Delimiter"), $oSelDelimiter->render()); +$oForm->add(i18n("Delimiter", "newsletter"), $oSelDelimiter->render()); $oAreaData = new cHTMLTextarea("txtData", $_REQUEST["txtData"], 80, 20); -$sInfo = ''.i18n("Import information").''. - '