Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cmf/README.txt,v
retrieving revision 1.1
diff -u -r1.1 README.txt
--- README.txt	19 Aug 2008 16:14:43 -0000	1.1
+++ README.txt	13 Jul 2009 18:27:56 -0000
@@ -25,6 +25,12 @@
   administer > site building > modules
 
 
+PERMISSIONS
+-----------
+* filter and manage site content - gives access to the CMF page.
+* view user content list - gives access to the user page.
+
+
 USE
 ---
 1. The functional page to filter and administer content can be found by navigating to:
Index: both.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cmf/both.inc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 both.inc
--- both.inc	3 Dec 2008 18:50:33 -0000	1.1.2.2
+++ both.inc	15 Jul 2009 00:33:26 -0000
@@ -2,6 +2,11 @@
 // $Id: both.inc,v 1.1.2.2 2008/12/03 18:50:33 nunoveloso18 Exp $
 
 /**
+ * @file
+ * Content management filter module file
+ */
+
+/**
  * Defines the form for mixed content administration filter results.
  *
  * @ingroup forms
@@ -11,7 +16,6 @@
  * @return array with forms properties 
  */
 function cmf_admin_both_form() {
-
   $destination = drupal_get_destination();
 
   // build an 'Update options' form
@@ -19,16 +23,16 @@
     $form['options'] = array(
       '#type' => 'fieldset', '#title' => t('Update options'),
       '#prefix' => '<div class="container-inline">', '#suffix' => '</div>'
-    );
+      );
     $form['options']['operation'] = array(
       '#type' => 'select', 
       '#options' => array(
-                      'publish' => t('Publish'), 
-                      'unpublish' => t('Unpublish'), 
-                      'delete' => t('Delete'),
-                    ), 
+        'publish' => t('Publish'), 
+        'unpublish' => t('Unpublish'), 
+        'delete' => t('Delete'),
+        ), 
       '#default_value' => 'publish'
-    );
+      );
     $form['options']['submit'] = array('#type' => 'submit', '#value' => t('Update'));
   }
 
@@ -36,8 +40,7 @@
   $form['header'] = array(
     '#type'  => 'value', 
     '#value' => cmf_build_header(),
-  );
-  
+    );
 
   $result = cmf_perform_query($form['header']['#value']);
   // build a table listing the appropriate objects
@@ -48,18 +51,18 @@
         $object->nid) .' '. theme('mark', node_mark($object->nid, $object->changed)));
       $form['kind']['n-'. $object->nid] = array('#value' => _cmf_get_img('node', t('node')));
       $form['type']['n-'. $object->nid] = $object->type == 'forum' ? array('#value' => '<p title="'. 
-        _cmf_get_forum($object->nid) .'">'. check_plain(node_get_types('name', $object)) .'</p>') : 
-        array('#value' =>  check_plain(node_get_types('name', $object)));
+        _cmf_get_forum($object->nid) .'">'. check_plain(node_get_types('name', $object)) .'</p>')
+        : array('#value' =>  check_plain(node_get_types('name', $object)));
       if (!(arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0)) {
         $form['username']['n-'. $object->nid] = array('#value' => theme('cmf_user', $object->uid));
       }
-      $form['status']['n-'. $object->nid] =  array('#value' =>  ($object->status ? t('published') : 
-        t('not published')));
+      $form['status']['n-'. $object->nid] = array('#value' =>  ($object->status ? t('published') 
+        : t('not published')));
       $form['created']['n-'. $object->nid] = array('#value' => format_date($object->created, 
         'small'));
       if (user_access('filter and manage site content')) {
         $form['operations']['n-'. $object->nid] = array('#value' => l(_cmf_get_img('edit', t('edit')) .' ' 
-          . t('edit'), 'node/'. $object->nid .'/edit', array(), $destination, null, false, true));
+          . t('edit'), 'node/'. $object->nid .'/edit', array(), $destination, NULL, FALSE, TRUE));
       }
     }
     else{
@@ -80,12 +83,11 @@
         'small'));
       if (user_access('filter and manage site content')) {
         $form['operations']['c-'. $object->cid] = array('#value' => l(_cmf_get_img('edit', t('edit')) . 
-          ' '. t('edit'), 'comment/edit/'. $object->cid, array(), $destination, null, false, true));
+          ' '. t('edit'), 'comment/edit/'. $object->cid, array(), $destination, NULL, FALSE, TRUE));
       }
     }
   }
 
-
   if (user_access('filter and manage site content')) {
     $form['objects'] = array('#type' => 'checkboxes', '#options' => $objects);
   }
