Index: openacs-4/packages/tasks/lib/tasks-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks-postgresql.xql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/tasks/lib/tasks-postgresql.xql 14 Oct 2005 13:50:07 -0000 1.7 +++ openacs-4/packages/tasks/lib/tasks-postgresql.xql 18 Oct 2005 15:32:25 -0000 1.8 @@ -108,7 +108,7 @@ and ao.object_id = t.task_id and ao.package_id = :package_id and t.start_date < now() - and t.party_id = :party_id + $employee_where_clause [template::list::page_where_clause -and -name tasks -key t.task_id] [template::list::filter_where_clauses -and -name tasks] [template::list::orderby_clause -orderby -name tasks] @@ -124,7 +124,7 @@ and ao.object_id = t.task_id and ao.package_id = :package_id and t.start_date < now() - and t.party_id = :party_id + $employee_where_clause [template::list::filter_where_clauses -and -name tasks] [template::list::orderby_clause -orderby -name tasks] Index: openacs-4/packages/tasks/lib/tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/tasks/lib/tasks.adp 29 Sep 2005 13:17:53 -0000 1.3 +++ openacs-4/packages/tasks/lib/tasks.adp 18 Oct 2005 15:32:25 -0000 1.4 @@ -4,4 +4,8 @@ #tasks.Assign_Process#

+ + + +
Index: openacs-4/packages/tasks/lib/tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/tasks/lib/tasks.tcl 17 Oct 2005 15:09:40 -0000 1.11 +++ openacs-4/packages/tasks/lib/tasks.tcl 18 Oct 2005 15:32:25 -0000 1.12 @@ -1,5 +1,33 @@ +# Usage: +# +# +# page, page_flush and page_size For pagination +# order_by For the order_by clause +# emp_f Filter to specify if you are going to show the tasks of the organizations only (1) or +# or also the employess tasks (2), default to 2. +# show_filters_p Boolean to specify if you want to show the filters menu or not. Default to 0 + + set tasks_url "/tasks/" +if { ![exists_and_not_null show_filters_p] } { + # Boolean to especify to show the filters or not + set show_filters_p 0 +} + +if { ![exists_and_not_null emp_f] } { + # Show tasks of the employees + set emp_f 2 +} + # If we are not viewing the tasks of a party, view the tasks of the user if {![exists_and_not_null party_id]} { @@ -45,6 +73,35 @@ } else { set group_where_clause "and group_distinct_member_map.group_id = [contacts::default_group]" } + +set filters_list [list user_id [list where_clause "ao.creation_user = :user_id"] \ + search_id {} \ + query {} \ + page_size {} \ + tasks_interval {} \ + process_instance {}] + +# We are going to verify if the party_id is an organization +# if it is, then we would retrieve the tasks also of the +# employees of the organization. + +set employee_where_clause "and t.party_id = :party_id" +if { [apm_package_installed_p organizations] && [exists_and_not_null contact_id]} { + set org_p [organization::organization_p -party_id $contact_id] + if { $org_p } { + lappend filters_list emp_f { + label "[_ mail-tracking.Emails_to]" + values { {"[_ mail-tracking.Organization]" 1} { "[_ mail-tracking.Employees]" 2 }} + } + } + + if { $org_p && [string equal $emp_f 2] } { + set emp_list [contact::util::get_employees -organization_id $contact_id] + lappend emp_list $contact_id + set employee_where_clause " and t.party_id in ([template::util::tcl_to_sql_list $emp_list])" + } +} + set done_url [export_vars -url -base "${tasks_url}contact" {orderby {status_id 2} {party_id $contact_id}}] set not_done_url [export_vars -url -base "${tasks_url}contact" {orderby {status_id 1} {party_id $contact_id}}] set return_url "[ad_conn url]?[ad_conn query]" @@ -125,19 +182,8 @@ -sub_class { narrow } \ - -filters { - party_id { - where_clause {t.party_id = :party_id} - } - user_id { - where_clause {ao.creation_user = :user_id} - } - search_id {} - query {} - page_size {} - tasks_interval {} - process_instance {} - } -orderby { + -filters $filters_list \ + -orderby { default_value "priority,desc" date { label "[_ tasks.Due]"