function commons_profile_views_pre_view in Drupal Commons 6.2
Implementation of hook_views_pre_view()
File
- modules/
features/ commons_profile/ commons_profile.module, line 120
Code
function commons_profile_views_pre_view(&$view) {
// When viewing the "Friends" block
if ($view->name == 'profile_following') {
// Get the current user being viewed
if ($account = _commons_profile_get_current_user()) {
// Get the set title
$title = $view->display_handler
->get_option('title');
// Fetch the user's friends count
//user_relationships_load isn't used because with 'user' option it would also return requestees matching $account->uid
$friends = db_result(db_query('SELECT count(rid) FROM {user_relationships} ur WHERE ur.requester_id = %d AND ur.approved = 1 and ur.rtid = 1', array(
$account->uid,
)));
// Add a friend count to the block
$title .= " ({$friends})";
// Set the new title
$view->display_handler
->set_option('title', $title);
}
}
}