function referral_user_view in User Referral 7
Implements hook_user_view().
File
- ./
referral.module, line 299 - The referral module.
Code
function referral_user_view($account, $view_mode, $langcod) {
global $user;
$referrals = array();
$link = "referral/" . _referral_uid2ref($account->uid);
if (variable_get('referral_show_on_user_profile', TRUE)) {
if (user_access('use referral')) {
if ($user->uid == $account->uid) {
// User is viewing own page, show referrals
$referrals[] = array(
'#title' => t('Your referral link'),
'#markup' => url($link, array(
'query' => NULL,
'fragment' => NULL,
'absolute' => TRUE,
)),
'#type' => 'user_profile_item',
);
$referrals[] = array(
'#title' => t('Referrals'),
'#markup' => l(t('View users you have referred'), 'referral/view'),
'#type' => 'user_profile_item',
);
}
}
}
if (!$user->uid) {
$referrals[] = array(
'#title' => t('Referral link'),
'#markup' => l(t('Register to this site using my referral link'), $link),
'#type' => 'user_profile_item',
);
referral_set_cookie(arg(1));
}
if ($referrals) {
$referrals['#type'] = 'user_profile_category';
$referrals['#title'] = t('Referrals');
$referrals['#weight'] = 10;
$account->content['Referrals'] = $referrals;
}
}