Index: openacs-4/packages/mail-tracking/lib/messages.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/lib/messages.tcl,v
diff -u -r1.16 -r1.17
--- openacs-4/packages/mail-tracking/lib/messages.tcl	17 Oct 2005 22:27:58 -0000	1.16
+++ openacs-4/packages/mail-tracking/lib/messages.tcl	18 Oct 2005 16:03:55 -0000	1.17
@@ -4,6 +4,8 @@
 # sender_id     - to filter mails for a single sender
 # package_id    - to filter mails for a package instance
 # object_id     - to filter mails for a object_id
+# page          - to filter the pagination
+# page_size     - to know how many rows show (optional default to 25)
 # show_filter_p - to show or not the filters in the inlcude, default to "t"
 # elements      - a list of elements to show in the list template. If not provided will show all elements.
 #                 Posible elemets are: sender_id recipient_id package_id subject object_id file_ids body sent_date
@@ -29,10 +31,18 @@
 set page_title [ad_conn instance_name]
 set context [list "index"]
 
+if { [info exist object_id] && [empty_string_p $object_id] } {
+   unset object_id
+}
+
 if { ![exists_and_not_null show_filter_p] } {
     set show_filter_p "t"
 }
 
+if { ![exists_and_not_null page_size] } {
+    set page_size 10
+}
+
 set tracking_url [apm_package_url_from_key "mail-tracking"]
 # Wich elements will be shown on the list template
 set rows_list [list]
@@ -57,7 +67,7 @@
 		 package_id {
 		     label "[_ mail-tracking.Package]"
 		     where_clause "package_id = :package_id"	
-		 }]
+		 } ]
 
 set recipient_where_clause ""
 
@@ -81,11 +91,17 @@
     }
 }
 
+
+
+
 template::list::create \
     -name messages \
     -selected_format normal \
     -multirow messages \
-    -key acs_mail_log_id \
+    -key acs_mail_log.log_id \
+    -page_size $page_size \
+    -page_flush_p 0 \
+    -page_query_name "messages_pagination" \
     -row_pretty_plural "[_ mail-tracking.messages]" \
     -elements { 
 	sender_id {
@@ -158,9 +174,7 @@
     } -filters $filters \
 
 
-set orderby [template::list::orderby_clause -name "messages" -orderby]
-
-db_multirow -extend { file_ids object_url sender receiver package_name package_url url_message_id download_files} messages select_messages {} {
+db_multirow -extend { file_ids object_url sender receiver package_name package_url url_message_id download_files} messages select_messages { } {
     set sender ""
     set receiver ""
     if { [catch { set sender [person::name -person_id $sender_id] } errMsg] } {
@@ -210,5 +224,7 @@
 
     set object_url "/o/$object_id"
 }
+
+
  
 ad_return_template
\ No newline at end of file
Index: openacs-4/packages/mail-tracking/lib/messages.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/lib/messages.xql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/mail-tracking/lib/messages.xql	29 Sep 2005 22:42:04 -0000	1.4
+++ openacs-4/packages/mail-tracking/lib/messages.xql	18 Oct 2005 16:02:14 -0000	1.5
@@ -9,9 +9,21 @@
         from acs_mail_log
 	where message_id <> 0
 	$recipient_where_clause
+	[template::list::page_where_clause -and -name messages]		
         [template::list::filter_where_clauses -and -name messages]
         [template::list::orderby_clause -orderby -name messages]
         </querytext>
     </fullquery>
 
+    <fullquery name="messages_pagination">
+        <querytext>
+         select log_id
+        from acs_mail_log	
+	where message_id <> 0	
+	$recipient_where_clause 
+        [template::list::filter_where_clauses -and -name messages]
+        [template::list::orderby_clause -orderby -name messages]
+        </querytext>
+    </fullquery>
+
 </queryset>