Index: openacs-4/packages/curriculum/lib/admin-curriculums-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/admin-curriculums-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/admin-curriculums-oracle.xql 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,55 @@ + + + + oracle8.1.6 + + + + select cc.curriculum_id, + cc.name as curriculum_name, + cc.sort_key as curriculum_sort_order, + ce.element_id, + ce.name as element_name, + ce.url as element_url, + ce.enabled_p as element_enabled_p, + ce.sort_key as element_sort_order, + author.first_names as author_first_names, + author.last_name as author_last_name, + author.email as author_email, + st.pretty_name as pretty_state, + st.short_name as state_short_name, + st.state_id, + st.hide_fields, + assignee.party_id as assignee_party_id, + assignee.email as assignee_email, + assignee.name as assignee_name + from cu_curriculums cc, + cu_elements ce, + cc_users author, + (select rpm.case_id, + p.party_id, + p.email, + acs_object.name(p.party_id) as name + from workflow_case_role_party_map rpm, + parties p + where rpm.role_id = :action_role + and p.party_id = rpm.party_id + ) assignee, + workflow_cases cas, + workflow_case_fsm cfsm, + workflow_fsm_states st + where cc.curriculum_id = ce.curriculum_id(+) + and cc.package_id = :package_id + and author.user_id = cc.owner_id + and cfsm.case_id = cas.case_id + and st.state_id = cfsm.current_state + and cas.workflow_id = :workflow_id + and cas.object_id = cc.curriculum_id + and cas.case_id = assignee.case_id(+) + $where_clauses + order by cc.sort_key, + ce.sort_key + + + + Index: openacs-4/packages/curriculum/lib/admin-curriculums-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/admin-curriculums-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/admin-curriculums-postgresql.xql 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,53 @@ + + + + postgresql7.1 + + + + select cc.curriculum_id, + cc.name as curriculum_name, + cc.sort_key as curriculum_sort_order, + ce.element_id, + ce.name as element_name, + ce.url as element_url, + ce.enabled_p as element_enabled_p, + ce.sort_key as element_sort_order, + author.first_names as author_first_names, + author.last_name as author_last_name, + author.email as author_email, + st.pretty_name as pretty_state, + st.short_name as state_short_name, + st.state_id, + st.hide_fields, + assignee.party_id as assignee_party_id, + assignee.email as assignee_email, + assignee.name as assignee_name + from cu_curriculums cc left outer join + cu_elements ce using (curriculum_id), + cc_users author, + workflow_cases cas left outer join + (select rpm.case_id, + p.party_id, + p.email, + acs_object__name(p.party_id) as name + from workflow_case_role_party_map rpm, + parties p + where rpm.role_id = :action_role + and p.party_id = rpm.party_id + ) assignee using (case_id), + workflow_case_fsm cfsm, + workflow_fsm_states st + where cc.package_id = :package_id + and author.user_id = cc.owner_id + and cfsm.case_id = cas.case_id + and st.state_id = cfsm.current_state + and cas.workflow_id = :workflow_id + and cas.object_id = cc.curriculum_id + $where_clauses + order by cc.sort_key, + ce.sort_key + + + + Index: openacs-4/packages/curriculum/lib/admin-curriculums.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/admin-curriculums.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/admin-curriculums.adp 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,84 @@ +

+ [ + Package parameters + | + Package permissions + ] +

+ + +Here are the available columns: +

@curriculums:columns@

