diff -ud ed_classified.orig/ed_classified.install ed_classified/ed_classified.install
--- ed_classified.orig/ed_classified.install	2008-08-10 18:15:44.000000000 -0700
+++ ed_classified/ed_classified.install	2008-10-10 23:45:24.000000000 -0700
@@ -14,6 +14,7 @@
     'fields' => array(
       'vid'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'nid'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'classified_auth' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
       'expires_on' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'expiration_notify_last_sent' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
     ),
diff -ud ed_classified.orig/ed_classified.module ed_classified/ed_classified.module
--- ed_classified.orig/ed_classified.module	2008-08-10 22:57:04.000000000 -0700
+++ ed_classified/ed_classified.module	2008-10-10 23:45:24.000000000 -0700
@@ -11,7 +11,7 @@
    * license terms.  Possession and use of this code signifies acceptance of license
    * terms.
    */
-  
+
   /** 
    * If you want to remove taxonomy links from the node, and you are using the phptemplate theme engine,
    * Simply create a node-ed_classified.tpl.php and remove (or modify) the contents of the $terms 
@@ -33,7 +33,7 @@
  *
  * Also note: you must clear the menu caches in order to see this change take effect post-install.
  */
-define('EDI_CLASSIFIED_PATH_NAME', 'ed-classified');  
+define('EDI_CLASSIFIED_PATH_NAME', 'ed-classified');
 
 
 define('EDI_CLASSIFIED_MODULE_VERSION', '$Id: ed_classified.module,v 1.1.4.45.2.2 2008/08/11 05:57:04 inactivist Exp $');
@@ -72,7 +72,7 @@
   $parms = _ed_classified_displayname_parms();
   if ($op == 'list') {
     $blocks[0]['info'] = t('@name - Popular (requires access log enabled)', $parms);
-    $blocks[1]['info'] = t('@name - Latest', $parms); 
+    $blocks[1]['info'] = t('@name - Latest', $parms);
     $blocks[2]['info'] = t('@name - Stats', $parms);
     return $blocks;
   }
