Index: openacs-4/packages/tasks/catalog/tasks.de_DE.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/catalog/tasks.de_DE.ISO-8859-1.xml,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/tasks/catalog/tasks.de_DE.ISO-8859-1.xml	8 Sep 2005 10:00:19 -0000	1.2
+++ openacs-4/packages/tasks/catalog/tasks.de_DE.ISO-8859-1.xml	14 Oct 2005 13:50:05 -0000	1.3
@@ -11,7 +11,7 @@
   <msg key="Custom_Task">Spezifische Aufgabe</msg>
   <msg key="Date">Datum</msg>
   <msg key="Delete">L�schen</msg>
-  <msg key="Delete_task_pretty">L�schen $task_pretty</msg>
+  <msg key="Delete_task_pretty">L�schen %task_pretty%</msg>
   <msg key="Done">Erledigt</msg>
   <msg key="Due">F�llig</msg>
   <msg key="Follow_Up_Call">Follow Up Anruf</msg>
@@ -20,19 +20,19 @@
   <msg key="lt_Add_Task_and_Add_Anot">Eine Aufgabe und einen weitere hinzuf�gen </msg>
   <msg key="lt_Add_Task_save________">Aufgabe hinzuf�gen} save} {{&lt;#_ Add Task und eine weitere hinzuf�gen</msg>
   <msg key="lt_Are_you_sure_you_want">Sind Sie sich sicher, dass Sie diesen Prozess l�schen wollen: %one_line% ?</msg>
-  <msg key="lt_Are_you_sure_you_want_1">Sind Sie sich sicher, dass Sie $task2_pretty l�schen wollen?</msg>
+  <msg key="lt_Are_you_sure_you_want_1">Sind Sie sich sicher, dass Sie %task2_pretty% l�schen wollen?</msg>
   <msg key="lt_Delete_from_Recruitin">Vom Recruiting System l�schen</msg>
   <msg key="lt_Either_a_custom_task_">Es ist entweder eine Standardaufgabe oder eine spezifische Aufgabe (custom task) erforderlich.</msg>
-  <msg key="lt_Originally_created_by">Urspr�nglich erzeugt von &lt;a href=\&quot;[contact::url -party_id $creation_id]\&quot;&gt;[contact::name -party_id $creation_id]&lt;/a&gt;</msg>
+  <msg key="lt_Originally_created_by">Urspr�nglich erzeugt von &lt;a href=\&quot;%creator_url%\&quot;&gt;%creator_name%&lt;/a&gt;</msg>
   <msg key="lt_Provide_Promotional_I">Unterlagen zuschicken</msg>
   <msg key="lt_Send_Personal_NoteLet">Notiz/Brief zuschicken</msg>
   <msg key="lt_Standard_tasks_are_ca">Standardaufgaben k�nnen nicht in Kombination mit spezifischen Aufgaben (custom tasks) genutzt werden</msg>
-  <msg key="lt_The_task_a_hreftaskst">Die Aufgabe &lt;a href=\&quot;/tasks/${task_url}\&quot;&gt;$task&lt;/a&gt; wurde hinzugef�gt</msg>
-  <msg key="lt_The_task_a_hreftaskst_1">Die Aufgabe wurde &lt;a href=\&quot;/tasks/${task_url}\&quot;&gt;$title&lt;/a&gt;  upgedated</msg>
-  <msg key="lt_The_task_lindex_task_">Die Aufgabe \&quot;[lindex $task_titles 0]\&quot; wurde gel�scht</msg>
-  <msg key="lt_The_task_task_was_add">Die Aufgaben \&quot;$task\&quot; wurden zu $names hinzugef�gt</msg>
-  <msg key="lt_The_tasks_task_list_w">Die Aufgaben ${task_list} wurden gel�scht</msg>
-  <msg key="lt_these_num_entries_tas">Diese $num_entries Aufgaben</msg>
+  <msg key="lt_The_task_a_hreftaskst">Die Aufgabe &lt;a href=\&quot;/tasks/%task_url%\&quot;&gt;%task%&lt;/a&gt; wurde hinzugef�gt</msg>
+  <msg key="lt_The_task_a_hreftaskst_1">Die Aufgabe wurde &lt;a href=\&quot;/tasks/%task_url%\&quot;&gt;%title%&lt;/a&gt;  upgedated</msg>
+  <msg key="lt_The_task_task_was_add">Die Aufgaben \&quot;%task%\&quot; wurden zu %names% hinzugef�gt</msg>
+  <msg key="lt_The_task_was">Die Aufgabe \&quot;%task_title%\&quot; wurde gel�scht</msg>
+  <msg key="lt_The_tasks_task_list_w">Die Aufgaben %task_list% wurden gel�scht</msg>
+  <msg key="lt_these_num_entries_tas">Diese %num_entries% Aufgaben</msg>
   <msg key="lt_Update_and_Add_New_Ta">Update und Anlegen neue Aufgabe</msg>
   <msg key="lt_You_are_not_allowed_t">Sie sind</msg>
   <msg key="more">mehr</msg>
Index: openacs-4/packages/tasks/lib/tasks-portlet.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks-portlet.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/tasks/lib/tasks-portlet.adp	13 Oct 2005 16:00:29 -0000	1.1
+++ openacs-4/packages/tasks/lib/tasks-portlet.adp	14 Oct 2005 13:50:07 -0000	1.2
@@ -8,7 +8,7 @@
       <tr>
         <td>
 	<include src="/packages/tasks/lib/tasks"
-		user_id=@user_id@
+		party_id=@party_id@
  		query="@query@"
  		search_id="@search_id@"
 		tasks_interval="@tasks_interval@"
Index: openacs-4/packages/tasks/lib/tasks-portlet.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks-portlet.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/tasks/lib/tasks-portlet.tcl	13 Oct 2005 16:00:29 -0000	1.1
+++ openacs-4/packages/tasks/lib/tasks-portlet.tcl	14 Oct 2005 13:50:07 -0000	1.2
@@ -1 +1,7 @@
+foreach optional_param {party_id query search_id tasks_interval} {
+    if {![info exists $optional_param]} {
+	set $optional_param {}
+    }
+}
+
 set portlet_layout [parameter::get -parameter "DefaultPortletLayout"]
\ No newline at end of file
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.6 -r1.7
--- openacs-4/packages/tasks/lib/tasks-postgresql.xql	13 Oct 2005 16:02:44 -0000	1.6
+++ openacs-4/packages/tasks/lib/tasks-postgresql.xql	14 Oct 2005 13:50:07 -0000	1.7
@@ -18,6 +18,7 @@
 		t.status_id, 
 		t.process_instance_id,
            	contact__name(ao.creation_user) as creation_name,
+                contact__name(t.party_id) as contact_name,
            	CASE WHEN t.due_date < now() THEN 't' ELSE 'f' END as due_date_passed_p,
            	s.title as status, 
 		t.object_id
@@ -35,13 +36,14 @@
         and ao.package_id = :package_id
       	and t.start_date < now()
         and t.due_date < ( now() + '$tasks_interval days'::interval )
+	and ao.creation_user = :user_id
         and t.party_id in ( select parties.party_id
                             from parties
                             left join cr_items on (parties.party_id = cr_items.item_id)
                             left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id),
                                  group_distinct_member_map
                             where parties.party_id = group_distinct_member_map.member_id
-                            and group_distinct_member_map.group_id = :group_id
+                            $group_where_clause
                             [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] )
     	[template::list::page_where_clause -and -name tasks -key t.task_id]
 	[template::list::filter_where_clauses -and -name tasks]
@@ -59,13 +61,14 @@
         and ao.package_id = :package_id
         and t.start_date < now()
         and t.due_date < ( now() + '$tasks_interval days'::interval )
+	and ao.creation_user = :user_id
         and t.party_id in ( select parties.party_id
                             from parties
                             left join cr_items on (parties.party_id = cr_items.item_id)
                             left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id),
                                  group_distinct_member_map
                             where parties.party_id = group_distinct_member_map.member_id
-                            and group_distinct_member_map.group_id = :group_id
+                            $group_where_clause
                             [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] )
 	[template::list::filter_where_clauses -and -name tasks]
         [template::list::orderby_clause -orderby -name tasks]
