Index: quotes.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quotes/quotes.module,v
retrieving revision 1.19.2.1.2.28
diff -u -p -r1.19.2.1.2.28 quotes.module
--- quotes.module	27 Sep 2008 17:41:52 -0000	1.19.2.1.2.28
+++ quotes.module	30 Sep 2008 01:50:35 -0000
@@ -623,11 +623,15 @@ function _quotes_block_configure($delta 
   drupal_add_js(drupal_get_path('module', 'quotes') .'/quotes.js');  
 
   $block = db_fetch_object(db_query("SELECT qb.* FROM {quotes_blocks} qb WHERE bid = %d", $delta));
-  $any_filters = $block->nid_filter . $block->rid_filter . $block->uid_filter . $block->tid_filter;
+  $any_filters = $block->nid_filter . $block->aid_filter . $block->rid_filter . $block->uid_filter . $block->tid_filter;
+  $block->aid_filter = explode(',', $block->aid_filter);
   $block->rid_filter = explode(',', $block->rid_filter);
   $block->uid_filter = explode(',', $block->uid_filter);
   $block->tid_filter = explode(',', $block->tid_filter);
 
+  // get authors
+  $authors = quotes_get_authors();
+
   // get roles
   $roles = user_roles(FALSE, 'create quotes');
 
@@ -761,6 +765,24 @@ function _quotes_block_configure($delta 
     '#description' => t('To restrict this block to display only certain quotes based on node IDs, enter the IDs here separated by commas, spaces, or returns.'),
     );
 
+  if (count($authors)) {
+    $form['quotes']['filters']['aid_filter'] = array(
+      '#type' => 'textarea',
+      '#title' => t('Author filter'),
+      '#multiple' => TRUE,
+      '#default_value' => $block->aid_filter,
+      '#options' => $authors,
+      '#description' => t('To restrict this block to display only quotes from certain authors, select the authors here.'),
+      );
+  }
+  else {
+    $form['quotes']['filters']['aid_filter'] = array(
+      '#type' => 'item',
+      '#title' => t('Author filter'),
+      '#description' => t('There are no authors.  To filter by authors, there must be at least one quote with an attributed author')
+      );
+  }
+
   if (count($roles)) {
     $form['quotes']['filters']['rid_filter'] = array(
       '#type' => 'select',
@@ -847,6 +869,7 @@ function _quotes_block_configure_save($d
       $edit['name'],
       $edit['block_type'],
       preg_replace('<[,\s]+>', ',', trim($edit['nid_filter'])),
+      implode(',', (array) $edit['aid_filter']),
       implode(',', (array) $edit['rid_filter']), 
       implode(',', (array) $edit['uid_filter']),
       implode(',', (array) $edit['tid_filter']),
@@ -863,8 +886,8 @@ function _quotes_block_configure_save($d
       $edit['max_length'],
       $delta
     );
-  db_query("UPDATE {quotes_blocks} SET name = '%s', block_type = %d, nid_filter = '%s', rid_filter = '%s',
-    uid_filter = '%s', tid_filter = '%s', cron_interval = %d, cron_step = %d,
+  db_query("UPDATE {quotes_blocks} SET name = '%s', block_type = %d, nid_filter = '%s', aid_filter = '%s', 
+    rid_filter = '%s', uid_filter = '%s', tid_filter = '%s', cron_interval = %d, cron_step = %d,
     count = %d, show_titles = %d, show_citation = %d, more_text = '%s',
     view_text = '%s', view_weight = %d, max_length = %d WHERE bid = %d", $vals);
 
@@ -977,7 +1000,7 @@ function theme_quotes_quote($node, $teas
   }
 
   if (variable_get('quotes_author_link', FALSE)) {
-    $author =  $node->quotes_author ? $leader . l($node->quotes_author, 'quotes/author/'. $node->quotes_aid, array('title' => t('View all quotes by this author'))) : '';
+    $author =  $node->quotes_author ? $leader . l($node->quotes_author, 'quotes/author/'. $node->quotes_author, array('title' => t('View all quotes by this author'))) : '';
     $author = decode_entities($author);
   }
   else {
@@ -989,7 +1012,7 @@ function theme_quotes_quote($node, $teas
       $bio = $node->quotes_bio ? ('<div class="quotes-bio">'. check_markup($node->quotes_bio, $node->format, ($user->uid == $node->uid)) .'</div>') : '';
       break;
     case 2:
-      $bio = $node->quotes_author ? ('<div class="quotes-bio-link">'. l(t('See biography and quotes'), 'quotes/author/'. $node->quotes_aid, array('title' => t('View all quotes by this author'))) .'</div>') : '';
+      $bio = $node->quotes_author ? ('<div class="quotes-bio-link">'. l(t('See biography and quotes'), 'quotes/author/'. $node->quotes_author, array('title' => t('View all quotes by this author'))) .'</div>') : '';
       break;
     default:
       $bio = NULL;
@@ -1111,7 +1134,7 @@ function quotes_get_quote($filters = arr
  *
  * @param $filters
  *   The array specifying filter criteria using the keys nid_filter,
- *   rid_filter, uid_filter, and tid_filter.
+ *   aid_filter, rid_filter, uid_filter, and tid_filter.
  * @param $aliases
  *   The array specifying the aliases to be used for the tables that
  *   may be joined based on the provided filter criteria. Keys are the
@@ -1158,6 +1181,10 @@ function quotes_block_where_sql($filters
     $where[] = " $aliases[node].nid IN ($filters[nid_filter]) ";
   }
 
+  if ($filters['aid_filter']) {
+    $where[] = " (q.aid IN ($filters[aid_filter])) ";
+  }
+
   if ($filters['rid_filter']) {
     $where[] = sprintf(" ($aliases[users_roles].rid IN ($filters[rid_filter]) OR (%d IN ($filters[rid_filter]) AND $aliases[node].uid = 0)) ", DRUPAL_ANONYMOUS_RID);
   }
@@ -1211,6 +1238,11 @@ function quotes_author($author = NULL) {
     // If no author given, display a selection list.
     return drupal_get_form('quotes_author_form');
   }
+  elseif ($author == t('unspecified')) {
+    $aid = 0;
+    $auth = array('name'=>$author, 'bio'=>'');
+  }
+  else {
 
   // See whether we have a name or an id.
   if (is_numeric($author)) {
@@ -1226,6 +1258,7 @@ function quotes_author($author = NULL) {
   if (!$aid) {
     return t('I couldn\'t locate that author.') . drupal_get_form('quotes_author_form');
   }
+  } // unspecified author
 
   $limit = variable_get('quotes_per_page', 10);
   drupal_set_title(decode_entities(t('Quotes by @name', (array('@name' => $author)))));
@@ -1252,9 +1285,15 @@ function quotes_author($author = NULL) {
 function quotes_author_form() {
   $form = array();
   $authors = quotes_get_authors();
+  $author_names = array();
+  foreach($authors as $name) {
+    $name = empty($name) ? t('unspecified') : $name;
+    $author_names[$name] = $name;
+  }
+
   $form['author'] = array(
     '#type' => 'select',
-    '#options' => $authors,
+    '#options' => $author_names,
     '#size' => min(25, count($authors)),
     '#description' => t('Select an author from the list.'),
     );
@@ -1498,3 +1537,34 @@ function quotes_validate($node, &$form) 
 
   _quotes_parse_import($node, TRUE);
 }
+
+/*
+ * implementation of hook_token_values
+ *
+ */
+function quotes_token_values($type, $object = NULL) {
+  $values = array();
+  switch ($type) {
+    case 'all':
+    case 'node':
+      $author = empty($object->quotes_author) ? 'unspecified' : $object->quotes_author;
+      $values['quotes-author'] = check_plain($author);
+      $values['quotes-author-raw'] = $author;
+      $values['quotes-author-id'] = $object->quotes_aid;
+      break;
+  }
+  return $values;
+}
+
+function quotes_token_list($type = 'all') {
+  $tokens = array();
+  switch($type) {
+    case 'all':
+    case 'node':
+      $tokens['node']['quotes-author'] = t('The author of this quote.');
+      $tokens['node']['quotes-author-raw'] = t('The author of this quote. WARNING - raw user input.)');
+      $tokens['node']['quotes-author-id'] = t('The author id of this quote.)');
+      break;
+  }
+  return $tokens;
+}