@@ -137,7 +137,9 @@
 
 function ed_classified_form_alter(&$form, $form_state, $form_id) {
   if ($form['type']['#value'] == EDI_CLASSIFIED_MODULE_NAME) {
-    if ($form_id == 'ed_classified_node_form' && $form['attachments'] && _ed_classified_variable_get('alter_attachment_text', EDI_CLASSIFIED_VAR_DEF_ALTER_ATTACHMENT_TEXT) ) {
+    if ($form_id == 'ed_classified_node_form'
+    && $form['attachments']
+    && _ed_classified_variable_get('alter_attachment_text', EDI_CLASSIFIED_VAR_DEF_ALTER_ATTACHMENT_TEXT)) {
       // Don't allow the attachments block to be collapsed.
       $form['attachments']['#collapsed']=FALSE;
       $form['attachments']['#collapsible']=FALSE;
@@ -247,51 +249,55 @@
   $parms = _ed_classified_displayname_parms();
   $name = _ed_classified_displayname();
 
-
   $items[EDI_CLASSIFIED_PATH_NAME] = array(
-                                           'title' => $name,
-                                           'access arguments' => array('access content'),
-                                           'type' => MENU_NORMAL_ITEM, // MENU_SUGGESTED_ITEM,
-                                           'page callback' => 'ed_classified_page');
+    'title' => $name,
+    'access arguments' => array('access content'),
+    'type' => MENU_NORMAL_ITEM, // MENU_SUGGESTED_ITEM,
+    'page callback' => 'ed_classified_page'
+  );
 
   $items['admin/content/node/' . EDI_CLASSIFIED_PATH_NAME] = array(
-                                                              'title' => _ed_classified_displayname(), 
-                                                              'access arguments' => array('administer classified ads'),
-                                                              'type'     => MENU_LOCAL_TASK,
-                                                              'page callback' => 'ed_classified_admin_overview'
-                                                                   );
+    'title' => _ed_classified_displayname(), 
+    'access arguments' => array('administer classified ads'),
+    'type' => MENU_LOCAL_TASK,
+    'page callback' => 'ed_classified_admin_overview'
+  );
 
   $items['admin/content/' . EDI_CLASSIFIED_PATH_NAME] = array(
-                                                              'title' => _ed_classified_displayname(), 
-                                                              'access arguments' => array('administer classified ads'),
-                                                              'type'     => MENU_NORMAL_ITEM,
-                                                              'page callback' => 'ed_classified_admin_overview',
-                                                              'description' => 'List and manage ' . $name .' nodes.'
-                                                                   );
-  $items['admin/settings/'. EDI_CLASSIFIED_PATH_NAME] = array(
-                                                              'title' => 'Configure ' . $name . ' settings', 
-                                                              'title arguments' => $parms,
-                                                              'description' => "Configure $name settings",
-                                                              'page callback' => 'drupal_get_form',
-                                                              'page arguments' => array('ed_classified_admin_settings'),
-                                                              'access arguments' => array('administer site configuration'),
-                                                              'type' => MENU_NORMAL_ITEM, // optional
-                                                              );
+    'title' => _ed_classified_displayname(), 
+    'access arguments' => array('administer classified ads'),
+    'type' => MENU_NORMAL_ITEM,
+    'page callback' => 'ed_classified_admin_overview',
+    'description' => 'List and manage ' . $name .' nodes.'
+  );
+
+  $items['admin/settings/' . EDI_CLASSIFIED_PATH_NAME] = array(
+    'title' => $name, 
+    'title arguments' => $parms,
+    'description' => "Configure $name settings",
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('ed_classified_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM, // optional
+  );
+
   $items['admin/' . EDI_CLASSIFIED_PATH_NAME . '/purge'] = array(
-                                                                 'title' => 'purge',
-                                                                 'page callback' => '_ed_classified_purge',
-                                                                 'access arguments' => array(user_access('administer classified ads')),
-                                                                 'type' => MENU_CALLBACK);
-  
+    'title' => 'purge',
+    'page callback' => '_ed_classified_purge',
+    'access arguments' => array(user_access('administer classified ads')),
+    'type' => MENU_CALLBACK
+  );
+
   /* per-user options - use menu loader wildcards */
-  $items['user/%user/'.EDI_CLASSIFIED_PATH_NAME] = array(
-                                                         'title' => 'My @name list',
-                                                         'title arguments' => $parms,
-                                                         'page callback' => 'ed_classified_by_user',
-                                                         'page arguments' => array(arg(1)),
-                                                         'access arguments' => array('access user profiles'),
-                                                         'type' => MENU_LOCAL_TASK,
-                                                         );
+  $items['user/%user/' . EDI_CLASSIFIED_PATH_NAME] = array(
+    'title' => 'My @name list',
+    'title arguments' => $parms,
+    'page callback' => 'ed_classified_by_user',
+    'page arguments' => array(1),
+    'access arguments' => array('access user profiles'),
+    'type' => MENU_LOCAL_TASK,
+  );
+
   return $items;
 }
 
@@ -302,8 +308,12 @@
 /**
  * Get a list of classified ads for a given user
  */
