function _commons_profile_image_links_block_view in Drupal Commons 6.2
Generate the profile image and action links block
File
- modules/
features/ commons_profile/ commons_profile.blocks.inc, line 63 - Block functions
Code
function _commons_profile_image_links_block_view() {
global $user;
// Make sure we're viewing a user
if (!($account = _commons_profile_get_current_user())) {
return NULL;
}
// Fetch the profile image
$account->imagecache_preset = variable_get('user_picture_imagecache_profiles', '');
$picture = theme('user_picture', $account);
// Generate a list of action links
$links = array();
// The links depend on whether or not the user is viewing
// their own profile
if ($user->uid == $account->uid) {
// Provide a link to edit your profile
$links['edit_profile'] = array(
'title' => t('Edit my profile'),
'href' => "user/{$account->uid}/edit",
);
// See if you have friend requests
if (user_access('maintain own relationships')) {
$requests = user_relationships_load(array(
'requestee_id' => $account->uid,
'approved' => FALSE,
));
if (count($requests)) {
// Provide a link to see the requests
$links['friend_requests'] = array(
'title' => t('Friend requests (!count)', array(
'!count' => count($requests),
)),
'href' => variable_get('user_relationships_requests_link', 'relationships/requests'),
);
}
}
// Add a link to view your bookmarks
$links['bookmarks'] = array(
'title' => t('My bookmarks'),
'href' => "user/{$account->uid}/bookmarks",
);
}
else {
// Provide relationship links/messages
if (user_access('maintain own relationships')) {
// For the Commons "Follower" relatinoship, hide controls to
// make another user unfollow the present user.
$actions = _user_relationships_ui_actions_between($user, $account);
static $rids_exclude;
if (empty($rids_exclude[$user->uid])) {
$rids_exclude[$user->uid] = array();
$query = db_query("SELECT rid FROM {user_relationships} WHERE rtid = 1 AND requester_id != %d AND requestee_id = %d", $user->uid, $user->uid);
while ($result = db_fetch_object($query)) {
$rids_exclude[$user->uid][$result->rid] = $result->rid;
}
}
foreach ($actions as $key => $action) {
if (in_array($key, $rids_exclude[$user->uid])) {
continue;
}
$links["ur_action_{$key}"] = array(
'title' => $action,
// No href because this is the best that UR can offer
'html' => TRUE,
'attributes' => array(
'class' => 'ur_action',
),
);
}
}
// If the current user has access to, provide a link
// to edit the viewed user's profile
if (user_access('administer users')) {
$links['edit_profile'] = array(
'title' => t('Edit !user\'s profile', array(
'!user' => $account->name,
)),
'href' => "user/{$account->uid}/edit",
);
}
// Provide link to contact the user
if (_contact_user_tab_access($account)) {
$links['contact'] = array(
'title' => t('Contact !user', array(
'!user' => $account->name,
)),
'href' => "user/{$account->uid}/contact",
);
}
}
// Allow other modules to alter the list of links
drupal_alter('commons_profile_action_links', $links, $account);
return array(
'subject' => '',
'content' => theme('commons_profile_image_action_links_block', $picture, $links, $account),
);
}