Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/forum/categoryOverview.inc.php
<?php

if(ADMIN & $cbPerms) {
	$show = "overview";
	
	if(preg_match("/^([1-9]+[0-9]*)$/", $categoryDeleteID)) {
		$delNodeArray = $nestedSet_category->deleteNode($categoryDeleteID);
		if(is_array($delNodeArray)) {
			foreach($delNodeArray as $v) {
				$threadQuery = mysql_query("SELECT * FROM ".TABLE."_forum_thread WHERE categoryID = '$v'");
				while($threadRow = mysql_fetch_assoc($threadQuery)) {
					$nestedSet_message->deleteNode($threadRow[rootID]);
				}
				
				mysql_query("DELETE FROM ".TABLE."_forum_thread WHERE categoryID = '$v'");
			}
		}
	}
	
	if($categoryAction == "edit") {
		if(!$categoryFormSend) {
			$categoryData = $nestedSet_category->getNode($categoryID, true);
			if($categoryData != false) {
				$counter = 0;
				foreach($categoryData as $k => $v) {
					$categoryData[$key] = stripslashes($v);
				}
					
				if(FORUM_CATEGORY_WRITEABLE & $categoryData[options]) {
					$categoryData['writable'] = 1;
				}
				
				$tpl->assign("categoryDetail_set", 1);
				$tpl->assign("categoryAction", "edit");
				$tpl->assign("categoryData", $categoryData);
				
				$show = "modifyview";
			}
		} else {
			$options = 0;
			if($categoryWritable == 1) {
				$options |= FORUM_CATEGORY_WRITEABLE;
			}
		
			$ns_values = array (
				"name"        => mysql_escape_string($categoryTitle),
				"description" => mysql_escape_string($categoryDescription),
				"options"     => $options
			);
			$nestedSet_category->updateNode($categoryID, $ns_values);
		}
	} 
	
	if($categoryAction == "new") {
		if(!$categoryFormSend) {
			$tpl->assign("categoryDetail_set", 1);
			$tpl->assign("categoryAction", "new");
			$tpl->assign("categoryParentID", $parentID);
			
			$show = "newview";
		} else {
			$parentCheck = $nestedSet_category->getNode($parentID);
			$options = 0;
			if($categoryWritable == 1) {
				$options |= FORUM_CATEGORY_WRITEABLE;
			}
		
			$ns_values = array (
				"name"        => mysql_escape_string($categoryTitle),
				"description" => mysql_escape_string($categoryDescription),
				"options"     => $options
			);
			
			if(!$parentCheck) {
				$nestedSet_category->createRootNode($ns_values);
			} else {
				$nestedSet_category->createSubNode($parentID, $ns_values);
			}
		}
		
	}
	
	if($show == "overview") {
		$categories = $nestedSet_category->getAllNodes(true);
		if($categories != false) {
			$counter = 0;
			foreach($categories as $k => $v) {
				foreach($v as $key => $value) {
					$v[$key] = stripslashes($value);
				}
				
				if(FORUM_CATEGORY_WRITEABLE & $v[options]) {
					$v['writable'] = 1;
				}
				
				$v['space'] = ($v[level] - 1) * 10;
				
				$categoryData[$counter] = $v;
				++$counter;
			}
			$tpl->assign("categoryData", $categoryData);
		}
		
		$tpl->assign("categoryOverview_set", 1);
	}
	
	$mainPluginContent[]  = $tpl->fetch($config['templates']."categoryAdmin.template", null, "pluginForum".$cbUserID);
}

?>
Return current item: Content*Builder