> > Bug (approved)

searching for Item-IDs does not work

Summary

approved
Jul 17, 2006
30 min ... 60 min
100%
Aug 10, 2006
Jul 17, 2006 / pixtur
Aug 10, 2006 / pixtur
pixtur, tino
 

Attached files

No files uploaded
 
This working until v0.06

Issue report

Minor
Not available
WinXP / Firefox 1.5
v0.063
 

8 Comments

tino:It works but...

11 years ago (2. update 11 years ago)

Hey Tom,

I implemented the search for Item-IDs.

But it doesn't work for numbers as a string in an Item so far.

pixtur:Just looked at the code...

11 years ago

Some hints:

please use this convention for else:

if(true) {

}
else {

}


Getting the item could have been implemented much shorter as:


        ### query string is a number? ###
        if(preg_match("/^\s*(\d+)!?\s*$/", $search_query, $matches)) {
          if($item= DbProjectItem::getVisibleById(intval($matches[1]))) {
            if($item->item == ITEM_TASK) {
              $PH->messages[]=__("Jumped to the only result found.");
              $PH->show( 'taskView',array('tsk'=>$tasks[0]->id));
              exit;
            }
            else if {
                #... and so on
            }
          }
        }

This would be valid since the fulltext search engine for mySQL wouldn't allow searching for numbers anyway. So we could guess the entering a valid id is meant as a direct jump.

tom

tino:Reply to Just looked at the code...

11 years ago (2. update 11 years ago)

Hey Tom,

is there something similar to DbProjectItem::getById for non-project items (Companies, Persons)?

tino:Can you give me a hint?

11 years ago (3. update 11 years ago)

Hey Tom,

from pages/search.inc.php

### query string is a number? ###
if(preg_match("/^[0-9]*$/", $search_query, $matches)) {
    # project items like projects, tasks, comments, efforts and files #
    if($item= DbProjectItem::getVisibleById(intval($matches[0]))) {
        new FeedbackMessage(__('Jumped to the only result found.'));
        switch ($item->type) {
            case ITEM_PROJECT:
                $PH->show('projView',array('prj'=>$item->id));
            	exit;
            case ITEM_TASK:
            	$PH->show('taskView',array('tsk'=>$item->id));
            	exit;
            case ITEM_COMMENT:
            	$PH->show('commentView',array('comment'=>$item->id));
            	exit;  
            # effort-view not implemented so far
            /*case ITEM_EFFORT:
            	$PH->show('effortView',array('effort'=>$item->id));
            	exit;  */  
            case ITEM_FILE:
            	$PH->show('fileView',array('file'=>$item->id));
            	exit; 			        			
        }
    }

For the person- and company-search I need something similar to DbProjectItem::getVisibleById.
Is there something similar, Tom?

So I can upload the cleaner and more accessible version of the search by Item-Id's.

tino:Allright...

11 years ago

good morning Tom.

You're right! I'll change it as soon as possible.

Is it right to search for projects, companies and persons too?

pixtur:Reply

11 years ago

we should search for all items that have an TypeView function:
  • Company
  • Person
  • Task
  • Comment
  • Effort
  • Project
  • File

tino:Reply to Reply

11 years ago (4. update 11 years ago)

Okay!
  • Company
  • Person
  • Task - done
  • Comment - done
  • Effort (not implemented cause we have no EffortView yet)
  • Project - done
  • File - done

Tom, do you have an idea with the EffortView.

We can add the search for efforts when we added an EffortView - or have you another idea how we can do it?

pixtur:effortView

11 years ago

Yes this has to be implemented. We need this anyway.

We already have an reference implementation, otherwise I would use the commentView and clone this function. This should not be much work. It's sad but I would need to finish the data-stuff before releason a new version and currently I have not much time for this.

tom