Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/artMultipleFolder.inc.php
<?php
	require_once($cbDirLib."CB_NestedSet.class.php");
	
	/* 
	* Initialisierung der NeSet Array's für das 
	* Folder Nested Set Objekt 
	*/
	$folderParams = array (
		'table'  => TABLE.'_columns',
		'id'     => 'fid',
		'parent' => 'mfolder',
		'root'   => 'rootID',
		'l'      => 'leftID',
		'r'      => 'rightID',
		'level'  => 'level',
		'norder' => 'order_num'
	);
	
	$folderAdditional = array (
		'name'          => 'fname',
		'status'        => 'status',
		'writestatus'   => 'writestatus',
		'description'   => 'describt',
		'loadurl'       => 'loadurl',
		'usersallowed'  => 'usersallowed',
		'groupsAllowed' => 'groupsAllowed',
		'skin'          => 'skin'
	);
	
	$nestedSet = CB_NestedSet::factory($folderParams, $folderAdditional);
		
	$errorList = array();
	
	/*
	* Allgemeinen Daten des Artikels auslesen (Hauptrubrik)
	*/
	$folderHitArr = array();
	$artGeneralQuery = mysql_query("SELECT * FROM ".TABLE."_art_general WHERE ide = '$id'");
	if(mysql_num_rows($artGeneralQuery) > 0) {
		$artGeneralRow = mysql_fetch_assoc($artGeneralQuery);
		$folderHitArr[$artGeneralRow[folderID]] = 1;
	} else {
		$errorList[] = $amText["wrongID"];
	}
	
	/*
	* Nur Admins, Besitzer und User mit Recht MOD_ALL dürfen das hier
	*/
	if(!$articlePerms->hasEditPermission($id)) {
		$errorList[] = $amText["wrongUser"];
	}
	
	/*
	* Aktualisierte Rubriken Zuordnung eintragen
	*/
	if($artMultipleSubmit == 1) {
		$delete = mysql_query("DELETE FROM ".TABLE."_art_folder WHERE articleID = '$id'");
		if(is_array($artMultipleFolderID)) {
			foreach($artMultipleFolderID as $v) {
				$_idCheck = false;
				if(preg_match("/^([0-9]*)$/", $v)) {
					$_idCheck = true;
				}
				
				if($v == $artGeneralRow[folderID]) {
					$_idCheck = false;
				}
				
				if($_idCheck) {
					$result = mysql_query("INSERT INTO ".TABLE."_art_folder (articleID, folderID) VALUES ('$id', '$v')");
				}
			}
		}
	}
	
	if(count($errorList) == 0) {
		
		/*
		* Alle Rubriken rausfinden, denen der Artikel zugeordnet ist.
		*/
		$folderArtIsInQuery = mysql_query("SELECT * FROM ".TABLE."_art_folder WHERE articleID = '$id'");
		while($folderArtIsInRow = mysql_fetch_assoc( $folderArtIsInQuery )) {
			$folderHitArr[$folderArtIsInRow[folderID]] = 1;
		}
		
		/*
		* Alle Rubriken auslesen
		*/
		$folderRow = $nestedSet->getAllNodes( true );
		if($folderRow != false) {
			foreach($folderRow as $v) {
				$_folderSpace = "";
				for($i = 1; $i <= $v[level] - 1; $i++) { 
					$_folderSpace .= "&nbsp;&nbsp;&nbsp;"; 
				}
				
				$_hit = "";
				if($folderHitArr[$v[id]] == 1) {
					$_hit = "selected";
				}
				
				$_main = "";
				if($v[id] == $artGeneralRow[folderID]) {
					$_main = $amText["mainFolderEmbraced"];
				}
				
				$folderSpace[] = $_folderSpace;
				$folderID[]    = $v[id];
				$folderName[]  = $v[name];
				$folderHit[]   = $_hit;
				$folderMain[]  = $_main;
			}
		}
		
		$tpl->assign("artMultipleFolder_general",
			array ( "TXT_ASSIGN"                 => $amText["assign"],
					"id"                         => $id
			)
		);
		
		$tpl->assign("artMultipleFolder_row",
			array ( "space" => $folderSpace,
					"id"    => $folderID,
					"name"  => $folderName,
					"hit"   => $folderHit,
					"main"  => $folderMain
			)
		);
		
		$tpl->assign("artMultipleFolder_set", "1");
	}
	
	if(count($errorList) > 0) {
		$tpl->assign("errorSet", "1");
		$tpl->assign("errorList", $errorList);
	}
	
	$mainPluginContent[]  = $tpl->fetch($config['templates']."artMultipleFolder.template", null, "pluginArt2".$cbUserID);
	$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginArt2".$cbUserID);
?>
Return current item: Content*Builder