@@ -88,6 +91,7 @@
 		t.status_id, 
 		t.process_instance_id,
            	contact__name(ao.creation_user) as creation_name,
+                contact__name(t.party_id) as contact_name,
            	CASE WHEN t.due_date < now() THEN 't' ELSE 'f' END as due_date_passed_p,
            	s.title as status, 
 		t.object_id
@@ -104,6 +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
     	[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]
@@ -119,6 +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
 	[template::list::filter_where_clauses -and -name tasks]
         [template::list::orderby_clause -orderby -name tasks]
     </querytext>
Index: openacs-4/packages/tasks/lib/tasks.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/tasks/lib/tasks.tcl	12 Oct 2005 13:24:47 -0000	1.8
+++ openacs-4/packages/tasks/lib/tasks.tcl	14 Oct 2005 13:50:07 -0000	1.9
@@ -4,12 +4,14 @@
 if {![exists_and_not_null party_id]} {
 
     # the user_id is used for the filter. user_id2 for comparison
-    set user_id [ad_conn user_id]
+    if {![exists_and_not_null user_id]} {
+	set user_id [ad_conn user_id]
+    }
     set contact_id $user_id
     set user_id2 $user_id
-    
-    # We don't know if the party has been provided, so we first set it to empty
-    # so we can unset it later :).
+    if {$user_id == [ad_conn user_id]} {
+	set user_id2 ""
+    }
     set party_id ""
     unset party_id
     set page_query_name own_tasks_pagination
@@ -21,27 +23,42 @@
     set query_name contact_tasks
 }
 
