function getRoles()
 {
     $roles = $this->db->getAll("SELECT id, contact_id, role_id FROM sotf_object_roles WHERE object_id='{$this->id}' ORDER BY role_id, contact_id");
     for ($i = 0; $i < count($roles); $i++) {
         $roles[$i]['role_name'] = $this->repository->getRoleName($roles[$i]['role_id']);
         $cobj = new sotf_Contact($roles[$i]['contact_id']);
         $roles[$i]['contact_data'] = $cobj->getAllWithIcon();
     }
     return $roles;
 }
    $contact->find();
    if ($contact->exists()) {
        $foundByEmail = 1;
        $contactId = $contact->id;
    }
}
if (!$foundByEmail) {
    $contact =& $repository->getObject($contactId);
}
if (!$contact) {
    raiseError("no_such_object", $contactId);
}
$smarty->assign('PAGETITLE', $contact->get('name'));
$smarty->assign('CONTACT_ID', $contactId);
$smarty->assign('CONTACT_NAME', $contact->get('name'));
$smarty->assign('CONTACT_DATA', $contact->getAllWithIcon());
$numProgs = $contact->countProgrammes();
$progs = $page->getlocalizedWithParams('has_programs', $numProgs);
$smarty->assign('PROGS', $progs);
$smarty->assign('NUMPROGS', $numProgs);
$refs = $contact->references();
while (list(, $row) = each($refs)) {
    $id = $row['object_id'];
    $role = $row['role_id'];
    if ($repository->getTable($id) != 'sotf_programmes') {
        $obj = $repository->getObject($id);
        if (!$obj) {
            logError("DB integrity error: role {$role} for {$id} which does not exist");
            continue;
        }
        $class = get_class($obj);