Changeset 1600

Show
Ignore:
Timestamp:
06/09/08 07:43:03 (5 months ago)
Author:
misja
Message:

#364, view of friend's blogs doesn't work with no friends or no posts - thanks edfactor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/blog/lib/weblogs_friends_view.php

    r1540 r1600  
    1616$friends = run("friends:get",array($page_owner)); 
    1717 
     18if (!empty($friends)) { 
    1819 
    19 $where2 = "weblog IN (" ; 
    20 $first=true; 
    21 // Uncoment the following lines if you want to see your own post in the friends list 
    22 //$where2 .= $page_owner; 
    23 //$first=false; 
     20  $where2 = "weblog IN (" ; 
     21  $first=true; 
     22   
     23   // Uncoment the following lines if you want to see your own post in the friends list 
     24   //$where2 .= $page_owner; 
     25   //$first=false; 
    2426 
    25 if (!empty($friends)) { 
    2627  foreach($friends as $friend) { 
    2728    if (!$first) { 
     
    3132    $first=false; 
    3233  } 
     34  $where2 .= ")"; 
     35 
     36  } 
     37    else { 
     38    $where2 = ''; 
    3339} 
    34 $where2 .= ")"; 
    3540 
    3641//Getting the field from the context extension 
     
    7580// $posts = $_SESSION['friends_posts_cache']->data; 
    7681error_log('('.$where1.') AND ('.$where2.') '.$where3); 
    77 $posts = get_records_select('weblog_posts','('.$where1.') AND ('.$where2.') '.$where3,null,'posted DESC','*',$weblog_offset,POSTS_PER_PAGE); 
    78 $numberofposts = count_records_select('weblog_posts','('.$where1.') AND ('.$where2.') ' .$where3); 
    79 if (!empty($posts)) { 
     82 
     83$posts = array(); 
     84$numberofposts = array(); 
     85 
     86if (!empty($friends)) { 
     87  $posts = get_records_select('weblog_posts','('.$where1.') AND ('.$where2.') '.$where3,null,'posted DESC','*',$weblog_offset,POSTS_PER_PAGE); 
     88  $numberofposts = count_records_select('weblog_posts','('.$where1.') AND ('.$where2.') ' .$where3); 
     89
     90// Don't update this if you don't have any friends 
     91if (!empty($friends) && !empty($posts)) { 
    8092 
    8193    $lasttime = ""; 
     
    124136else{ 
    125137  $type =(isset($extraType))?$extraType:$extensionContext; 
    126   $run_result = "<p>".sprintf(__gettext("Your friends currently don't have any %s"), strtolower($type))."</p>";   
     138   
     139  if (empty($friends)) { 
     140  
     141  $run_result = "<p>".sprintf(__gettext("You don't currently have any friends."))."</p>";   
     142  } 
     143  else { 
     144 
     145  $run_result = "<p>".sprintf(__gettext("Your friends currently don't have any blog posts."))."</p>";   
     146  } 
    127147} 
    128148?>