@@ -94,7 +96,6 @@
   return $form;
 }
 
-
 /** 
  * Form validation before submit. \n
  * We can't execute any 'Update options' if no objects were selected.
@@ -105,7 +106,7 @@
  *
  * @param the ID of the passed form
  * @param array with the form properties values
- */ 
+ */
 function cmf_admin_both_form_validate($form_id, $form_values) {
   $form_values['objects'] = array_diff($form_values['objects'], array(0));
   if (count($form_values['objects']) == 0) {
@@ -114,7 +115,6 @@
   }
 }
 
-
 /** 
  * Handle post-validation form submission. \n
  * Execute the chosen 'Update option' on the selected objects, such as
@@ -126,10 +126,9 @@
  *
  * @param the ID of the passed form
  * @param array with the form properties values
- */ 
+ */
 function cmf_admin_both_form_submit($form_id, $form_values) {
-  
-  // queries building
+  // Queries building.
   switch ($form_values['operation']) {
     case 'publish':
         $node_query    = 'UPDATE {node} SET status = 1 WHERE nid = %d';
@@ -145,7 +144,7 @@
       break;
   }
 
-  // perform queries
+  // Perform queries.
   foreach ($form_values['objects'] as $flag) {
     if ($flag) {
       $object = explode('-', $flag);
@@ -162,7 +161,6 @@
         _comment_update_node_statistics($comment->nid);
         // Allow modules to respond to the updating of a comment.
         comment_invoke_comment($comment, $form_values['operation']);
-
       }
     }
   }
@@ -177,14 +175,13 @@
   }
 }
 
-
 /** 
  * Theme results table.
  *
  * @ingroup themable
  *
  * @return table with filter results
- */ 
+ */
 function theme_cmf_admin_both_form($form) {
   $output = drupal_render($form['options']);
 
Index: cmf.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cmf/cmf.module,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 cmf.module
--- cmf.module	3 Dec 2008 18:50:33 -0000	1.1.2.2
+++ cmf.module	15 Jul 2009 01:06:24 -0000
@@ -9,43 +9,28 @@
  *
  * @attention Copyright (C) 2008 Nuno Veloso <nunoveloso18 (at) gmail (dot) com>
  * @author Nuno André Veloso Matias (http://www.nunoveloso.org)
- *
- * @warning For more information on licensing, read the LICENCE.txt file.
  */
 
-
 /**
  * Implementation of hook_help().
  */
 function cmf_help($section='') {
-
-  $output = '';
-
   switch ($section) {
-
     case "admin/help#cmf":
-
-      $output .= '<p>'.  t('This module adds an easier way for administrators to filter the 
-        content on a Drupal site for administration purposes.') .'</p>';
-
-      $output .= '<p>'.  t('It\'s an improvement over the content page in the administration area 
-        of Drupal. It can show on the same page nodes and comments and adds new filters like role 
-        and author.') .'</p>';
-
+      $output = '<p>'. t("This module adds an easier way for administrators to filter the content on a Drupal site for administration purposes.") .'</p>';
+      $output .= '<p>'. t("It's an improvement over the content page in the administration area of Drupal. It can show on the same page nodes and comments and adds new filters like role and author.") .'</p>';
       break;
   }
   return $output;
 } 
 
-
 /**
  * Implementation of hook_perm().
  */
 function cmf_perm() {
-  return array('admin cmf module', 'filter and manage site content', 'view user content list');
+  return array('filter and manage site content', 'view user content list');
 }
 
-
 /**
  * Implementation of hook_menu().
  */
@@ -62,7 +47,7 @@
       'description' => t('All-in-one advanced filter and management of your site content.'),
       'callback'    => 'cmf_admin_content_page',
       'access'      => $manage_access,
-    );
+      );
 
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
       $items[] = array(
@@ -72,26 +57,24 @@
         'callback'    => 'cmf_admin_content_page',
         'access'      => $manage_access || $view_access,
         'type'        => MENU_LOCAL_TASK,
-      );
+        );
     }
 //  }
   return $items;
 }
 
-
 /** 
  * Called when user goes to example.com/admin/content/filter
  *
  * @return the HTML generated from the $form data structure
- */ 
+ */
 function cmf_admin_content_page() {
-  
   if (!isset($_SESSION['cmf_content_kind'])) {
     $_SESSION['cmf_content_kind'] = 'node';
   }
-  
+
   if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
-    $true = true;
+    $true = TRUE;
   }
 
   $output = drupal_get_form('cmf_filter_form', $true);
@@ -122,10 +105,9 @@
   return $output;
 }
 
