Add search by node creation date and the author

mohanjith - March 12, 2008 - 20:30
Project:Drupal
Version:7.x-dev
Component:node system
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

It makes sense to be able to search by author and the creation date for a site with many nodes. This patch will add the ability to search by the author and creation date.

AttachmentSize
node.module.patch3.58 KB
Testbed results
node.module.patchfailedFailed: Failed to apply patch. Detailed results

#1

flobruit - March 13, 2008 - 00:30

Attaching a revised version of the patch that is relative to the main drupal folder.

AttachmentSize
search-date-author-233476-1.patch 3.59 KB
Testbed results
search-date-author-233476-1.patchfailedFailed: Failed to apply patch. Detailed results

#2

robertDouglass - April 10, 2008 - 13:57

created-evaluator looks specific to your site. Can you make that a generic Drupal term?

#3

robertDouglass - April 21, 2008 - 18:43

-1 to module_exists('js_calendar') as well.

#4

tbartels - July 3, 2008 - 17:19

created-evaluator is the name of the form-field for the comparison selector, not site-specific

+ $form['advanced']['created']['created-evaluator'] = array(
+ '#type' => 'select',
+ '#title' => t('Created date comparison'),
+ '#options' => array('' => '---', '<' => 'Before', '=' => 'On', '>' => 'After'),
+ '#multiple' => FALSE,
+ );

#5

Susurrus - July 3, 2008 - 18:56

This still needs a reroll minus the js_calendar code.

#6

Susurrus - July 6, 2008 - 00:50
Status:needs review» needs work

#7

Susurrus - July 6, 2008 - 02:09
Status:needs work» needs review

I've rerolled to remove the js_calendar part, renamed created-evaluator to created-comparator, and added the searching code for 'author', which was missing.

Still not really a fan of the organization, but I think fixing that would be for a follow-up patch.

AttachmentSize
search_author_date.patch 3.72 KB
Testbed results
search_author_date.patchfailedFailed: Failed to apply patch. Detailed results

#8

Susurrus - July 6, 2008 - 02:12

Alright, a few tabs in that patch. Here's a new one without tabs.

There should really be a check for all submitted patches through coder.module to confirm that the coding standards were adhered to. Would probably speed up development time.

AttachmentSize
search_author_date.patch 3.72 KB
Testbed results
search_author_date.patchfailedFailed: Failed to apply patch. Detailed results

#9

Susurrus - July 9, 2008 - 20:50

Makes it a little nicer to have the autocomplete feature available for usernames if the user have access user profiles permission.

I would think it'd be easier if the FAPI for textfield could check the menu system for appropriate permissions before attaching autocomplete URLs than having to do the check this way.

AttachmentSize
search_author_date_0.patch 3.87 KB
Testbed results
search_author_date_0.patchfailedFailed: Failed to apply patch. Detailed results

#10

Alex72RM - August 21, 2008 - 06:44

Maybe it's necessary another revision for Drupal 5.10.

The last part of patch doesn't match node.module:

@@ -1978,6 +2030,15 @@
   if (isset($form_state['values']['language']) && is_array($form_state['values']['language'])) {
     $keys = search_query_insert($keys, 'language', implode(',', array_filter($form_state['values']['language'])));
   }
+  if (isset($form_state['values']['author']) && $form_state['values']['author'] != '') {
+    $keys = search_query_insert($keys, 'author', $form_state['values']['author']);
+  }
+  if (isset($form_state['values']['created-comparator']) && $form_state['values']['created-comparator'] != '') {
+    $keys = search_query_insert($keys, 'created-comparator', $form_state['values']['created-comparator']);
+  }
+  if (isset($form_state['values']['created-date']) && $form_state['values']['created-date'] != '' && strtotime($form_state['values']['created-date']) !== FALSE) {
+    $keys = search_query_insert($keys, 'created-date', strtotime($form_state['values']['created-date']));
+  }
   if ($form_state['values']['or'] != '') {
     if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' ' . $form_state['values']['or'], $matches)) {
       $keys .= ' ' . implode(' OR ', $matches[1]);

#11

Susurrus - August 21, 2008 - 20:03

This patch isn't for Drupal 5.x, it's for 7.x, as all feature requests currently should be.

#12

Alex72RM - October 8, 2008 - 10:10
Status:needs review» won't fix

#13

greg.harvey - January 11, 2009 - 15:25
Status:won't fix» needs review

Why was this set to "won't fix"? Looks like a useful addition to node.module to me!

#14

System Message - January 11, 2009 - 15:40
Status:needs review» needs work

The last submitted patch failed testing.

 
 

Drupal is a registered trademark of Dries Buytaert.