* @license http://www.contenido.org/license/LIZENZ.txt * @link http://www.4fb.de * @link http://www.contenido.org * @since file available since contenido release <= 4.6 * * {@internal * created 2007-01-01, Bj�rn Behrens (HerrB) * modified 2008-06-27, Dominik Ziegler, add security fix * modified 2008-08-03, Bj�rn Behrens (HerrB), complete makeover to fix bugs and reduce memory waste * * $Id: include.newsletter_left_top.php 128 2019-07-03 11:58:28Z oldperl $: * }} * */ if(!defined('CON_FRAMEWORK')) { die('Illegal call'); } ###################################### # Initialization ###################################### if (!is_object($oTpl)) { $oTpl = new Template; } if (!is_object($oDB)) { $oDB = new DB_ConLite; // We have really to send a special SQL statement - we need a DB object } $oUser = new cApiUser($auth->auth["uid"]); $oClient = new cApiClient($client); $oClientLang = new cApiClientLanguage(false, $client, $lang); ###################################### # 0. BUTTONS ###################################### // Newsletter $sId = 'img_newsletter'; $oTpl->set('s', 'INEWSLETTER', $sId); if ($perm->have_perm_area_action('news')) { $sButtonRow = ''; $sButtonRow .= ''. i18n('; $sButtonRow .= ''; } // Job dispatch $sId = 'img_dispatch'; $oTpl->set('s', 'IDISPATCH', $sId); if ($perm->have_perm_area_action('news_jobs')) { $sButtonRow .= ''; $sButtonRow .= ''.i18n('; $sButtonRow .= ''; } // Recipients $sId = 'img_recipient'; $oTpl->set('s', 'IRECIPIENTS', $sId); if ($perm->have_perm_area_action('recipients')) { $sButtonRow .= ''; $sButtonRow .= ''.i18n('; $sButtonRow .= ''; } // Recipient groups $sId = 'img_recipientgroup'; $oTpl->set('s', 'IRECIPIENTGROUP', $sId); if ($perm->have_perm_area_action('recipientgroups')) { $sButtonRow .= ''; $sButtonRow .= ''.i18n('; $sButtonRow .= ''; } $oTpl->set('s', 'BUTTONROW', $sButtonRow); unset($sButtonRow); ###################################### # 1. NEWSLETTER ###################################### ###################################### # 1.1 Newsletter: Actions folding row ###################################### $sLink = "actionlink"; // ID for HTML element $oActionsRow = new cFoldingRow("28cf9b31-e6d7-4657-a9a7-db31478e7a5c",i18n("Actions", "cl_newsletter"), $sLink); $oTpl->set('s', 'ACTIONLINK', $sLink); if ($perm->have_perm_area_action("news", "news_create")) { // Create the link to add a newsletter $sContent = '
'."\n"; $oLink = new cHTMLLink; $oLink->setMultiLink("news", "", "news", "news_create"); $oLink->setContent(''.i18n("Create newsletter", "cl_newsletter")); $sContent .= $oLink->render() . '
'."\n"; $oActionsRow->setContentData($sContent); } else { $oActionsRow->setContentData(""); } ###################################### # 1.2 Newsletter: Settings folding row ###################################### $sLink = "settingslink"; $oSettingsRow = new cFoldingRow("d64baf0a-aea9-47b3-8490-54a00fce02b5",i18n("Settings", "cl_newsletter"), $sLink); $oTpl->set('s', 'SETTINGSLINK', $sLink); // HTML Newsletter: Template and newsletter category // Note, that in PHP 5 it is not possible to have a truely working copy of an object // so, we are filling two almost identical objects with the same data ("clone" may work, but is not available in PHP4 ...) $oSelHTMLTemplateIDCat = new cHTMLSelectElement("selHTMLTemplateCat"); $oSelHTMLTemplateIDCat->setStyle("width: 220px;"); $oSelHTMLNewsletterIDCat = new cHTMLSelectElement("selHTMLNewsletterCat"); $oSelHTMLNewsletterIDCat->setStyle("width: 220px;"); $oOptionTemplate = new cHTMLOptionElement("--".i18n("Please select", "cl_newsletter")."--", 0); $oSelHTMLTemplateIDCat->addOptionElement(0, $oOptionTemplate); $oOptionNewsletter = new cHTMLOptionElement("--".i18n("Please select", "cl_newsletter")."--", 0); $oSelHTMLNewsletterIDCat->addOptionElement(0, $oOptionNewsletter); $sSQL = "SELECT tblCat.idcat AS idcat, tblCatLang.name AS name, tblCatTree.level AS level, "; $sSQL .= "tblCatLang.visible AS visible, tblCatLang.public AS public FROM "; $sSQL .= $cfg["tab"]["cat"]." AS tblCat, ".$cfg["tab"]["cat_lang"]." AS tblCatLang, "; $sSQL .= $cfg["tab"]["cat_tree"]." AS tblCatTree "; $sSQL .= "WHERE tblCat.idclient = '".Contenido_Security::toInteger($client)."' AND tblCatLang.idlang = '".Contenido_Security::toInteger($lang)."' AND "; $sSQL .= "tblCatLang.idcat = tblCat.idcat AND tblCatTree.idcat = tblCat.idcat "; $sSQL .= "ORDER BY tblCatTree.idtree"; $oDB->query($sSQL); while ($oDB->next_record()) { $sSpaces = "  "; for ($i = 0; $i < $oDB->f("level"); $i ++) { $sSpaces .= "     "; } $oOptionTemplate = new cHTMLOptionElement($sSpaces.$oDB->f("name"), $oDB->f("idcat")); $oOptionNewsletter = new cHTMLOptionElement($sSpaces.$oDB->f("name"), $oDB->f("idcat")); if ($oDB->f("visible") == 0 || $oDB->f("public") == 0) { $oOptionTemplate->setStyle("color: #666666;"); $oOptionNewsletter->setStyle("color: #666666;"); } $oSelHTMLTemplateIDCat->addOptionElement($oDB->f("idcat"), $oOptionTemplate); $oSelHTMLNewsletterIDCat->addOptionElement($oDB->f("idcat"), $oOptionNewsletter); } // Get html template category $iHTMLTemplateIDCat = (int)$oClientLang->getProperty("newsletter", "html_template_idcat"); if ($iHTMLTemplateIDCat < 0) { $iHTMLTemplateIDCat = 0; } $oSelHTMLTemplateIDCat->setDefault($iHTMLTemplateIDCat); // Get html newsletter article category $iHTMLNewsletterIDCat = (int)$oClientLang->getProperty("newsletter", "html_newsletter_idcat"); if ($iHTMLNewsletterIDCat < 0) { $iHTMLNewsletterIDCat = 0; } $oSelHTMLNewsletterIDCat->setDefault($iHTMLNewsletterIDCat); // Global HTML newsletter option $bHTMLNewsletter = false; if ($iHTMLTemplateIDCat > 0 && $iHTMLNewsletterIDCat > 0 && $oClientLang->getProperty("newsletter", "html_newsletter") == "true") { // If necessary idcats are not specified or the option is disabled, // then HTML are not used $bHTMLNewsletter = true; } $oCkbHTMLNewsletter = new cHTMLCheckbox("ckbHTMLNewsletter", "enabled", "", $bHTMLNewsletter); // Disable HTML options, if user has no rights if (!$perm->have_perm_area_action($area, "news_html_settings")) { $oSelHTMLTemplateIDCat->setDisabled("disabled"); $oSelHTMLNewsletterIDCat->setDisabled("disabled"); $oCkbHTMLNewsletter->setDisabled("disabled"); } // Destination for sending test newsletter $oSelTestDestination = new cHTMLSelectElement("selTestDestination"); $oSelTestDestination->setStyle("width: 220px;"); $oOption = new cHTMLOptionElement(i18n("My mail address", "cl_newsletter"), 0); $oSelTestDestination->addOptionElement(0, $oOption); $oRcpGroups = new RecipientGroupCollection; $oRcpGroups->setWhere("idclient", (int)$client); $oRcpGroups->setWhere("idlang", (int)$lang); $oRcpGroups->setOrder("groupname"); $oRcpGroups->query(); $bTestTargetFound = false; // Get client and language specific test destination. As lang is client specific, lang is sufficient $iTestDestination = (int)$oUser->getProperty("newsletter", "test_idnewsgrp_lang" . $lang); while ($oRcpGroup = $oRcpGroups->next()) { $iID = $oRcpGroup->get($oRcpGroup->primaryKey); if ($iTestDestination == $iID) { $bTestTargetFound = true; } $oOption = new cHTMLOptionElement($oRcpGroup->get("groupname"), $iID); $oSelTestDestination->addOptionElement($iID, $oOption); } unset($oRcpGroups); if (!$bTestTargetFound) { // Currently specified test target doesn't exist anymore, get back to "my mail" $iTestDestination = 0; } if (!$perm->have_perm_area_action($area, "news_send_test")) { // No right to send somewhere else than to yourself $iTestDestination = 0; $oSelTestDestination->setDisabled("disabled"); } $oSelTestDestination->setDefault($iTestDestination); $oBtnSave = new cHTMLButton("submit", i18n("Save", "cl_newsletter")); $sContent = '
'."\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 .= '
'.$oCkbHTMLNewsletter->toHTML(false).' '.i18n("Enable HTML Newsletter", "cl_newsletter").'
'.i18n("HTML Template Category:", "cl_newsletter").'
'.$oSelHTMLTemplateIDCat->render().'
'.i18n("HTML Newsletter Category:", "cl_newsletter").'
'.$oSelHTMLNewsletterIDCat->render().'
'.i18n("Send test destination:", "cl_newsletter").'
'.$oSelTestDestination->render().'
'.$oBtnSave->render().'
'."\n"; $sContent .= '
'."\n"; $sContent .= '
'."\n"; $oSettingsRow->setContentData($sContent); ###################################### # 1.3 Newsletter: List options folding row ###################################### // Items per Page $iItemsPerPage = (int)$oUser->getProperty("itemsperpage", "news"); // Also used in query below if ($iItemsPerPage == 0) { $iItemsPerPage = 25; // All can't be saved } $oSelItemsPerPage = new cHTMLSelectElement("elemperpage"); $oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); $oSelItemsPerPage->setDefault($iItemsPerPage); // Sort By $oSelSortBy = new cHTMLSelectElement("sortby"); $oOption = new cHTMLOptionElement("Name", "name"); $oSelSortBy->addOptionElement($sKey, $oOption); $oSelSortBy->setDefault("name"); // Sort Order $oSelSortOrder = new cHTMLSelectElement("sortorder"); $oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter"))); $oSelSortOrder->setDefault("ASC"); // Search For $oTextboxFilter = new cHTMLTextbox("filter", "", 16); // Search In $oSelSearchIn = new cHTMLSelectElement("searchin"); $oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--"); $oSelSearchIn->addOptionElement("all", $oOption); $oOption = new cHTMLOptionElement("Name", "name"); $oSelSearchIn->addOptionElement($sKey, $oOption); $oSelSearchIn->setDefault("name"); // Apply button $oBtnApply = new cHTMLButton("submit", i18n("Apply", "cl_newsletter")); $sContent = '
'."\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 .= '
'. i18n("Items / page", "cl_newsletter").''.$oSelItemsPerPage->render().'
'. i18n("Sort by", "cl_newsletter").''.$oSelSortBy->render().'
'. i18n("Sort order", "cl_newsletter").''.$oSelSortOrder->render().'
'. i18n("Search for", "cl_newsletter").''.$oTextboxFilter->render().'
'. i18n("Search in", "cl_newsletter").''.$oSelSearchIn->render().'
 '.$oBtnApply->render().'
