<?php
function fn_root_r($aql)
{
	$list = $aql->Consume(1);
	
	$ids = $list[0]->value;	
	
	global $db;
	global $installfolder;
	$apool = array();
	
	require_once($installfolder.'/model/relationship.php');
	
	$rels = Relationships::GetAllRelationships();
	foreach($list[0]->value as $a)
	{
		foreach($rels as $r)
		{
			if ($r->id == $a)
			{
				$apool[] = $r->GetRootAsset();
			}
		}
	}	
	
	$a = new AQLStackElement();
	$a->typename = "assetlist";
	$a->islist = true;
	$a->value = $apool;
	array_push($aql->stack,$a);

}
?>