]>
src.bluestatic.org Git - bugdar.git/blob - search.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 $fetchtemplates = array (
16 //'search_results_bit'
19 require_once ( './global.php' );
21 if (! can_perform ( 'cansearch' ))
27 define ( 'MODE' , intval ( $bugsys- > in
[ 'mode' ]));
28 define ( 'MODE_ANY' , (( MODE
== 1 ) ? 1 : 0 ));
29 define ( 'MODE_ALL' , (( MODE
== 2 ) ? 1 : 0 ));
30 define ( 'MODE_RAW' , (( MODE
== 3 ) ? 1 : 0 ));
32 define ( 'SEARCH_WORD_MIN' , 3 );
34 // ###################################################################
36 if ( empty ( $_REQUEST [ 'do' ]))
38 $_REQUEST [ 'do' ] = 'search' ;
41 // ###################################################################
43 if ( $_REQUEST [ 'do' ] == 'results' )
45 // -------------------------------------------------------------------
46 // parse out our product/component/version
47 $pcv = parse_pcv_select ( $bugsys- > in
[ 'pcv_select' ]);
49 // -------------------------------------------------------------------
51 if ( $bugsys- > in
[ 'summary' ])
53 $keywords = preg_split ( '#\s+#' , $bugsys- > in
[ 'summary' ]);
55 // #*# need to have some str to bool conversions
57 foreach ( $keywords AS $word )
59 if ( strlen ( $word ) < SEARCH_WORD_MIN
)
66 $querybuild [ 'text' ] .= " + $word" ;
70 $querybuild ['text'] .= " $word" ;
73 if (! preg_match ( '#-(.+?)#' , trim ( $word )))
79 $hilight = preg_replace('#[^0-9a-zA-Z_ ]#', '', $hilight );
80 $hilight = trim( $hilight );
81 $hilight = preg_replace('#\s#', '+', $hilight );
83 $temp = trim( $querybuild ['text']);
85 if (MODE_ALL OR MODE_RAW)
87 $bool_flag = ' IN BOOLEAN MODE';
90 $querybuild ['text'] = " AND\n\t\t\t (\n\t\t\t\t MATCH
( bug
. summary
) AGAINST ( ' $temp' $bool_flag ) \n\t\t\t\t OR MATCH (comment.comment) AGAINST (' $temp'$bool_flag )\n\t\t\t) ";
93 // -------------------------------------------------------------------
95 if ( $bugsys- >in['reporter'])
97 // force email or name?? make a distinction?
98 // more elegant way to do this? probably
99 $user = $db- >query_first(" SELECT
* FROM user WHERE email
= '" . $bugsys- >in[' reporter
'] . "' OR MATCH ( displayname
) AGAINST ( '" . $bugsys- >in[' reporter
'] . "' ) ");
102 $querybuild ['reporter'] = " AND bug
. userid
= $user [ userid
] OR comment
. userid
= $user [ userid
] ";
106 // -------------------------------------------------------------------
107 // product/component/version stuff
108 if (is_array( $bugsys- >in['pcv']))
110 $querybuild ['pcv'] = " AND bug
. productid
= $pcv [ product
] AND bug
. componentid
= $pcv [ component
] AND bug
. versionid
= $pcv [ version
] ";
113 // -------------------------------------------------------------------
114 // severity, priority, status, resolution, assignedto
117 if ( $bugsys- >in['severity'])
119 $querybuild ['severity'] = " AND bug
. severity
= " . intval( $bugsys- >in['severity']);
123 if ( $bugsys- >in['priority'])
125 $querybuild ['priority'] = " AND bug
. priority
= " . intval( $bugsys- >in['priority']);
129 if ( $bugsys- >in['status'])
131 $querybuild ['status'] = " AND bug
. status
= " . intval( $bugsys- >in['status']);
135 if ( $bugsys- >in['resolution'])
137 $querybuild ['resolution'] = " AND bug
. resolution
= " . intval( $bugsys- >in['resolution']);
141 if ( $bugsys- >in['assignedto'])
143 $querybuild ['assignedto'] = " AND bug
. assignedto
= " . intval( $bugsys- >in['assignedto']);
146 // -------------------------------------------------------------------
148 if ( $bugsys- >in['date'])
150 // now - (seconds/day * number of days)
151 $dateline = time() - (intval( $bugsys- >in['date']) * 3600);
152 $querybuild ['date'] = " AND bug
. dateline
>= $dateline" ;
155 // -------------------------------------------------------------------
157 $sortby = array ( 'bugid' , 'severity' , 'priority' , 'status' , 'resolution' , 'dateline' );
158 $orderby = array ( 'ASC' , 'DESC' );
159 $bugsys- > in
[ 'orderby' ] = strtoupper ( $bugsys- > in
[ 'orderby' ]);
160 if ( in_array ( $bugsys- > in
[ 'sortby' ], $sortby ) AND in_array ( $bugsys- > in
[ 'orderby' ], $orderby ))
162 $sortclause = "ORDER BY " . $bugsys- > in
[ 'sortby' ] . ' ' . $bugsys- > in
[ 'orderby' ];
164 else if ( $bugsys- > in
[ 'sortby' ] == 'relevance' )
174 // -------------------------------------------------------------------
176 $search = $db- > query ( "
177 SELECT bug.*, comment.commentid,
178 user1.displayname AS firstreport,
179 user2.displayname AS lastpost
180 FROM " . TABLE_PREFIX
. "bug AS bug
181 LEFT JOIN " . TABLE_PREFIX
. "comment AS comment
182 ON (bug.bugid = comment.bugid)
183 LEFT JOIN user AS user1
184 ON (bug.userid = user1.userid)
185 LEFT JOIN user AS user2
186 ON (bug.lastpostby = user2.userid)
188 " . implode ( " \n\t\t\t " , $querybuild ) . "
192 $numrows = $db- >num_rows( $search );
196 echo 'no results found';
200 while ( $bug = $db- >fetch_array( $search ))
202 $bug ['bgcolour'] = $bugsys- >datastore['status'][" $bug [ status
] "]['color'];
203 $bug ['product'] = $bugsys- >datastore['product'][" $bug [ productid
] "]['title'];
204 $bug ['version'] = $bugsys- >datastore['version'][" $bug [ versionid
] "]['version'];
205 $bug ['status'] = $bugsys- >datastore['status'][" $bug [ status
] "]['status'];
206 $bug ['resolution'] = $bugsys- >datastore['resolution'][" $bug [ resolution
] "]['resolution'];
207 $bug ['lastpostinfo'] = datelike('standard', $bug ['lastposttime']) . ' by ' . $bug ['lastpost'];
208 $bug ['urladd'] = " & amp
; hilight
= $hilight" ;
209 eval ( ' $bugs .= "' . $template- > fetch ( 'trackerhome_bits' ) . '";' );
212 eval ( ' $template- >flush("' . $template- > fetch ( 'search_results' ) . '");' );
214 // print_r($querybuild);
217 // ###################################################################
219 if ( $_REQUEST [ 'do' ] == 'search' )
221 $pcv_select = construct_pcv_select ( 'radio' , '--' );
223 $blankselect = '<option value="0">- Choose -</option>' ;
225 $select [ 'severity' ] = $blankselect ;
226 foreach ( $bugsys- > datastore
[ 'severity' ] AS $severity )
228 $value = $severity [ 'severityid' ];
229 $label = $severity [ 'severity' ];
230 eval ( ' $select [severity] .= "' . $template- > fetch ( 'selectoption' ) . '";' );
233 $select [ 'priority' ] = $blankselect ;
234 foreach ( $bugsys- > datastore
[ 'priority' ] AS $priority )
236 $value = $priority [ 'priorityid' ];
237 $label = $priority [ 'priority' ];
238 eval ( ' $select [priority] .= "' . $template- > fetch ( 'selectoption' ) . '";' );
241 $select [ 'status' ] = $blankselect ;
242 foreach ( $bugsys- > datastore
[ 'status' ] AS $status )
244 $value = $status [ 'statusid' ];
245 $label = $status [ 'status' ];
246 eval ( ' $select [status] .= "' . $template- > fetch ( 'selectoption' ) . '";' );
249 $select [ 'resolution' ] = $blankselect ;
250 foreach ( $bugsys- > datastore
[ 'resolution' ] AS $resolution )
252 $value = $resolution [ 'resolutionid' ];
253 $label = $resolution [ 'resolution' ];
254 eval ( ' $select [resolution] .= "' . $template- > fetch ( 'selectoption' ) . '";' );
257 $select [ 'dev' ] = $blankselect ;
258 foreach ( $bugsys- > datastore
[ 'assignto' ] AS $dev )
260 $value = $dev [ 'userid' ];
261 $label = construct_user_display ( $dev , false );
262 eval ( ' $select [dev] .= "' . $template- > fetch ( 'selectoption' ) . '";' );
265 eval ( ' $template- >flush("' . $template- > fetch ( 'search' ) . '");' );
268 /*=====================================================================*\
269 || ###################################################################
272 || ###################################################################
273 \*=====================================================================*/