[interchange-cvs] interchange - heins modified code/SystemTag/tree.coretag
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Thu Aug 1 23:31:01 2002
User: heins
Date: 2002-08-02 03:30:49 GMT
Modified: code/SystemTag tree.coretag
Log:
* Honor HIDE_FIELD in queries.
* Add ability to add additional WHERE clauses in queries, so that you can
exclude certain things. For instance,
[tree
start=3DProducts
where=3D"distributor_only =3D '[scratch dealer]'"
....
]
Revision Changes Path
1.2 +15 -3 interchange/code/SystemTag/tree.coretag
rev 1.2, prev_rev 1.1
Index: tree.coretag
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /anon_cvs/repository/interchange/code/SystemTag/tree.coretag,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- tree.coretag 29 Jan 2002 05:52:38 -0000 1.1
+++ tree.coretag 2 Aug 2002 03:30:49 -0000 1.2
@@ -30,7 +30,9 @@
=20
my $sort =3D '';
if($opt->{sort}) {
- $sort .=3D ' ORDER BY ';
+ $sort .=3D ' ';
+ $sort .=3D 'ORDER BY '
+ unless $opt->{sort} =3D~ /^\s*order\s+by\s+/i;
my @sort;
@sort =3D ref $opt->{sort}
? @{$opt->{sort}}=09
@@ -43,7 +45,17 @@
undef $opt->{sort};
}
=20
- my $qb =3D "select * from $table where $parent =3D $qkey$sort";
+ my $where =3D '';
+ if( my $f =3D $db->config('HIDE_FIELD')) {
+ $where .=3D " AND $f !=3D 1";
+ }
+
+ if($opt->{where}) {
+ $where .=3D " AND ($opt->{where})";
+ }
+
+ my $qb =3D "select * from $table where $parent =3D $qkey$where$sort";
+
my $ary =3D $db->query( {
hashref =3D> 1,
sql =3D> $qb,
@@ -135,7 +147,7 @@
my $a;
if ($opt->{autodetect} or ! $stop) {
my $key =3D $db->quote($next, $parent);
- my $q =3D "SELECT * FROM $table WHERE $parent =3D $key$sort";
+ my $q =3D "SELECT * FROM $table WHERE $parent =3D $key$where$sort";
#::logDebug("next row query=3D$q");
$a =3D $db->query(
{=20