// Retrieves array of ids for records of $get_module linked to $from_module by $get_id // Example: to retrieve list of Contacts associated to Account X: $return = get_linked_records("Contacts", "Accounts", "X"); function get_linked_records($get_module, $from_module, $get_id) { global $beanList, $beanFiles; // instantiate and retrieve $from_module $from_class = $beanList[$from_module]; require_once($beanFiles[$from_class]); $from_mod = new $from_class(); $from_mod->retrieve($get_id); // loop through link fields of $module_1, checking for a link to $module_2 $link_found = FALSE; foreach ($from_mod->get_linked_fields() as $linked_field) { $field = $linked_field['name']; $from_mod->load_relationship($field); if (empty($obj_1->$field)) { continue; } elseif ($from_mod->$field->getRelatedModuleName() == $get_module) { $link_found = TRUE; break; } } if ($link_found === FALSE) { return FALSE; } $id_arr = $from_mod->$link_field->get(); return $id_arr; }