diff --git a/common.inc.php b/common.inc.php index 2a3d643..67b9102 100644 --- a/common.inc.php +++ b/common.inc.php @@ -1286,5 +1286,20 @@ function getTextFromHtml($html) { return $text; } +function getUserForSponsor($sponsor_id) { + // loop through each contact and draw a form with their data in it. + $q = mysql_query("SELECT *,MAX(year) FROM users LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id + WHERE + sponsors_id='" . $sponsor_id . "' + AND types LIKE '%sponsor%' + GROUP BY uid + HAVING deleted='no' + ORDER BY users_sponsor.primary DESC,lastname,firstname + LIMIT 1 + "); + $r=mysql_fetch_object($q); + return user_load_by_uid($r->uid); +} + ?>