'."\n"; $sContent .= '
'."\n"; $sContent .= '
'."\n"; // To template $sLink = "listoption"; $oListOptionsRow = new cFoldingRow("9d0968be-601d-44f8-a666-99d51c9c777d",i18n("List options", "cl_newsletter"), $sLink); $oListOptionsRow->setContentData($sContent); $oTpl->set('s', 'LISTOPTIONLINK', $sLink); ###################################### # 1.4 Newsletter: Paging folding row ###################################### // Add paging folding row (current page = 1) to get HTML paging container (later on updated by ...menu.php) $oPagerLink = new cHTMLLink; $oPagerLink->setLink("main.php"); $oPagerLink->setTargetFrame("left_bottom"); $oPagerLink->setCustom("elemperpage", $iItemsPerPage); $oPagerLink->setCustom("filter", ""); //$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]); $oPagerLink->setCustom("sortby", "name"); $oPagerLink->setCustom("sortorder", "ASC"); $oPagerLink->setCustom("searchin", "name"); $oPagerLink->setCustom("frame", "2"); $oPagerLink->setCustom("area", "news"); $oPagerLink->enableAutomaticParameterAppend(); $oPagerLink->setCustom("contenido", $sess->id); $sLink = "pagerlink"; $oTpl->set('s', 'PAGINGLINK', $sLink); //$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e302", $iItemCount, $iItemsPerPage, 1, $oPagerLink, 'page', $sLink); $oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e302", 0, 1, 1, $oPagerLink, 'page', $sLink); ###################################### # Newsletter: Container ###################################### $sContainerId = 'cont_newsletter'; $sContainer = '
'; $sContainer .= ''; if ($perm->have_perm_area_action("news", "news_create")) { $sContainer .= $oActionsRow->render(); } if ($perm->have_perm_area_action("news", "news_html_settings")) { $sContainer .= $oSettingsRow->render(); } $sContainer .= $oListOptionsRow->render(); $sContainer .= $oPagerRow->render(); $sContainer .= '
'; $sContainer .= '
'; $oTpl->set('s', 'CNEWSLETTER', $sContainer); $oTpl->set('s', 'ID_CNEWSLETTER', $sContainerId); ###################################### # 2. Job dispatch ###################################### // Specify fields for search, sort and validation. Design makes enhancements // using plugins possible (currently not implemented). If you are changing things here, // remember to update include. ... menu.php, also. // field: Field name in the db // caption: Shown field name (-> user) // base: Elements from core code (other type may be: "plugin") // sort: Element can be used to be sorted by // search: Element can be used to search in $aFields = array(); $aFields["name"] = array("field" => "name", "caption" => i18n("Name", "cl_newsletter"), "type" => "base,sort,search"); $aFields["created"] = array("field" => "created", "caption" => i18n("Created", "cl_newsletter"), "type" => "base,sort"); $aFields["status"] = array("field" => "status", "caption" => i18n("Status", "cl_newsletter"), "type" => "base,sort"); $aFields["cronjob"] = array("field" => "use_cronjob", "caption" => i18n("Use cronjob", "cl_newsletter"), "type" => "base"); ###################################### # 2.1 Job dispatch: List options folding row ###################################### // Author $oSelAuthor = new cHTMLSelectElement("selAuthor"); // Get possible authors/users from available jobs // For this query genericdb can't be used, as the class id is always included (distinct won't work) $sSQL = "SELECT DISTINCT author, authorname FROM ".$cfg["tab"]["news_jobs"]." ORDER BY authorname"; $oDB->query($sSQL); $aItems = array(); $bUserInList = false; while ($oDB->next_record()) { if ($oDB->f("author") == $auth->auth["uid"]) { $bUserInList = true; } $aItems[] = array($oDB->f("author"), urldecode($oDB->f("authorname"))); } $oSelAuthor->autoFill($aItems); if (!$bUserInList) { // Current ser hasn't sent newsletter jobs, yet - add him to the list (it's the default author) $oOption = new cHTMLOptionElement($auth->auth["uname"], $auth->auth["uid"]); $oSelAuthor->addOptionElement($auth->auth["uid"], $oOption); } $oSelAuthor->setDefault($auth->auth["uid"]); // Items per page $iItemsPerPage = (int)$oUser->getProperty("itemsperpage", "news_jobs"); // Used also below in query if ($iItemsPerPage == 0) { $iItemsPerPage = 25; // All can't be saved } $oSelItemsPerPage = new cHTMLSelectElement("elemperpage"); $oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); $oSelItemsPerPage->setDefault($iItemsPerPage); // Sort by $oSelSortBy = new cHTMLSelectElement("sortby"); foreach ($aFields as $sKey => $aData) { if (strpos($aData["type"], "sort") !== false) { $oOption = new cHTMLOptionElement($aData["caption"], $sKey); $oSelSortBy->addOptionElement($sKey, $oOption); } } $oSelSortBy->setDefault("created"); // Sort order $oSelSortOrder = new cHTMLSelectElement("sortorder"); $oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter"))); $oSelSortOrder->setDefault("DESC"); // Filter $oTxtFilter = new cHTMLTextbox("filter", "", 16); //Search in $oSelSearchIn = new cHTMLSelectElement("searchin"); $oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--"); $oSelSearchIn->addOptionElement("all", $oOption); foreach ($aFields as $sKey => $aData) { if (strpos($aData["type"], "search") !== false) { $oOption = new cHTMLOptionElement($aData["caption"], $sKey); $oSelSearchIn->addOptionElement($sKey, $oOption); } } $oSelSearchIn->setDefault("--all--"); $oBtnApply = new cHTMLButton("submit", i18n("Apply", "cl_newsletter")); $sContent = '
'."\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"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= '
'. i18n("Author", "cl_newsletter").''.$oSelAuthor->render().'
'. i18n("Items / page", "cl_newsletter").''.$oSelItemsPerPage->render().'
'. i18n("Sort by", "cl_newsletter").''.$oSelSortBy->render().'
'. i18n("Sort order", "cl_newsletter").''.$oSelSortOrder->render().'
'. i18n("Search for", "cl_newsletter").''.$oTxtFilter->render().'
'. i18n("Search in", "cl_newsletter").''.$oSelSearchIn->render().'
 '.$oBtnApply->render().'
