Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/col_man/column.inc.php
<?php
	// +----------------------------------------------------------------------+
	// | column.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: column.inc.php,v 1.4 2004/10/01 09:15:06 jstoeber Exp $                                                                |
	// +----------------------------------------------------------------------+
	
	/*
	* Sprachdatei für die eingestellte Sprache einbinden
	*/
	if(file_exists($lang_path.$lang_pf."/plugin/column.lang.php")) {
		include($lang_path.$lang_pf."/plugin/column.lang.php");
	} else {
		include($lang_path."en/plugin/column.lang.php");
	}
	
	/*
	* Senden der Texte ans Smarty Template. Mit {$columnMessages.index} kann man auf jeden 
	* Text zugreifen
	*/
	$tpl->assign("columnMessages", $rmText);
	$tpl->assign("columnLinks", $rmLink);
		
	include($pluginLocation.'/plugin.config');
	
	include_once($cbDirLib."CB_column.class.php");
	
	/*
	* NestedSet Klasse zum Bearbeiten des Rubriken Baumes inkludieren
	*/
	require_once($cbDirLib."CB_NestedSet.class.php");
	
	/* 
	* Rechte Klasse inkludieren 
	*/
	require_once($cbDirLib."CB_permission2.class.php");
	
	/*
	* Rechte Objekt initialisieren. Es wird die User ID übergeben und die System Rechte
	* Palette. Das Objekt fragt anhand der User ID alle User Gruppen ab und speichert 
	* alle Rubriken, in die der User schreiben darf
	*/
	$restrictArr = array (
		'userID'  => $cbUserID,
		'cbPerms' => $cbPerms
	);
	
	$columnPerms = CB_permission::factory("column", $restrictArr);
	
	/*
	* Berechtigung im Column Manager zu arbeiten? Das geht nur, wenn in irgendeiner Rechte 
	* Palette das Recht COLUMN_PERM_EDIT_COLUMN steht.
	*/
	if($columnPerms->hasAccess()) {
		$columnGeneralUserPerms = $columnPerms->getSpecificPermissionSet("general");
		
		/*
		* wenn eine spezielle Rubrik gewählt wurde, dann werden gleich die spezifischen 
		* Rechte für diese Rubrik abgefragt
		*/
		if($fid) {
			$columnSpecificUserPerms = $columnPerms->getSpecificPermissionSet($fid);
		}
		
		//Ableitung des Column Option Objektes
		$columnOption = new CBOption();
		$columnOption->setModule("column");
		$columnOption->getOptionList();
		
		/* 
		* 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',
			'options'       => 'options',
			'writestatus'   => 'writestatus',
			'description'   => 'describt',
			'loadurl'       => 'loadurl',
			'skin'          => 'skin'
		);
		
		$nestedSet = CB_NestedSet::factory($folderParams, $folderAdditional);
		
		/*
		* Column Perm Objekt kann das Nested Set auch gut gebrauchen
		*/
		$columnPerms->setNestedSetObject($nestedSet);
	
		$cbColumn = new CB_Column();
		$userid = $cbUserID;
			
		$tpl->assign("FID",          $fid);
		$tpl->assign("TYPE",         $type);
		$tpl->assign("TXT_FOLDER",   $rmText['folder']);
		$tpl->assign("SUB_FOLDER",   $rmLink['subFolder']);
		$tpl->assign("STATUS_CLOSED",$rmText["statusClosed"]);
		$tpl->assign("STATUS_OPEN",  $rmText["statusOpen"]);
		$tpl->assign("USERACCESS",   $lg_text["restrict-folder-for-user"]);
		$tpl->assign("DESC",         $lg_text["description"]);
	
		/*
		* Anlegen einer Rubrik per NestedSet Objekt
		*/
		if(isset($create)) {
			if(empty($type)) { $type = "main"; }
			
			$options = 0;
			if($folderStatus == "o") {
				$options |= COLUMN_OPTION_ONLINE;
			}
			if(((ADMIN & $cbPerms) || (COL_MNG & $cbPerms)) && $columnOptionLocalPermsOnly == 1) {
				$options |= COLUMN_OPTION_LOCAL_PERMS;
			}
			
			$ns_values = array (
				"name"          => mysql_escape_string($nfname),
				"writestatus"   => mysql_escape_string($folderStatus),
				"description"   => mysql_escape_string($nfdesc),
				"options"       => $options,
				"loadurl"       => mysql_escape_string($loadurl),
				"skin"          => mysql_escape_string($skinTemplate)
			);
			
			if($type == "main") {
				if($columnPerms->hasEditPermission()) {
					$result = $nestedSet->createRootNode($ns_values);
				}
			}
			
			if($type == "sub") {
				if($columnPerms->hasEditPermission($sfofv)) {
					$result = $nestedSet->createSubNode($sfofv, $ns_values);
					
					/* 
					* Vererbung der Rechte der übergeordneten Rubrik an die neue Rubrik
					*/
					$parentRightSetQuery = mysql_query("SELECT * FROM ".TABLE."_permission WHERE name = '$sfofv' AND type = 'columnPerms'");
					while($parentRightSetRow = mysql_fetch_assoc($parentRightSetQuery)) {
						$columnPerms->insertPermission($result, $parentRightSetRow[value], $parentRightSetRow[parameter]);
					}
				}
			}
			
			if($result == false) {
				$error[] = $rmText["not_all_set"];
			} else {
				$nfq = 1;
			}
		}
		
		/*
		* Modifizieren einer Rubrik per NestedSet
		*/
		if(isset($gdmodify)) {
			if($columnPerms->hasEditPermission($fid)) {
				$preModify = $nestedSet->getNode($fid, true);
				
				$options = 0;
				if($folderStatus == "o") {
					$options |= COLUMN_OPTION_ONLINE;
				}
				if((ADMIN & $cbPerms) || (COL_MNG & $cbPerms)) {
					if($columnOptionLocalPermsOnly == 1) {
						$options |= COLUMN_OPTION_LOCAL_PERMS;
					}
				} else {
					/*
					* Option muss gesetzt werden, wenn der User kein Admin ist und die 
					* Option schon gesetzt war. Sonst würde der gesetzte Flag entfallen
					*/
					if(COLUMN_OPTION_LOCAL_PERMS & $preModify['options']) {
						$options |= COLUMN_OPTION_LOCAL_PERMS;
					}
				}
				
				$ns_values = array (
					"name"          => mysql_escape_string($nfname),
					"writestatus"   => mysql_escape_string($folderStatus),
					"description"   => mysql_escape_string($nfdesc),
					"options"       => $options,
					"loadurl"       => mysql_escape_string($loadurl),
					"skin"          => mysql_escape_string($skinTemplate)
				);
				
				$result = $nestedSet->updateNode($fid, $ns_values);
								
				if($result == "1") {
					$error[] = $rmText["not_all_set"];
				} else {
					$nfqq = 1;
				}
			}
		}
		
	
		if(isset($nfq)) {
			// Log Vorgang: Rubrik erzeugt
			cb_log(12);
			$message[] = $rmText["folder_create"];
		} elseif(isset($nfqq) AND empty($mfq)) {
			// Log Vorgang: Rubrik modifiziert
			cb_log(11);
			$message[] = $rmText["folder_modify"];
		}
		
		switch($sub) {
			case "colModify":
				include($pluginLocation."/colModify.inc.php");
				break;
			case "rightAdmin":
				if((ADMIN & $cbPerms) || (COL_MNG & $cbPerms)) {
					$editColRightSet = "general";
					include($pluginLocation."/colRightAdmin.inc.php");
					$mainPluginContent[] = $rightAdminTPLOutput;
				} else {
					$error[] = $rmError['noPermEditAccess'];
				}
				break;
			default:
				include($pluginLocation."/colManagement.inc.php");
				break;
		}
		
		$menuSubNav[] = "";
		$menuEntry[]  = $rmText["columnManagement"];
		$menuPrefix[] = '<img src="'.$cbDirGfx.'moarrow.gif" width="8" align="middle" height="11" border="0" alt="arrow">&nbsp;';
		
		if((ADMIN & $cbPerms) || (COL_MNG & $cbPerms)) {
			$menuSubNav[] = "&sub=rightAdmin";
			$menuEntry[]  = $rmText["columnRights"];
			$menuPrefix[] = '&nbsp;|&nbsp;';
		}
		
		$tpl->assign("plugin_menu_data",
			array ( "PRE"       => $menuPrefix,
					"SUBNAV"    => $menuSubNav,
					"MENUENTRY" => $menuEntry
			)
		);
	} else {
		/*
		* Wann kann jemand ins CM rein?
		* a) derjenige ist Admin
		* b) eine der Gruppen des User hat das Recht COLUMN_PERM_EDIT_COLUMN in 
		*    irgendeiner Rubrik gesetzt bekommen, einschließlich der allgemeinen Rechte
		*/
		$error[] = $rmError['noAccess'];
	}
	
	
	/* Fehler zuweisen */
	if(count($error) > 0) {
		$tpl->assign("errorSet", "1");
		$tpl->assign("errorList", $error);
	}
	
	/* Nachrichten zuweisen */
	if(count($message) > 0) {
		$tpl->assign("messageSet", "1");
		$tpl->assign("messageList", $message);
	}
	
	/* Message Content abrufen */
	$mainMessageContent = $tpl->fetch($config['templates']."messages.template", null, "pluginColumn".$cbUserID);
	
	/* Content zuweisen */
	$tpl->assign("messageContent", $mainMessageContent);
	$tpl->assign("pluginContent", $mainPluginContent);
	$tpl->display($config['templates']."plugin.template");
?>
Return current item: Content*Builder