-function ed_classified_by_user($uid=0) {
-  return ed_classified_admin_overview($uid);
+function ed_classified_by_user($account) {
+  if (!$account) {
+    drupal_not_found();
+    return;
+  }
+  return ed_classified_admin_overview($account->uid);
 }
 
 /**
@@ -315,11 +325,11 @@
   $can_edit = user_access('administer classified ads') || ($uid == $user->uid && user_access('edit own classified ads'));
   $showstats = module_exists('statistics') && variable_get('statistics_count_content_views', 0);
   $header = array(
-                  array('data' => t('Title'),        'field' => 'title'),
-                  /*    array('data' => t('Creator'),      'field' => ' */
+                  array('data' => t('Title'),      'field' => 'title'),
+                  /*array('data' => t('Creator'),    'field' => ''), */
                   array('data' => t('Created'),    'field' => 'created'),
                   array('data' => t('Published?'), 'field' => 'status'),
-                  array('data' => t('Expires'),      'field' => 'expires_on'));
+                  array('data' => t('Expires'),    'field' => 'expires_on'));
   if ($showstats) {
     $header[] = array('data' => t('Total'), 'field' => 'totalcount');
     $header[] = array('data' => t('Recent'), 'field' => 'daycount');
@@ -334,13 +344,13 @@
 
   
   if ($expired) {
-    $unpublished = ' AND n.status = 0 and ec.expires_on < ' . time();
+    $unpublished = ' AND n.status = 0 AND ec.expires_on < ' . time();
   }
 
   // if statistics enabled, etc.
   if ($showstats) {
-  // outer join allws us to see nodes that have no entries in the node_counter table
-  $sql = "SELECT * FROM {node} n, {edi_classified_nodes} ec LEFT OUTER JOIN {node_counter} ON node_counter.nid = ec.nid WHERE n.vid = ec.vid $unpublished $user_select "  . tablesort_sql($header);
+    // outer join allows us to see nodes that have no entries in the node_counter table
+    $sql = "SELECT n.*, ec.classified_auth, ec.expires_on, ec.expiration_notify_last_sent, nc.totalcount, nc.daycount FROM {node} n, {edi_classified_nodes} ec LEFT OUTER JOIN {node_counter} AS nc ON nc.nid = ec.nid WHERE n.vid = ec.vid $unpublished $user_select "  . tablesort_sql($header);
   }
   else {
     $sql = "SELECT * FROM {node} n, {edi_classified_nodes} ec WHERE n.vid = ec.vid $unpublished $user_select "  . tablesort_sql($header);
@@ -358,22 +368,33 @@
                     array('data' => $expired ? t('expired') : format_date($ad->expires, 'custom', 'n/j/y', $ad->expires_on) . t(' (!expire_interval)', array('!expire_interval'=>$expire_interval)),  'nowrap' => 'nowrap', 
                           'class'=>$expired ? 'classified-expired-flag' : 'classified-unexpired-flag'));
     if ($showstats) {
-      $fields[] = array('data' => $ad->totalcount);
-      $fields[] = array('data' => $ad->daycount);
+      // because some nodes may never have been counted, we put 0 by default
+      $fields[] = array('data' => ($ad->totalcount == NULL ? 0 : $ad->totalcount));
+      $fields[] = array('data' => ($ad->daycount == NULL ? 0 : $ad->daycount));
+    }
+    if ($can_edit) {
+      $fields[] = array('data' => ' [' . _ed_classified_make_edit_link($ad, 'edit') .']');
     }
-    $fields[] = $can_edit ? array('data' => ' [' . _ed_classified_make_edit_link($ad, 'edit') .']') : '';
 
     $rows[] = $fields;
   }
 
   // TODO: use similar approach as the /admin/node page - checkboxes, delete button, confirmation
   if($uid != 0 && user_access('create classified ads')) {
-    $output = '<div class="classified-profile-link-add">' . l(t('Create a new ad'),drupal_get_path_alias("node/add/".EDI_CLASSIFIED_PATH_NAME)) . "</div>\n";
+    $output = '<div class="classified-profile-link-add">'
+      . l(t('Create a new ad'),
+          drupal_get_path_alias("node/add/" . EDI_CLASSIFIED_PATH_NAME),
+          array('attributes' => array('title' => t("Click here to create a new Classified Ad."))))
+      . "</div>\n";
   }
 
   $output .=  theme('table', $header, $rows) . theme('pager', NULL, 50, 0);
