function disqus_user in Disqus 6
Implementation of hook_user().
File
- ./
disqus.module, line 199
Code
function disqus_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'load':
// Only show on the profile if desired. Don't show on the administrator's profile.
if (user_access('display disqus comments on profile', $account) && $account->uid != 1) {
// Check which Disqus domain to use.
$domain = variable_get('disqus_domain', NULL);
if (!empty($domain)) {
// Save the data to the user object.
$account->disqus = array(
'domain' => $domain,
);
}
// Build the absolute URL without the alias for the disqus_url flag.
$account->disqus['url'] = url("user/{$account->uid}", array(
'absolute' => TRUE,
));
// Build the title.
$account->disqus['title'] = check_plain(strip_tags($account->name));
// Provide the identifier.
$account->disqus['identifier'] = 'user/' . $account->uid;
// Inject the script.
if ($developer = variable_get('disqus_developer', FALSE)) {
$account->disqus['developer'] = $developer;
}
}
break;
case 'view':
if (isset($account->disqus) && user_access('view disqus comments')) {
// Inject Disqus into the user object.
switch (variable_get('disqus_location', 'content_area')) {
case 'content_area':
// Inject into the user content.
$account->content['disqus'] = array(
'#value' => theme('disqus_comments', $account->disqus),
'#weight' => variable_get('disqus_weight', 50),
);
break;
case 'variable':
// Inject it into a variable.
$account->disqus_comments = theme('disqus_comments', $account->disqus);
break;
}
}
break;
}
}