+set package_id [apm_package_id_from_key tasks]
+
+if { ![exists_and_not_null tasks_interval] } {
+    set tasks_interval 7
+}
 if { ![exists_and_not_null orderby] } {
     set orderby "priority,desc"
 }
 if { ![exists_and_not_null status_id] } {
     set status_id "1"
 }
+if { ![exists_and_not_null package_id] } {
+    set package_id [ad_conn package_id]
+}
+if { ![exists_and_not_null row_list] } {
+    set row_list {checkbox {} deleted_p {} priority {} title {} process_title {} contact_name {} date {} creation_user {}}
+}
+if {[exists_and_not_null search_id]} {
+    set group_where_clause ""
+} else {
+    set group_where_clause "and group_distinct_member_map.group_id = [contacts::default_group]"
+}
 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]"
 set add_url [export_vars -base "${tasks_url}task" {return_url orderby status_id {party_id $contact_id}}]
 set bulk_actions [list "[_ tasks.Reassign]" "reassign-task" "[_ tasks.Reassign_selected]"]
 
-set package_id [ad_conn package_id]
-set group_id "11428599"
 
 template::list::create \
     -name tasks \
     -multirow tasks \
     -bulk_actions $bulk_actions \
     -bulk_action_method post \
     -bulk_action_export_vars { } \
+    -selected_format normal \
     -key task_id \
     -page_size "50" \
     -page_flush_p 0 \
@@ -82,6 +99,10 @@
 		</else>
 	    }
 	}