'."\n"; $sContent .= '
'."\n"; $sContent .= '
'."\n"; // To template $sLink = "listoptiondisp"; $oListOptionsRow = new cFoldingRow("dfa6cc00-0acf-11db-9cd8-0800200c9a66",i18n("List options", "cl_newsletter"), $sLink); $oListOptionsRow->setContentData($sContent); $oTpl->set('s', 'LISTOPTIONLINKDISP', $sLink); ###################################### # 2.2 Job dispatch: Paging folding row ###################################### $oPagerLink = new cHTMLLink; $oPagerLink->setLink("main.php"); $oPagerLink->setTargetFrame('left_bottom'); $oPagerLink->setCustom("selAuthor", $auth->auth["uid"]); $oPagerLink->setCustom("elemperpage", $iItemsPerPage); $oPagerLink->setCustom("filter", ""); //$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]); $oPagerLink->setCustom("sortby", "created"); $oPagerLink->setCustom("sortorder", "DESC"); $oPagerLink->setCustom("searchin", "--all--"); $oPagerLink->setCustom("frame", "2"); // HIER!!! Stimmt das? $oPagerLink->setCustom("area", "news_jobs"); $oPagerLink->enableAutomaticParameterAppend(); $oPagerLink->setCustom("contenido", $sess->id); $sLink = "pagerlinkdisp"; $oTpl->set('s', 'PAGINGLINKDISP', $sLink); //$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e303", $iItemCount, $iItemsPerPage, 1, $oPagerLink, "page", $sLink); $oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e303", 0, 1, 1, $oPagerLink, 'page', $sLink); ###################################### # Job dispatch: Container ###################################### $sContainerId = 'cont_dispatch'; $sContainer = '
'; $sContainer .= ''; $sContainer .= $oListOptionsRow->render(); $sContainer .= $oPagerRow->render(); $sContainer .= '
'; $sContainer .= '
'; $oTpl->set('s', 'CDISPATCH', $sContainer); $oTpl->set('s', 'ID_CDISPATCH', $sContainerId); ###################################### # 3. Recipients ###################################### // See comment at 2. Job dispatch $aFields = array(); $aFields["name"] = array("field" => "name", "caption" => i18n("Name", "cl_newsletter"),"type" => "base,sort,search"); $aFields["email"] = array("field" => "email", "caption" => i18n("E-Mail", "cl_newsletter"),"type" => "base,sort,search"); $aFields["confirmed"] = array("field" => "confirmed", "caption" => i18n("Confirmed", "cl_newsletter"), "type" => "base"); $aFields["deactivated"] = array("field" => "deactivated", "caption" => i18n("Deactivated", "cl_newsletter"), "type" => "base"); ###################################### # 3.1 Recipients: Actions folding row ###################################### $sContent = '
'."\n"; // Create a link to add a recipient if ($perm->have_perm_area_action("recipients", "recipients_create")) { $oLink = new cHTMLLink; $oLink->setMultiLink("recipients","","recipients","recipients_create"); $oLink->setContent(''.i18n("Create recipient", "cl_newsletter").''); $sContent .= $oLink->render().'
'."\n"; } // Create a link to import recipients if ($perm->have_perm_area_action("recipients", "recipients_create")) { $oLink = new cHTMLLink; $oLink->setMultiLink("recipients", "", "recipients_import", "recipients_import"); $oLink->setContent(''.i18n("Import recipients", "cl_newsletter").''); $sContent .= $oLink->render().'
'."\n"; } // Create a link to purge subscribed but not confirmed recipients $iTimeframe = (int)$oClient->getProperty("newsletter", "purgetimeframe"); if ($iTimeframe <= 0) { $iTimeframe = 30; } if ($perm->have_perm_area_action("recipients", "recipients_delete")) { $oLink = new cHTMLLink; $oLink->setLink('javascript:showPurgeMsg("'.i18n('Purge recipients', "cl_newsletter").'", "'.sprintf(i18n("Do you really want to remove recipients, that have not been confirmed since %s days and over?", "cl_newsletter"), '"+purgetimeframe+"').'")'); $oLink->setContent(''.i18n("Purge recipients", "cl_newsletter").''); $sContent .= $oLink->render(); } $sContent .= '
'."\n"; $oTpl->set('s', 'VALUE_PURGETIMEFRAME', $iTimeframe); // To template $sLink = "actionrec"; $oListActionsRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a66", i18n("Actions", "cl_newsletter"), $sLink); $oListActionsRow->setContentData($sContent); $oTpl->set('s', 'ACTIONLINKREC', $sLink); ###################################### # 3.2 Recipients: Settings folding row ###################################### $oTxtTimeframe = new cHTMLTextbox("txtPurgeTimeframe", $iTimeframe, 5); $oBtnSave = new cHTMLButton("submit", i18n("Save", "cl_newsletter")); $sContent = '
'."\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 .= '
'. i18n("Purge timeframe", "cl_newsletter").':'.$oTxtTimeframe->render().' '.i18n("days", "cl_newsletter").'
 '.$oBtnSave->render().'
