/[drupal]/contributions/modules/facebook_status/facebook_status_views_handler_field_cross_pic.inc
ViewVC logotype

Contents of /contributions/modules/facebook_status/facebook_status_views_handler_field_cross_pic.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Fri Jun 5 00:40:42 2009 UTC (5 months, 3 weeks ago) by icecreamyou
Branch: MAIN
CVS Tags: DRUPAL-6--2-0-RC1, HEAD
Branch point for: DRUPAL-6--2
File MIME type: text/x-php
Fixed Activity 1.x support
Partially added Activity 2.x support
Fixed a bug where some users on some Drupal installations needed the "edit all statuses" permission to post any status
#482364 User Picture of submitter in View
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Handling for cross-posting.
7 */
8
9 /**
10 * Shows either the status owner (if the status was posted to one's own profile)
11 * or the status owner and status poster (if the status was posted elsewhere).
12 * Also shows the user picture.
13 */
14 class facebook_status_views_handler_field_cross_pic extends views_handler_field {
15 function render($values) {
16 if ($values->facebook_status_pid && $values->facebook_status_uid) {
17 $uid = $values->facebook_status_uid;
18 $pid = $values->facebook_status_pid;
19 }
20 else if ($values->facebook_status_sid) {
21 $status = facebook_status_load($values->facebook_status_sid);
22 $uid = $status->uid;
23 $pid = $status->pid;
24 }
25 if (isset($uid) && $pid == $uid) {
26 $account = user_load(array('uid' => $uid));
27 return t('!picture !user', array('!picture' => facebook_status_display_user_picture($account), '!user' => theme('username', $account)));
28 }
29 else {
30 $args = array('!poster' => theme('username', user_load(array('uid' => $pid))), '!owner' => theme('username', user_load(array('uid' => $uid))));
31 $args['!poster-picture'] = facebook_status_display_user_picture(user_load(array('uid' => $pid)));
32 $args['!owner-picture'] = facebook_status_display_user_picture(user_load(array('uid' => $uid)));
33 return t('!poster-picture !poster &raquo; !owner-picture !owner', $args);
34 }
35 }
36 }
37
38 /**
39 * Displays the user picture. Similar to theme('user_picture', $account) but
40 * does not have problems with some themes floating the picture or wrapping it
41 * in a div. However, this function is stylistically poor etiquette: the
42 * technically correct way to do this would be to use CSS to format the output
43 * of the original theme function, and the second-best way would be to write a
44 * new theme function.
45 */
46 function facebook_status_display_user_picture($account) {
47 $picture = '';
48 if (variable_get('user_pictures', 0)) {
49 if (!empty($account->picture) && file_exists($account->picture)) {
50 $picture = file_create_url($account->picture);
51 }
52 else if (variable_get('user_picture_default', '')) {
53 $picture = variable_get('user_picture_default', '');
54 }
55 if ($picture) {
56 $alt = t("@user's picture", array('@user' => $account->name));
57 $picture = '<img src="'. check_url($picture) .'" alt="'. check_plain($alt) .'" />';
58 if (!empty($account->uid) && user_access('access user profiles')) {
59 $attributes = array('attributes' => array('title' => t('View user profile.'), 'class' => 'facebook_status_user_picture'), 'html' => TRUE);
60 $picture = l($picture, 'user/'. $account->uid, $attributes);
61 }
62 }
63 }
64 return $picture;
65 }

  ViewVC Help
Powered by ViewVC 1.1.2