+
+ +@debug_output;noquote@ + + + + + + + + + + +
  • No curriculums + + +
  • Add a curriculum + +
  • + +
  • +@curriculums.curriculum_name@ +- +[ +delete + +| +down + + +up + +] + + +
    + +
  • Index: openacs-4/packages/curriculum/lib/admin-curriculums.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/admin-curriculums.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/admin-curriculums.tcl 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,64 @@ +ad_page_contract { + + Curriculum listing widget. + + @author Ola Hansson (ola@polyxena.net) + @creation-date 2003-06-03 + @cvs-id $Id: admin-curriculums.tcl,v 1.1 2003/06/03 10:21:50 olah Exp $ + +} { +} -properties { + state_id:onevalue +} +# state_id is an integer or the string "any", provided as an property. + +# Scoping. +set package_id [curriculum::conn package_id] + +permission::require_permission -object_id $package_id -privilege admin + +# Workflow. +set workflow_id [curriculum::get_instance_workflow_id] + +# We might need this if we want to present statistics, see bug-tracker (we need it for this page, too). +set initial_state_id [workflow::fsm::get_initial_state -workflow_id $workflow_id] + +set action_role [db_string select_resolve_role {*SQL*}] + +#### +# Filters. +#### + +# Filter by workflow state. +if { [string equal "any" $state_id] } { + set where_clauses {} +} else { + set where_clauses {{cfsm.current_state = :state_id}} +} + +# Construct a nicely formatted string to use in the query file. +set where_clauses [ad_decode $where_clauses {} {} " and [join $where_clauses "\n and "]"] + +# List of curriculums and their elements. +db_multirow -extend { + curriculum_id_export + element_id_export +} curriculums select_curriculums {*SQL*} { + + set curriculum_id_export [export_vars -url curriculum_id] + set element_id_export [export_vars -url element_id] +} + +set curriculum_count [curriculum::conn -nocache curriculum_count] + +## +## DEBUG. FIXME. +## +set debug_output " +debug_output +
    package_id: $package_id +
    workflow_id: $workflow_id +
    action_role: $action_role +" + +ad_return_template Index: openacs-4/packages/curriculum/lib/admin-curriculums.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/Attic/admin-curriculums.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/admin-curriculums.xql 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,18 @@ + + + + + + + select a.assigned_role + from workflow_actions a, + workflow_fsm_action_en_in_st aeis + where a.action_id = aeis.action_id + and aeis.state_id = :initial_state_id + and a.workflow_id = :workflow_id + and a.assigned_role is not null + + + + + Index: openacs-4/packages/curriculum/lib/bar.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/Attic/bar.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/bar.adp 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + +
    + + + + + + + + Checked + + + Unchecked + + + + @elements.name@ + + + @elements.name@ + + + ? + + [Remove] +
    +
    +
    Index: openacs-4/packages/curriculum/lib/bar.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/bar.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/bar.tcl 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,27 @@ +ad_page_contract { + + Horizontal curriculum bar. + + @author Ola Hansson (ola@polyxena.net) + @creation-date 2003-05-23 + @cvs-id $Id: bar.tcl,v 1.1 2003/06/03 10:21:50 olah Exp $ + +} { +} -properties { + package_url:onevalue + logged_in_p:onevalue + return_url:onevalue + elements:multirow +} + +set package_url [curriculum::conn package_url] + +set logged_in_p [ad_conn user_id] + +set return_url [ad_conn url] +set return_url_export [export_vars -url return_url] + +# Upvar the "elements" multirow datasource for the curriculum bar. +curriculum::get_bar -bar_p 1 + +ad_return_template Index: openacs-4/packages/curriculum/lib/curriculum-ave-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/curriculum-ave-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/curriculum-ave-oracle.xql 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,19 @@ + + + + oracle8.1.6 + + + + select distinct u.first_names || ' ' || u.last_name || ' (' || u.email || ')' as name, + u.user_id + from cc_users u + where upper(nvl(u.first_names || ' ', '') || + nvl(u.last_name || ' ', '') || + u.email || ' ' || + nvl(u.screen_name, '')) like upper('%'||:value||'%') + order by name + + + + Index: openacs-4/packages/curriculum/lib/curriculum-ave-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/curriculum-ave-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/curriculum-ave-postgresql.xql 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,19 @@ + + + + postgresql7.1 + + + + select distinct u.first_names || ' ' || u.last_name || ' (' || u.email || ')' as name, + u.user_id + from cc_users u + where upper(coalesce(u.first_names || ' ', '') || + coalesce(u.last_name || ' ', '') || + u.email || ' ' || + coalesce(u.screen_name, '')) like upper('%'||:value||'%') + order by name + + + + Index: openacs-4/packages/curriculum/lib/curriculum-ave.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/curriculum-ave.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/curriculum-ave.adp 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,17 @@ + +@title@ +@context@ + + +

    + @start_over_label@ +

    +
    + + +

    + @notification_label@ +

    +
    + + 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/curriculum-ave.tcl 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,257 @@ +ad_page_contract { + + Add/edit/view curriculum. + + @author Ola Hansson (ola@polyxena.net) + @creation-date 2003-06-03 + @cvs-id $Id: curriculum-ave.tcl,v 1.1 2003/06/03 10:21:50 olah Exp $ + +} { + curriculum_id:integer,optional + {return_url "."} +} -properties { + title:onevalue + context:onevalue +} + +set package_id [curriculum::conn package_id] +set user_id [ad_conn user_id] +set actions [list] +set element_mode {} +set desc_help_text "This text should describe the curriculum and its purpose." + +if { [set new_p [ad_form_new_p -key curriculum_id]] } { + + #### + # New curriculum. + #### + + permission::require_permission -object_id $package_id -privilege write + + set form_mode edit + set title "Create Curriculum" + +} else { + + #### + # Edit/display curriculum. + #### + + permission::require_permission -object_id $curriculum_id -privilege write + + #### + # Workflow. + #### + + # 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 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} + +# Curriculum "owner" select box. +set users_list [list] +lappend users_list [list [person::name -person_id $user_id] "$user_id"] +lappend users_list [list "Search..." ":search:"] + + +#### +# +# Build the form. +# +#### + +# It's a shame to have to specify "{mode display}" for every single element +# and then force the "edit_fields" into edit mode depending on wf status, etc. +# This might be figured out by ad_form, e.g. if there exist any actions ... + +ad_form -name curriculum -cancel_url $return_url -mode $form_mode -actions $actions -form { + curriculum_id:key + {name:text + {mode $element_mode} + {label Name} + {html {size 50}} + } +} + +# Add status field on display/edit. +if { !$new_p } { + ad_form -extend -name curriculum -form { + {pretty_state:text(inform) + {label Status} + {before_html } + {after_html } + } + } +} + +ad_form -extend -name curriculum -form { + {description:text(textarea) + {mode $element_mode} + {label Description} + {help_text $desc_help_text} + {html {rows 10 cols 50 wrap soft}} + optional + } +} + +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

    "]" + + # 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" + + } + +} + +# More fixed form elements +# FIXME. Datatype "search" does not appear to work with ad_form very well. +# Do we need an owner anyway when we're using workflow roles? +ad_form -extend -name curriculum -form { + {owner_id:search + {mode $element_mode} + {result_datatype integer} + {label Owner} + {options $users_list} + {search_query {[db_map user_search]}} + optional + } +} + +#### +# +# Done defining the form elements. +# +#### + +# Set editable fields. Must do this after the "-form" block! +if { !$new_p && $wf_action_exists_p } { + + foreach field [workflow::action::get_element -action_id $action_id -element edit_fields] { + element set_properties curriculum $field -mode edit + } +} + +ad_form -extend -name curriculum -edit_request { + + curriculum::get -curriculum_id $curriculum_id -array curriculum_array + + template::util::array_to_vars curriculum_array + # FIXME. + set description [list $description $desc_format] + + # Hide elements that should be hidden because of a certain wf status. + foreach element $curriculum_array(hide_fields) { + element set_properties curriculum $element -widget hidden + } + +} -validate { + + {name + {[string length $name] <= [set length 200]} + "Name may not be more than $length characters long." + } + +} -new_data { + +#[template::util::richtext::get_property contents $description] +#[template::util::richtext::get_property format $description] + + curriculum::new \ + -name $name \ + -description $description \ + -desc_format text/html \ + -owner_id $owner_id \ + -package_id $package_id + +} -edit_data { + +#[template::util::richtext::get_property contents $description] +#[template::util::richtext::get_property format $description] + + curriculum::edit \ + -curriculum_id $curriculum_id \ + -name $name \ + -description $description \ + -desc_format text/html \ + -owner_id $owner_id \ + -action_id $action_id \ + -array curriculum_array + +} -after_submit { + + # Force the curriculum bar to update. + #curriculum::elements_flush + + ad_returnredirect $return_url + ad_script_abort + +} + + +ad_return_template Index: openacs-4/packages/curriculum/lib/element-ave.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/element-ave.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/element-ave.adp 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,5 @@ + +@title@ +@context@ + + Index: openacs-4/packages/curriculum/lib/element-ave.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/element-ave.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/element-ave.tcl 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,118 @@ +ad_page_contract { + + Add/edit curriculum element. + + @author Ola Hansson (ola@polyxena.net) + @creation-date 2003-05-26 + @cvs-id $Id: element-ave.tcl,v 1.1 2003/06/03 10:21:50 olah Exp $ + +} { + element_id:integer,optional + curriculum_id:integer + {return_url "."} + {mode:nohtml,optional "edit"} +} -properties { + title:onevalue + context:onevalue +} + +set package_id [curriculum::conn package_id] +set subsite_url [curriculum::conn subsite_url] + +if { [set new_p [ad_form_new_p -key element_id]] } { + + #### + # New element. + #### + + permission::require_permission -object_id $curriculum_id -privilege write + + set form_mode edit + set title "Add Element" + +} else { + + #### + # Edit/display element. + #### + + # Since we permit several curriculums per package instance we + # require permission on curriculum_id, not package_id basis. + permission::require_permission -object_id $curriculum_id -privilege write + + set form_mode display + set curriculum_name [acs_object_name $curriculum_id] + set element_name [acs_object_name $element_id] + set title "Edit Element \"$element_name\" (part of $curriculum_name)" +} + +set context {$title} + +ad_form -name element -export {curriculum_id} -cancel_url $return_url -mode $form_mode -form { + element_id:key + {name:text + {label Name} + {html {size 50}} + } + {description:richtext + {label Description} + {html {rows 10 cols 50 wrap soft}} + optional + } + {url:text(text) + {label URL} + {help_text "A leading \"http://\" indicates that the URL is external."} + {html {size 50}} + {value $subsite_url} + } +} + +ad_form -extend -name element -edit_request { + + curriculum::element::get -element_id $element_id -array element_array + + template::util::array_to_vars element_array + + set description [list $description $desc_format] + +} -validate { + + {name + {[string length $name] <= [set length 200]} + "Name may not be more than $length characters long." + } + {url + {[string length $url] <= [set length 400]} + "URL may not be more than $length characters long." + } + +} -new_data { + + curriculum::element::new \ + -curriculum_id $curriculum_id \ + -name $name \ + -description [template::util::richtext::get_property contents $description] \ + -desc_format [template::util::richtext::get_property format $description] \ + -url $url \ + -enabled_p t + +} -edit_data { + + curriculum::element::edit \ + -element_id $element_id \ + -name $name \ + -description [template::util::richtext::get_property contents $description] \ + -desc_format [template::util::richtext::get_property format $description] \ + -url $url + +} -after_submit { + + # Force the curriculum bar to update. + curriculum::elements_flush + + ad_returnredirect $return_url + ad_script_abort + +} + +ad_return_template Index: openacs-4/packages/curriculum/lib/user-curriculums.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/user-curriculums.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/user-curriculums.adp 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,110 @@ + + +

    + [ + Refresh all curriculums + + | + Remove all curriculums + + ] +

    + + + + + + + + +
    NameDescriptionStatusOptions
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + No elements +
  • +
    +
    @elements.curriculum_name@@elements.curriculum_desc@ + + + Removed + + + Displayed + + + Refresh + + | + + Display + + + Remove + + +
    + + Contains @elements.groupnum@ element(s). -- We could put the above table row in this row if that is better ... + +
    +
  • + @elements.groupnum@. + @elements.element_name@ +
  • +
    @elements.element_desc;noquote@ + + Visited + + + Unvisited + + + + Revisit + + + Visit + +
    + +
    + +
    +
    + + +
  • + No published curriculums +
  • +
    Index: openacs-4/packages/curriculum/lib/user-curriculums.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/lib/user-curriculums.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum/lib/user-curriculums.tcl 3 Jun 2003 10:21:50 -0000 1.1 @@ -0,0 +1,21 @@ +ad_page_contract { + + Curriculum listing widget for users. + + @author Ola Hansson (ola@polyxena.net) + @creation-date 2003-05-31 + @cvs-id $Id: user-curriculums.tcl,v 1.1 2003/06/03 10:21:50 olah Exp $ + +} { +} -properties { + logged_in_p:onevalue +} + +set logged_in_p [ad_conn user_id] + +#set curriculum_count [curriculum::conn -nocache curriculum_count] + +# Upvar the "elements" multirow datasource for the curriculum bar. +curriculum::get_bar -bar_p 0 + +ad_return_template