Get record ID in drop-down list's function

Hello. I have some legacy code from SugarCRM 7 that is not working with our upgraded SugarCRM 11. The end result is to populate a drop-down field based on the Opportunity record being viewed. I am having difficulty figuring out how to get the ID for the record currently being viewed.

custom/Extension/modules/Opportunities/Ext/Vardefs/my_custom_vars.php:
$dictionary['Opportunity']['fields']['referral_c']['function'] = 'get_opportunities_contacts_dropdown' ;

custom/include/custom_utils.php:

function get_opportunities_contacts_dropdown() {
        $list = array();

        if( isset($_GET['bean_id']) ){

                $bean_id = $_GET['bean_id'];

                $dropdown_query = "select contacts.id, contacts.first_name, contacts.last_name from contacts inner join opportunities_contacts on contacts.id = opportunities_contacts.contact_id inner join opportunities on opportunities.id = opportunities_contacts.opportunity_id where contacts.deleted = 0 and opportunities.deleted = 0 and opportunities_contacts.deleted = 0 and opportunities.id ='".$bean_id."';";

                $result = $GLOBALS['db']->query($dropdown_query,true," Error getting contact data fields: ");

                if (!$result) {
                        $message  = 'Invalid query or could not connect: ' . mysql_error() . "\n";
                        $message .= 'Whole query: ' . $query;
                        sugar_upgrade_die($message);
                }
				
                while ($temp_row = $GLOBALS['db']->fetchByAssoc($result)) {
				    $list[$temp_row['id']] = $temp_row['first_name'] . " " . $temp_row['last_name'];
                }
        }
        return $list;
}

The $_GET['bean_id'] is no longer set in SugarCRM 11. How can I get the ID for the currently viewed record? Thanks.