+        contact_name {
+	    label "[_ tasks.Contact]"
+	    link_url_eval $contact_url
+	} 
         date {
 	    label "[_ tasks.Date]"
 	    display_template {
@@ -141,15 +162,28 @@
             orderby_asc "lower(p.title) asc, t.priority desc, t.due_date asc"
 	    default_direction asc
 	}
+	contact_name {
+	    label "[_ tasks.Created_By]"
+            orderby_desc "lower(contact__name(t.party_id)) desc, t.due_date asc, t.priority, lower(t.title)"
+            orderby_asc "lower(contact__name(t.party_id)) asc, t.due_date asc, t.priority, lower(t.title)"
+	    default_direction asc
+	}
 	creation_user {
 	    label "[_ tasks.Created_By]"
             orderby_desc "lower(contact__name(ao.creation_user)) desc, t.due_date asc, t.priority, lower(t.title)"
             orderby_asc "lower(contact__name(ao.creation_user)) asc, t.due_date asc, t.priority, lower(t.title)"
 	    default_direction asc
 	}
+    } -formats {
+	normal {
+	    label "Table"
+	    layout table
+	    row $row_list
+	}
     }
 
 db_multirow -extend {creation_user_url contact_url complete_url done_p task_plus_url task_minus_url description_html task_url} -unclobber tasks $query_name {} {
+    set contact_url [contact::url -party_id $party_id]
     set creation_user_url [contact::url -party_id $creation_user]
     regsub -all "/tasks/" $creation_user_url "/contacts/" creation_user_url
     set complete_url [export_vars -base "${tasks_url}mark-completed" -url {task_id orderby {party_id $contact_id} return_url}]
Index: openacs-4/packages/tasks/sql/postgresql/tasks-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/sql/postgresql/tasks-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/tasks/sql/postgresql/tasks-create.sql	7 Oct 2005 21:41:44 -0000	1.3
+++ openacs-4/packages/tasks/sql/postgresql/tasks-create.sql	14 Oct 2005 13:50:07 -0000	1.4
@@ -1,120 +1,3 @@
-create table tasks (
-        task_id                 integer
-                                constraint tasks_pk
-                                primary key
-                                constraint tasks_task_fk
-                                references acs_objects,
-        party_id                integer
-                                constraint tasks_party_fk
-                                references parties,
-        object_id               integer
-                                constraint tasks_object_fk
-                                references acs_objects,
-        process_id              integer
-                                constraint tasks_process_fk
-                                references pm_process,
-        title                   varchar(1000),
-        description             text,
-        mime_type               varchar(200) default 'text/plain'
-                                constraint tasks_mime_type_fk
-                                references cr_mime_types,
-        comment                 text,
-        due_date                timestamptz,
-        priority                integer default 0,
-        status                  char(1) default 'o'
-                                constraint tasks_status_ck
-                                check (status in ('o', 'c'))
-);
-
-
-create index tasks_party_idx on tasks(party_id);
-create index tasks_object_idx on tasks(object_id);
-create index tasks_due_date_idx on tasks(due_date);
-create index tasks_status_idx on tasks(status);
-
-create function inline_0 ()
-returns integer as'
-begin
-    perform acs_object_type__create_type(
-        ''tasks_task'',
-        ''Tasks Task'',
-        ''Tasks Tasks'',
-        ''acs_object'',
-        ''tasks'',
-        ''task_id'',
-        ''tasks'',
-        ''f'',
-        null,
-        null
-    );
-
-    return null;
-end;' language 'plpgsql';
-
-select inline_0();
-drop function inline_0();
-
-select define_function_args('tasks__new','party_id,object_id,process_id,title,description,mime_type;text/plain,comment,due_date,priority;0,status;o,creation_date;now,creation_user,creation_ip,package_id');
-
-create or replace function tasks__new (
-  tasks.party_id%TYPE,
-  tasks.object_id%TYPE,
-  tasks.process_id%TYPE,
-  tasks.title%TYPE,
-  tasks.description%TYPE,
-  tasks.mime_type%TYPE,
-  tasks.comment%TYPE,
-  tasks.due_date%TYPE,
-  tasks.priority%TYPE,
-  tasks.status%TYPE,
-  acs_objects.creation_date%TYPE,
-  acs_objects.creation_user%TYPE,
-  acs_objects.creation_ip%TYPE,
-  acs_objects.package_id%TYPE
-) returns integer as '
-declare
-  new__party_id      alias for $1;
-  new__object_id     alias for $2;
-  new__process_id    alias for $3;
-  new__title         alias for $4;
-  new__description   alias for $5;
-  new__mime_type     alias for $6;
-  new__comment       alias for $7;
-  new__due_date      alias for $8;
-  new__priority      alias for $9;
-  new__status        alias for $10;
-  new__creation_date alias for $11;
-  new__creation_user alias for $12;
-  new__creation_ip   alias for $13;
-  new__package_id    alias for $14;
-  v_task_id        tasks.task_id%TYPE;
-begin
-  -- Create the object
-
-  v_task_id := acs_object__new(
-      null,
-      'tasks_task', 
-      new__creation_date, 
-      new__creation_user, 
-      new__creation_ip, 
-      new__package_id,
-      ''t'',
-      new__title,
-      new__package_id
-  );
-
-  insert into tasks (
-    task_id, folder_id, party_id, object_id, process_id, title, description, mime_type,
-    comment, due_date, priority, status
-  ) values (
-    v_task_id, new__folder_id, new__party_id, new__object_id, new__process_id, new__title,
-    new__description, new__mime_type, new__comment, new__due_date, new__priority, new__status
-  );
-
-  return v_task_id;
-
-end;' language 'plpgsql';
-
 -----------------------------------------------------
 -- 
 -- Create the data model for the timecard application
Index: openacs-4/packages/tasks/www/contact.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/contact.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/tasks/www/contact.adp	13 Oct 2005 16:05:23 -0000	1.6
+++ openacs-4/packages/tasks/www/contact.adp	14 Oct 2005 13:50:07 -0000	1.7
@@ -4,12 +4,14 @@
 <table widht="50%">
 <tr>
     <td>
-	<include src="/packages/tasks/lib/tasks-portlet"
+	<include src="/packages/tasks/lib/tasks"
 		 party_id=@party_id@
 		 orderby="@orderby@"
 		 page="@page@"
 		 page_size="@page_size@"
-		 page_flush_p="f"/>
+                 search_id=""
+                 row_list="@row_list@"
+                 query=""/>
     </td>
 </tr>
 </table>
Index: openacs-4/packages/tasks/www/contact.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/contact.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/tasks/www/contact.tcl	7 Oct 2005 21:46:39 -0000	1.4
+++ openacs-4/packages/tasks/www/contact.tcl	14 Oct 2005 13:50:07 -0000	1.5
@@ -33,3 +33,4 @@
 set package_id [ad_conn package_id]
 set admin_p [permission::permission_p -object_id $package_id -privilege admin]
 set context {}
+set row_list {checkbox {} deleted_p {} priority {} title {} process_title {} date {} creation_user {}}
Index: openacs-4/packages/tasks/www/index-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index-postgresql.xql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/tasks/www/index-postgresql.xql	7 Oct 2005 21:46:39 -0000	1.4
+++ openacs-4/packages/tasks/www/index-postgresql.xql	14 Oct 2005 13:50:07 -0000	1.5
@@ -28,8 +28,8 @@
                             left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id),
                                  group_distinct_member_map
                             where parties.party_id = group_distinct_member_map.member_id
