function theme_privatemsg_user_picture in Privatemsg 5
Same name and namespace in other branches
- 5.3 privatemsg.module \theme_privatemsg_user_picture()
2 theme calls to theme_privatemsg_user_picture()
- privatemsg_list_form in ./
privatemsg.module - theme_privatemsg_view in ./
privatemsg.module - Returns content to view a private message.
File
- ./
privatemsg.module, line 2499
Code
function theme_privatemsg_user_picture($account) {
if (variable_get('user_pictures', 0)) {
if ($account->picture && file_exists($account->picture)) {
$picture = $account->picture;
}
else {
$picture = variable_get('user_picture_default', '');
}
$alt = t("@user's picture", array(
'@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous')),
));
$presets = imagecache_preset_by_name(variable_get('privatemsg_imagecache_preset', 0));
if (strpos($picture, 'http://') === FALSE && module_exists('imagecache') && !empty($presets) && variable_get('privatemsg_imagecache_preset', 0)) {
$picture = theme('imagecache', variable_get('privatemsg_imagecache_preset', 0), $picture, $alt, $alt, false);
}
else {
$info = image_get_info($picture);
$newpicture = dirname($picture) . '/picture-' . $account->uid . "-avatar." . $info['extension'];
if (!file_exists($newpicture) || filectime($newpicture) < filectime($picture)) {
image_scale($picture, $newpicture, 64, 64);
if (!file_exists($newpicture)) {
$newpicture = $picture;
}
}
$picture = file_create_url($newpicture);
$picture = theme('image', $picture, $alt, $alt, '', FALSE);
}
if (isset($picture)) {
if (!empty($account->uid) && user_access('access user profiles')) {
$picture = l($picture, "user/{$account->uid}", array(
'title' => t('View user profile.'),
), NULL, NULL, FALSE, TRUE);
}
if (variable_get('privatemsg_online_status', 1)) {
// code to show online/offline status
$time_period = variable_get('user_block_seconds_online', 1200);
$uid = $account->uid;
// get the current userid for the avatar.
$users = db_query("SELECT uid, name, access FROM {users} WHERE access >= %d AND uid = %s", time() - $time_period, $uid);
$total_users = db_num_rows($users);
if ($total_users == 1) {
$output = '<span style="color: #00DD45; font-weight: bold; display:block;">' . t('Online') . '</span>';
}
else {
$output = '<span style="color: #AA4444; display:block;">' . t('Offline') . '</span>';
}
}
return '<div class="picture">' . $output . $picture . '</div>';
}
}
}