<?php

	/*
	*	Gekko - Open Source Web Development Framework
	*	------------------------------------------------------------------------
	*	Copyright (C) 2004-2005, J. Carlos Nieto <xiam@users.sourceforge.net>
	*	This program is Free Software.
	*
	*	@package	Gekko
	*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
	*	@author		J. Carlos Nieto <xiam@users.sf.net>
	*	@version	CVS: $Id:$
	*	@link		http://gekkoware.sourceforge.net
	*/

	if (!defined("IN-GEKKO")) die("Get a life!");

	function menuAddLink($menu, $title, $link, $icon = "link.png", $auth_access = "*", $level = 0) {

		/* Appending to the bottom link */
		$q = $GLOBALS["db"]->query("SELECT OrderID FROM ".db_table("menu_link")." WHERE
		MenuLink = '{$menu}' ORDER BY OrderID DESC LIMIT 1", __FILE__, __LINE__, true);

		$orderid = 0;
		if ($GLOBALS["db"]->num_rows($q)) {
			$row = $GLOBALS["db"]->fetch_row($q);
			$orderid = $row["OrderID"];
		}
		$orderid++;

		/* inserting */
		$GLOBALS["db"]->query("
		INSERT INTO ".db_table("menu_link")." (
			ID,
			MenuLink,
			OrderID,
			Type,
			Level,
			Title,
			Link,
			Tooltip,
			Icon,
			auth_Access
		) VALUES (
			'".$GLOBALS["db"]->free_id("menu_link")."',
			'{$menu}',
			'{$orderid}',
			'0',
			'$level',
			'{$title}',
			'{$link}',
			'',
			'{$icon}',
			'{$auth_access}'
		)
		", __FILE__, __LINE__, true);
	}

	function menu_removeLink($link) {
		$GLOBALS["db"]->query("DELETE FROM ".db_table("menu_link")." WHERE MenuLink = '{$link}'", __FILE__, __LINE__, true);
	}
?>