koptein / dabr

Automatically exported from code.google.com/p/dabr
0 stars 0 forks source link

Fix (Un)Block #332

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What are the steps to trigger the problem?
1) Check User's profile

What happened?
DM & (Un)block problems

What did you expect to happen?
Allows DM if user is following you.
Show if you blocked the user.

---
@@ -1362,22 +1509,26 @@
 }

 function theme_user_header($user) {
+   $own_profile = (strtolower($user->screen_name) == 
strtolower(user_current_username())) ? true : false;
    $following = friendship($user->screen_name);
    $followed_by = $following->relationship->target->followed_by; //The $user is followed by the authenticating
-   $following = $following->relationship->target->following;
+   $following_to = $following->relationship->target->following;
    $name = theme('full_name', $user);
    $full_avatar = theme_get_full_avatar($user);
-   $link = theme('external_link', $user->url);
+   $link = $user->url ? theme('external_link', $user->url) : NULL;
    //Some locations have a prefix which should be removed (UbertTwitter and iPhone)
    //Sorry if my PC has converted from UTF-8 with the U (artesea)
-   $cleanLocation = str_replace(array("iPhone: ","ÃœT: "),"",$user->location);
+   $cleanLocation = str_replace(array("iPhone: ","ÜT: "),"",$user->location);
    $raw_date_joined = strtotime($user->created_at);
    $date_joined = date('jS M Y', $raw_date_joined);
    $tweets_per_day = twitter_tweets_per_day($user, 1);
    $bio = twitter_parse_tags($user->description);
    $out = "<div class='profile'>";
-   $out .= "<span class='avatar'>".theme('external_link', $full_avatar, 
theme('avatar', theme_get_avatar($user)))."</span>";
+   $out .= "<span class='avatar'>".theme('external_link', $full_avatar, 
theme('avatar', theme_get_avatar($user),true))."</span>";
    $out .= "<span class='status shift'><b>{$name}</b><br />";
+
+   // Social info
+   $out .= social_info($user->screen_name);
    $out .= "<span class='about'>";
    if ($user->verified == true) {
        $out .= '<strong>Verified Account</strong><br />';
@@ -1386,9 +1537,9 @@
        $out .= '<strong>Private/Protected Tweets</strong><br />';
    }

-   $out .= "Bio: {$bio}<br />";
-   $out .= "Link: {$link}<br />";
-   $out .= "Location: <a href=\"http://maps.google.com/m?q={$cleanLocation}\" 
target=\"" . get_target() . "\">{$user->location}</a><br />";
+   $out .= IfThenEcho($bio,"Bio: ","<br />");
+   $out .= IfThenEcho($link,"Link: ","<br />");
+   $out .= $user->location ? "Location: <a 
href=\"http://maps.google.com/m?q={$cleanLocation}\" target=\"" . get_target() 
. "\">{$user->location}</a><br />" : "";
    $out .= "Joined: {$date_joined} (~" . pluralise('tweet', $tweets_per_day, true) . " per day)";
    $out .= "</span></span>";
    $out .= "<div class='features'>";
@@ -1397,51 +1548,36 @@
    //If the authenticated user is not following the protected used, the API will return a 401 error when trying to view friends, followers and favourites
    //This is not the case on the Twitter website
    //To avoid the user being logged out, check to see if she is following the protected user. If not, don't create links to friends, followers and favourites
-   if ($user->protected == true && $followed_by == false) {
+   if ($user->protected == true && $followed_by == false && !$own_profile) {
        $out .= " | " . pluralise('follower', $user->followers_count, true);
        $out .= " | " . pluralise('friend', $user->friends_count, true);
        $out .= " | " . pluralise('favourite', $user->favourites_count, true);
-   }
-   else {
+   }   else {
        $out .= " | <a href='followers/{$user->screen_name}'>" . pluralise('follower', $user->followers_count, true) . "</a>";
        $out .= " | <a href='friends/{$user->screen_name}'>" . pluralise('friend', $user->friends_count, true) . "</a>";
        $out .= " | <a href='favourites/{$user->screen_name}'>" . pluralise('favourite', $user->favourites_count, true) . "</a>";
+       $out .= " | <a href='gallery/{$user->screen_name}'>Gallery</a>";
    }

    $out .= " | <a href='lists/{$user->screen_name}'>" . pluralise('list', $user->listed_count, true) . "</a>";
-   $out .= " | <a href='directs/create/{$user->screen_name}'>Direct Message</a>";
    //NB we can tell if the user can be sent a DM $following->relationship->target->following;
    //Would removing this link confuse users?

-   
-   //  One cannot follow, block, nor report spam oneself.
-   if (strtolower($user->screen_name) !== strtolower(user_current_username())) {
-   
+   //Deprecated 
http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show
+   if (!$own_profile) {
+       if ($following_to == true){
+           $out .= " | <a href='directs/create/{$user->screen_name}'>DM</a>";
+       } else { $out .= " | No DM"; }
        if ($followed_by == false) {
            $out .= " | <a href='follow/{$user->screen_name}'>Follow</a>";
-       }
-       else {
-           $out .= " | <a href='unfollow/{$user->screen_name}'>Unfollow</a>";
-       }
-   
+       }   else { $out .= " | <a href='unfollow/{$user->screen_name}'>Unfollow</a>";   }
        //We need to pass the User Name and the User ID.  The Name is presented in the UI, the ID is used in checking
-       $out.= " | <a 
href='confirm/block/{$user->screen_name}/{$user->id}'>(Un)Block</a>";
-       /*
-       //This should work, but it doesn't. Grrr.
        $blocked = $following->relationship->source->blocking; //The $user is blocked by the authenticating
-       if ($blocked == true)
-       {
+       if ($blocked == true)   {
            $out.= " | <a href='confirm/block/{$user->screen_name}/{$user->id}'>Unblock</a>";
-       }
-       else
-       {
-           $out.= " | <a 
href='confirm/block/{$user->screen_name}/{$user->id}'>Block</a>";
-       }
-       */
-
+       } else { $out.= " | <a 
href='confirm/block/{$user->screen_name}/{$user->id}'>Block</a>"; }
        $out .= " | <a href='confirm/spam/{$user->screen_name}/{$user->id}'>Report Spam</a>";
-   }
-   
+   } else { $out .=    " | <a href='directs/create/{$user->screen_name}'>DM to 
me</a>"; }
    $out .= " | <a href='search?query=%40{$user->screen_name}'>Search @{$user->screen_name}</a>";
    $out .= "</div></div>";
    return $out;

Original issue reported on code.google.com by mcev...@gmail.com on 27 Apr 2012 at 10:19

Attachments:

GoogleCodeExporter commented 8 years ago
Looks good - but it's missing the IfThenEcho() function & the social_info() 
function.
If you can upload a full patch, I'd be happy to integrate it.

Original comment by terence.eden on 7 May 2012 at 4:05

GoogleCodeExporter commented 8 years ago
Hi, I forgot to delete those lines in the patch. The IfThenEcho() function was 
for 4sq page, but I used it here too to avoid show "Bio: ", "Link: " without a 
description.

And social_info() it's to show icons from other social networks/webs the user 
has. Makes a request via API and caches the result, so I don't know if you 
would implement this.

function IfThenEcho($item,$prev = NULL,$prox = NULL,$return = NULL){
    return (isset($item) && $item != NULL ) ? $prev.$item.$prox : $return;
}

Original comment by mcev...@gmail.com on 10 May 2012 at 12:57

GoogleCodeExporter commented 8 years ago
How to use this ?

Original comment by supersan...@gmail.com on 10 Jul 2012 at 11:30

GoogleCodeExporter commented 8 years ago
Fixed in r495

Original comment by ryancul...@gmail.com on 19 Mar 2013 at 11:39