Location: PHPKode > projects > Epiware Document Management > Epiware_4.8.6/epi/epi_lib_new_wiki_path.php
<?php
	require("./module_prepend.php");

	$id_x = $_POST['id'];

	function get_path($id, &$db){
		$finished = false;
		$returnMe = '';

		$sql = "SELECT name FROM user_docs WHERE doc_id = '$id' AND folder = '1'";
		$result = $db->perform_looping_query($sql);
		if(is_resource($result) && $db->row_count($result) > 0){
			$row = $db->get_next_row($result);
			$name = $row['name'];
		} else { //should return something...  *shrug*
			return "/";
		}//if(is_resource($result) && $db->row_count($result) > 0) 

		while(!$finished){
			$returnMe = '/' . $name . $returnMe;
			
			$sql = "SELECT r.parent_id, u.name FROM relation as r, user_docs as u WHERE r.child_id = '$id' AND r.parent_id = u.doc_id";
			$result = $db->perform_looping_query($sql);
			if(is_resource($result) && $db->row_count($result) > 0){
				$row = $db->get_next_row($result);
				$name = $row['name'];
				$id = $row['parent_id'];
			} else {
				$finished = true;
			}//if(is_resource($result) && $db->row_count($result) > 0)
		}//while(!$finished)

		return $returnMe;
	}//function get_path($id, &$db)

	if(!defined("WIKI_ROOT")){
		$sql = "SELECT doc_id FROM user_docs WHERE group_id = '$group_id' AND doc_type = 'Wiki Folder'";
		$result = $db->perform_looping_query($sql);
		if(is_resource($result) && $db->row_count($result) > 0){
			$row = $db->get_next_row($result);
			define("WIKI_ROOT",get_path($row['doc_id'], $db) . '/');
		} else {
			define("WIKI_ROOT","/");
		}
	} 

	$wholePath = '';
	
	$wholePath = get_path($id_x,$db);

	if(WIKI_ROOT != '/'){
		$wholePath = '/' . str_replace(WIKI_ROOT, "", $wholePath);
	}
	$wholePath = substr($wholePath,1); //gotta knock off the leading slash

	echo $wholePath;
?>
Return current item: Epiware Document Management