Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/newsletter2/categoryOverview.inc.php
<?php
/*
* Newsletter löschen
*/
if($nlAction == "deleteCategory" && isset($categoryID)) {
	$nlCategoryPreDeleteQuery = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TABLE."_nl_category WHERE categoryID = '$categoryID'"));
	/*
	* Nur Admins oder die Ersteller der Kategorie dürfen diese löschen
	*/
	if((ADMIN & $cbPerms) || ($cbUserID == $nlCategoryPreDeleteQuery[userID])) {
		$nlPreDeleteIDArr = array();
		$nlPreDeleteQuery = mysql_query("SELECT * FROM ".TABLE."_nl_general WHERE categoryID = '$categoryID'");
		while($nlPreDeleteRow = mysql_fetch_assoc($nlPreDeleteQuery)) {
			$result = mysql_query("DELETE FROM ".TABLE."_nl_content WHERE newsletterID = '".$nlPreDeleteRow[newsletterID]."'");
		}
		
		$result = mysql_query("DELETE FROM ".TABLE."_nl_general WHERE categoryID = '$categoryID'");
		$result = mysql_query("DELETE FROM ".TABLE."_nl_subscription WHERE categoryID = '$categoryID'");
		$result = mysql_query("DELETE FROM ".TABLE."_nl_category WHERE categoryID = '$categoryID'");
	} else {
		$nlMessage[] = $newsletterText["infoNoPermissionToDelete"];
	}
}

/*
* Kategorien Übersicht erzeugen
*/
$nlCategorySet = 0;
$nlCategoryID          = array();
$nlCategoryName        = array();
$nlCategoryDescription = array();
$nlCategoryOptions     = array();
$nlCategoryDatetime    = array();
$nlCategoryUnsendNr    = array();
$nlCategorySendNr      = array();

$nlCategoryQuery = mysql_query("SELECT * FROM ".TABLE."_nl_category ORDER BY name ASC");
while( $nlCategoryRow = mysql_fetch_assoc($nlCategoryQuery) ) {
	/* 
	* Herausfinden, wie viele Newsletter schon versendet wurden oder 
	* wie viele ungesendete Newsletter vorhanden sind
	*/
	$_nlCategoryUnsendNr = 0;
	$_nlCategorySendNr   = 0;
	$_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];
		}
	}
	
	/* Kategorie online oder offline? */
	$_nlStatusText = "";
	$_nlStatus     = 1;
	if(!(1 & $nlCategoryRow[options])) {
		$_nlStatusText = $newsletterText["offline"];
		$_nlStatus     = 0;
	}
	
	$nlCategoryStatusText[]  = $_nlStatusText;
	$nlCategoryStatus[]      = $_nlStatus;
	$nlCategoryUnsendNr[]    = $_nlCategoryUnsendNr;
	$nlCategorySendNr[]      = $_nlCategorySendNr;
	$nlCategoryID[]          = $nlCategoryRow[categoryID];
	$nlCategoryName[]        = stripslashes($nlCategoryRow[name]);
	$nlCategoryDescription[] = stripslashes($nlCategoryRow[description]);
	$nlCategoryOptions[]     = $nlCategoryRow[options];
	$nlCategoryDatetime[]    = $nlCategoryRow[datetime];
	
	$nlCategorySet = 1;
}

$tpl->assign("nlCategoryOverviewRow",
	array ( "id"            => $nlCategoryID,
			"name"          => $nlCategoryName,
			"description"   => $nlCategoryDescription,
			"datetime"      => $nlCategoryDatetime,
			"number_send"   => $nlCategorySendNr,
			"number_unsend" => $nlCategoryUnsendNr,
			"status_text"   => $nlCategoryStatusText,
			"status"        => $nlCategoryStatus
	)
);

$tpl->assign("nlCategoryOverview", 
	array ( "category_set"     => $nlCategorySet )
);

$tpl->assign("nlCategoryOverview_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