Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/col_man/colManagement.inc.php
<?php
// +----------------------------------------------------------------------+
// | colManagment.inc.php                                                 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The C*B Development Group                    |
// +----------------------------------------------------------------------+
// | This source file is subject to version 1.0 of the CB license,        |
// | that is bundled with this package in the file license.txt            |
// | If you did not receive a copy of the PHP license please send a       |
// | note to hide@address.com so we can mail you            |
// | a copy immediately.                                                  |
// +----------------------------------------------------------------------+
// | Authors: Jörg Stöber <hide@address.com>                |
// |          Michael Pfannkuchen <hide@address.com>                |
// | $Id: colManagement.inc.php,v 1.3 2004/09/29 00:35:55 cb_fog Exp $                                                                |
// +----------------------------------------------------------------------+
	
if($columnPerms->hasAccess()) {
	/*
	* Rubriken löschen
	*/
	if(isset($_POST[delbox])) {
		$delbox2 = $_POST[delbox];
		unset($delbox);
		
		foreach($delbox2 as $k => $v) {
			if(($v != "") && ($v != null) && $columnPerms->hasEditPermission($v)) {
				$delbox[$k] = $v;
			}
		}
		
		if(count($delbox) > 0) {	
			foreach($delbox as $k => $v) {
				$nestedSet->deleteNode($v);
				$query = mysql_query("DELETE FROM ".TABLE."_permission WHERE name = '$v' AND type = 'columnPerms'");
				$query = mysql_query("DELETE FROM ".TABLE."_language WHERE type = 'column' AND typeID = '$v'");
			}
			cb_log(10);
			// DISPLAY TEMPLATE
			$message[] = $rmText["folder_delete"];
		}
	}
	
	/*
	* Rubriken verschieben
	*/
	if(isset($_POST[moveBranchDest]) && ($_POST[moveBranchDest] != "noValue") && !empty($_POST[fid])) {
		if($columnPerms->hasEditPermission($_POST[fid])) {
			if($_POST[moveBranchDest] == "toplevel") {
				$result = $nestedSet->_moveToRoot($_POST[fid]);
			} else {
				$result = $nestedSet->moveBranch($_POST[fid], $_POST[moveBranchDest], CB_NESE_MOVEBELOW);
			}
			
			if($result != 0) {
				// DISPLAY TEMPLATE
				if($result == 2) {
					$error[] = $rmText["branchIsChild"];
				}
				if($result == 1) {
					$error[] = $rmText["fNotExists"];
				}
			}
		}
	}
	
	/*
	* zu öffnende Rubrik setzen
	*/
	if(isset($newOpenfolder) && preg_match("/^([0-9]*)$/i", $newOpenfolder)) {
		$_SESSION[openfolder] = $newOpenfolder;
	}
	
	/*
	* zu schließende Rubrik setzen
	*/
	if($closeOpenfolder == $_SESSION[openfolder]) {
		$_SESSION[openfolder] = "";
	}
	
	// Startrubrik setzen (welche im BTPL als default genommen wird
	if($columnPerms->hasEditPermission()) {
		if(isset($newMainFolder)) {
			if(!$cbOption->getSingleOption("COLUMN_mainFolder")) {
				$cbOption->insertOption("COLUMN_mainFolder", $newMainFolder);
			} else {
				$cbOption->updateOption("COLUMN_mainFolder", $newMainFolder);
			}
			$cbOption->getOptionList();
		}
		$COLUMN_mainFolder = $cbOption->getSingleOption("COLUMN_mainFolder");
	}

	if(isset($action)) {
		if($columnPerms->hasEditPermission($fid)) {
			/* Sortierreihenfolge ändern */
			if($action == "sortup") {
				$nestedSet->sortNodeUp($fid);
			}
			if($action == "sortdown") {
				$nestedSet->sortNodeDown($fid);
			}
			cb_log(18);
		}
	}

	$tpl->assign("MAIN_FOLDER", $rmLink['mainFolder']);
	$tpl->assign("SUB_FOLDER",  $rmLink['subFolder']);
	$tpl->assign("TXT_NAME",    $rmText['name']); 
	
	$tpl->assign("folder_tree",
		array ( "F_NEW"	 	=> $rmText['new'],
			 	"F_EDIT"	=> $rmText['modify'],
			 	"F_DEL"	 	=> $rmText['del'],
				"F_SORT"	=> $rmText['txt_sort'],
			 	"F_SORT_U"  => $rmText['sort_u'],
			 	"F_SORT_d"  => $rmText['sort_d']
		)
	);

	$cTreeData = $nestedSet->getRootNodes();
	if($cTreeData != false) {
		if($_SESSION[openfolder] != "") {
			$openBranch = $nestedSet->getDescendants($_SESSION[openfolder]);
		}
		foreach($cTreeData as $key => $val) {
			$columnTreeData[] = $val;
			if($key == $_SESSION[openfolder] && $openBranch != false) {
				foreach($openBranch as $k => $v) {
					$columnTreeData[] = $v;
				}
			}
		}
	}
	
	if(is_array($columnTreeData)) {
		foreach($columnTreeData as $v) {
			if($v[fid] == $COLUMN_mainFolder) {
				$folderMainChk[] = "checked";
			} else {
				$folderMainChk[] = "";
			}
			
			if($v[loadurl] == "") {
				$thisLoadField = "";
			} else {
				if(preg_match("/^(http|ftp|https)/i", $v[loadurl])) {
					$thisLoadField = $rmText['load_page'];
				} else {
					$thisLoadField = $rmText['load_moduleCall'];
				}
			}
			
			if($v[fid] == $v[rootID]) {
				if($v[fid] == $_SESSION[openfolder]) {
					$openstate = 1;
				} else {
					$openstate = 0;
				}
			} else {
				$openstate = 2;
			}
			
			$fLeft[]           = $v[leftID];
			$fRight[]           = $v[rightID];
			$folderOpen[]      = $openstate;
			$folderName[]      = $v[fname];
			$folderID[]        = $v[fid];
			$folderSpace[]     = ($v[level] - 1) * 20 ;
			$folderLevel[]     = $v[level];
			$folderLoadField[] = $thisLoadField;
			$folderEditPerm[]  = $columnPerms->hasEditPermission($v[fid]);
		}
	}
	$tpl->assign("folder_tree",
		array ( "FNAME"          => $folderName,
			 	"LEFT"           => $fLeft,
				"RIGHT"          => $fRight,
				"OPENSTATE"      => $folderOpen,
				"ID"             => $folderID,
			 	"SPACE"          => $folderSpace,
			 	"LEVEL"          => $folderLevel,
			 	"LOADFIELD"      => $folderLoadField,
				"MAIN_CHECKED"   => $folderMainChk,
				"EDITPERMISSION" => $folderEditPerm
		)
	);

	$tpl->assign("overview_set", "1");
	$tpl->assign("column_set", "1");
	
	$mainPluginContent[]  = $tpl->fetch($config['templates']."colManagement.template", null, "pluginColumn".$cbUserID);
}
?>
Return current item: Content*Builder