From b5d489b4ce30472f974fdb794cfea77a624c7bee Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 11 Mar 2008 12:53:04 +0000 Subject: user_info() ftw git-svn-id: https://code.elgg.org/elgg/trunk@162 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'engine') diff --git a/engine/lib/users.php b/engine/lib/users.php index 7a0de2af0..0130da549 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -356,6 +356,35 @@ } /** + * Get a particular piece of user info + * @param string $fieldname The name of the field we want to get + * @param int $user_id The id of the user we're checking for + * @return The value we seek, or false if the user doesn't exist + */ + function user_info($fieldname, $user_id) { + + // Name table + static $id_to_name_table; + + // Returns field from a given ID + + $user_id = (int) $user_id; + + if (!empty($user_id)) { + if (!isset($id_to_name_table[$user_id][$fieldname])) { + $id_to_name_table[$user_id] = (array) get_data_row("select * from users where id = {$user_id}"); // get_record('users','ident',$user_id); + } + if (isset($id_to_name_table[$user_id][$fieldname])) { + return $id_to_name_table[$user_id][$fieldname]; + } + } + + // If we've got here, the user didn't exist in the database + return false; + + } + + /** * Enter description here... * * @param unknown_type $criteria -- cgit v1.2.3