-
-/**********************
-*  FILTERS            *
-**********************/ 
+/**
+ * FILTERS
+ */
 
 /**
  * Defines the form for content administration filters.
@@ -133,10 +115,10 @@
  * @ingroup forms
  * @see cmf_filter_form_submit()
  * 
- * @param (optional) true if the filter to be built serves the user profile page
+ * @param (optional) TRUE if the filter to be built serves the user profile page.
  * @return array with forms properties 
  */
-function cmf_filter_form($true = null) {
+function cmf_filter_form($true = NULL) {
   $session = &$_SESSION['cmf_overview_filter'];
   $session = is_array($session) ? $session : array();
   $filters = cmf_filters($true);
@@ -146,7 +128,7 @@
     '#title'       => t('General Settings'),
     '#collapsible' => TRUE,
     '#collapsed'   => TRUE,
-  ); 
+    );
   $form['general']['max-rows'] = array(
     '#type'          => 'textfield', 
     '#title'         => t('Max rows'),
@@ -154,7 +136,7 @@
     '#default_value' => isset($_SESSION['cmf_max_rows']) ? $_SESSION['cmf_max_rows'] : 50,
     '#prefix' => '<div class="container-inline">',
     '#suffix' => '</div>',
-  );
+    );
   $form['general']['kind'] = array(
     '#type'          => 'select', 
     '#title'         => t('Content'),
@@ -162,46 +144,56 @@
     '#default_value' => isset($_SESSION['cmf_content_kind']) ? $_SESSION['cmf_content_kind'] : 
                         'node',
     '#prefix'        => '<div class="container-inline">',
-  );
+    );
   $form['general']['buttons']['apply'] = array(
     '#type'  => 'submit',
      '#value' => t('Apply'),
     '#suffix' => '</div>',
-  );
-
+    );
 
   $i = 0;
   $form['filters'] = array('#type' => 'fieldset',
     '#title' => t('Show only items where'),
     '#theme' => 'node_filters',
-  );
+    );
   foreach ($session as $filter) {
     list($type, $value) = $filter;
     if ($type == 'category') {
       // Load term name from DB rather than search and parse options array.
-      $value = module_invoke('taxonomy', 'get_term', $value);
+      $value = taxonomy_get_term($value);
       $value = $value->name;
     }
+    elseif ($type == 'title') {
+      // Just sanitize it and add quotes.
+      $value = "'". $value ."'";
+    }
     else {
       $value = $filters[$type]['options'][$value];
     }
-    // avoid not applicable filter verbose
-    if ($true && !($type == 'user' || $type == 'blocked' || $type == 'role')) {
-      $string = ($i++ ? '<em>and</em> where <strong>%a</strong> is <strong>%b</strong>' : 
-        '<strong>%a</strong> is <strong>%b</strong>');
-      $form['filters']['current'][] = array('#value' => t($string, 
-        array('%a' => $filters[$type]['title'] , '%b' => $value)));
+    // Avoid not applicable filter verbose. Note '%' does check_plain.
+    if ($type == 'title') {
+      if ($i++) {
+        $form['filters']['current'][] = array('#value' => t('<em>and</em> where <strong>%a</strong> contains <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
+       }
+       else {
+        $form['filters']['current'][] = array('#value' => t('<strong>%a</strong> contains <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
+      }
     }
     else {
-      $string = ($i++ ? '<em>and</em> where <strong>%a</strong> is <strong>%b</strong>' : 
-        '<strong>%a</strong> is <strong>%b</strong>');
-      $form['filters']['current'][] = array('#value' => t($string, 
-        array('%a' => $filters[$type]['title'] , '%b' => $value)));    
+      if ($i++) {
+        $form['filters']['current'][] = array('#value' => t('<em>and</em> where <strong>%a</strong> is <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
+       }
+       else {
+        $form['filters']['current'][] = array('#value' => t('<strong>%a</strong> is <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
+      }
     }
-    // those ifs remove the respective option if it is already being filtered on.
+    // These ifs remove the respective option if it is already being filtered on.
     if ($type == 'type') {
       unset($filters['type']);
     }
+    if ($type == 'title') {
+      unset($filters['title']);
+    }
     if ($type == 'user') {
       unset($filters['users']);
       unset($filters['user']);
@@ -218,7 +210,7 @@
   $script = 'document.getElementById(\'edit-user\').style.display="none"';
 //  $script = 'document.getElementById("edit-user").style.visibility="hidden"';
   drupal_add_js($script, 'inline', 'header');
-*/
+ */
 
   // preparing select boxes
   foreach ($filters as $key => $filter) {
@@ -230,22 +222,29 @@
           '#type'     => 'select', 
           '#options'  => $filter['options'], 
 //          '#disabled' => TRUE,
-        );
+          );
         break;
-        
+
       case 'users':
         $form['filters']['status'][$key] = array(
           '#type'              => 'textfield', 
           '#autocomplete_path' => 'user/autocomplete', 
-          '#size'              => 20,
-        );
+          '#size'              => 39,
+          );
+        break;
+
+      case 'title':
+        $form['filters']['status'][$key] = array(
+          '#type' => 'textfield', 
+          '#size' => 39,
+          );
         break;
-        
+
       default: 
         $form['filters']['status'][$key] = array(
           '#type'    => 'select', 
           '#options' => $filter['options'],
-        );
+          );
     }
   }
   // building radio buttons
@@ -254,27 +253,26 @@
     '#type'          => 'radios', 
     '#options'       => $names, 
     '#default_value' => $keyz[0],
-  );
+    );
   // building buttons depending on the filter state
   $form['filters']['buttons']['submit'] = array(
     '#type'  => 'submit', 
     '#value' => (count($session) ? t('Refine') : t('Filter')),
-  );
+    );
   if (count($session)) {
     $form['filters']['buttons']['undo'] = array(
       '#type'  => 'submit', 
       '#value' => t('Undo'),
-    );
+      );
     $form['filters']['buttons']['reset'] = array(
       '#type'  => 'submit', 
       '#value' => t('Reset'),
-    );
+      );
   }
 
   return $form;
 }
 
