mgd_is_group_in_group_tree()

This function checks wheter a certain group is in the tree below another one. It does this by traversing the group tree upwards until it either hits the group in question or fails.

Parameter Syntax

Searches wheter the Group $id is somewhere in the tree below $rootid. Returns true if this is true (whooo!), false on failure.

Code

<?php

function mgd_is_group_in_group_tree ($id, $rootid) {
  if (
$id == $rootid) return true;
  
$grp = mgd_get_group($id);

  do {
    if (
$grp->id == $rootid) return true;
    if (
$grp->owner == 0) return false;
    
$grp = mgd_get_group($grp->owner);
  } while (
$id != $grp->id);
  
  die (
"mgd_is_group_in_group_tree: "
       
. "We should not get to this line...");
}

?>