Index: openacs-4/packages/curriculum/lib/curriculum-ave.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/curriculum-ave.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/lib/curriculum-ave.tcl 3 Jun 2003 10:21:50 -0000 1.1 +++ openacs-4/packages/curriculum/lib/curriculum-ave.tcl 15 Jun 2003 15:33:02 -0000 1.2 @@ -37,58 +37,73 @@ # Edit/display curriculum. #### - permission::require_permission -object_id $curriculum_id -privilege write + set write_p [permission::permission_p -object_id $curriculum_id -privilege write] - #### - # Workflow. - #### + if { $write_p } { + + #permission::require_permission -object_id $curriculum_id -privilege write - # The form goes into "edit" mode if there is a workflow action ... - set action_id [form get_action curriculum] - set wf_action_exists_p [expr ![empty_string_p $action_id]] + #### + # Workflow. + #### - # FIXME. Do we need this when we require permission above already? - # Registration required for all actions. -# if { $wf_action_exists_p } { -# ad_maybe_redirect_for_registration -# } - - set case_id [workflow::case::get_id \ - -object_id $curriculum_id \ - -workflow_short_name [curriculum::workflow_short_name]] - - # Check permissions. - if { ![workflow::case::action::available_p -case_id $case_id -action_id $action_id] } { - curriculum::security_violation -user_id $user_id -curriculum_id $curriculum_id -action $action_id - } - - # Action buttons. - if { !$wf_action_exists_p } { - foreach available_action_id [workflow::case::get_available_actions -case_id $case_id] { - workflow::action::get -action_id $available_action_id -array available_action - lappend actions [list " $available_action(pretty_name) " $available_action(action_id)] + # The form goes into "edit" mode if there is a workflow action ... + set action_id [form get_action curriculum] + set wf_action_exists_p [expr ![empty_string_p $action_id]] + + # FIXME. Do we need this when we require permission above already? + # Registration required for all actions. + # if { $wf_action_exists_p } { + # ad_maybe_redirect_for_registration + # } + + set case_id [workflow::case::get_id \ + -object_id $curriculum_id \ + -workflow_short_name [curriculum::workflow_short_name]] + + # Check permissions. + if { ![workflow::case::action::available_p -case_id $case_id -action_id $action_id] } { + curriculum::security_violation -user_id $user_id -curriculum_id $curriculum_id -action $action_id } - } + + # Action buttons. + if { !$wf_action_exists_p } { + foreach available_action_id [workflow::case::get_available_actions -case_id $case_id] { + workflow::action::get -action_id $available_action_id -array available_action + lappend actions [list " $available_action(pretty_name) " $available_action(action_id)] + } + } + + # Action pretty names. + if { $wf_action_exists_p } { + + # Hmm... Not elegant but initially we need to set the mode for each element + # of the form to display mode, thus overriding the default form mode, + # and then "open up" the edit_fields for the given action for editing. + # We can't just change the mode of the entire form to display mode because + # then the form will lose its OK and Cancel buttons when an action button is pressed. + + set element_mode display + + set action_pretty_name [workflow::action::get_element -action_id $action_id -element pretty_name] + } else { + set action_pretty_name {} + } + + set curriculum_name [acs_object_name $curriculum_id] + set title "[ad_decode $action_pretty_name "" "View" $action_pretty_name] Curriculum: $curriculum_name" + } else { - # Action pretty names. - if { $wf_action_exists_p } { + # Display mode only! (User doesn't have write perms) - # Hmm... Not elegant but initially we need to set the mode for each element - # of the form to display mode, thus overriding the default form mode, - # and then "open up" the edit_fields for the given action for editing. - # We can't just change the mode of the entire form to display mode because - # then the form will lose its OK and Cancel buttons when an action button is pressed. + set wf_action_exists_p 0 + set curriculum_name [acs_object_name $curriculum_id] + set title "Curriculum: $curriculum_name" - set element_mode display - - set action_pretty_name [workflow::action::get_element -action_id $action_id -element pretty_name] - } else { - set action_pretty_name {} } - + + set form_mode display - set curriculum_name [acs_object_name $curriculum_id] - set title "[ad_decode $action_pretty_name "" "View" $action_pretty_name] Curriculum ($curriculum_name)" } set context {$title} @@ -118,8 +133,8 @@ } } -# Add status field on display/edit. -if { !$new_p } { +# Add status field on display/edit mode for people with write privs. +if { !$new_p && $write_p } { ad_form -extend -name curriculum -form { {pretty_state:text(inform) {label Status} @@ -141,32 +156,32 @@ if { !$new_p } { - # Extend the form with assignee widgets (only in edit or display mode). - workflow::case::role::add_assignee_widgets -case_id $case_id -form_name curriculum - - # FIXME. Get values for the role assignment widgets. - workflow::case::role::set_assignee_values -case_id $case_id -form_name curriculum - - # Set values for description field. - # Is before_html the right placement of this? Perhaps we should link - # to a different page where we show the case log? - element set_properties curriculum description \ - -before_html "[workflow::case::get_activity_html -case_id $case_id][ad_decode $action_id "" "" "

$action_pretty_name by user_first_names user_last_name

"]" + if { $write_p } { + # Extend the form with assignee widgets (only in edit or display mode). + workflow::case::role::add_assignee_widgets -case_id $case_id -form_name curriculum + + # FIXME. Get values for the role assignment widgets. + workflow::case::role::set_assignee_values -case_id $case_id -form_name curriculum + + # Set values for description field. + # Is before_html the right placement of this? Perhaps we should link + # to a different page where we show the case log? + element set_properties curriculum description \ + -before_html "[workflow::case::get_activity_html -case_id $case_id][ad_decode $action_id "" "" "

$action_pretty_name by user_first_names user_last_name

"]" + + } # Single-curriculum notifications and "start over" link. - if { !$wf_action_exists_p } { - - set notification_link [curriculum::get_watch_link -curriculum_id $curriculum_id] - foreach { notification_url notification_label notification_title } $notification_link { - # Do nothing! - } - - set start_over_url "start-over?[export_vars -url curriculum_id]" - set start_over_label "Restart this curriculum" - set start_over_title "Clear all checkboxes in $curriculum_name" - - } - + set notification_link [curriculum::get_watch_link -curriculum_id $curriculum_id] + foreach { notification_url notification_label notification_title } $notification_link { + # Do nothing! + } + + #set start_over_url "start-over?[export_vars -url curriculum_id]" + #set start_over_label "Restart this curriculum" + #set start_over_title "Clear all checkboxes in $curriculum_name" + + } # More fixed form elements