Index: recent_changes.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/recent_changes/recent_changes.module,v retrieving revision 1.5 diff -u -r1.5 recent_changes.module --- recent_changes.module 4 Apr 2007 23:54:17 -0000 1.5 +++ recent_changes.module 23 Apr 2007 08:27:53 -0000 @@ -31,11 +31,58 @@ 'access' => user_access('view revisions'), 'type' => MENU_NORMAL_ITEM ); + $items[] = array( + 'title' => t('Recent changes'), + 'path' => 'admin/settings/recent_changes', + 'callback' => 'drupal_get_form', + 'callback arguments' => array('recent_changes_admin_settings'), + 'access' => user_access('administer site'), + 'type' => MENU_NORMAL_ITEM + ); } return $items; } /** + * Implementing hook_settings + */ +function recent_changes_admin_settings() { + $form['node'] = array( + '#type' => 'fieldset', + '#title' => t('Nodes'), + '#collapsible' => FALSE, + '#collapsed' => TRUE, + ); + $form['node']['recent_changes_show_filter'] = array( + '#type' => 'checkbox', + '#title' => t('Display filter'), + '#default_value' => variable_get('recent_changes_show_filter', TRUE), + '#description' => t('Check if you want to display the content filter.'), + ); + $form['node']['recent_changes_filter_node_type'] = array( + '#type' => 'select', + '#title' => t('Node types to filter on'), + '#default_value' => variable_get('recent_changes_filter_node_type', node_get_types('names')), + '#options' => array_merge(array(''), node_get_types('names')), + '#multiple' => FALSE, + '#description' => t('Select the node types you would like to filter on. Select none for all types.'), + ); + $form['comment'] = array( + '#type' => 'fieldset', + '#title' => t('Comments'), + '#collapsible' => FALSE, + '#collapsed' => TRUE, + ); + $form['comment']['recent_changes_show_comments'] = array( + '#type' => 'checkbox', + '#title' => t('Show comments by default'), + '#default_value' => variable_get('recent_changes_show_comments', TRUE), + '#description' => t('Check if you want to show the comment changes by default.'), + ); + return system_settings_form($form); +} + +/** * Menu callback which displays a list of recent changes. */ function recent_changes_view() { @@ -70,7 +117,7 @@ else { // Default values $show_comments = recent_changes_show_comments(); - $node_type = ''; + $node_type = variable_get('recent_changes_filter_node_type', ''); } // Add feed @@ -481,7 +529,7 @@ list($join, $where, $distinct) = _db_rewrite_sql($result, 'r', 'nid'); if ($node_type) { // Filter on node type - $where .= " AND n.type = '" . check_plain($node_type) . "'"; + $where .= ($where ? ' AND ' : '') . " n.type = '" . check_plain($node_type) . "'"; } if ($join) { $result .= ' ' . $join; @@ -499,7 +547,7 @@ $result = 'SELECT n.type, c.nid, 0 AS vid, c.cid, n.title, c.timestamp, c.subject AS log, c.uid, c.name FROM {comments} c LEFT JOIN {node} n ON c.nid = n.nid'; list($join, $where, $distinct) = _db_rewrite_sql($result, 'c', 'nid'); if ($node_type) { - $where .= " AND n.type = '" . check_plain($node_type) . "'"; + $where .= ($where ? ' AND ' : '') . " n.type = '" . check_plain($node_type) . "'"; } if ($join) { $result .= ' ' . $join;