| | 363 | |
|---|
| | 364 | /** |
|---|
| | 365 | * Gets the value of a particular profile item. |
|---|
| | 366 | * |
|---|
| | 367 | * @uses $CFG |
|---|
| | 368 | * @param $userid int The ident of the user we're querying. |
|---|
| | 369 | * @param $profile_field string The short name of the profile item we're querying. |
|---|
| | 370 | * @return string The value of the profile item - or a blank string. |
|---|
| | 371 | */ |
|---|
| | 372 | |
|---|
| | 373 | function get_profile_item($userid, $profile_field) { |
|---|
| | 374 | |
|---|
| | 375 | global $CFG, $db, data; |
|---|
| | 376 | $body = ""; |
|---|
| | 377 | |
|---|
| | 378 | foreach($data['profile:details'] as $field_row) { |
|---|
| | 379 | if ($field_row->internal_name == $profile_field) { |
|---|
| | 380 | $field = $field_row; |
|---|
| | 381 | } |
|---|
| | 382 | } |
|---|
| | 383 | if (!empty($field) { |
|---|
| | 384 | $value = get_record_sql("select * from ".$CFG->prefix."profile_data where owner = {$userid} and name = " . $db->qstr($field->internal_name)); |
|---|
| | 385 | if (run("users:access_level_check", $value->access)) { |
|---|
| | 386 | $body = display_output_field(array($value->value,$field->field_type,$field->internal_name,$field->name,$value->ident)); |
|---|
| | 387 | } |
|---|
| | 388 | } |
|---|
| | 389 | |
|---|
| | 390 | return $body; |
|---|
| | 391 | |
|---|
| | 392 | } |
|---|