Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/README.txt,v
retrieving revision 1.4
diff -u -p -r1.4 README.txt
--- README.txt	10 Dec 2007 21:22:48 -0000	1.4
+++ README.txt	15 Dec 2007 13:28:35 -0000
@@ -63,6 +63,10 @@ Installation
 - Configure Simplenews on the Simplenews admin pages:
     Administer > Content Management > Newsletters > Settings.
 
+------------
+Simplenews block
+------------
+
 - Configure the Simplenews block on the block configuration page. On the Block admin page
   (Administer > Site building > Blocks) click the Configure link of the appropriate
   simplenews block.
@@ -72,6 +76,12 @@ Installation
   Links in the simplenews block (to previous issues, previous issues and RSS-feed) are only
   displayed to users who have "view links in block" privileges.
 
+- More control over the content of simplenews blocks is possible using the block 
+  theming. Additional variables are available for custom features:
+    $block['subscribed'] is TRUE if user is subscribed to the newsletter
+    $block['user'] is TRUE if the user is logged in (authenticated)
+    $block['tid'] is the term id number of the newsletter
+
 ------------
 Collaboration with other modules
 ------------
Index: simplenews.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews.module,v
retrieving revision 1.70
diff -u -p -r1.70 simplenews.module
--- simplenews.module	11 Dec 2007 07:58:03 -0000	1.70
+++ simplenews.module	15 Dec 2007 13:28:39 -0000
@@ -623,37 +623,58 @@ function simplenews_block($op = 'list', 
       if ($type == 'newsletter') {
         if ($newsletter = taxonomy_get_term($tid)) {
           $block['subject'] = check_plain($newsletter->name);
-        $block['content'] = theme('simplenews_block', $newsletter);
+          $block['content'] = theme('simplenews_block', _simplenews_block($newsletter->tid));
         }
       }
       return $block;
   }
 }
 
-function theme_simplenews_block($newsletter) {
-  $output = '';
-  if (variable_get('simplenews_block_m_status_'. $newsletter->tid, 1)) {
-    $output .= '<p>'. variable_get('simplenews_block_m_'. $newsletter->tid, t('Stay informed on our latest news!')) .'</p>';
+/**
+ * Helper function: generate block content before theming
+ * 
+ */
+function _simplenews_block($tid) {
+  global $user;
+  $block = array();
+  $recent = simplenews_recent_newsletters($tid, variable_get('simplenews_block_i_'. $tid, 5));
+  
+  $block['subscribed'] = (simplenews_user_is_subscribed($user->mail, $tid) == TRUE);
+  $block['user'] = !empty($user->uid);
+  $block['tid'] = $tid;
+  $block['message'] = check_plain(variable_get('simplenews_block_m_'. $tid, t('Stay informed on our latest news!')));
+  if (user_access('subscribe to newsletters')) {
+    $block['form'] = drupal_get_form('simplenews_block_form', $tid);
+    $block['subscription-link'] = l(t('Manage my subscriptions'), 'newsletter/subscriptions'); 
   }
-  if (variable_get('simplenews_block_f_'. $newsletter->tid, 1) && user_access('subscribe to newsletters')) {
-    $output .= drupal_get_form('simplenews_block_form', $newsletter->tid);
+  if (user_access('view links in block') || user_access('administer newsletters')) {
+    $block['newsletter-link'] = l(t('Previous issues'), 'taxonomy/term/'. $tid);
+    $block['itemlist'] = theme('item_list', $recent, t('Previous issues'), 'ul', array('class' => 'newsletter-list'));
+    $block['rssfeed'] = theme('feed_icon', url('taxonomy/term/'. $tid .'/0/feed'));
   }
-  if ((!variable_get('simplenews_block_f_'. $newsletter->tid, 1)) && (user_access('subscribe to newsletters')) ){
-    $output .= '<p>'. l(t('Manage my subscriptions'), 'newsletter/subscriptions/'). '</p>';
+
+  return $block;
+}
+ 
+function theme_simplenews_block($block) {
+  $output = ''; 
+  if (variable_get('simplenews_block_m_status_'. $block['tid'], 1) && !empty($block['message'])) {
+    $output .= "<p>". $block['message'] ."</p>\n";
   }
-  if (user_access('view links in block') || user_access('administer newsletters')) {
-    if (variable_get('simplenews_block_l_'. $newsletter->tid, 1)) {
-      $output .= l(t('Previous issues'), 'taxonomy/term/'. $newsletter->tid);
-    }
-    elseif (variable_get('simplenews_block_i_status_'. $newsletter->tid, 0)) {
-      $output .= t('Previous issues');
-    }
-    if (variable_get('simplenews_block_i_status_'. $newsletter->tid, 0)) {
-      $output .= simplenews_recent_newsletters($newsletter->tid, variable_get('simplenews_block_i_'. $newsletter->tid, 5));
-    }
-    if (variable_get('simplenews_block_r_'. $newsletter->tid, 1)) {
-      $output .= theme('feed_icon', url('taxonomy/term/'. $newsletter->tid .'/0/feed'));
-    }
+  if (variable_get('simplenews_block_f_'. $block['tid'], 1)) {
+    $output .= $block['form'];
+  }
+  else {
+    $output .= "<p>". $block['subscription-link']. "</p>\n";
+  }
+  if (variable_get('simplenews_block_l_'. $block['tid'], 1)) {
+    $output .= $block['newsletter-link'];
+  }
+  if (variable_get('simplenews_block_i_status_'. $block['tid'], 0)) {
+    $output .= $block['itemlist'];
+  }
+  if (variable_get('simplenews_block_r_'. $block['tid'], 1)) {
+    $output .= $block['rssfeed'] ."\n";
   }
   return $output;
 }
@@ -928,14 +949,13 @@ function simplenews_subscription_manager
 }
 
 function simplenews_recent_newsletters($tid, $count = 5, $title = NULL) {
-  $result = db_query_range(db_rewrite_sql('SELECT n.nid, n.title, n.created FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid INNER JOIN {simplenews_newsletters} sn ON n.nid = sn.nid WHERE (t.tid = %d AND n.status = 1 AND sn.s_status > 0) ORDER BY n.created DESC'), $tid, 0, $count);
+  $result = db_query_range(db_rewrite_sql('SELECT n.nid, n.title, sn.s_status FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid INNER JOIN {simplenews_newsletters} sn ON n.nid = sn.nid WHERE (t.tid = %d AND n.status = 1 AND sn.s_status > 0) ORDER BY n.created DESC'), $tid, 0, $count);
   $titles = array();
   while ($item = db_fetch_object($result)) {
-    $titles[] = l($item->title, 'node/'. $item->nid);
-  }
-  if ($titles) {
-    return theme('item_list', $titles, $title);
+    $titles[$item->nid]['data'] = l($item->title, 'node/'. $item->nid);
+    $titles[$item->nid]['class'] = 'newsletter-issue newsletter-'. ($item->s_status > 0)? 'send' : 'created';
   }
+  return $titles;  
 }
