Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/newsletter2/categoryDetail.inc.php
<?php
/*
* Page Split Klasse einbinden
*/
include($cbDirLib."CB_pageSplit.class.php");

/* Offsets setzen, wenn nicht vorhanden */
if (!$nlUnsendOffset) { $nlUnsendOffset = 0; }
if (!$nlSendOffset)   { $nlSendOffset = 0; }

/* Einstellungen für das Page Splitting setzen */
$nlLimit = 1;
if($nlOption->getSingleOption("nlResultsPerPage") > 1) {
	$nlLimit   = $nlOption->getSingleOption("nlResultsPerPage");
}

$nlUrlVars = $PHP_SELF."?load=".$load."&sub=2&categoryID=".$categoryID;

/*
* Newsletter löschen
*/
if($nlAction == "deleteNewsletter" && isset($newsletterID)) {
	$nlPreDeleteQuery = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TABLE."_nl_general WHERE newsletterID = '$newsletterID'"));
	$categoryID = $nlPreDeleteQuery[categoryID];
	
	if((ADMIN & $cbPerms) || ($cbUserID == $nlPreDeleteQuery[userID])) {
		$result = mysql_query("DELETE FROM ".TABLE."_nl_general WHERE newsletterID = '$newsletterID'");
		$result = mysql_query("DELETE FROM ".TABLE."_nl_content WHERE newsletterID = '$newsletterID'");
	} else {
		$nlMessage[] = $newsletterText["infoNoPermissionToDelete"];
	}
}

/*
* Kategorien Detail Übersicht erzeugen
*/
$nlError = false;
if(!preg_match("/^([0-9]*)$/", $categoryID)) {
	$nlError = true;
}

