Index: openacs-4/packages/openfts-driver/tcl/openfts-driver-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/openfts-driver/tcl/openfts-driver-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/openfts-driver/tcl/openfts-driver-procs.tcl 1 Sep 2001 20:33:52 -0000 1.1 +++ openacs-4/packages/openfts-driver/tcl/openfts-driver-procs.tcl 15 Sep 2001 21:31:50 -0000 1.2 @@ -2,6 +2,9 @@ query offset limit + user_id + df + dt } { @author Neophytos Demetriou } { @@ -10,7 +13,6 @@ set result(ids) "" set result(stopwords) "" - array set self [Search::OpenFTS::new ofts] if ![array size self] { error "Search failed." @@ -42,22 +44,45 @@ } set txttbl [split $opt(txttid) .] + + set date_range_condition "" + if { $df != "" } { + append date_range_condition "'$df' <= last_modified and" + } + if { $dt != "" } { + append date_range_condition "'$dt' >= last_modified and" + } + + set permission_check_enabled_p [ad_parameter -package_id [apm_package_id_from_key openfts-driver] permission_check_enabled_p] + set permission_check_condition "" + if { $permission_check_enabled_p } { + append permission_check_condition "and acs_permission__permission_p( $opt(txttid), $user_id, 'read') = 't'" + } + set sql_count " select count(*) from [lindex $txttbl 0]$tables - where $condition" + where + $date_range_condition + $condition + $permission_check_condition" set sql_sort " - select $opt(txttid) as id$out + select $opt(txttid) as object_id$out from [lindex $txttbl 0]$tables - where $condition + where + $date_range_condition + $condition + $permission_check_condition $order limit $limit offset $offset" set result(stopwords) $opt(rejected) set result(count) [db_exec_plsql sql_count $sql_count] - db_foreach sql_sort $sql_sort {lappend result(ids) $id} + if { $result(count) > 0} { + db_foreach sql_sort $sql_sort {lappend result(ids) $object_id} + } return [array get result] } @@ -113,7 +138,7 @@ } { openfts_driver__unindex $tid - openfts_driver__index $tid $txt $title + openfts_driver__index $tid $txt $title $keywords return }