Index: openacs-4/packages/imsld/tcl/imsld-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-install-procs.tcl,v diff -u -r1.51 -r1.52 --- openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 29 Oct 2009 11:09:59 -0000 1.51 +++ openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 14 Jan 2010 09:44:45 -0000 1.52 @@ -642,303 +642,303 @@ } 1.0d 1.1d { - # property instances - content::type::new -content_type imsld_property_instance -supertype content_revision -pretty_name "#imsld.lt_IMS-LD_Property_Insta#" -pretty_plural "#imsld.lt_IMS-LD_Property_Insta_1#" -table_name imsld_property_instances -id_column instance_id - - content::type::attribute::new -content_type imsld_property_instance -attribute_name property_id -datatype number -pretty_name "#imsld.Property_Identifier#" -column_spec "integer" - content::type::attribute::new -content_type imsld_property_instance -attribute_name identifier -datatype string -pretty_name "#imsld.lt_Property_String_Ident#" -column_spec "varchar(100)" - content::type::attribute::new -content_type imsld_property_instance -attribute_name party_id -datatype number -pretty_name "#imsld.Party_Identifier#" -column_spec "integer" - content::type::attribute::new -content_type imsld_property_instance -attribute_name run_id -datatype number -pretty_name "#imsld.Run_Identifier#" -column_spec "integer" - content::type::attribute::new -content_type imsld_property_instance -attribute_name value -datatype string -pretty_name "#imsld.Property_Value#" -column_spec "varchar(4000)" + # property instances + content::type::new -content_type imsld_property_instance -supertype content_revision -pretty_name "#imsld.lt_IMS-LD_Property_Insta#" -pretty_plural "#imsld.lt_IMS-LD_Property_Insta_1#" -table_name imsld_property_instances -id_column instance_id + + content::type::attribute::new -content_type imsld_property_instance -attribute_name property_id -datatype number -pretty_name "#imsld.Property_Identifier#" -column_spec "integer" + content::type::attribute::new -content_type imsld_property_instance -attribute_name identifier -datatype string -pretty_name "#imsld.lt_Property_String_Ident#" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_property_instance -attribute_name party_id -datatype number -pretty_name "#imsld.Party_Identifier#" -column_spec "integer" + content::type::attribute::new -content_type imsld_property_instance -attribute_name run_id -datatype number -pretty_name "#imsld.Run_Identifier#" -column_spec "integer" + content::type::attribute::new -content_type imsld_property_instance -attribute_name value -datatype string -pretty_name "#imsld.Property_Value#" -column_spec "varchar(4000)" - set i 0 - foreach run [db_list_of_lists runs { - select ir.run_id, - ir.imsld_id, - ic.item_id as component_item_id, - icm.manifest_id, - rug.group_id as run_group_id - from imsld_runs ir, - imsld_imsldsi ii, - imsld_componentsi ic, - imsld_cp_organizationsi ico, - imsld_cp_manifestsi icm, - imsld_run_users_group_ext rug - where ir.imsld_id = ii.imsld_id - and ii.item_id = ic.imsld_id - and ii.organization_id = ico.item_id - and ico.manifest_id = icm.item_id - and rug.run_id = ir.run_id - }] { - set run_id [lindex $run 0] - set imsld_id [lindex $run 1] - set component_item_id [lindex $run 2] - set manifest_id [lindex $run 3] - set run_group_id [lindex $run 4] - incr i - - set community_id [imsld::community_id_from_manifest_id -manifest_id $manifest_id] - set run_folder_id [imsld::instance::create_run_folder -run_id $run_id -community_id $community_id] - set cr_folder_id [content::item::get_parent_folder -item_id $component_item_id] - #in case the content type is not registered - content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_property_instance - content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_property_instance - set global_folder_id [imsld::global_folder_id -community_id $community_id] + set i 0 + foreach run [db_list_of_lists runs { + select ir.run_id, + ir.imsld_id, + ic.item_id as component_item_id, + icm.manifest_id, + rug.group_id as run_group_id + from imsld_runs ir, + imsld_imsldsi ii, + imsld_componentsi ic, + imsld_cp_organizationsi ico, + imsld_cp_manifestsi icm, + imsld_run_users_group_ext rug + where ir.imsld_id = ii.imsld_id + and ii.item_id = ic.imsld_id + and ii.organization_id = ico.item_id + and ico.manifest_id = icm.item_id + and rug.run_id = ir.run_id + }] { + set run_id [lindex $run 0] + set imsld_id [lindex $run 1] + set component_item_id [lindex $run 2] + set manifest_id [lindex $run 3] + set run_group_id [lindex $run 4] + incr i + + set community_id [imsld::community_id_from_manifest_id -manifest_id $manifest_id] + set run_folder_id [imsld::instance::create_run_folder -run_id $run_id -community_id $community_id] + set cr_folder_id [content::item::get_parent_folder -item_id $component_item_id] + #in case the content type is not registered + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_property_instance + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_property_instance + set global_folder_id [imsld::global_folder_id -community_id $community_id] - db_foreach property_in_component { - select property_id, - identifier, - type, - datatype, - initial_value, - role_id, - existing_href, - uri, - component_id as component_item_id - from imsld_properties - where component_id = :component_item_id - } { - incr i - switch $type { - loc { - # get instance info - if { ![db_0or1row get_instance_info { - select instance_id as old_instance_id, - party_id, - value - from imsld_property_instances - where property_id = :property_id - and identifier = :identifier - and run_id = :run_id - }] } { - continue - } + db_foreach property_in_component { + select property_id, + identifier, + type, + datatype, + initial_value, + role_id, + existing_href, + uri, + component_id as component_item_id + from imsld_properties + where component_id = :component_item_id + } { + incr i + switch $type { + loc { + # get instance info + if { ![db_0or1row get_instance_info { + select instance_id as old_instance_id, + party_id, + value + from imsld_property_instances + where property_id = :property_id + and identifier = :identifier + and run_id = :run_id + }] } { + continue + } - if { ![db_0or1row loc_already_instantiated_p { - select 1 - from imsld_property_instancesi - where property_id = :property_id - and identifier = :identifier - and run_id = :run_id - }] } { - set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ - [list value $value] \ - [list identifier $identifier] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $identifier \ - -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] - - if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value - } - # delete old instance - db_dml delte_old_instance { - delete from imsld_property_instances where instance_id = :old_instance_id - } - } - } - locpers { - foreach party_id [db_list users_in_run { - select ar.object_id_two as party_id - from acs_rels ar - where ar.object_id_one = :run_group_id - and ar.rel_type = 'imsld_run_users_group_rel' - }] { - - # get instance info - if { ![db_0or1row get_instance_info { - select instance_id as old_instance_id, - party_id, - value - from imsld_property_instances - where property_id = :property_id - and identifier = :identifier - and party_id = :party_id - and run_id = :run_id - }] } { - continue - } - - if { ![db_0or1row locrole_already_instantiated_p { - select 1 - from imsld_property_instancesi - where property_id = :property_id - and identifier = :identifier - and party_id = :party_id - and run_id = :run_id - }] } { - set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ - [list value $value] \ - [list identifier $identifier] \ - [list party_id $party_id] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $identifier \ - -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] - if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value - } - # delete old instance - db_dml delte_old_instance { - delete from imsld_property_instances where instance_id = :old_instance_id - } - } - } - } - locrole { - foreach party_id [db_list roles_instances_in_run { - select ar1.object_id_two as party_id - from acs_rels ar1, acs_rels ar2, acs_rels ar3, - public.imsld_run_users_group_ext run_group - where ar1.rel_type = 'imsld_role_group_rel' - and ar1.object_id_two = ar2.object_id_one - and ar2.rel_type = 'imsld_roleinstance_run_rel' - and ar2.object_id_two = ar3.object_id_one - and ar3.object_id_one = run_group.group_id - and run_group.run_id = :run_id - }] { - # get instance info - if { ![db_0or1row get_instance_info { - select instance_id as old_instance_id, - party_id, - value - from imsld_property_instances - where property_id = :property_id - and identifier = :identifier - and party_id = :party_id - and run_id = :run_id - }] } { - continue - } - - if { ![db_0or1row locrole_already_instantiated_p { - select 1 - from imsld_property_instancesi - where property_id = :property_id - and identifier = :identifier - and party_id = :party_id - and run_id = :run_id - }] } { - - set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ - [list value $value] \ - [list identifier $identifier] \ - [list party_id $party_id] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $identifier \ - -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] - if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value - } - - # delete old instance - db_dml delte_old_instance { - delete from imsld_property_instances where instance_id = :old_instance_id - } - } - } - } - globpers { - foreach party_id [db_list user_in_run { - select ar.object_id_two as party_id - from acs_rels ar - where ar.object_id_one = :run_group_id - and ar.rel_type = 'imsld_run_users_group_rel' - }] { - # get instance info - if { ![db_0or1row get_instance_info { - select instance_id as old_instance_id, - party_id, - value - from imsld_property_instances - where identifier = :identifier - and party_id = :party_id - }] } { - continue - } - - if { ![db_0or1row globpers_already_instantiated_p { - select 1 - from imsld_property_instancesi - where identifier = :identifier - and party_id = :party_id - }] } { - # not instantiated... is it already defined (existing href)? or must we use the one of the global definition? - if { ![string eq $existing_href ""] } { - # it is already defined - # NOTE: there must be a better way to deal with this, - # but by the moment we treat the href as the property value - set initial_value $existing_href - } - # TODO: the property must be somehow instantiated in the given URI also - set instance_id [imsld::item_revision_new -attributes [list [list value $value] \ - [list identifier $identifier] \ - [list party_id $party_id] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $identifier \ - -parent_id [expr [string eq $datatype "file"] ? $global_folder_id : $cr_folder_id]] - if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value - } - - # delete old instance - db_dml delte_old_instance { - delete from imsld_property_instances where instance_id = :old_instance_id - } - } - } - } - global { - # get instance info - if { ![db_0or1row get_instance_info { - select instance_id as old_instance_id, - party_id, - value - from imsld_property_instances - where identifier = :identifier - }] } { - continue - } + if { ![db_0or1row loc_already_instantiated_p { + select 1 + from imsld_property_instancesi + where property_id = :property_id + and identifier = :identifier + and run_id = :run_id + }] } { + set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ + [list value $value] \ + [list identifier $identifier] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -title $identifier \ + -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] + + if { [string eq $datatype "file"] } { + # initialize the file to an empty one so the fs doesn't generate an error when requesting the file + imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value + } + # delete old instance + db_dml delte_old_instance { + delete from imsld_property_instances where instance_id = :old_instance_id + } + } + } + locpers { + foreach party_id [db_list users_in_run { + select ar.object_id_two as party_id + from acs_rels ar + where ar.object_id_one = :run_group_id + and ar.rel_type = 'imsld_run_users_group_rel' + }] { + + # get instance info + if { ![db_0or1row get_instance_info { + select instance_id as old_instance_id, + party_id, + value + from imsld_property_instances + where property_id = :property_id + and identifier = :identifier + and party_id = :party_id + and run_id = :run_id + }] } { + continue + } + + if { ![db_0or1row locrole_already_instantiated_p { + select 1 + from imsld_property_instancesi + where property_id = :property_id + and identifier = :identifier + and party_id = :party_id + and run_id = :run_id + }] } { + set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ + [list value $value] \ + [list identifier $identifier] \ + [list party_id $party_id] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -title $identifier \ + -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] + if { [string eq $datatype "file"] } { + # initialize the file to an empty one so the fs doesn't generate an error when requesting the file + imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value + } + # delete old instance + db_dml delte_old_instance { + delete from imsld_property_instances where instance_id = :old_instance_id + } + } + } + } + locrole { + foreach party_id [db_list roles_instances_in_run { + select ar1.object_id_two as party_id + from acs_rels ar1, acs_rels ar2, acs_rels ar3, + public.imsld_run_users_group_ext run_group + where ar1.rel_type = 'imsld_role_group_rel' + and ar1.object_id_two = ar2.object_id_one + and ar2.rel_type = 'imsld_roleinstance_run_rel' + and ar2.object_id_two = ar3.object_id_one + and ar3.object_id_one = run_group.group_id + and run_group.run_id = :run_id + }] { + # get instance info + if { ![db_0or1row get_instance_info { + select instance_id as old_instance_id, + party_id, + value + from imsld_property_instances + where property_id = :property_id + and identifier = :identifier + and party_id = :party_id + and run_id = :run_id + }] } { + continue + } + + if { ![db_0or1row locrole_already_instantiated_p { + select 1 + from imsld_property_instancesi + where property_id = :property_id + and identifier = :identifier + and party_id = :party_id + and run_id = :run_id + }] } { + + set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ + [list value $value] \ + [list identifier $identifier] \ + [list party_id $party_id] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -title $identifier \ + -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] + if { [string eq $datatype "file"] } { + # initialize the file to an empty one so the fs doesn't generate an error when requesting the file + imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value + } + + # delete old instance + db_dml delte_old_instance { + delete from imsld_property_instances where instance_id = :old_instance_id + } + } + } + } + globpers { + foreach party_id [db_list user_in_run { + select ar.object_id_two as party_id + from acs_rels ar + where ar.object_id_one = :run_group_id + and ar.rel_type = 'imsld_run_users_group_rel' + }] { + # get instance info + if { ![db_0or1row get_instance_info { + select instance_id as old_instance_id, + party_id, + value + from imsld_property_instances + where identifier = :identifier + and party_id = :party_id + }] } { + continue + } + + if { ![db_0or1row globpers_already_instantiated_p { + select 1 + from imsld_property_instancesi + where identifier = :identifier + and party_id = :party_id + }] } { + # not instantiated... is it already defined (existing href)? or must we use the one of the global definition? + if { ![string eq $existing_href ""] } { + # it is already defined + # NOTE: there must be a better way to deal with this, + # but by the moment we treat the href as the property value + set initial_value $existing_href + } + # TODO: the property must be somehow instantiated in the given URI also + set instance_id [imsld::item_revision_new -attributes [list [list value $value] \ + [list identifier $identifier] \ + [list party_id $party_id] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -title $identifier \ + -parent_id [expr [string eq $datatype "file"] ? $global_folder_id : $cr_folder_id]] + if { [string eq $datatype "file"] } { + # initialize the file to an empty one so the fs doesn't generate an error when requesting the file + imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value + } + + # delete old instance + db_dml delte_old_instance { + delete from imsld_property_instances where instance_id = :old_instance_id + } + } + } + } + global { + # get instance info + if { ![db_0or1row get_instance_info { + select instance_id as old_instance_id, + party_id, + value + from imsld_property_instances + where identifier = :identifier + }] } { + continue + } - if { ![db_0or1row global_already_instantiated_p { - select 1 - from imsld_property_instancesi - where identifier = :identifier - }] } { - # not instantiated... is it already defined (existing href)? or must we use the one of the global definition? - if { ![string eq $existing_href ""] } { - # it is already defined - # NOTE: there must be a better way to deal with this, but by the moment we treat the href as the property value - set initial_value $existing_href - } - # TODO: the property must be somehow instantiated in the given URI also - set instance_id [imsld::item_revision_new -attributes [list [list value $value] \ - [list identifier $identifier] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -parent_id [expr [string eq $datatype "file"] ? $global_folder_id : $cr_folder_id]] - if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value - } - - # delete old instance - db_dml delte_old_instance { - delete from imsld_property_instances where instance_id = :old_instance_id - } - } - } - } - } - } - } + if { ![db_0or1row global_already_instantiated_p { + select 1 + from imsld_property_instancesi + where identifier = :identifier + }] } { + # not instantiated... is it already defined (existing href)? or must we use the one of the global definition? + if { ![string eq $existing_href ""] } { + # it is already defined + # NOTE: there must be a better way to deal with this, but by the moment we treat the href as the property value + set initial_value $existing_href + } + # TODO: the property must be somehow instantiated in the given URI also + set instance_id [imsld::item_revision_new -attributes [list [list value $value] \ + [list identifier $identifier] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -parent_id [expr [string eq $datatype "file"] ? $global_folder_id : $cr_folder_id]] + if { [string eq $datatype "file"] } { + # initialize the file to an empty one so the fs doesn't generate an error when requesting the file + imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] -string $value + } + + # delete old instance + db_dml delte_old_instance { + delete from imsld_property_instances where instance_id = :old_instance_id + } + } + } + } + } + } + } } } @@ -988,7 +988,7 @@ } { imsld::rel_type_delete -rel_type imsld_role_group_rel imsld::rel_type_delete -rel_type imsld_roleinstance_run_rel -#TODO: drop attributes + #TODO: drop attributes imsld::rel_type_delete -rel_type imsld_run_users_group_rel } @@ -999,7 +999,7 @@ } { imsld::group_type_delete -group_type imsld_role_group -#TODO: drop attributes + #TODO: drop attributes imsld::group_type_delete -group_type imsld_run_users_group } @@ -1321,37 +1321,37 @@ set dotlrn_root_folder_id [dotlrn_fs::get_dotlrn_root_folder_id] db_transaction { - # create the root cr dir + # create the root cr dir - set global_folder_id [imsld::cr::folder_new \ - -parent_id $dotlrn_root_folder_id \ - -folder_name $folder_name \ - -folder_label "IMS-LD"] + set global_folder_id [imsld::cr::folder_new \ + -parent_id $dotlrn_root_folder_id \ + -folder_name $folder_name \ + -folder_label "IMS-LD"] - # PERMISSIONS FOR FILE-STORAGE + # PERMISSIONS FOR FILE-STORAGE - # Before we go about anything else, lets just set permissions - # straight. - # Disable folder permissions inheritance - permission::set_not_inherit -object_id $global_folder_id + # Before we go about anything else, lets just set permissions + # straight. + # Disable folder permissions inheritance + permission::set_not_inherit -object_id $global_folder_id - # Set read permissions for *all* other professors within .LRN - # (so they can see the content) - set party_id_professor [dotlrn::user::type::get_segment_id -type professor] - permission::grant -party_id $party_id_professor -object_id $global_folder_id -privilege read - - # Set read permissions for *all* other admins within .LRN - # (so they can see the content) - set party_id_admins [dotlrn::user::type::get_segment_id -type admin] - permission::grant -party_id $party_id_admins -object_id $global_folder_id -privilege read + # Set read permissions for *all* other professors within .LRN + # (so they can see the content) + set party_id_professor [dotlrn::user::type::get_segment_id -type professor] + permission::grant -party_id $party_id_professor -object_id $global_folder_id -privilege read + + # Set read permissions for *all* other admins within .LRN + # (so they can see the content) + set party_id_admins [dotlrn::user::type::get_segment_id -type admin] + permission::grant -party_id $party_id_admins -object_id $global_folder_id -privilege read } # register content types content::folder::register_content_type -folder_id $global_folder_id \ - -content_type imsld_property_instance + -content_type imsld_property_instance # allow subfolders inside our parent folder content::folder::register_content_type -folder_id $global_folder_id \ - -content_type content_folder + -content_type content_folder return $global_folder_id } Index: openacs-4/packages/imsld/tcl/imsld-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-procs.tcl,v diff -u -r1.122 -r1.123 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 13 Jan 2010 16:09:47 -0000 1.122 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 14 Jan 2010 09:44:45 -0000 1.123 @@ -2716,7 +2716,7 @@ } } # get associated urls - + db_foreach associated_urls { *SQL* } { set a_node [$dom_doc createElement a] Index: openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl,v diff -u -r1.22 -r1.23 --- openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl 13 Jan 2010 16:13:44 -0000 1.22 +++ openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl 14 Jan 2010 09:44:45 -0000 1.23 @@ -23,84 +23,84 @@ {-tmpfile ""} } { db_1row instance_info { - select ins.run_id, - prop.component_id, - ins.identifier, - ins.party_id, - prop.type, - prop.role_id, - prop.existing_href, - prop.uri, - prop.datatype, - prop.initial_value, - ins.property_id, - ins.title, - ins.item_id - from imsld_property_instancesx ins, - imsld_properties prop - where ins.instance_id = :instance_id - and ins.property_id = prop.property_id - and content_revision__is_live(ins.instance_id) = 't' + select ins.run_id, + prop.component_id, + ins.identifier, + ins.party_id, + prop.type, + prop.role_id, + prop.existing_href, + prop.uri, + prop.datatype, + prop.initial_value, + ins.property_id, + ins.title, + ins.item_id + from imsld_property_instancesx ins, + imsld_properties prop + where ins.instance_id = :instance_id + and ins.property_id = prop.property_id + and content_revision__is_live(ins.instance_id) = 't' } - # db_dml update_instance_value { *SQL* } + # db_dml update_instance_value { *SQL* } set instance_item_id \ - [imsld::item_revision_new -attributes \ - [list [list run_id $run_id] \ - [list value $value] \ - [list identifier $identifier] \ - [list party_id $party_id] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $title \ - -item_id $item_id] - + [imsld::item_revision_new -attributes \ + [list [list run_id $run_id] \ + [list value $value] \ + [list identifier $identifier] \ + [list party_id $party_id] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -title $title \ + -item_id $item_id] + if { [string eq "file" $datatype] } { - set instance_id \ - [content::item::get_live_revision -item_id $instance_item_id] - - # Get the filename part of the upload file - if { ![regexp {[^//\\]+$} $upload_file file_name] } { - # no match - set file_name [imsld::safe_url_name -name $upload_file] - } + set instance_id \ + [content::item::get_live_revision -item_id $instance_item_id] + + # Get the filename part of the upload file + if { ![regexp {[^//\\]+$} $upload_file file_name] } { + # no match + set file_name [imsld::safe_url_name -name $upload_file] + } - set mime_type [cr_filename_to_mime_type -create $file_name] - # database_p according to the file storage parameter - set fs_package_id \ - [site_node_apm_integration::get_child_package_id \ - -package_id [dotlrn_community::get_package_id \ - [dotlrn_community::get_community_id]] \ - -package_key "file-storage"] - set database_p [parameter::get -parameter \ - "StoreFilesInDatabaseP" -package_id $fs_package_id] - set content_length [file size $tmpfile] - if { !$database_p } { - # create the new item - set filename [cr_create_content_file $item_id $instance_id $tmpfile] - db_dml set_file_content { - update cr_revisions - set content = :filename, - mime_type = :mime_type, - content_length = :content_length - where revision_id = :instance_id - } - } else { - # create the new item - db_dml lob_content " + set mime_type [cr_filename_to_mime_type -create $file_name] + # database_p according to the file storage parameter + set fs_package_id \ + [site_node_apm_integration::get_child_package_id \ + -package_id [dotlrn_community::get_package_id \ + [dotlrn_community::get_community_id]] \ + -package_key "file-storage"] + set database_p [parameter::get -parameter \ + "StoreFilesInDatabaseP" -package_id $fs_package_id] + set content_length [file size $tmpfile] + if { !$database_p } { + # create the new item + set filename [cr_create_content_file $item_id $instance_id $tmpfile] + db_dml set_file_content { + update cr_revisions + set content = :filename, + mime_type = :mime_type, + content_length = :content_length + where revision_id = :instance_id + } + } else { + # create the new item + db_dml lob_content " update cr_revisions set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] where revision_id = :instance_id" -blob_files [list $tmpfile] - - # Unfortunately, we can only calculate the file size after the lob - # is uploaded - db_dml lob_size { - update cr_revisions - set content_length = :content_length - where revision_id = :instance_id - } - } + + # Unfortunately, we can only calculate the file size after the lob + # is uploaded + db_dml lob_size { + update cr_revisions + set content_length = :content_length + where revision_id = :instance_id + } + } } } @@ -121,21 +121,21 @@ # property info if { [string eq $property_id ""] } { - # context info in case we need to obtain the property_id from the identifier - db_1row context_info { - select ic.item_id as component_item_id - from imsld_componentsi ic, imsld_imsldsi ii, imsld_runs ir, imsld_run_users_group_ext rug - where ic.imsld_id = ii.item_id - and content_revision__is_live(ii.imsld_id) = 't' - and ii.imsld_id = ir.imsld_id - and rug.run_id = ir.run_id - and ir.run_id = :run_id - } + # context info in case we need to obtain the property_id from the identifier + db_1row context_info { + select ic.item_id as component_item_id + from imsld_componentsi ic, imsld_imsldsi ii, imsld_runs ir, imsld_run_users_group_ext rug + where ic.imsld_id = ii.item_id + and content_revision__is_live(ii.imsld_id) = 't' + and ii.imsld_id = ir.imsld_id + and rug.run_id = ir.run_id + and ir.run_id = :run_id + } db_1row property_info_from_identifier { select type, property_id, role_id, - datatype + datatype from imsld_properties where component_id = :component_item_id and identifier = :identifier @@ -145,7 +145,7 @@ select type, identifier, role_id, - datatype + datatype from imsld_properties where property_id = :property_id } @@ -155,136 +155,136 @@ # run-time procs or from the monitor interface if we are inside the monitor # interface, we know the role_instance_id, otherwise we have to find it out if { [string eq "" $role_instance_id] && [string eq $type "locrole"] } { - if { ![string eq $role_id ""] } { - # find the role instance we are working on - set role_instance_id [imsld::roles::get_user_role_instance -run_id $run_id -role_id $role_id -user_id $user_id] - if { !$role_instance_id } { - # runtime error... the user doesn't belong to any role instance - util_user_message -message "[_ imsld.lt_User_does_not_belong_]" - ad_script_abort - } - } + if { ![string eq $role_id ""] } { + # find the role instance we are working on + set role_instance_id [imsld::roles::get_user_role_instance -run_id $run_id -role_id $role_id -user_id $user_id] + if { !$role_instance_id } { + # runtime error... the user doesn't belong to any role instance + util_user_message -message "[_ imsld.lt_User_does_not_belong_]" + ad_script_abort + } + } } db_1row get_property_instance { select ins.instance_id, ins.value as old_value from imsld_property_instances ins, - imsld_properties prop + imsld_properties prop where ins.property_id = prop.property_id - and prop.property_id = :property_id + and prop.property_id = :property_id and ((prop.type = 'global') or (prop.type = 'loc' and ins.run_id = :run_id) or (prop.type = 'locpers' and ins.run_id = :run_id and ins.party_id = :user_id) or (prop.type = 'locrole' and ins.run_id = :run_id and ins.party_id = :role_instance_id) or (prop.type = 'globpers' and ins.party_id = :user_id)) - and content_revision__is_live(ins.instance_id) = 't' + and content_revision__is_live(ins.instance_id) = 't' } if { ![string eq $datatype "file"] } { - # validate against restrictions - set enumeration_list [list] - db_foreach restriction { - select restriction_type, - value as restriction_value - from imsld_restrictions - where property_id = :property_id - } { - switch $restriction_type { - length { - if { [length $value] <> $restriction_value } { - return [list 0 "[_ imsld.lt_The_length_must_be_re]"] - } - } - minLength { - if { [length $value] < $restriction_value } { - return [list 0 "[_ imsld.lt_The_length_must_be_gr]"] - } - } - maxLength { - if { [length $value] > $restriction_value } { - return [list 0 "[_ imsld.lt_The_length_must_be_lo]"] - } - } - enumeration { - lappend enumeration_list $restriction_value - } - maxInclusive { - if { $value > $restriction_value } { - return [list 0 "[_ imsld.lt_The_value_must_be_low]"] - } - } - minInclusive { - if {$value < $restriction_value } { - return [list 0 "[_ imsld.lt_The_value_must_be_gre]"] - } - } - maxExclusive { - if { $value >= $restriction_value } { - return [list 0 "[_ imsld.lt_The_value_must_be_low_1]"] - } - } - minExclusive { - if { $value <= $restriction_value } { - return [list 0 "[_ imsld.lt_The_value_must_be_gre_1]"] - } - } - totalDigits { - if { [expr int($value)] <> $restriction_value } { - return [list 0 "[_ imsld.lt_The_integer_part_cant]"] - } - } - fractionDigits { - if { [expr [string length "$value"] - [string last "." "$value"] - 1] > $restriction_value } { - return [list 0 "[_ imsld.lt_The_decimal_digits_ca]"] - } - } - pattern { - if { ![regexp "$restriction_value" $value] } { - return [list 0 "[_ imsld.lt_The_value_value_doesn]"] - } - } - } - } - - if { [llength $enumeration_list] && [lsearch -exact $enumeration_list $value] == -1 } { - return [list 0 "[_ imsld.lt_The_value_value_is_no]"] - } - imsld::runtime::property::instance_value_set -instance_id $instance_id -value $value + # validate against restrictions + set enumeration_list [list] + db_foreach restriction { + select restriction_type, + value as restriction_value + from imsld_restrictions + where property_id = :property_id + } { + switch $restriction_type { + length { + if { [length $value] <> $restriction_value } { + return [list 0 "[_ imsld.lt_The_length_must_be_re]"] + } + } + minLength { + if { [length $value] < $restriction_value } { + return [list 0 "[_ imsld.lt_The_length_must_be_gr]"] + } + } + maxLength { + if { [length $value] > $restriction_value } { + return [list 0 "[_ imsld.lt_The_length_must_be_lo]"] + } + } + enumeration { + lappend enumeration_list $restriction_value + } + maxInclusive { + if { $value > $restriction_value } { + return [list 0 "[_ imsld.lt_The_value_must_be_low]"] + } + } + minInclusive { + if {$value < $restriction_value } { + return [list 0 "[_ imsld.lt_The_value_must_be_gre]"] + } + } + maxExclusive { + if { $value >= $restriction_value } { + return [list 0 "[_ imsld.lt_The_value_must_be_low_1]"] + } + } + minExclusive { + if { $value <= $restriction_value } { + return [list 0 "[_ imsld.lt_The_value_must_be_gre_1]"] + } + } + totalDigits { + if { [expr int($value)] <> $restriction_value } { + return [list 0 "[_ imsld.lt_The_integer_part_cant]"] + } + } + fractionDigits { + if { [expr [string length "$value"] - [string last "." "$value"] - 1] > $restriction_value } { + return [list 0 "[_ imsld.lt_The_decimal_digits_ca]"] + } + } + pattern { + if { ![regexp "$restriction_value" $value] } { + return [list 0 "[_ imsld.lt_The_value_value_doesn]"] + } + } + } + } + + if { [llength $enumeration_list] && [lsearch -exact $enumeration_list $value] == -1 } { + return [list 0 "[_ imsld.lt_The_value_value_is_no]"] + } + imsld::runtime::property::instance_value_set -instance_id $instance_id -value $value } else { - imsld::runtime::property::instance_value_set -instance_id $instance_id -upload_file $upload_file -tmpfile $tmpfile + imsld::runtime::property::instance_value_set -instance_id $instance_id -upload_file $upload_file -tmpfile $tmpfile } # Recursive call only if the property value has changed if { $old_value != $value } { - - # There might be infinite recursive loops, so the counter - # recursivity_count is used to avoid crashing the server - if { ![exists_and_not_null recursivity_count] } { - # this is the first recursive call, initialize the variable - set recursivity_count 1 - } else { - incr recursivity_count - } -#FIXME: the parameter has to be set as a package parameter. Meanwhile, I use a constant - set ConditionsRecursionLimit [parameter::get -package_id [apm_package_id_from_key imsld-portlet] -parameter ConditionsRecursionLimit ] - set ConditionsRecursionLimit 20 - - if { $recursivity_count >= $ConditionsRecursionLimit } { - ns_log error "IMSLD::imsld::runtime::property::property_value_set [_ imsld.lt_Unstable_state_reache]" - ad_return_error "[_ imsld.lt_Unestable_state_reach]" "[_ imsld.lt_Unstable_state_reache]" - ad_script_abort - } + + # There might be infinite recursive loops, so the counter + # recursivity_count is used to avoid crashing the server + if { ![exists_and_not_null recursivity_count] } { + # this is the first recursive call, initialize the variable + set recursivity_count 1 + } else { + incr recursivity_count + } + #FIXME: the parameter has to be set as a package parameter. Meanwhile, I use a constant + set ConditionsRecursionLimit [parameter::get -package_id [apm_package_id_from_key imsld-portlet] -parameter ConditionsRecursionLimit ] + set ConditionsRecursionLimit 20 + + if { $recursivity_count >= $ConditionsRecursionLimit } { + ns_log error "IMSLD::imsld::runtime::property::property_value_set [_ imsld.lt_Unstable_state_reache]" + ad_return_error "[_ imsld.lt_Unestable_state_reach]" "[_ imsld.lt_Unstable_state_reache]" + ad_script_abort + } set conditions_list [db_list get_conditions_from_property { - select ici.condition_id - from imsld_conditionsi ici, - acs_rels ar, - imsld_propertiesi ipi - where ipi.property_id = :property_id - and ipi.item_id = ar.object_id_one - and ar.rel_type = 'imsld_prop_cond_rel' - and ar.object_id_two = ici.item_id + select ici.condition_id + from imsld_conditionsi ici, + acs_rels ar, + imsld_propertiesi ipi + where ipi.property_id = :property_id + and ipi.item_id = ar.object_id_one + and ar.rel_type = 'imsld_prop_cond_rel' + and ar.object_id_two = ici.item_id order by ici.condition_id }] #property conditions @@ -301,14 +301,14 @@ }] { foreach condition_id $conditions_list { set condition_xml [db_string get_xml_piece { - select condition_xml - from imsld_conditions - where condition_id=:condition_id + select condition_xml + from imsld_conditions + where condition_id=:condition_id }] dom parse $condition_xml document $document documentElement condition_node imsld::condition::execute -run_id $run_id -user_id $member_id -condition $condition_node - $document delete + $document delete } } @@ -344,7 +344,7 @@ and ar.rel_type = 'imsld_prop_wpv_is_rel' }] { imsld::condition::eval_when_prop_value_is_set \ - -complete_act_item_id $complete_act_item_id -run_id $run_id + -complete_act_item_id $complete_act_item_id -run_id $run_id } # role conditions, time conditions... the rest of conditions must be @@ -395,7 +395,7 @@ from imsld_properties where component_id = :component_item_id and identifier = :identifier - limit 1 + limit 1 } } else { db_1row property_info_from_id { @@ -404,7 +404,7 @@ role_id from imsld_properties where property_id = :property_id - limit 1 + limit 1 } } @@ -414,24 +414,24 @@ set role_instance_id [imsld::roles::get_user_role_instance -run_id $run_id -role_id $role_id -user_id $user_id] if { !$role_instance_id } { # runtime error... the user doesn't belong to any role instance - util_user_message -message "[_ imsld.lt_User_does_not_belong_]" - ad_script_abort + util_user_message -message "[_ imsld.lt_User_does_not_belong_]" + ad_script_abort } } db_1row get_property_value { select prop.datatype, coalesce(ins.value, prop.initial_value) as value from imsld_property_instances ins, - imsld_properties prop + imsld_properties prop where ins.property_id = :property_id - and prop.property_id = ins.property_id + and prop.property_id = ins.property_id and ((prop.type = 'global') or (prop.type = 'loc' and ins.run_id = :run_id) or (prop.type = 'locpers' and ins.run_id = :run_id and ins.party_id = :user_id) or (prop.type = 'locrole' and ins.run_id = :run_id and ins.party_id = :role_instance_id) or (prop.type = 'globpers' and ins.party_id = :user_id)) - and content_revision__is_live(ins.instance_id) = 't' + and content_revision__is_live(ins.instance_id) = 't' } return $value } @@ -466,11 +466,11 @@ } { set user_id [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] if { [string eq $action "show"] } { - set is_visible_p "t" + set is_visible_p "t" } else { - set is_visible_p "f" + set is_visible_p "f" } - + db_dml set_isvisible_shown_hidden { *SQL* } } @@ -535,8 +535,8 @@ if {![info exist user_id]} { set user_id [ad_conn user_id] } - - # according to the spec, the activity structures doesn't have any isvisible attribute + + # according to the spec, the activity structures doesn't have any isvisible attribute # so we show the referenced activities, learning infos and environments db_1row context_info { @@ -645,9 +645,9 @@ select cr.live_revision as child_structure_id from imsld_activity_structuresi ias, acs_rels ar, cr_items cr where ar.object_id_one = ias.item_id - and ias.structure_id = :structure_id - and ar.rel_type = 'imsld_as_as_rel' - and cr.item_id = ar.object_id_two + and ias.structure_id = :structure_id + and ar.rel_type = 'imsld_as_as_rel' + and cr.item_id = ar.object_id_two } { set has_visible_child_p [imsld::runtime::activity_structure::has_visible_child_p \ -run_id $run_id \ @@ -670,13 +670,13 @@ returns a list of all the user_ids associated to the run } { return [db_list get_users_in_run { - select gmm.member_id - from group_member_map gmm, - imsld_run_users_group_ext iruge, - acs_rels ar1 - where iruge.run_id=:run_id - and ar1.object_id_two=iruge.group_id - and ar1.object_id_one=gmm.group_id - group by member_id + select gmm.member_id + from group_member_map gmm, + imsld_run_users_group_ext iruge, + acs_rels ar1 + where iruge.run_id=:run_id + and ar1.object_id_two=iruge.group_id + and ar1.object_id_one=gmm.group_id + group by member_id }] }