diff --git a/register_participants.inc.php b/register_participants.inc.php index 0ae496d..2aaf1a4 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -655,6 +655,26 @@ function addRegistration($userId){ return $regnum; } +// get the registration id for a specific user. +//Accepts either the user object or the user id, and returns the registration id, or NULL if none is set, error message if something's borked +function getRegistrationsId($user){ + // get the user id + if(is_array($user)){ + if(!array_key_exists('id', $user)) return "register_participants.inc.php::getRegistrationsId -> Invalid user object"; + $uid = $user['id']; + }else{ + $uid = $user; + } + + // grab their registrations id + $result = mysql_fetch_assoc(mysql_query("SELECT registrations_id FROM users WHERE id = $uid")); + if(mysql_error()){ + return "register_participants.inc.php::getRegistrationsId -> " . $mysql_error(); + } + + return $result['registrations_id']; +} + function getProject($registrations_id){ global $conference; // FIXME - in the future, this should be able to handle a many-to-many