'."\n"; $sContent .= '
'."\n"; $sContent .= '
'."\n"; // To template $sLink = "settingsrec"; $oSettingsRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a69",i18n("Settings", "cl_newsletter"), $sLink); $oSettingsRow->setContentData($sContent); $oTpl->set('s', 'SETTINGSLINKREC', $sLink); ###################################### # 3.3 Recipients: List options folding row ###################################### $iItemsPerPage = (int)$oUser->getProperty("itemsperpage", "recipients"); if ($iItemsPerPage == 0) { $iItemsPerPage = 25; // All can't be saved } $oSelItemsPerPage = new cHTMLSelectElement("elemperpage"); $oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); $oSelItemsPerPage->setDefault($iItemsPerPage); $oSelSortBy = new cHTMLSelectElement("sortby"); foreach ($aFields as $sKey => $aData) { if (strpos($aData["type"], "sort") !== false) { $oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]); $oSelSortBy->addOptionElement($aData["field"], $oOption); } } $oSelSortBy->setDefault("name"); $oSelSortOrder = new cHTMLSelectElement("sortorder"); $oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter"))); $oSelSortOrder->setDefault("ASC"); $oSelRestrictGroup = new cHTMLSelectElement("restrictgroup"); $oOption = new cHTMLOptionElement(i18n("-- All groups --", "cl_newsletter"), "--all--"); $oSelRestrictGroup->addOptionElement("all", $oOption); // Fetch recipient groups $oRGroups = new RecipientGroupCollection; $oRGroups->setWhere("idclient", $client); $oRGroups->setWhere("idlang", $lang); $oRGroups->setOrder("defaultgroup DESC, groupname ASC"); $oRGroups->query(); $i = 1; while ($oRGroup = $oRGroups->next()) { if ($oRGroup->get("defaultgroup") == 1) { $sGroupname = $oRGroup->get("groupname") . "*"; } else { $sGroupname = $oRGroup->get("groupname"); } $oOption = new cHTMLOptionElement($sGroupname, $oRGroup->get("idnewsgroup")); $oSelRestrictGroup->addOptionElement($i, $oOption); $i++; } $oSelRestrictGroup->setDefault("--all--"); $oTxtFilter = new cHTMLTextbox("filter", "", 16); $oSelSearchIn = new cHTMLSelectElement("searchin"); $oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--"); $oSelSearchIn->addOptionElement("all", $oOption); foreach ($aFields as $sKey => $aData) { if (strpos($aData["type"], "search") !== false) { $oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]); $oSelSearchIn->addOptionElement($aData["field"], $oOption); } } $oSelSearchIn->setDefault("--all--"); $oBtnApply = new cHTMLButton("submit", i18n("Apply")); $sContent = '
'."\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"; $sContent .= ' '."\n"; $sContent .= ' '."\n"; $sContent .= '
'. i18n("Items / page", "cl_newsletter").''.$oSelItemsPerPage->render().'
'. i18n("Sort by", "cl_newsletter").''.$oSelSortBy->render().'
'. i18n("Sort order", "cl_newsletter").''.$oSelSortOrder->render().'
'. i18n("Show group", "cl_newsletter").''.$oSelRestrictGroup->render().'
'. i18n("Search for", "cl_newsletter").''.$oTxtFilter->render().'
'. i18n("Search in", "cl_newsletter").''.$oSelSearchIn->render().'
 '.$oBtnApply->render().'
