<?php 

	//let's get my rights :)
		//first let's find out all the groups I have
		$this->db->ChangeDatabase(DB_WARPIT_MAIN);
		$userId = $_SESSION['UserInfo']['id'];
		$groupId = $this->db->get( '_user',$userId,'permissionGroup' );
		$groups[] = $groupId;
		while ($groupId = $this->db->get( '_PermissionGroups',$groupId,'id_sup' ))
			$groups[] = $groupId;
			
		//find out if this user has auto enabled projects
		$sql = $this->db->SQLexecute( "SELECT allow FROM _PermissionLink WHERE id_permission = 8 AND p_type=0 AND (id_user=$userId OR id_permission_group IN (".implode(',',$groups).") )" );
		//this means that we show all projects that are not denied! otherwise we show only those that have allow
		$hasAutoEnabled = false;
		while($row = $this->db->fetchRow($sql))
		{
			if($row[0])
			{
				$hasAutoEnabled = true;
				break;
			}
		}
		
		$bla = array();
		if (is_array($nodes)) {
			if($hasAutoEnabled && $nodes) {
				foreach ($nodes as $id => &$menu) {
					//find out if I have the right
					$sql = $this->db->SQLexecute( "SELECT deny FROM _PermissionLink WHERE deny=1 AND id_permission = '{$menu['id']}' AND p_type=2 AND (id_user=$userId OR id_permission_group IN (".implode(',',$groups).") )" );
					$res = $this->db->fetchRow($sql);
					if($res[0] != 1)
						$bla[] = $menu;
					;
				}
			} else if($nodes) {
				foreach ($nodes as $id => &$menu) {
					//find out if I have the right
					$sql = $this->db->SQLexecute( "SELECT allow FROM _PermissionLink WHERE allow=1 AND id_permission = '{$menu['id']}' AND p_type=2 AND (id_user=$userId OR id_permission_group IN (".implode(',',$groups).") )" );
					$res = $this->db->fetchRow($sql);
					if($res[0] == 1)
						$bla[] = $menu;
					;
				}
			}
		}

?>