if(!$nlError) {
	$nlCategoryRow = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TABLE."_nl_category WHERE categoryID = '$categoryID'"));
	
	/*
	* Anzahl gesendeter / nicht gesendeter Newsletter
	*/
	$_nlInCategoryQuery = mysql_query("SELECT (1 & options) AS send, COUNT(*) AS sendCounter FROM ".TABLE."_nl_general WHERE categoryID = '".$nlCategoryRow[categoryID]."' GROUP BY send");
	while($_nlInCategoryRow = mysql_fetch_assoc($_nlInCategoryQuery)) {
		if( $_nlInCategoryRow[send] == 0) {
			$nlCategoryUnsendNr = $_nlInCategoryRow[sendCounter];
		} else {
			$nlCategorySendNr   = $_nlInCategoryRow[sendCounter];
		}
	}
	
	/* 
	* Anzahl Empfänger herausfinden
	*/
	$_nlReceiverCountQuery = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS receiverCounter FROM ".TABLE."_nl_subscription WHERE categoryID = '$categoryID'"));
	$nlCategoryRow['receiverAmount'] = $_nlReceiverCountQuery[receiverCounter];
	
	$nlCategoryRow[name]        = stripslashes($nlCategoryRow[name]);
	$nlCategoryRow[description] = stripslashes($nlCategoryRow[description]);

	/*
	* Liste der gesendeten Newsletter der aktuellen Seite abrufen
	*/
	$nlCategoryRow['send']['set'] = 0;
	$_nlSendQuery        = mysql_query("SELECT general.title, general.sendTime, general.newsletterID, COUNT(content.newsletterID) AS contentCounter FROM ".TABLE."_nl_general AS general LEFT JOIN ".TABLE."_nl_content AS content ON general.newsletterID = content.newsletterID WHERE general.categoryID = '".$categoryID."' AND (1 & general.options) != 0 GROUP BY general.newsletterID, content.newsletterID ORDER BY general.sendtime DESC LIMIT $nlSendOffset,$nlLimit");
	while($_nlSendRow    = mysql_fetch_assoc($_nlSendQuery)) {
		$nlCategoryRow['send']['row'][] = $_nlSendRow;
		$nlCategoryRow['send']['set']   = 1;
	}
	
	/*
	* Liste der letzten 5 noch nicht gesendeten Newsletter abrufen
	*/
	$nlCategoryRow['unsend']['set'] = 0;
	$_nlUnsendQuery = mysql_query("SELECT general.title, general.sendTime, general.newsletterID, COUNT(content.newsletterID) AS contentCounter FROM ".TABLE."_nl_general AS general LEFT JOIN ".TABLE."_nl_content AS content ON general.newsletterID = content.newsletterID WHERE general.categoryID = '".$categoryID."' AND (1 & general.options) = 0 GROUP BY general.newsletterID, content.newsletterID ORDER BY general.sendtime DESC LIMIT $nlUnsendOffset,$nlLimit");
	while($_nlUnsendRow = mysql_fetch_assoc($_nlUnsendQuery)) {
		$nlCategoryRow['unsend']['row'][] = $_nlUnsendRow;
		$nlCategoryRow['unsend']['set']   = 1;
	}
	
	/*
	* Anzahl an gesendeten Newlettern herausfinden, um Page Links 
	* basteln zu können
	*/
	$_nlSendCounterQuery = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) as sendCounter FROM ".TABLE."_nl_general WHERE categoryID = '".$categoryID."' AND (1 & options) != 0"));
	$nlSendCounter       = $_nlSendCounterQuery[sendCounter];
	$nlCategoryRow['send']['amount'] = $_nlSendCounterQuery[sendCounter];
	$nlSendPageLinkObject= new CB_pageSplit($nlLimit, $nlSendOffset, $nlSendCounter);
	
	/*
	* Anzahl an ungesendeten Newlettern herausfinden, um Page Links 
	* basteln zu können
	*/
	$_nlUnsendCounterQuery = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) as unsendCounter FROM ".TABLE."_nl_general WHERE categoryID = '".$categoryID."' AND (1 & options) = 0"));
	$nlUnsendCounter       = $_nlUnsendCounterQuery[unsendCounter];
	$nlCategoryRow['unsend']['amount'] = $_nlUnsendCounterQuery[unsendCounter];
	$nlUnsendPageLinkObject= new CB_pageSplit($nlLimit, $nlUnsendOffset, $nlUnsendCounter);
	
	$nlCategoryRow['unsend']['pageNav']['split_status'] = $nlUnsendPageLinkObject->isSplitInPages();
	$nlCategoryRow['unsend']['pageNav']['next_set']     = $nlUnsendPageLinkObject->nextPageExists();
	$nlCategoryRow['unsend']['pageNav']['last_set']     = $nlUnsendPageLinkObject->lastPageExists();
	$nlCategoryRow['unsend']['pageNav']['next_offset']  = $nlUnsendPageLinkObject->getNextOffset();
	$nlCategoryRow['unsend']['pageNav']['last_offset']  = $nlUnsendPageLinkObject->getLastOffset();
	$nlCategoryRow['unsend']['pageNav']['pages']        = $nlUnsendPageLinkObject->getPages();
	$nlCategoryRow['unsend']['pageNav']['actual_page']  = $nlUnsendPageLinkObject->getActualPage();
	
	$nlCategoryRow['send']['pageNav']['split_status'] = $nlSendPageLinkObject->isSplitInPages();
	$nlCategoryRow['send']['pageNav']['next_set']     = $nlSendPageLinkObject->nextPageExists();
	$nlCategoryRow['send']['pageNav']['last_set']     = $nlSendPageLinkObject->lastPageExists();
	$nlCategoryRow['send']['pageNav']['next_offset']  = $nlSendPageLinkObject->getNextOffset();
	$nlCategoryRow['send']['pageNav']['last_offset']  = $nlSendPageLinkObject->getLastOffset();
	$nlCategoryRow['send']['pageNav']['pages']        = $nlSendPageLinkObject->getPages();
	$nlCategoryRow['send']['pageNav']['actual_page']  = $nlSendPageLinkObject->getActualPage();
	
	$tpl->assign("nlCategoryDetail", $nlCategoryRow);
	
	/*
		"ID"                     => $categoryID,
				"NAME"                   => $nlCategoryName,
				"DESCRIPTION"            => $nlCategoryDescription,
				"DATETIME"               => $nlCategoryDatetime,
				"SENDNUMBER"             => $nlCategorySendNr,
				"UNSENDNUMBER"           => $nlCategoryUnsendNr,
				"RECEIVERNUMBER"         => $_nlReceiverCountQuery[receiverCounter],
				"SEND_SET"               => $nlSendSet,
				"UNSEND_SET"             => $nlUnsendSet,
				"SEND_LAST_PAGE_LINK"    => $nlSendPageLinkObject->getBackLink($nlUrlVars."&nlSendOffset=", $newsletterText["lastPage"]),
				"SEND_PAGES_LINKS"       => $nlSendPageLinkObject->getPageLinks($nlUrlVars."&nlSendOffset="),
				"SEND_NEXT_PAGE_LINK"    => $nlSendPageLinkObject->getNextLink($nlUrlVars."&nlSendOffset=", $newsletterText["nextPage"]),
				"UNSEND_LAST_PAGE_LINK"  => $nlUnsendPageLinkObject->getBackLink($nlUrlVars."&nlUnsendOffset=", $newsletterText["lastPage"]),
				"UNSEND_PAGES_LINKS"     => $nlUnsendPageLinkObject->getPageLinks($nlUrlVars."&nlUnsendOffset="),
				"UNSEND_NEXT_PAGE_LINK"  => $nlUnsendPageLinkObject->getNextLink($nlUrlVars."&nlUnsendOffset=", $newsletterText["nextPage"]),
				
				"TXT_POSSIBLE_ACTIONS"   => $newsletterText["possibleActions"],
				"TXT_NL_CREATE_NEW"      => $newsletterText["nlCreateNew"],
				"TXT_EDIT_CATEGORY"      => $newsletterText["editCategory"],
				"TXT_TITLE"              => $newsletterText["title"],
				"TXT_VERSIONS"           => $newsletterText["versions"],
				"TXT_NO_UNSEND_NL"       => $newsletterText["infoNoUnsendNL"],
				"TXT_NO_SEND_NL"         => $newsletterText["infoNoSendNL"],
				"TXT_SEND_AT"            => $newsletterText["sendAt"]
	*/
	
	$tpl->assign("nlCategoryDetail_set", "1");
	
	$mainPluginContent[]  = $tpl->fetch($config['templates']."newsletter.template", null, "pluginNL".$cbUserID);
	$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginNL".$cbUserID);
}
?>
Return current item: Content*Builder