'."\n"; $sContent .= '
'."\n"; $sContent .= '
'."\n"; // To template $sLink = "listoptionsrec"; $oListOptionsRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a66",i18n("List options", "cl_newsletter"), $sLink); $oListOptionsRow->setContentData($sContent); $oTpl->set('s', 'LISTOPTIONLINKREC', $sLink); ###################################### # 3.4 Recipients: Paging ###################################### $oPagerLink = new cHTMLLink; $oPagerLink->setLink("main.php"); $oPagerLink->setTargetFrame('left_bottom'); $oPagerLink->setCustom("elemperpage", $iItemsPerPage); $oPagerLink->setCustom("filter", ""); $oPagerLink->setCustom("restrictgroup", "--all--"); $oPagerLink->setCustom("sortby", "name"); $oPagerLink->setCustom("sortorder", "ASC"); $oPagerLink->setCustom("searchin", "--all--"); $oPagerLink->setCustom("frame", "2"); $oPagerLink->setCustom("area", "recipients"); $oPagerLink->enableAutomaticParameterAppend(); $oPagerLink->setCustom("contenido", $sess->id); // To template $sLink = "pagingrec"; $oTpl->set('s', 'PAGINGLINKREC', $sLink); //$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e304", $iItemCount, $iItemsPerPage, 1, $oPagerLink, "page", $sLink); $oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e304", 0, 1, 1, $oPagerLink, 'page', $sLink); ###################################### # Recipients: Container ###################################### $sContainerId = 'cont_recipients'; $sContainer = '
'; $sContainer .= ''; if ($perm->have_perm_area_action('recipients', "recipients_delete") || $perm->have_perm_area_action("recipients", "recipients_create")) { $sContainer .= $oListActionsRow->render(); } $sContainer .= $oSettingsRow->render(); $sContainer .= $oListOptionsRow->render(); $sContainer .= $oPagerRow->render(); $sContainer .= '
'; $sContainer .= '
'; $oTpl->set('s', 'CRECIPIENTS', $sContainer); $oTpl->set('s', 'ID_CRECIPIENTS', $sContainerId); ###################################### # 4 Recipient groups ###################################### // See comment at 2. Job dispatch $aFields = array(); $aFields["name"] = array("field" => "groupname", "caption" => i18n("Name", "cl_newsletter"), "type" => "base,sort,search"); ###################################### # 4.1 Recipient groups: Actions ###################################### $sContent = '
'."\n"; // Create a link to add a group if ($perm->have_perm_area_action("recipientgroups", "recipientgroup_create")) { $oLnk = new cHTMLLink; $oLnk->setMultiLink("recipientgroups","","recipientgroups","recipientgroup_create"); $oLnk->setContent(''.i18n("Create group", "cl_newsletter").''); $sContent .= $oLnk->render().'
'."\n"; } $sContent .= '
'."\n"; $sLink = "actiongroup"; $oListActionsRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a67",i18n("Actions", "cl_newsletter"), $sLink); $oListActionsRow->setContentData($sContent); $oTpl->set('s', 'ACTIONLINKGROUP', $sLink); ###################################### # 4.2 Recipient groups: List Options ###################################### $iItemsPerPage = (int)$oUser->getProperty("itemsperpage", "recipientgroups"); if ($iItemsPerPage == 0) { $iItemsPerPage = 25; // All can't be saved } $oSelItemsPerPage = new cHTMLSelectElement("elemperpage"); $oSelItemsPerPage->autoFill(array(0 => i18n("-- All --", "cl_newsletter"), 25 => 25, 50 => 50, 75 => 75, 100 => 100)); $oSelItemsPerPage->setDefault($iItemsPerPage); $oSelSortBy = new cHTMLSelectElement("sortby"); foreach ($aFields as $sKey => $aData) { if (strpos($aData["type"], "sort") !== false) { $oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]); $oSelSortBy->addOptionElement($aData["field"], $oOption); } } $oSelSortBy->setDefault("name"); $oSelSortOrder = new cHTMLSelectElement("sortorder"); $oSelSortOrder->autoFill(array("ASC" => i18n("Ascending", "cl_newsletter"), "DESC" => i18n("Descending", "cl_newsletter"))); $oSelSortOrder->setDefault("ASC"); $oTxtFilter = new cHTMLTextbox("filter", "", 16); $oSelSearchIn = new cHTMLSelectElement("searchin"); $oOption = new cHTMLOptionElement(i18n("-- All fields --", "cl_newsletter"), "--all--"); $oSelSearchIn->addOptionElement("all", $oOption); foreach ($aFields as $sKey => $aData) { if (strpos($aData["type"], "search") !== false) { $oOption = new cHTMLOptionElement($aData["caption"], $aData["field"]); $oSelSearchIn->addOptionElement($aData["field"], $oOption); } } $oSelSearchIn->setDefault("--all--"); $oBtnApply = new cHTMLButton("submit", i18n("Apply", "cl_newsletter")); $sContent = '
'."\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 .= '
'. i18n("Items / page", "cl_newsletter").''.$oSelItemsPerPage->render().'
'. i18n("Sort by", "cl_newsletter").''.$oSelSortBy->render().'
'. i18n("Sort order", "cl_newsletter").''.$oSelSortOrder->render().'
'. i18n("Search for", "cl_newsletter").''.$oTxtFilter->render().'
'. i18n("Search in", "cl_newsletter").''.$oSelSearchIn->render().'
 '.$oBtnApply->render().'