-                            and group_distinct_member_map.group_id = :group_id
-                            [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] ))
+                            $group_where_clause
+                            [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] )
         [template::list::page_where_clause -and -name tasks -key t.task_id]
         [template::list::orderby_clause -orderby -name tasks]
     </querytext>
@@ -52,8 +52,8 @@
                             left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id),
                                  group_distinct_member_map
                             where parties.party_id = group_distinct_member_map.member_id
-                            and group_distinct_member_map.group_id = :group_id
-                            [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] ))
+                            $group_where_clause
+                            [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] )
         [template::list::orderby_clause -orderby -name tasks]
     </querytext>
 </fullquery>
@@ -75,8 +75,8 @@
                             left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id),
                                  group_distinct_member_map
                             where parties.party_id = group_distinct_member_map.member_id
-                            and group_distinct_member_map.group_id = :group_id
-                            [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] ))
+                            $group_where_clause
+                            [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] )
     </querytext>
 </fullquery>
 
Index: openacs-4/packages/tasks/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/tasks/www/index.adp	13 Oct 2005 16:05:23 -0000	1.6
+++ openacs-4/packages/tasks/www/index.adp	14 Oct 2005 13:50:07 -0000	1.7
@@ -5,15 +5,14 @@
 <table width="50%">
 <tr>
     <td>
-	<include src="/packages/tasks/lib/tasks-portlet"
+	<include src="/packages/tasks/lib/tasks"
 		 user_id=@user_id@
 		 query="@query@"
 		 search_id="@search_id@"
 		 tasks_interval="@tasks_interval@"
 		 orderby="@orderby@"
 		 page="@page@"
-		 page_size="@page_size@"
-		 page_flush_p="@page_flush_p@">
+		 page_size="@page_size@">
     </td>
 </tr>
 </table>
\ No newline at end of file
Index: openacs-4/packages/tasks/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/tasks/www/index.tcl	7 Oct 2005 21:46:39 -0000	1.5
+++ openacs-4/packages/tasks/www/index.tcl	14 Oct 2005 13:50:07 -0000	1.6
@@ -5,17 +5,15 @@
     @creation-date 2004-07-28
     @cvs-id $Id$
 } {
-    {orderby "due_date,asc"}
+    {orderby:optional ""}
     {format "normal"}
     {search_id:integer ""}
     {query ""}
     {page:optional "1"}
     {page_size:integer "25"}
     {tasks_interval:integer "7"}
-    {page_flush_p "f"}
 }
 
-
 set title "[_ tasks.Tasks]"
 set context {}
 set user_id [ad_conn user_id]
@@ -24,140 +22,7 @@
 
 set return_url [export_vars -base $url -url {orderby format search_id query page page_size tasks_interval {page_flush_p t}}]
 
-if { $orderby == "contact_name,asc" } {
-    set name_order 0
-} elseif { $orderby == "contact_name,desc" } {
-    set name_order 1
-} else {
-    set name_order 0
-}
 