-  if ($uid == 0 && user_access('administer classified ads'))
-    $output .= l(t('purge old expired ads'), drupal_get_path_alias('admin/' . EDI_CLASSIFIED_PATH_NAME . '/purge'));
+  if ($uid != 0 && user_access('administer classified ads')) {
+    $days = _ed_classified_variable_get('ad_expired_purge_age', EDI_CLASSIFIED_VAR_DEF_PURGE_AGE);
+    $output .= l(t('Purge old expired ads'),
+      drupal_get_path_alias('admin/' . EDI_CLASSIFIED_PATH_NAME . '/purge'),
+      array('attributes' => array('title' => t("Delete ads that are !days days old, marked expired and unpublished.", array('!days' => $days)))));
+  }
  
   return $output;
 }
@@ -392,7 +413,9 @@
     $tree = taxonomy_get_tree(_ed_classified_get_vid(), $cats[$i]->tid, -1);
     $descendant_tids = array_merge(array($cats[$i]->tid), array_map('_taxonomy_get_tid_from_term', $tree));
     $last = db_fetch_object(db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN (%s) AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), implode(',', $descendant_tids), 0, 1));
-    $cats[$i]->latest = node_load(array('nid' => $last->nid));
+    if(isset($last->nid)) {
+      $cats[$i]->latest = node_load(array('nid' => $last->nid));
+    }
   }
 
   // TODO: order by created date, #views, what?
@@ -438,6 +461,7 @@
 function ed_classified_access($op, $node, $account) {
   global $account;
   //echo "hook_access: $op, $node->nid, $account->uid, $node->uid<br/>";
+
   if ($op == 'create') {
     return user_access('create classified ads', $account);
   }
@@ -515,12 +539,14 @@
               '#description'=> t('If this is checked, the ad\'s expiration date will be reset upon saving changes.  Duration may depend on assigned categories.'));
     }
   }
+
   // TODO: Enter additional form elements
   // TODO: Expiration, contact info, category (from the classified taxonomy dedicated to classified)
   // if user has appropriate access, display and allow change of state, expiration date.
   if (user_access('administer classified ads')) {
     // show state here.
   }
+
   // append our form submit handler
   $form['#submit'][]= '_ed_classified_form_submit';
   return $form;
@@ -600,6 +626,7 @@
       $expiration_changed = TRUE;
     }
   }
+
   // log and notify if needed
   if ($expiration_changed) {
     $msg = t('Ad expiration extended from %expires_old to %expires_new.', 
@@ -620,6 +647,10 @@
   }
   else {
     db_query("UPDATE {edi_classified_nodes} SET expires_on='%d' WHERE vid = %d", $node->expires_on, $node->vid);
+    // classified auth is set only if the user has permission
+    if(isset($node->classified_auth)) {
+      db_query("UPDATE {edi_classified_nodes} SET classified_auth = %d WHERE vid = %d", $node->classified_auth, $node->vid);
+    }
   }
 }
 