'."\n"; $sContent .= '
'."\n"; $sContent .= '
'."\n"; // To template $sLink = "listoptionsgroup"; $oListOptionsRow = new cFoldingRow("79efc1fc-111d-11dc-8314-0800200c9a66",i18n("List options", "cl_newsletter"), $sLink); $oListOptionsRow->setContentData($sContent); $oTpl->set('s', 'LISTOPTIONLINKGROUP', $sLink); ###################################### # 4.3 Recipient groups: Paging ###################################### $oPagerLink = new cHTMLLink; $oPagerLink->setLink("main.php"); $oPagerLink->setTargetFrame('left_bottom'); $oPagerLink->setCustom("elemperpage", $iItemsPerPage); $oPagerLink->setCustom("filter", ""); $oPagerLink->setCustom("sortby", "name"); $oPagerLink->setCustom("sortorder", "ASC"); $oPagerLink->setCustom("searchin", "--all--"); $oPagerLink->setCustom("frame", "2"); $oPagerLink->setCustom("area", "recipientgroups"); $oPagerLink->enableAutomaticParameterAppend(); $oPagerLink->setCustom("contenido", $sess->id); // To template $sLink = "paginggroup"; $oTpl->set('s', 'PAGINGLINKGROUP', $sLink); //$oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e305", $iItemCount, $iItemsPerPage, 1, $oPagerLink, "page", $sLink); $oPagerRow = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e305", 0, 1, 1, $oPagerLink, 'page', $sLink); ###################################### # Recipient Groups: Container ###################################### $sContainerId = 'cont_recipientgroup'; $sContainer = '
'; $sContainer .= ''; if ($perm->have_perm_area_action("recipientgroups", "recipientgroup_create")) { $sContainer .= $oListActionsRow->render(); } $sContainer .= $oListOptionsRow->render(); $sContainer .= $oPagerRow->render(); $sContainer .= '
'; $sContainer .= '
'; $oTpl->set('s', 'CRECIPIENTGROUP', $sContainer); $oTpl->set('s', 'ID_CRECIPIENTGROUP', $sContainerId); $oTpl->set('s', 'SESSID', $sess->id); $oTpl->generate($cfg['path']['templates'] . $cfg['templates']['newsletter_left_top']); ?>