| 1 |
<?php |
<?php |
| 2 |
// $Id: user.module,v 1.1074 2009/10/31 18:04:01 dries Exp $ |
// $Id: user.module,v 1.1075 2009/11/01 21:26:44 webchick Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 2084 |
* |
* |
| 2085 |
* @param $account |
* @param $account |
| 2086 |
* A user object. |
* A user object. |
| 2087 |
|
* @param $build_mode |
| 2088 |
|
* Build mode, e.g. 'full'. |
| 2089 |
* |
* |
| 2090 |
* @return |
* @return |
| 2091 |
* An array as expected by drupal_render(). |
* An array as expected by drupal_render(). |
| 2092 |
*/ |
*/ |
| 2093 |
function user_build($account) { |
function user_build($account, $build_mode = 'full') { |
| 2094 |
// Retrieve all profile fields and attach to $account->content. |
// Retrieve all profile fields and attach to $account->content. |
| 2095 |
user_build_content($account); |
user_build_content($account, $build_mode); |
| 2096 |
|
|
| 2097 |
$build = $account->content; |
$build = $account->content; |
| 2098 |
// We don't need duplicate rendering info in account->content. |
// We don't need duplicate rendering info in account->content. |
| 2101 |
$build += array( |
$build += array( |
| 2102 |
'#theme' => 'user_profile', |
'#theme' => 'user_profile', |
| 2103 |
'#account' => $account, |
'#account' => $account, |
| 2104 |
|
'#build_mode' => $build_mode, |
| 2105 |
); |
); |
| 2106 |
|
|
| 2107 |
|
// Allow modules to modify the structured user. |
| 2108 |
|
drupal_alter('user_build', $build); |
| 2109 |
|
|
| 2110 |
return $build; |
return $build; |
| 2111 |
} |
} |
| 2112 |
|
|
| 2115 |
* |
* |
| 2116 |
* @param $account |
* @param $account |
| 2117 |
* A user object. |
* A user object. |
| 2118 |
* |
* @param $build_mode |
| 2119 |
|
* Build mode, e.g. 'full'. |
| 2120 |
*/ |
*/ |
| 2121 |
function user_build_content($account) { |
function user_build_content($account, $build_mode = 'full') { |
| 2122 |
|
// Remove previously built content, if exists. |
| 2123 |
$account->content = array(); |
$account->content = array(); |
| 2124 |
|
|
|
$accounts = array($account->uid, $account); |
|
|
field_attach_prepare_view('user', $accounts, 'full'); |
|
|
|
|
| 2125 |
// Build fields content. |
// Build fields content. |
| 2126 |
$account->content += field_attach_view('user', $account); |
field_attach_prepare_view('user', array($account->uid, $account), $build_mode); |
| 2127 |
|
$account->content += field_attach_view('user', $account, $build_mode); |
| 2128 |
|
|
| 2129 |
// Populate $account->content with a render() array. |
// Populate $account->content with a render() array. |
| 2130 |
module_invoke_all('user_view', $account); |
module_invoke_all('user_view', $account, $build_mode); |
| 2131 |
} |
} |
| 2132 |
|
|
| 2133 |
/** |
/** |