-
-set first_p 1
-foreach page_s [list 25 50 100 500] {
-    if { [string is false $first_p] } {
-        append name_label " | "
-    }
-    if { $page_size == $page_s } {
-        append name_label $page_s
-    } else {
-        append name_label "<a href=\"[export_vars -base . -url {rel_type format query_id query page orderby {page_size $page_s}}]\">$page_s</a>"
-    }
-    set first_p 0
-}
-
-set admin_p [permission::permission_p -object_id $package_id -privilege admin]
-set context {}
-
-template::list::create \
-    -name tasks \
-    -multirow tasks \
-    -key task_id \
-    -page_size "50" \
-    -page_flush_p $page_flush_p \
-    -page_query_name tasks_pagination \
-    -elements {
-        priority {
-	    label "[_ tasks.Priority]"
-	}
-        contact_name {
-	    label "[_ tasks.Contact]"
-	    link_url_eval $contact_url
-	} 
-	title {
-	    label "[_ tasks.Task]"
-            display_template {
-		<a href="@tasks.task_url@" title="@tasks.title@">@tasks.title@</a>
-		<if @tasks.description@ not nil>
-                <p style="padding: 0; margin: 0; font-size: 0.85em; padding-left: 2em;">
-		@tasks.description_html;noquote@
-		</p>
-		</if>
-	    }
-	}
-        process_title {
-	    label "[_ tasks.Process]"
-	}
-        due_date {
-	    label "[_ tasks.Due]"
-            display_template {
-		<if @tasks.overdue_p@><span class="overdue"></if>
-		<a href="@tasks.task_minus_url@" style="text-decoration: none; font-weight: bold;">&laquo;</a>&nbsp;@tasks.due_date;noquote@&nbsp;<a href="@tasks.task_plus_url@" style="text-decoration: none; font-weight: bold;">&raquo;</a>
-		<if @tasks.overdue_p@></span></if>
-	    }
-	}
-    } \
-    -bulk_actions [list \
-		       "[_ tasks.Mark_Completed]" "mark-completed" "[_ tasks.Mark_Completed]" \
-		       "[_ tasks.Delete]" "delete" "[_ tasks.Delete]" \
-		       "[_ contacts.Mail_Merge]" "mail-merge" "[_ contacts.lt_E-mail_or_Mail_the_se]" \
-		      ]\
-    -bulk_action_export_vars {
-        {return_url}
-    } -pass_properties { } \
-    -sub_class {
-        narrow
-    } \
-    -filters {
-	search_id {}
-	query {}
-	page_size {}
-	tasks_interval {}
-    } \
-    -orderby {
-        default_value $orderby
-        due_date {
-            label "Due"
-            orderby_desc "t.due_date desc, t.priority, lower(t.title)"
-            orderby_asc "t.due_date asc, t.priority, lower(t.title)"
-            default_direction asc
-        }
-        priority {
-            label "Priority"
-            orderby_desc "t.priority desc, t.due_date asc, lower(t.title)"
-            orderby_asc "t.priority asc, t.due_date asc, lower(t.title)"
-            default_direction desc
-        }
-        title {
-            label "Task"
-            orderby_desc "lower(t.title) desc, t.priority desc, t.due_date asc"
-            orderby_asc "lower(t.title) asc, t.priority desc, t.due_date asc"
-            default_direction asc
-        }
-	contact_name {
-	    label "Contact"
-	    orderby_asc "lower(contact__name(t.party_id,'1'::boolean)) asc"
-	    orderby_desc "lower(contact__name(t.party_id,'0'::boolean)) asc"
-	    default_direction asc
-	}
-        process_title {
-	    label "Process"
-            orderby_desc "lower(p.title) desc, t.priority desc, t.due_date asc"
-            orderby_asc "lower(p.title) asc, t.priority desc, t.due_date asc"
-	    default_direction asc
-	}
-    }
-
-db_multirow -extend { contact_url description_html task_url task_plus_url task_minus_url } -unclobber tasks tasks_select {} {
-    set contact_url "/contacts/${party_id}/"
-    set task_url [export_vars -base "task" -url {orderby status_id task_id}]
-    set task_plus_url  [export_vars -base "task-interval" -url {{action plus}  {days 7} task_id status_id orderby return_url}]
-    set task_minus_url [export_vars -base "task-interval" -url {{action minus} {days 7} task_id status_id orderby return_url}]
-
-    regsub -all "\r|\n" $description {LiNeBrEaK} description
-    set description_html [ad_html_text_convert \
-			      -from $mime_type \
-			      -to "text/html" \
-			      -truncate_len "400" \
-			      -more "<a href=\"${task_url}\">[_ tasks.more]</a>" \
-			      -- $description]
-    regsub -all {LiNeBrEaKLiNeBrEaK} $description_html {LiNeBrEaK} description_html
-    regsub -all {LiNeBrEaK} $description_html {\&nbsp;\&nbsp;\&#182;\&nbsp;} description_html
-    regsub -all " " $due_date {\&nbsp;} due_date
-}
-
-set tasks_count [db_string tasks_count {} -default {0}]
-
 set package_id [site_node::get_element -url "/contacts" -element object_id]
 if { [exists_and_not_null search_id] } {
     contact::search::log -search_id $search_id
@@ -174,7 +39,7 @@
     {search_id:integer(select),optional {label ""} {options $search_options} {html {onChange "javascript:acs_FormRefresh('search')"}}}
     {query:text(text),optional {label ""} {html {size 20 maxlength 255}}}
     {save:text(submit) {label {[_ contacts.Search]}} {value "go"}}
-    {tasks_interval:integer(text),optional {label "&nbsp;&nbsp;<span style=\"font-size: smaller;\">[_ tasks.View_next]</span>"} {after_html "<span style=\"font-size: smaller;\">days &nbsp;&nbsp;&nbsp;Results:</span>&nbsp;$tasks_count"} {html {size 2 maxlength 3 onChange "javascript:acs_FormRefresh('search')"}}}
+    {tasks_interval:integer(text),optional {label "&nbsp;&nbsp;<span style=\"font-size: smaller;\">[_ tasks.View_next]</span>"} {after_html "<span style=\"font-size: smaller;\">days"} {html {size 2 maxlength 3 onChange "javascript:acs_FormRefresh('search')"}}}
 }
 
 if { [parameter::get -boolean -parameter "ForceSearchBeforeAdd" -default "0"] } {
@@ -194,3 +59,4 @@
     } -after_submit {
     }
 
+set orderby ""
Index: openacs-4/packages/tasks/www/task.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/task.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/tasks/www/task.tcl	6 Oct 2005 16:31:55 -0000	1.5
+++ openacs-4/packages/tasks/www/task.tcl	14 Oct 2005 13:50:07 -0000	1.6
@@ -89,23 +89,39 @@
 set status_options [db_list_of_lists status_options { }]
 set status_options [lang::util::localize $status_options]
 
-ad_form -name add_edit \
-    -cancel_url $return_url \
-    -cancel_label "[_ tasks.Cancel]" \
-    -edit_buttons $edit_buttons \
-    -form {
-        task_id:key
-        return_url:text(hidden),optional
-        orderby:text(hidden),optional
-        status_id:integer(hidden),optional
-        party_id:integer(hidden)
-        other_party_ids:text(hidden),optional
-	{names:text(hidden),optional {label "[_ tasks.Add_task_to]"}}
-        {assign_party_id:text(select),optional 
+ad_form -name add_edit -form {
+    task_id:key
+    return_url:text(hidden),optional
+    orderby:text(hidden),optional
+    status_id:integer(hidden),optional
+    party_id:integer(hidden)
+    other_party_ids:text(hidden),optional
+    {names:text(hidden),optional {label "[_ tasks.Add_task_to]"}}
+}
+
+if {[exists_and_not_null party_id] && $party_id != $user_id} {
+    ad_form -extend -name add_edit -form {
+	{assign_party_id:text(hidden) {value $party_id}}
+	{assign_party:text(inform),optional 
 	    {label "[_ tasks.Add_task_to]"}
+	    {value $names}
+	}
+    }
+} else {
+    ad_form -extend -name add_edit -form {
+	{assign_party_id:text(select),optional 
+	    {label "[_ tasks.Add_task_to]"}
 	    {options { $assign_parties_options}}
 	    {help_text "[_ tasks.Select_the_user_to]"}
 	}
+    }
+}
+
+ad_form -extend -name add_edit \
+    -cancel_url $return_url \
+    -cancel_label "[_ tasks.Cancel]" \
+    -edit_buttons $edit_buttons \
+    -form {
         {task_prescribed:text(select),optional
             {label "[_ tasks.Standard_Task]"}
 	    {options {
@@ -200,7 +216,6 @@
     } -new_data {
 
 	foreach party $all_parties {
-
 	    set task_id [tasks::task::new \
 			     -title ${task} \
 			     -description ${description} \