Index: buddylist.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/buddylist/buddylist.module,v
retrieving revision 1.88
diff -u -p -r1.88 buddylist.module
--- buddylist.module	4 Feb 2007 15:52:28 -0000	1.88
+++ buddylist.module	19 Feb 2007 19:26:10 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: buddylist.module,v 1.88 2007/02/04 15:52:28 robertDouglass Exp $
+// $Id: buddylist.module,v 1.68.2.13 2007/02/04 15:53:43 robertDouglass Exp $
 
 if (module_exists('views')) {
   include_once('buddylist_views.inc');
@@ -287,14 +287,6 @@ function buddylist_admin_settings() {
     '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
     '#description' => t('This setting controls the maximum number of posts to display in a user\'s "@buddy recent posts" block given that the "@buddies\' recent posts" block is enabled in the !link.', array('!link' => l(t('block settings'), 'admin/build/block')) + buddylist_translation()),
   );
-  $form['block_settings']['buddylist_list_block_title'] = array(
-    '#type' => 'textfield',
-    '#title' => t('"My @buddies list" block title', buddylist_translation()),
-    '#default_value' => variable_get('buddylist_list_block_title', t('My @buddy list', buddylist_translation())),
-    '#size' => 70,
-    '#maxlength' => 128,
-    '#description' => t('This will be the title for the "My @buddy list" block. If none is specified, "My @buddy list" will be used.', buddylist_translation()),
-  );
   $form['block_settings']['buddylist_block_title'] = array(
     '#type' => 'textfield',
     '#title' => t('"My @buddies\' recent posts" block title', buddylist_translation()),
@@ -311,6 +303,29 @@ function buddylist_admin_settings() {
     '#maxlength' => 128,
     '#description' => t('This will be the title for the @buddy list status block. If none is specified, "My @buddy list status" will be used.', buddylist_translation()),
   );
+  $form['block_settings']['buddylist_list_block_title'] = array(
+    '#type' => 'textfield',
+    '#title' => t('"My @buddies list" block title', buddylist_translation()),
+    '#weight' => 1,
+    '#default_value' => variable_get('buddylist_list_block_title', t('My @buddy list', buddylist_translation())),
+    '#size' => 70,
+    '#maxlength' => 128,
+    '#description' => t('This will be the title for the "My @buddy list" block. If none is specified, "My @buddy list" will be used.', buddylist_translation()),
+  );
+  $form['block_settings']['buddylist_block_if_no_buddies'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Show "My @buddies list" block even if @buddylist is empty', buddylist_translation()),
+    '#weight' => 2,
+    '#default_value' => variable_get('buddylist_block_if_no_buddies', FALSE),
+    '#description' => t('If a user has no @buddies, the @buddy block can show a message.', buddylist_translation()),
+  );
+  $form['block_settings']['buddylist_empty_text'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Show this text in "My @buddies list" if @buddylist is empty', buddylist_translation()),
+    '#weight' => 3,
+    '#default_value' => variable_get('buddylist_empty_text', t(buddylist_empty_text_default(), buddylist_translation())),
+    '#description' => t('If a user has no @buddies and the above checkbox is checked, this message is shown instead of a list.', buddylist_translation()),
+  );
 
    $form['mail'] = array(
     '#type' => 'fieldset',
@@ -543,6 +558,7 @@ function buddylist_block($op = 'list', $
     switch ($delta) {
       case 0 : // Shows buddylist block
         if ($buddies = buddylist_get_buddies()) {
+          // we have buddies defined and generate the list
           $i = 0;
           foreach (array_keys($buddies) as $buddy) {
             $users[] = user_load(array('uid' => $buddy));
@@ -551,17 +567,26 @@ function buddylist_block($op = 'list', $
               break;
             }
           }
-
           $block['content'] = theme('user_list', $users);
-          $block['subject'] = variable_get('buddylist_list_block_title', t('My @buddy list', buddylist_translation()));
+        } else {
+          // buddylist is empty
+          if(variable_get('buddylist_block_if_no_buddies', FALSE)) {
+            // Show a message that we have no buddies yet
+            $block['content'] = variable_get('buddylist_empty_text', t(buddylist_empty_text_default(), buddylist_translation()));
+          } else {
+            // If no buddies defined and no message available, end 'case' without returning block.
+            break;
+          }
+        }
+        // this is the same output whether buddylist or not
+        $block['subject'] = variable_get('buddylist_list_block_title', t('My @buddy list', buddylist_translation()));
 
-          // check if a "more" link should generated by seeing if there are more buddies than the specified $upperlimit
-          if (count($buddies) > variable_get('buddylist_blocklisting_size', 5)) {
+        // check if a "more" link should generated by seeing if there are more buddies than the specified $upperlimit
+        if (count($buddies) > variable_get('buddylist_blocklisting_size', 5)) {
             $block['content'] .=  '<div class="more-link">' . l(t('more'), 'buddylist', array('title' => t('View more.'))) . '</div>';
-          }
-          return $block;
         }
-        break;
+        return $block;
+      break;
 
       case 1: // Shows my buddies recent posts block
         $buddies = buddylist_get_buddies();
@@ -732,7 +757,7 @@ function buddylist_buddylisting_page($ui
     $output .= theme('table', $header, $rows);
   }
   else {
-    $output .= t('No @buddies found.', buddylist_translation());
+    $output .= variable_get('buddylist_empty_text', t(buddylist_empty_text_default(), buddylist_translation()));
   }
 
   $output .= theme('pager', NULL, $buddies_per_page);
@@ -1550,4 +1575,13 @@ function buddylist_approval_mail_replace
     '@siteurl' => $GLOBALS["base_url"],
     '@adder_list_link' => url("buddylist/". $user->uid ."/buddies/list", NULL, NULL, TRUE),
   );
-}
\ No newline at end of file
+}
+
+function buddylist_empty_text_default() {
+  return <<<MESSAGE
+<p>You haven't made any @buddies, yet.</p>
+
+<p>You can add a @buddy by visiting a user's profile page.</p>
+MESSAGE;
+}
+
