Index: openacs-4/packages/tasks/lib/task-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/task-form.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/tasks/lib/task-form.tcl 1 Mar 2006 12:29:27 -0000 1.1
+++ openacs-4/packages/tasks/lib/task-form.tcl 13 Mar 2006 07:38:41 -0000 1.2
@@ -32,8 +32,12 @@
lappend export_vars $key
}
}
-#ad_return_error "ASD" "$mode $object_id"
+# this is being included for contacts
+set party_id [ns_queryget party_id]
+lappend export_vars party_id
+
+
# after being submitted via the form object_id is a single list item string,
# this removes that limitation, and simplifies passing object_id to the form
# by not requiring an ugly hack to maintain two lists
@@ -68,15 +72,17 @@
[list "[_ tasks.Add_Task]" save] \
[list "[_ tasks.lt_Add_Task_and_Add_Anot]" save_add_another] \
]
+
} else {
if { $object_count > 1 } {
ad_return_error "[_ tasks.Not_Allowed]" "[_ tasks.lt_You_are_not_allowed_t]"
}
set edit_buttons [list \
[list "[_ tasks.Update]" save] \
- [list "[_ tasks.lt_Update_and_Add_New_Ta]" save_add_another] \
[list "[_ tasks.Delete]" delete]
]
+# [list "[_ tasks.lt_Update_and_Add_New_Ta]" save_add_another] \
+
}
@@ -92,7 +98,7 @@
set names [list]
foreach object $object_id {
- lappend names "[db_string get_acs_object_name { select acs_object__name(:object) }]"
+ lappend names "[db_string get_acs_object_name { select acs_object__name(:object) }]"
}
set names [join $names ", "]
@@ -219,55 +225,66 @@
} -validate {
# {end_date {[calendar::date_valid_p -date $end_date]} {This is not a valid date. Either the date doesn't exist or it is not formatted correctly. Correct formatting is: YYYY-MM-DD or YYYYMMDD}}
{task { [string equal [string trim $task] {}] != [string equal [string trim $task_prescribed] {}] } {[_ tasks.lt_Either_a_custom_task_]}}
- } -new_data {
- foreach object $object_id {
- set task_id [tasks::task::new \
+ } -on_submit {
+
+ # we don't use new_data and edit_data blocks because otherwise the save_add_another
+ # gets messed up if we are adding a second task
+
+ if { ![db_0or1row get_it { select 1 from acs_objects where object_id = :task_id }] } {
+
+ foreach object $object_id {
+ set task_id [tasks::task::new \
+ -title ${task} \
+ -description ${description} \
+ -mime_type "text/plain" \
+ -comment ${comment} \
+ -object_id ${object} \
+ -due_date ${due_date} \
+ -status_id ${status} \
+ -package_id ${package_id} \
+ -priority ${priority}]
+ }
+
+ if { [llength $object_id] == 1 } {
+ set task_url [export_vars -base [ad_conn url] -url {task_id return_url}]
+ util_user_message -html -message "[_ tasks.lt_The_task_a_hreftaskst]"
+ } else {
+ util_user_message -html -message "[_ tasks.lt_The_task_task_was_add]"
+ }
+
+ } else {
+
+ set task_id [tasks::task::edit \
+ -task_id ${task_id} \
-title ${task} \
-description ${description} \
-mime_type "text/plain" \
-comment ${comment} \
- -object_id ${object} \
-due_date ${due_date} \
-status_id ${status} \
- -package_id ${package_id} \
- -priority ${priority}]
- }
+ -priority ${priority} \
+ -assignee_id ${assignee_id}]
- if { [llength $object_id] == 1 } {
- set task_url [export_vars -base [ad_conn url] -url {task_id return_url}]
- util_user_message -html -message "[_ tasks.lt_The_task_a_hreftaskst]"
- } else {
- util_user_message -html -message "[_ tasks.lt_The_task_task_was_add]"
+ set task_url [export_vars -base task -url {task_id return_url}]
+ set title $task
+ util_user_message -html -message "[_ tasks.lt_The_task_a_hreftaskst_1]"
+
}
- } -edit_data {
-
- set task_id [tasks::task::edit \
- -task_id ${task_id} \
- -title ${task} \
- -description ${description} \
- -mime_type "text/plain" \
- -comment ${comment} \
- -due_date ${due_date} \
- -status_id ${status} \
- -priority ${priority} \
- -assignee_id ${assignee_id}]
-
- set task_url [export_vars -base task -url {task_id return_url}]
- set title $task
- util_user_message -html -message "[_ tasks.lt_The_task_a_hreftaskst_1]"
-
-
} -after_submit {
-# if { ![exists_and_not_null return_url] } {
-# set return_url [export_vars -url -base "contact" {object_id}]
-# }
-# if { [ns_queryget "formbutton:save_add_another"] != "" } {
-# set return_url [export_vars -url -base [ad_conn url] {return_url}]
-# }
- ad_returnredirect $return_url
- ad_script_abort
-
+ if { [ns_queryget "formbutton:save_add_another"] != "" } {
+ template::element::set_value add_edit task_prescribed ""
+ template::element::set_value add_edit task ""
+ template::element::set_value add_edit comment ""
+ template::element::set_value add_edit due_date ""
+ template::element::set_value add_edit status "1"
+ template::element::set_value add_edit priority "1"
+ template::element::set_value add_edit description ""
+ template::element::set_value add_edit comment ""
+ } else {
+ ad_returnredirect $return_url
+ ad_script_abort
+ }
}
if { $task_action eq "edit" } {