-
 /** 
  * Handle post-validation form submission.
  *
@@ -283,46 +281,45 @@
  *
  * @param the ID of the passed form
  * @param array with the form properties values
- */ 
+ */
 function cmf_filter_form_submit($form_id, $form_values) {
   $filters = cmf_filters();
   switch ($form_values['op']) {
     case t('Filter'):
     case t('Refine'):
-    
       if (isset($form_values['filter'])) {
         $filter = $form_values['filter'];
 
         // convert AJAX search value to select box value
         if ($filter == 'users') {
           $users = cmf_get_users('name');
-          
-          $uid = db_result(db_query('
-            SELECT uid
-            FROM {users}
-            WHERE name = "%s"',
-            $form_values['users']
-          ));
-
+          $uid = db_result(db_query('SELECT uid FROM {users} WHERE name = "%s"', $form_values['users']));
           $form_values['user'] = $uid;
-          
           $filter = 'user';
         }
 
+        if ($filter == 'title') {
+          $string = $form_values['title'];
+          $filters['title']['options'][$string] = $string;
+        }
+
         // Flatten the options array to accommodate hierarchical/nested options.
         $flat_options = form_options_flatten($filters[$filter]['options']);
 
-        if (isset($flat_options[$form_values[$filter]])) {
+        if (isset($flat_options[$form_values[$filter]]) || $filter == 'title') {
           $_SESSION['cmf_overview_filter'][] = array($filter, $form_values[$filter]);
         }
       }
       break;
+
     case t('Undo'):
       array_pop($_SESSION['cmf_overview_filter']);
       break;
+
     case t('Reset'):
       $_SESSION['cmf_overview_filter'] = array();
       break;
+
     case t('Apply'):
       $_SESSION['cmf_max_rows'] = $form_values['max-rows'];
       $_SESSION['cmf_content_kind'] = $form_values['kind'];
@@ -354,45 +351,52 @@
   return $output;
 }
 
-
 /**
  * List node administration filters that can be applied.
  *
- * @param (optional) true if the filter to be built serves the user profile page
+ * @param (optional) TRUE if the filter to be built serves the user profile page
  * @return array with filter properties
  */
-function cmf_filters($true = null) {
+function cmf_filters($true = NULL) {
   // Regular filters
-  $filters['status'] = array('title' => t('node status'),
-    'options' => array('status-1'   => t('published'),     'status-0' => t('not published'),
-                       'promote-1'  => t('promoted'),      'promote-0' => t('not promoted'),
-                       'sticky-1'   => t('sticky'),        'sticky-0' => t('not sticky')));
+  $filters['status'] = array(
+    'title' => t('node status'),
+    'options' => array(
+      'status-1'   => t('published'),
+      'status-0' => t('not published'),
+      'promote-1'  => t('promoted'),
+      'promote-0' => t('not promoted'),
+      'sticky-1'   => t('sticky'),
+      'sticky-0' => t('not sticky'),
+      ),
+    );
   $filters['type'] = array('title' => t('node type'), 'options' => node_get_types('names'));
   // The taxonomy filter
   if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) {
     $filters['category'] = array('title' => t('category'), 'options' => $taxonomy);
   }
-  // cmf filters
+  // Cmf filters.
+  $filters['title'] = array('title' => t('title/subject'));
+  // Don't show these on the user page.
   if (!$true) {
     $filters['user'] = array('title' => t('user list'), 'options' => cmf_get_users('names'));
     $filters['users'] = array('title' => t('user name'));
     $filters['role'] = array('title' => t('user role'), 'options' => cmf_get_roles('names'));
-    $filters['blocked'] = array('title' => t('user status'), 'options' => array(1 => t('active'), 
-      0 => t('blocked')));
+    $filters['blocked'] = array('title' => t('user status'), 
+      'options' => array(1 => t('active'), 0 => t('blocked')));
   }
   return $filters;
 }
 
-
-/**********************
-*  QUERIES            *
-**********************/
+/**
+ * QUERIES
+ */
 
 /** 
  * Build the variable parts of the query to be performed regarding the filter status.
  *
  * @return associative array with WHERE JOIN qury parts and respective arguments
- */ 
+ */
 function cmf_build_filter_query() {
   $filters = cmf_filters();
 
@@ -407,24 +411,34 @@
         list($key, $value) = explode('-', $value, 2);
         $where[] = 'n.'. $key .' = %d';
         break;
+
       case 'category':
         $table = "tn$index";
         $where[] = "$table.tid = %d";
         $join .= "INNER JOIN {term_node} $table ON n.nid = $table.nid ";
         break;
+
       case 'type':
         $where[] = "n.type = '%s'";
         break;
+
       case 'user':
         $where[] = "u.uid = %d"; 
         break;
+
       case 'role':
         $where[] = "u.uid = ur.uid AND ur.rid = %d"; 
         $join .= "INNER JOIN {users_roles} ur ON u.uid = ur.uid ";
         break;
+
+      case 'title':
+        $where[] = "n.title LIKE ('%%%s%%')"; 
+        break;
+
       case 'users':
         $where[] = "u.name = '%s'"; 
         break;
+
       case 'blocked':
         $where[] = "u.status = %d AND u.uid != 0";
         break;
@@ -436,20 +450,18 @@
   return array('where' => $where, 'join' => $join, 'args' => $args);
 }
 
-
 /** 
  * Build the header of the result table.
  *
  * @return array respecting tablesort_sql()
- */ 
+ */
 function cmf_build_header() {
-
   $header = array();
 
   if (user_access('filter and manage site content')) {
     $header[] = theme('table_select_header_cell');
   }
-  
+
   switch ($_SESSION['cmf_content_kind']) {
     case 'node':
       $header[] = array('data' => t('Title'), 'field' => 'title');
@@ -461,6 +473,7 @@
       $header[] = array('data' => t('Status'), 'field' => 'status');
       $header[] = array('data' => t('Time'), 'field' => 'created', 'sort' => 'desc');
       break;
+
     case 'comment':
       $header[] = array('data' => t('Subject'), 'field' => 'subject');
       $header[] = array('data' => t('Kind'));
@@ -471,6 +484,7 @@
       $header[] = array('data' => t('Status'), 'field' => 'status');
       $header[] = array('data' => t('Time'), 'field' => 'created', 'sort' => 'desc');
       break;
+
     case 'both':
       $header[] = array('data' => t('Title') .'/'. t('Subject'), 'field' => 'title');
       $header[] = array('data' => t('Kind'));
@@ -485,85 +499,91 @@
   if (user_access('filter and manage site content')) {
     $header[] = array('data' => t('Operations'));
   }
-  
+
   return $header;
 }
 
-
 /** 
- * Permform adjusted query.
+ * Perform adjusted query.
  *
  * @param array respecting tablesort_sql()
  * @return result of permormed query
- */ 
-function cmf_perform_query($header, $kind = null) {
-
+ */
+function cmf_perform_query($header, $kind = NULL) {
   $filter = cmf_build_filter_query();  
 
   if (is_null($kind)) {
     $kind = $_SESSION['cmf_content_kind'];
   }
-  
+
   if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
     $filter['where'] .= ' AND u.uid = '. arg(1);
   }
 
   switch ($kind) {
     case 'node':
-      return pager_query('
-        SELECT n.nid, n.title, n.type, u.name AS username, u.uid, n.status, n.created, n.changed
-        FROM {node} n INNER JOIN {users} u ON n.uid = u.uid '. $filter['join'] . 
-        $filter['where'] . 
-        tablesort_sql($header), 
+      return pager_query('SELECT n.nid, n.title, n.type, u.name AS username, u.uid, n.status, n.created, n.changed
+        FROM {node} n INNER JOIN {users} u ON n.uid = u.uid '
+        . $filter['join']
+        . $filter['where']
+        . tablesort_sql($header), 
         isset($_SESSION['cmf_max_rows']) ? $_SESSION['cmf_max_rows'] : 50, 0, NULL, $filter['args']
       );
       break;
+
     case 'comment':
-      return pager_query('
-        SELECT c.cid, c.subject, c.nid, c.comment, c.timestamp AS created, c.status, c.name, 
+      return pager_query('SELECT c.cid, c.subject, c.nid, c.comment, c.timestamp AS created, c.status, c.name, 
           c.homepage, u.name AS username, u.uid, n.type
-        FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid INNER JOIN {users} u ON u.uid = c.uid 
-          '. $filter['join'] . 
-        $filter['where'] . 
-        tablesort_sql($header), 
+        FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid INNER JOIN {users} u ON u.uid = c.uid '
+        . $filter['join']
+        . $filter['where']
+        . tablesort_sql($header), 
         isset($_SESSION['cmf_max_rows']) ? $_SESSION['cmf_max_rows'] : 50, 0, NULL, $filter['args']
       );
       break;
+
     case 'both':
       $args = array_merge($filter['args'], $filter['args']);
-      return pager_query('
-        SELECT 0 AS cid, n.nid, n.title, NULL AS comment, n.type, u.name AS username, u.uid, 
-          n.status, n.created, n.changed
-        FROM {node} n INNER JOIN {users} u ON n.uid = u.uid '. $filter['join'] . 
-        $filter['where'] .' 
-        UNION
-        SELECT c.cid, c.nid, c.subject AS title, c.comment, n.type, u.name AS username, u.uid, 
+      $where = $filter['where'];
+      $cwhere = str_replace(array('n.title', 'n.uid'), array('c.subject', 'c.uid'), $where);
+      $count_query = 'SELECT ('
+        .'SELECT COUNT(*) FROM {node} n'
+        .' INNER JOIN {users} u ON n.uid = u.uid '
+        . $filter['join']
+        .' '. $where
+        .') + ('
+        .'SELECT COUNT(*) FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid '
+        .' INNER JOIN {users} u ON u.uid = c.uid '
+        . $filter['join']
+        .' '. $cwhere
+        .') AS count';
+      return pager_query('SELECT 0 AS cid, n.nid, n.title, NULL AS comment, n.type, u.name AS username,
+        u.uid, n.status, n.created, n.changed
+        FROM {node} n INNER JOIN {users} u ON n.uid = u.uid '
+        . $filter['join'] 
+        .' '. $where
+        .' UNION SELECT c.cid, c.nid, c.subject AS title, c.comment, n.type, u.name AS username, u.uid, 
           c.status, c.timestamp AS created, 0 AS changed
-        FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid INNER JOIN {users} u ON u.uid = c.uid 
-          '. $filter['join'] .
-        $filter['where'] . 
-        tablesort_sql($header), 
-        isset($_SESSION['cmf_max_rows']) ? $_SESSION['cmf_max_rows'] : 50, 0, NULL, $args
+        FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid INNER JOIN {users} u ON u.uid = c.uid '
+        . $filter['join']
+        .' '. $cwhere
+        . tablesort_sql($header), 
+        isset($_SESSION['cmf_max_rows']) ? $_SESSION['cmf_max_rows'] : 50, 0, $count_query, $args
       );
       break;
   }
 }
 
-
-/**********************
-*  RESULTS            *
-**********************/
-
+/**
+ * RESULTS
+ */
 include(drupal_get_path('module', 'cmf') ."/node.inc");
-
 include(drupal_get_path('module', 'cmf') ."/comment.inc");
-
 include(drupal_get_path('module', 'cmf') ."/both.inc");
 
-
-/**********************
-*  AUX                *
-**********************/
+/**
+ * AUX
+ */
 
 /**
  * Builds a list of available users
@@ -572,30 +592,23 @@
  * @return array of all available users
  */
 function cmf_get_users($op) {
-
   switch ($op) {
     case 'names':
-      $result = db_query('
-        SELECT uid, name
-        FROM {users}
-        WHERE uid != 0
-        ORDER BY name'
-      );
+      $result = db_query('SELECT uid, name FROM {users} WHERE uid <> 0 ORDER BY name');
       break;
   }
 
   $users    = array();
-  $users[0] = variable_get('anonymous', null);
+  $users[0] = variable_get('anonymous', t('anonymous'));
 
   for ($i = 0; $i < db_num_rows($result); $i++) {
     $user = db_fetch_object($result);
     $users[$user->uid] = $user->name;
   }
-  
+
   return $users;
 }
 
-
 /**
  * Builds a list of available roles
  *
@@ -603,14 +616,9 @@
  * @return array of all available roles
  */
 function cmf_get_roles($op) {
-
   switch ($op) {
     case 'names':
-      $result = db_query('
-        SELECT *
-        FROM {role}
-        ORDER BY name'
-      );
+      $result = db_query('SELECT rid, name FROM {role} ORDER BY name');
       break;
   }
 
@@ -620,11 +628,10 @@
     $role = db_fetch_object($result);
     $roles[$role->rid] = $role->name;
   }
-  
+
   return $roles;
 }
 
-
 /**
  * Get the html code of an image
  *
@@ -632,10 +639,9 @@
  * @return html tag img
  */
 function _cmf_get_img($action, $title) {
-
   $path =  base_path() . drupal_get_path('module', 'cmf') .'/images/'. $action .'.png';
 
-  if ($title == null) {
+  if ($title == NULL) {
     $html = '<img src="'. $path .'" alt="untitled image" />';
   }
   else {
@@ -645,7 +651,6 @@
   return $html;
 }
 
-
 /** 
  * Theme (node) type cell on table result.
  *
@@ -653,19 +658,11 @@
  *
  * @param 0 or node type key
  * @return formated (node) type
- */ 
+ */
 function theme_cmf_type($type) { 
-
-  return db_result(db_query('
-    SELECT name
-    FROM {node_type}
-    WHERE type = "%s"',
-    $type
-  ));
-
+  return db_result(db_query('SELECT name FROM {node_type} WHERE type = "%s"', $type));
 } 
 
-
 /** 
  * Theme user cell on table result.
  *
@@ -673,24 +670,15 @@
  *
  * @param user ID
  * @return clickable username with status
- */ 
+ */
 function theme_cmf_user($uid) { 
-
   if ($uid == 0) {
-    return variable_get('anonymous', null);
+    return variable_get('anonymous', t('anonymous'));
   }
 
-  $result = db_query('
-    SELECT name, status
-    FROM {users}
-    WHERE uid = %d',
-    $uid
-  );
-
+  $result = db_query('SELECT name, status FROM {users} WHERE uid = %d', $uid);
   $user = db_fetch_array($result);
-
   $url_alias = _cmf_get_user_path($uid);
-  
   $url = $url_alias ? $url_alias : 'user/'. $uid;
 
   if ($user['status']) {
@@ -698,13 +686,12 @@
   }
   else {
     $output .= l(_cmf_get_img('blocked', t('blocked')) .' '. $user['name'], $url, array(),
-      null, null, false, true);  
+      NULL, NULL, FALSE, TRUE);  
   }
 
   return $output; 
 } 
 
-
 /** 
  * Get the alias path to a user profile
  *
@@ -712,13 +699,7 @@
  * @return the relative URL of the user profile
  */
 function _cmf_get_user_path($uid) {
-
-  return db_result(db_query('
-    SELECT dst
-    FROM {url_alias}
-    WHERE src = "%s";',
-    'user/'. $uid
-  ));
+  return db_result(db_query('SELECT dst FROM {url_alias} WHERE src = "%s";', 'user/'. $uid));
 }
 
 /** 
@@ -728,15 +709,11 @@
  * @return the name and forum description
  */
 function _cmf_get_forum($nid) {
-
-	$node = node_load($nid);
-
+  $path = array();
+  $node = node_load($nid);
   $parents = taxonomy_get_parents_all($node->tid);
-
-	foreach ($parents as $parent) {
+  foreach ($parents as $parent) {
     $path[] = $parent->name;
-	}
-
-	return implode(' > ', array_reverse($path));
-
+  }
+  return implode(' > ', array_reverse($path));
 }
Index: comment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cmf/comment.inc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 comment.inc
--- comment.inc	3 Dec 2008 18:50:33 -0000	1.1.2.2
+++ comment.inc	13 Jul 2009 17:44:41 -0000
@@ -2,6 +2,11 @@
 // $Id: comment.inc,v 1.1.2.2 2008/12/03 18:50:33 nunoveloso18 Exp $
 
 /**
+ * @file
+ * Content management filter module file
+ */
+
+/**
  * Defines the form for comments administration filter results.
  *
  * @ingroup forms
@@ -57,7 +62,7 @@
     $form['created'][$comment->cid] = array('#value' => format_date($comment->created, 'small'));
     if (user_access('filter and manage site content')) {
       $form['operations'][$comment->cid] = array('#value' => l(_cmf_get_img('edit', t('edit')) .' '. 
-        t('edit'), 'comment/edit/'. $comment->cid, array(), $destination, null, false, true));
+        t('edit'), 'comment/edit/'. $comment->cid, array(), $destination, NULL, FALSE, TRUE));
     }
   }
   
@@ -80,7 +85,7 @@
  *
  * @param the ID of the passed form
  * @param array with the form properties values
- */ 
+ */
 function cmf_admin_comments_form_validate($form_id, $form_values) {
   $form_values['comments'] = array_diff($form_values['comments'], array(0));
   if (count($form_values['comments']) == 0) {
@@ -101,7 +106,7 @@
  *
  * @param the ID of the passed form
  * @param array with the form properties values
- */ 
+ */
 function cmf_admin_comments_form_submit($form_id, $form_values) {
   $operations = comment_operations();
   if ($operations[$form_values['operation']][1]) {
@@ -136,7 +141,7 @@
  * @ingroup themable
  *
  * @return table with filter results
- */ 
+ */
 function theme_cmf_admin_comments_form($form) {
   $output = drupal_render($form['options']);
   if (isset($form['title']) && is_array($form['title'])) {
Index: node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cmf/node.inc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 node.inc
--- node.inc	3 Dec 2008 18:50:33 -0000	1.1.2.2
+++ node.inc	13 Jul 2009 17:46:28 -0000
@@ -2,6 +2,11 @@
 // $Id: node.inc,v 1.1.2.2 2008/12/03 18:50:33 nunoveloso18 Exp $
 
 /**
+ * @file
+ * Content management filter module file
+ */
+
+/**
  * Defines the form for nodes administration filter results.
  *
  * @ingroup forms
@@ -11,7 +16,6 @@
  * @return array with forms properties 
  */
 function cmf_admin_nodes_form() {
-
   $destination = drupal_get_destination();
 
   // build an 'Update options' form
@@ -22,7 +26,7 @@
     );
     $options = array();
     foreach (module_invoke_all('node_operations') as $operation => $array) {
-       $options[$operation] = $array['label'];
+      $options[$operation] = $array['label'];
     }
     $form['options']['operation'] = array(
       '#type' => 'select', 
@@ -37,7 +41,7 @@
     '#type'  => 'value', 
     '#value' => cmf_build_header(),
   );
-  
+
   $result = cmf_perform_query($form['header']['#value']);
   // build a table listing the appropriate nodes
   while ($node = db_fetch_object($result)) {
@@ -56,19 +60,18 @@
     $form['created'][$node->nid] = array('#value' => format_date($node->created, 'small'));
     if (user_access('filter and manage site content')) {
       $form['operations'][$node->nid] = array('#value' => l(_cmf_get_img('edit', t('edit')) .' '. 
-        t('edit'), 'node/'. $node->nid .'/edit', array(), $destination, null, false, true));
+        t('edit'), 'node/'. $node->nid .'/edit', array(), $destination, NULL, FALSE, TRUE));
     }
   }
 
   if (user_access('filter and manage site content')) {
     $form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
-   }
+  }
   $form['pager'] = array('#value' => theme('pager', NULL, $_SESSION['cmf_max_rows'], 0));
-  
+
   return $form;
 }
 
-
 /** 
  * Form validation before submit. \n
  * We can't execute any 'Update options' if no nodes were selected.
@@ -79,7 +82,7 @@
  *
  * @param the ID of the passed form
  * @param array with the form properties values
- */ 
+ */
 function cmf_admin_nodes_form_validate($form_id, $form_values) {
   $nodes = array_filter($form_values['nodes']);
   if (count($nodes) == 0) {
@@ -87,7 +90,6 @@
   }
 }
 
-
 /** 
  * Handle post-validation form submission. \n
  * Execute the chosen 'Update option' on the selected nodes, such as
@@ -99,7 +101,7 @@
  *
  * @param the ID of the passed form
  * @param array with the form properties values
- */ 
+ */
 function cmf_admin_nodes_form_submit($form_id, $form_values) {
   $operations = module_invoke_all('node_operations');
   $operation = $operations[$form_values['operation']];
@@ -127,14 +129,13 @@
   }
 }
 
-
 /** 
  * Theme results table.
  *
  * @ingroup themable
  *
  * @return table with filter results
- */ 
+ */
 function theme_cmf_admin_nodes_form($form) {
   $output = drupal_render($form['options']);
   if (isset($form['title']) && is_array($form['title'])) {
@@ -169,4 +170,4 @@
   $output .= drupal_render($form);
 
   return $output;
-}
\ No newline at end of file
+}

