Code: Alles auswählen
cInclude("classes", "widgets/class.widgets.page.php");
cInclude("classes", "widgets/class.widgets.foldingrow.php");
cInclude("classes", "widgets/class.widgets.pager.php");
cInclude("classes", "class.ui.php");
cInclude("classes", "class.newsletter.recipients.php");
cInclude("classes", "class.properties.php");
$oPage = new cPage;
$oMenu = new UI_Menu;
$oRecipients = new RecipientCollection;
$sLocation = $sess->url("main.php?area=$area&frame=$frame");
/* Updating keys, if activated; all recipients */
if (getSystemProperty("newsletter","updatekeys")) {
$updatedrecipients = $recipients->updateKeys();
$notis = $notification->returnNotification("info", sprintf(i18n("%d recipients, with no or incompatible key has been updated. Deactivate update function."),$updatedrecipients));
}
/* Set default values */
if (!isset($_REQUEST["elemperpage"]) || !is_numeric($_REQUEST['elemperpage'])) {
$_REQUEST["elemperpage"] = 25;
}
if (!isset($_REQUEST['restrictgroup']) || !is_numeric($_REQUEST['restrictgroup'])) {
$_REQUEST['restrictgroup'] = "--all--";
}
/* Initialization */
$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");
$delTitle = i18n("Delete recipient");
$delDescr = i18n("Do you really want to delete the following recipient:<br>");
/* Actions folding row */
$oListActionRow = new cFoldingRow("f0d7bf80-e73e-11d9-8cd6-0800200c9a66",i18n("Actions"));
/* Create a link to add a recipient */
$oLink = new cHTMLLink;
$oLink->setMultiLink("recipients","","recipients","recipients_create");
$oLink->setContent('<img style="padding-right: 4px;" src="'.$cfg["path"]["images"] . 'users_add.gif" align="middle">'.i18n("Create recipient").'</a>');
$sContent = '<div style="padding: 4px; padding-left: 12px; border-bottom: 1px solid black; background: '.$cfg['color']['table_dark'].';">'.chr(10);
$sContent .= $oLink->render().'<br />'.chr(10);
/* Create a link to purge subscribed but not confirmed recipients */
$oLink = new cHTMLLink;
$oLink->setLink("javascript:showPurgeMsg();");
$oLink->setContent('<img style="padding-right: 4px;" src="'.$cfg["path"]["images"] . 'users_purge.gif" align="middle">'.i18n("Purge recipients").'</a>');
$sContent .= $oLink->render().'</div>'.chr(10);
$oListActionRow->setContentData($sContent);
$properties = new PropertyCollection;
$iTimeframe = $properties->getValue("clientsetting", $client, "newsletter", "purgetimeframe");
if (!$iTimeframe || !is_numeric($iTimeframe)) {
$iTimeframe = 30;
}
if (isset($_REQUEST["purgetimeframe"]) && is_numeric($_REQUEST["purgetimeframe"]) && $_REQUEST["purgetimeframe"] > 0 && $_REQUEST["purgetimeframe"] != $iTimeframe) {
$iTimeframe = $_REQUEST["purgetimeframe"];
$properties->setValue("clientsetting", $client, "newsletter", "purgetimeframe", $iTimeframe);
}
$purgeTitle = i18n("Purge recipients");
$purgeDescr = sprintf(i18n("Do you really want to remove recipients, which hasn't been confirmed since %d days and over?"), $iTimeframe);
/* Options folding row */
$oOptionRow = new cFoldingRow("5ddbe820-e6f1-11d9-8cd6-0800200c9a66",i18n("Options"));
$oTextboxTimeframe = new cHTMLTextbox("purgetimeframe", $iTimeframe, 5);
$oSubmitOptions = new cHTMLButton("submit", i18n("Save"));
$sContent = '<div style="border-bottom: 1px solid black; background: '.$cfg['color']['table_dark'].';">'.chr(10);
$sContent .= '<form onsubmit="append_registered_parameters(this);" id="options" name="options" method="get" action="main.php?1">'.chr(10);
$sContent .= ' <input type="hidden" name="area" value="'.$area.'">'.chr(10);
$sContent .= ' <input type="hidden" name="frame" value="'.$frame.'">'.chr(10);
$sContent .= ' <input type="hidden" name="contenido" value="'.$sess->id.'">'.chr(10);
$sContent .= ' <input type="hidden" name="elemperpage" value="'.$_REQUEST["elemperpage"].'">'.chr(10);
$sContent .= ' <input type="hidden" name="sortby" value="'.$_REQUEST["sortby"].'">'.chr(10);
$sContent .= ' <input type="hidden" name="sortorder" value="'.$_REQUEST["sortorder"].'">'.chr(10);
$sContent .= ' <input type="hidden" name="restrictgroup" value="'.$_REQUEST["restrictgroup"].'">'.chr(10);
$sContent .= ' <input type="hidden" name="filter" value="'.$_REQUEST["filter"].'">'.chr(10);
$sContent .= ' <input type="hidden" name="searchin" value="'.$_REQUEST["searchin"].'">'.chr(10);
$sContent .= ' <table>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td>'. i18n("Purge timeframe").':</td>'.chr(10);
$sContent .= ' <td>'.$oTextboxTimeframe->render().' '.i18n("days").'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td> </td>'.chr(10);
$sContent .= ' <td>'.$oSubmitOptions->render().'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' </table>'.chr(10);
$sContent .= '</form>'.chr(10);
$sContent .= '</div>'.chr(10);
$oOptionRow->setContentData($sContent);
/* List options folding row */
$oListOptionRow = new cFoldingRow("ddc36ef2-25ad-4f3c-ba8f-ee13afccbcc6",i18n("List options"));
$oSelectItemsPerPage = new cHTMLSelectElement("elemperpage");
$oSelectItemsPerPage->autoFill(array("--all--" => i18n("-- All --"), 25 => 25, 50 => 50, 75 => 75, 100 => 100));
$oSelectItemsPerPage->setDefault($_REQUEST["elemperpage"]);
$oSelectSortBy = new cHTMLSelectElement("sortby");
foreach ($aFields as $sKey => $aData) {
if (strpos($aData["type"], "sort") !== false) {
$oOption = new cHTMLOptionElement($aData["caption"], $sKey);
$oSelectSortBy->addOptionElement($sKey, $oOption);
}
}
$oSelectSortBy->setDefault($_REQUEST["sortby"]);
$oSelectSortOrder = new cHTMLSelectElement("sortorder");
$oSelectSortOrder->autoFill(array("asc" => i18n("Ascending"), "desc" => i18n("Descending")));
$oSelectSortOrder->setDefault($_REQUEST["sortorder"]);
$oSelectRestrictGroup = new cHTMLSelectElement("restrictgroup");
$oOption = new cHTMLOptionElement(i18n("-- All groups --"), "--all--");
$oSelectRestrictGroup->addOptionElement("all", $oOption);
// fetch recipient groups
$oRGroups = new RecipientGroupCollection;
$oRGroups->select("idclient = '$client' AND idlang = '$lang'","", "defaultgroup DESC, groupname ASC");
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"));
$oSelectRestrictGroup->addOptionElement($sGroupname, $oOption);
}
$oSelectRestrictGroup->setDefault($_REQUEST["restrictgroup"]);
$oTextboxFilter = new cHTMLTextbox("filter", $_REQUEST["filter"], 16);
$oSelectSearchIn = new cHTMLSelectElement("searchin");
$oOption = new cHTMLOptionElement(i18n("-- All fields --"), "--all--");
$oSelectSearchIn->addOptionElement("all", $oOption);
foreach ($aFields as $sKey => $aData) {
if (strpos($aData["type"], "search") !== false) {
$oOption = new cHTMLOptionElement($aData["caption"], $sKey);
$oSelectSearchIn->addOptionElement($sKey, $oOption);
}
}
$oSelectSearchIn->setDefault($_REQUEST["searchin"]);
$oSubmit = new cHTMLButton("submit", i18n("Apply"));
$sContent = '<div style="border-bottom: 1px solid black; background: '.$cfg['color']['table_dark'].';">'.chr(10);
$sContent .= '<form onsubmit="append_registered_parameters(this);" id="filterform" name="filterform" method="get" action="main.php?1">'.chr(10);
$sContent .= ' <input type="hidden" name="area" value="'.$area.'">'.chr(10);
$sContent .= ' <input type="hidden" name="frame" value="'.$frame.'">'.chr(10);
$sContent .= ' <input type="hidden" name="contenido" value="'.$sess->id.'">'.chr(10);
$sContent .= ' <table>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td>'. i18n("Items / page").'</td>'.chr(10);
$sContent .= ' <td>'.$oSelectItemsPerPage->render().'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td>'. i18n("Sort by").'</td>'.chr(10);
$sContent .= ' <td>'.$oSelectSortBy->render().'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td>'. i18n("Sort order").'</td>'.chr(10);
$sContent .= ' <td>'.$oSelectSortOrder->render().'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td>'. i18n("Show group").'</td>'.chr(10);
$sContent .= ' <td>'.$oSelectRestrictGroup->render().'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td>'. i18n("Search for").'</td>'.chr(10);
$sContent .= ' <td>'.$oTextboxFilter->render().'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td>'. i18n("Search in").'</td>'.chr(10);
$sContent .= ' <td>'.$oSelectSearchIn->render().'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' <tr>'.chr(10);
$sContent .= ' <td> </td>'.chr(10);
$sContent .= ' <td>'.$oSubmit->render().'</td>'.chr(10);
$sContent .= ' </tr>'.chr(10);
$sContent .= ' </table>'.chr(10);
$sContent .= '</form>'.chr(10);
$sContent .= '</div>'.chr(10);
$oListOptionRow->setContentData($sContent);
/* Request data */
$oRecipients->setWhere("recipientcollection.idclient", $client);
$oRecipients->setWhere("recipientcollection.idlang", $lang);
if ($_REQUEST["restrictgroup"] != "--all--") {
$oRecipients->link("RecipientGroupMemberCollection");
$oRecipients->setWhere("RecipientGroupMemberCollection.idnewsgroup", $_REQUEST["restrictgroup"]);
}
$oRecipients->query();
$aDataTable = array();
while ($oRecipient = $oRecipients->next()) {
$aDataTable[$oRecipient->get("idnewsrcp")]["id"] = $oRecipient->get("idnewsrcp");
foreach ($aFields as $sKey => $aData) {
if (strpos($aData["type"], "base") !== false) {
if ($sKey == "name") {
$name = $oRecipient->get("name");
if (empty($name)) {
$aDataTable[$oRecipient->get("idnewsrcp")][$sKey] = $oRecipient->get("email");
} else {
$aDataTable[$oRecipient->get("idnewsrcp")][$sKey] = $name;
}
} else {
$aDataTable[$oRecipient->get("idnewsrcp")][$sKey] = $oRecipient->get($aData["field"]);
}
} else {
$aDataTable[$oRecipient->get("idnewsrcp")][$sKey] = call_user_func("recipients_".$aData["field"]."_getvalue", $sKey);
}
}
if ($_REQUEST["filter"] != "") {
if ($_REQUEST["searchin"] == "--all--" || $_REQUEST["searchin"] == "") {
$found = false;
foreach ($aDataTable[$oRecipient->get("idnewsrcp")] as $key => $value) {
if (strpos($value, htmlentities($_REQUEST["filter"])) !== false) {
$found = true;
}
}
if ($found == false) {
unset($aDataTable[$oRecipient->get("idnewsrcp")]);
}
} else {
if (strpos($aDataTable[$oRecipient->get("idnewsrcp")][$_REQUEST["searchin"]], htmlentities($_REQUEST["filter"])) === false) {
unset($aDataTable[$oRecipient->get("idnewsrcp")]);
}
}
}
}
if ($_REQUEST["sortorder"] == "asc") {
$sortorder = SORT_ASC;
} else {
$sortorder = SORT_DESC;
}
$aDataTable = array_csort($aDataTable, $_REQUEST["sortby"], $sortorder);
/* Content */
$mPage = $_REQUEST["page"];
$mList = new UI_Menu;
$iMenu = 0;
$iItemCount = 0;
if ($mPage == 0) {
$mPage = 1;
}
$elemperpage = $_REQUEST["elemperpage"];
if ($elemperpage == 0) {
$elemperpage = 25;
}
foreach ($aDataTable as $mkey => $params) {
$idnewsrcp = $params["id"];
$oLink = new cHTMLLink;
$oLink->setMultiLink($area, "", $area, "");
$oLink->setCustom("idrecipient", $idnewsrcp);
if ($params["deactivated"] || !$params["confirmed"]) {
$oLink->updateAttributes(array("style" => "color:#A20000"));
}
$iItemCount++;
if ($iItemCount > ($elemperpage * ($mPage - 1)) && $iItemCount < (($elemperpage * $mPage) + 1)) {
$iMenu++;
$delete = '<a title="'.$delTitle.'" href="javascript://" onclick="showDelMsg('.$idnewsrcp.',\''.addslashes($params["name"]).'\')"><img src="'.$cfg['path']['images'].'delete.gif" border="0" title="'.$delTitle.'" alt="'.$delTitle.'"></a>';
$mList->setTitle($iMenu, $params["name"]);
$mList->setLink($iMenu, $oLink);
$mList->setActions($iMenu, "delete", $delete);
$mList->setImage($iMenu, "images/users.gif");
}
}
$oPagerLink = new cHTMLLink;
$oPagerLink->setLink("main.php");
$oPagerLink->setCustom("elemperpage", $elemperpage);
$oPagerLink->setCustom("filter", $_REQUEST["filter"]);
$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
$oPagerLink->setCustom("sortby", $_REQUEST["sortby"]);
$oPagerLink->setCustom("sortorder", $_REQUEST["sortorder"]);
$oPagerLink->setCustom("searchin", $_REQUEST["searchin"]);
$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
$oPagerLink->setCustom("frame", $frame);
$oPagerLink->setCustom("area", $area);
$oPagerLink->enableAutomaticParameterAppend();
$oPagerLink->setCustom("contenido", $sess->id);
$oPager = new cObjectPager("0ed6d632-6adf-4f09-a0c6-1e38ab60e301", $iItemCount, $elemperpage, $mPage, $oPagerLink, "page");
$execScript = '
<script type="text/javascript">
/* Session-ID */
var sid = "'.$sess->id.'";
/* Create messageBox instance */
box = new messageBox("", "", "", 0, 0);
function showDelMsg(lngId, strElement) {
box.confirm("'.$delTitle.'", "'.$delDescr.'<b>" + strElement + "</b>", "deleteRecipient(\'" + lngId + "\')");
}
/* Function for deleting recipients */
function deleteRecipient(idrecipient) {
oForm = document.getElementById("filterform");
url = "main.php?area=recipients";
url += "&action=recipients_delete";
url += "&frame=4";
url += "&idrecipient=" + idrecipient;
url += "&contenido=" + sid;
url += get_registered_parameters();
url += "&restrictgroup=" + oForm.restrictgroup.value;
url += "&sortby=" + oForm.sortby.value;
url += "&sortorder=" + oForm.sortorder.value;
url += "&filter=" + oForm.filter.value;
url += "&elemperpage=" + oForm.elemperpage.value;
parent.parent.right.right_bottom.location.href = url;
}
function showPurgeMsg() {
box.confirm("'.$purgeTitle.'", "'.$purgeDescr.'", "purgeRecipients()");
}
/* Function for purging recipients */
function purgeRecipients() {
oForm = document.getElementById("filterform");
url = "main.php?area=recipients";
url += "&action=recipients_purge";
url += "&frame=4";
url += "&contenido=" + sid;
url += get_registered_parameters();
url += "&restrictgroup=" + oForm.restrictgroup.value;
url += "&sortby=" + oForm.sortby.value;
url += "&sortorder=" + oForm.sortorder.value;
url += "&filter=" + oForm.filter.value;
url += "&elemperpage=" + oForm.elemperpage.value;
parent.parent.right.right_bottom.location.href = url;
}
</script>';
$oPage->setMargin(0);
$oPage->addScript('messagebox', '<script type="text/javascript" src="scripts/messageBox.js.php?contenido='.$sess->id.'"></script>');
$oPage->addScript('delete', $execScript);
$oPage->addScript('cfoldingrow.js', '<script language="JavaScript" src="scripts/cfoldingrow.js"></script>');
$oPage->addScript('parameterCollector.js', '<script language="JavaScript" src="scripts/parameterCollector.js"></script>');
$oPage->setContent(array('<table border="0" cellspacing="0" cellpadding="0" width="100%">', $oListActionRow, $oOptionRow, $oListOptionRow, $oPager, '</table>', $mList->render(false)));
$oPage->render();
?>