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.2 -r1.3 --- openacs-4/packages/tasks/sql/postgresql/tasks-create.sql 25 Sep 2005 23:49:23 -0000 1.2 +++ openacs-4/packages/tasks/sql/postgresql/tasks-create.sql 7 Oct 2005 21:41:44 -0000 1.3 @@ -1,3 +1,120 @@ +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/tcl/tasks-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/tcl/tasks-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/tasks/tcl/tasks-procs.tcl 25 Sep 2005 23:49:23 -0000 1.2 +++ openacs-4/packages/tasks/tcl/tasks-procs.tcl 7 Oct 2005 21:41:45 -0000 1.3 @@ -15,6 +15,64 @@ namespace eval tasks::process::instance {} +ad_proc -public tasks::new { + -party_id:required + {-object_id ""} + {-process_id ""} + -title:required + {-description ""} + {-mime_type "text/plain"} + {-comment ""} + -due_date:required + {-priority 0} + {-status "o"} + {-user_id ""} + {-ip_addr ""} + {-package_id ""} +} { + insert new task +} { + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + if {[empty_string_p $user_id]} { + set user_id [ad_conn user_id] + } + if {[empty_string_p $ip_addr]} { + set ip_addr [ad_conn peeraddr] + } + + set task_id [db_exec_plsql create_task {}] + + return $task_id +} + +ad_proc -public tasks::edit { + -task_id:required + -title:required + {-description ""} + {-mime_type "text/plain"} + {-comment ""} + -due_date:required + {-priority 0} + {-status "o"} + {-user_id ""} + {-ip_addr ""} +} { + update task +} { + if {[empty_string_p $user_id]} { + set user_id [ad_conn user_id] + } + if {[empty_string_p $ip_addr]} { + set ip_addr [ad_conn peeraddr] + } + + db_dml update_task {} + db_dml update_object {} +} + + ad_proc -public tasks::project_id { {-package_id ""} } { Index: openacs-4/packages/tasks/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/tasks/www/index.tcl 26 Sep 2005 08:20:06 -0000 1.3 +++ openacs-4/packages/tasks/www/index.tcl 7 Oct 2005 21:41:45 -0000 1.4 @@ -104,7 +104,6 @@ query {} page_size {} tasks_interval {} - process_instance {} } \ -orderby { default_value $orderby @@ -158,7 +157,6 @@ regsub -all " " $due_date {\ } due_date } - set tasks_count [db_string tasks_count {} -default {0}] Index: openacs-4/packages/tasks/www/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/tasks/www/index.xql 25 Sep 2005 23:49:23 -0000 1.2 +++ openacs-4/packages/tasks/www/index.xql 7 Oct 2005 21:41:45 -0000 1.3 @@ -17,7 +17,7 @@ and group_distinct_member_map.group_id = '11428599' [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] ) and role_id = '1' ) assigned_tasks - where ci.parent_id = '$project_id' + where ci.parent_id = :project_id and ci.item_id = pt.task_id and ci.live_revision = ptr.task_revision_id and ci.live_revision = cr.revision_id @@ -27,9 +27,9 @@ and pt.task_id = assigned_tasks.task_id and pt.task_id = ao.object_id and CASE WHEN ao.creation_user = assigned_tasks.party_id THEN - CASE WHEN assigned_tasks.party_id = '$user_id' THEN 'f'::boolean ELSE 't'::boolean END + CASE WHEN assigned_tasks.party_id = :user_id THEN 'f'::boolean ELSE 't'::boolean END ELSE 't'::boolean END - and ptr.end_date < ( now() + '$tasks_interval days'::interval ) + and ptr.end_date < ( now() + :tasks_interval || ' days'::interval ) [template::list::orderby_clause -orderby -name tasks] @@ -50,7 +50,7 @@ and group_distinct_member_map.group_id = '11428599' [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] ) and role_id = '1' ) assigned_tasks - where ci.parent_id = '$project_id' + where ci.parent_id = :project_id and ci.item_id = pt.task_id and ci.live_revision = ptr.task_revision_id and ci.live_revision = cr.revision_id @@ -60,9 +60,9 @@ and pt.task_id = assigned_tasks.task_id and pt.task_id = ao.object_id and CASE WHEN ao.creation_user = assigned_tasks.party_id THEN - CASE WHEN assigned_tasks.party_id = '$user_id' THEN 'f'::boolean ELSE 't'::boolean END + CASE WHEN assigned_tasks.party_id = :user_id THEN 'f'::boolean ELSE 't'::boolean END ELSE 't'::boolean END - and ptr.end_date < ( now() + '$tasks_interval days'::interval ) + and ptr.end_date < ( now() + :tasks_interval || ' days'::interval ) @@ -95,7 +95,7 @@ and CASE WHEN ao.creation_user = assigned_tasks.party_id THEN CASE WHEN assigned_tasks.party_id = :user_id THEN 'f'::boolean ELSE 't'::boolean END ELSE 't'::boolean END - and ptr.end_date < ( now() + '$tasks_interval days'::interval ) + and ptr.end_date < ( now() + :tasks_interval || ' days'::interval ) [template::list::page_where_clause -and -name tasks -key pt.task_id] [template::list::orderby_clause -orderby -name tasks]