diff -ud ed_classified.orig/ed_classified_themefuncs.inc ed_classified/ed_classified_themefuncs.inc
--- ed_classified.orig/ed_classified_themefuncs.inc	2008-08-10 18:15:44.000000000 -0700
+++ ed_classified/ed_classified_themefuncs.inc	2008-10-10 23:45:24.000000000 -0700
@@ -43,7 +43,7 @@
   //    var_dump($ads); 
   $content = '';
   foreach($ads as $x) {
-    $content .= '<li>'. l($x->title, drupal_get_path_alias('node/'.$x->nid)); 
+    $content .= '<li class="classified-ad-item">'. l($x->title, drupal_get_path_alias('node/'.$x->nid)); 
     if ($display_ad_category) {
       $term = _ed_classified_get_primary_category($x);
       if ($term) {
@@ -123,8 +123,13 @@
   //      if ($cat->count)
   //        $content.= l('foo', _ed_classified_make_category_path($cat->tid), array('html' => TRUE));
   $content.= theme('ed_classified_category_name', $cat); 
-  if (trim($cat->description) != '')
-    $content.= theme('ed_classified_category_description', $cat);
+
+  // Removed the description from below the name, instead it is integrated with the name
+  // (i.e. it appears as a title in there)
+  //if(trim($cat->description) != '') {
+  //  $content .= theme('ed_classified_category_description', $cat);
+  //}
+
   // TODO: get preview list 
   if ($cat->latest) {
     $content .= '<div class=\'title\'>' . t('Latest ad: ') . l($cat->latest->title, drupal_get_path_alias('node/'.$cat->latest->nid)) . '</div>';
@@ -161,7 +166,8 @@
     $content .= ' class="sticky"';
   }
   $content .= ">\n";
-  $content .= '<h3>'.l($ad->title, drupal_get_path_alias('node/'.$ad->nid))."</h3>";
+  $content .= '<h3>'.l($ad->title, drupal_get_path_alias('node/'.$ad->nid),
+  			array('attributes' => array('title' => 'Description here!')))."</h3>";
   $content .= '<div class=\'classified-description\'>' . check_markup($ad->body, $ad->format, FALSE) . '</div>';
   if (theme_get_setting('toggle_node_info_' . $ad->type)) {
     $content .= '<div class="classified-author">'. t('Posted by: !name', array('!name' => theme('username', $ad))) . "</div>\n";
@@ -179,7 +185,10 @@
 
 function theme_ed_classified_category_name($cat)
 {
-  return '<div class=\'classified-cat-name\'>' . l($cat->name, _ed_classified_make_category_path($cat->tid)) . "</div>\n";
+  return '<div class=\'classified-cat-name\'>'
+  		. l($cat->name, _ed_classified_make_category_path($cat->tid),
+			array('attributes' => array('title' => $cat->description)))
+		. "</div>\n";
 }
 
 function theme_ed_classified_category_description($cat)
diff -ud ed_classified.orig/ed_classified_utils.inc ed_classified/ed_classified_utils.inc
--- ed_classified.orig/ed_classified_utils.inc	2008-08-10 18:15:44.000000000 -0700
+++ ed_classified/ed_classified_utils.inc	2008-10-10 23:45:24.000000000 -0700
@@ -126,14 +126,14 @@
     $duration = 0;
     foreach ($terms as $term) {
       if ($term) {
-        $d = _ed_classified_get_duration($term);
+        $d = _ed_classified_get_duration($term->tid);
         if ($d > $duration) $duration = $d;
       }
     }
     return $duration; 
   }
   else {
-    return _ed_classified_get_duration($terms);
+    return _ed_classified_get_duration($terms->tid);
   }
 }
 
@@ -178,7 +178,10 @@
  * Get a list of latest ads for block use
  */
 function ed_classified_get_latest_ads_list() {
-  $q = db_query('select title, nid, created as timestamp, changed from {node} where type="ed_classified" AND status = 1 ORDER BY created DESC LIMIT %d;', _ed_classified_variable_get('block_latest_limit', 4));
+  $q = db_query('SELECT n.title, n.nid, n.created AS timestamp, n.changed'
+     . ' FROM {node} AS n, {edi_classified_nodes} AS ec'
+        . ' WHERE n.type = \'ed_classified\' AND n.status = 1 AND n.nid = ec.nid AND n.vid = ec.vid AND ec.classified_auth <> 0 AND ec.expires_on > ' . time()
+	. ' ORDER BY created DESC LIMIT %d;', _ed_classified_variable_get('block_latest_limit', 4));
   return theme('ed_classified_ads_block', _ed_classified_query_results_to_array($q), TRUE, FALSE, TRUE );
 }
 
@@ -210,7 +213,7 @@
  */
 function ed_classified_get_ad_expiration($nid) {
   $expires = 0;// TODO: need windows-compatible old date - use time()?
-  $q = db_query("select expires_on from {edi_classified_nodes} ecn where ecn.nid = %d;", $nid);
+  $q = db_query("SELECT expires_on FROM {edi_classified_nodes} ecn WHERE ecn.nid = %d;", $nid);
   $num_nodes = db_result($q);
   if ($q && $num_nodes != 0)
     $expires = db_result($q);
