Re: plugin.php - extend constraint
[email protected] (LuigiT) Tue, 22 Apr 2003 09:24:33 GMT
| Newsgroups | gmane.comp.web.phpopentracker.devel |
|---|---|
| Message-ID | <[email protected]> |
In Thu, 17 Apr 2003 16:27:13 +0200, Sebastian Bergmann <[email protected]> ha scritto: >LuigiT wrote: >> modify to plugin.php v 1.18 2003/02/09 08:21:13 bergmann > > Could you please provide a unified diff (cvs diff -u) of your patch > against the CVS HEAD revision of that file? Hi, sorry for my holiday :-) I'm not very know with CVS. I hope you understand something. LuigiT cvs diff -u -wb Plugin.php (in directory F:\cvs\luigi\tracker\phpOpenTracker\API\) Index: Plugin.php =================================================================== RCS file: f:/cvs/tracker/phpOpenTracker/API/Plugin.php,v retrieving revision 1.1.1.1 diff -u -w -b -r1.1.1.1 Plugin.php --- Plugin.php 22 Apr 2003 08:32:57 -0000 1.1.1.1 +++ Plugin.php 22 Apr 2003 09:12:52 -0000 @@ -14,14 +14,14 @@ // | Author: Sebastian Bergmann <[email protected]> | // +---------------------------------------------------------------------+ // -// $Id: Plugin.php,v 1.1.1.1 2003/04/22 08:32:57 wina Exp $ +// $Id: Plugin.php,v 1.18 2003/02/09 08:21:13 bergmann Exp $ // /** * Base Class for phpOpenTracker API plugins * * @author Sebastian Bergmann <[email protected]> -* @version $Revision: 1.1.1.1 $ +* @version $Revision: 1.18 $ * @since phpOpenTracker 1.0.0 */ class phpOpenTracker_API_Plugin { @@ -69,12 +69,43 @@ function _constraint($constraints, $selfJoinPossiblyRequired = false) { $constraint = ''; $selfJoinRequired = false; + $field_bf = ''; - foreach ($constraints as $field => $value) { + foreach ($constraints as $campo => $value_new) { + + //luigi estrazione campo (extract field from constraint) + $field = substr($campo, 0, strcspn ( $campo, "0123456789")); + //luigi compatibilità con le vecchie versioni (compatibility with old version) + if (is_array($value_new)) { + $value = $value_new[0]; + if ($field_bf != $field) { + $comp = $value_new[1]; + } + } + else { + $value = $value_new; + $comp = "="; + } + //luigi concatenazione (connecting rules) + if ($field_bf != $field) { + if ($field_bf != '') { + $constraint .= ") AND ("; + } + else { + $constraint .= " AND (("; + } + $field_bf = $field; + } + else { + if ($comp === "=") + $constraint .= " OR "; + else + $constraint .= " AND "; + } switch ($field) { case 'document': { $constraint .= sprintf( - " AND accesslog%s.document_id = %d", + " accesslog%s.document_id = %d", ($selfJoinPossiblyRequired) ? '2' : '', $value, @@ -86,10 +117,9 @@ } } break; - case 'entry_document': { $constraint .= sprintf( - " AND accesslog%s.document_id = %d AND accesslog%s.entry_document = '1'", + " accesslog%s.document_id = %d AND accesslog%s.entry_document = '1'", ($selfJoinPossiblyRequired) ? '2' : '', $value, @@ -104,7 +134,7 @@ case 'exit_document': { $constraint .= sprintf( - ' AND accesslog%s.document_id = %d AND accesslog%s.exit_target_id <> 0', + ' accesslog%s.document_id = %d AND accesslog%s.exit_target_id <> 0', ($selfJoinPossiblyRequired) ? '2' : '', $value, @@ -119,7 +149,7 @@ case 'exit_target': { $constraint .= sprintf( - ' AND accesslog%s.exit_target_id = %d', + ' accesslog%s.exit_target_id = %d', ($selfJoinPossiblyRequired) ? '2' : '', $value @@ -136,16 +166,20 @@ case 'referer': case 'user_agent': { $constraint .= sprintf( - ' AND visitors.%s_id = %d', + ' visitors.%s_id %s %d', $field, + $comp, $value ); } break; } } - + //luigi chiusura concatenazione (close rules) + if ($field_bf != '') { + $constraint .= "))"; + } if ($selfJoinPossiblyRequired) { return array( $constraint, ***** CVS exited normally with code 1 ***** ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf