Index: openacs-4/packages/dotlrn/tcl/class-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/class-procs.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/dotlrn/tcl/class-procs.tcl 30 Nov 2001 03:41:17 -0000 1.13 +++ openacs-4/packages/dotlrn/tcl/class-procs.tcl 5 Dec 2001 13:32:40 -0000 1.14 @@ -19,84 +19,95 @@ namespace eval dotlrn_class { ad_proc -public new { - {-description ""} - {-class_key:required} - {-pretty_name:required} - {-parent_type "dotlrn_class_instance"} + {-description ""} + {-class_key:required} + {-pretty_name:required} + {-parent_type "dotlrn_class_instance"} } { - Creates a new class, like "Structure and Interpretation of Computer Programs." - The return value is the short class name, a key that works in SQL, and that uniquely - identifies the class. + Creates a new class, like "Structure and Interpretation of Computer Programs." + The return value is the short class name, a key that works in SQL, and that uniquely + identifies the class. - This class can then be instantiated for a particular semester. + This class can then be instantiated for a particular semester. } { - db_transaction { - # create the community type - set class_key [dotlrn_community::new_type \ - -description $description \ - -community_type_key $class_key \ - -parent_type $parent_type \ - -pretty_name $pretty_name] + db_transaction { + # create the community type + set class_key [dotlrn_community::new_type \ + -description $description \ + -community_type_key $class_key \ + -parent_type $parent_type \ + -pretty_name $pretty_name] - # insert the class row (this would be much easier if object types were objects, too - ben) - db_dml insert_class {} - } + # insert the class row (this would be much easier if object types were objects, too - ben) + db_dml insert_class {} + } } ad_proc -public new_instance { - {-description ""} - {-class_type:required} - {-class_name:required} - {-term:required} - {-year:required} + {-description ""} + {-class_type:required} + {-class_name:required} + {-term:required} + {-year:required} } { - Creates a new instance of a class for a particular term and year, - and returns the class instance key. + Creates a new instance of a class for a particular term and year, + and returns the class instance key. } { - set term [string trim $term] - set year [string trim $year] + set term [string trim $term] + set year [string trim $year] - set community_key "$class_type-$term-$year" + set community_key "$class_type-$term-$year" - set extra_vars [ns_set create] - ns_set put $extra_vars year $year - ns_set put $extra_vars term $term - ns_set put $extra_vars class_key $class_type - - # Create the community - return [dotlrn_community::new \ - -description $description \ - -community_type $class_type \ - -object_type dotlrn_class_instance \ - -community_key $community_key \ - -pretty_name $class_name \ - -extra_vars $extra_vars] + set extra_vars [ns_set create] + ns_set put $extra_vars year $year + ns_set put $extra_vars term $term + ns_set put $extra_vars class_key $class_type + + # Create the community + return [dotlrn_community::new \ + -description $description \ + -community_type $class_type \ + -object_type dotlrn_class_instance \ + -community_key $community_key \ + -pretty_name $class_name \ + -extra_vars $extra_vars] } ad_proc -public available_roles { } { - Returns the available roles + Returns the available roles } { - return { - {instructor_rel "Instructor"} - {ta_rel "Teaching Assistant"} - {student_rel "Student"} - {admin_rel "Administrator"} - } + return { + {instructor_rel "Instructor"} + {ta_rel "Teaching Assistant"} + {student_rel "Student"} + {admin_rel "Administrator"} + } } ad_proc -public package_key { } { - Returns the package key for this package + Returns the package key for this package } { - return "dotlrn" + return "dotlrn" } ad_proc -public one_class_package_key { } { - Returns the package key for this package + Returns the package key for this package } { - return "dotlrn" + return "dotlrn" } + ad_proc -public get_url_part {} { + returns the url part for this community type + } { + return "classes" + } + + ad_proc -public get_url {} { + returns the url part for this community type + } { + return "/[get_url_part]" + } } Index: openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl 4 Dec 2001 23:56:14 -0000 1.6 +++ openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl 5 Dec 2001 13:32:40 -0000 1.7 @@ -20,14 +20,31 @@ # if installed if {[dotlrn::is_instantiated]} { + + set dotlrn_classes_url "[dotlrn::get_url][dotlrn_class::get_url]" + if {![dotlrn::is_instantiated_here -url $dotlrn_classes_url]} { + dotlrn::mount_package \ + -package_key [dotlrn::package_key] \ + -url [dotlrn_class::get_url_part] \ + -directory_p "t" + } + + set dotlrn_clubs_url "[dotlrn::get_url][dotlrn_club::get_url]" + if {![dotlrn::is_instantiated_here -url $dotlrn_clubs_url]} { + dotlrn::mount_package \ + -package_key [dotlrn::package_key] \ + -url [dotlrn_club::get_url_part] \ + -directory_p "t" + } + # Grantee set grantee_id [dotlrn::get_full_users_rel_segment_id] set package_id [dotlrn::get_package_id] # Grant the permission if {![ad_permission_p -user_id $grantee_id $package_id dotlrn_browse]} { - ad_permission_grant $grantee_id $package_id dotlrn_browse + ad_permission_grant $grantee_id $package_id dotlrn_browse } # We go through all Applets and make sure they are added. @@ -37,25 +54,9 @@ # called repeatedly since this script is eval'd at every server startup # - aks foreach applet [dotlrn_community::list_applets] { - # Callback on all applets - dotlrn_community::applet_call $applet "AddApplet" [list] + # Callback on all applets + dotlrn_community::applet_call $applet "AddApplet" [list] } - - set dotlrn_classes_url "[dotlrn::get_url][dotlrn_class::get_url]" - if {![dotlrn::is_instantiated_here $dotlrn_classes_url]} { - dotlrn::mount_package - -package_key [dotlrn::package_key] \ - -url $dotlrn_classes_url \ - -directory_p 1 - } - - set dotlrn_clubs_url "[dotlrn::get_url][dotlrn_club::get_url]" - if {![dotlrn::is_instantiated_here $dotlrn_clubs_url]} { - dotlrn::mount_package - -package_key [dotlrn::package_key] \ - -url $dotlrn_clubs_url \ - -directory_p 1 - } } # Make sure that privacy is turned on Index: openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl 4 Dec 2001 23:56:14 -0000 1.19 +++ openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl 5 Dec 2001 13:32:40 -0000 1.20 @@ -97,27 +97,33 @@ } ad_proc -public mount_package { + {-parent_node_id ""} {-package_key:required} {-url:required} {-directory_p:required} } { mount a package under dotlrn } { + set parent_node_id [ad_decode $parent_node_id "" [get_node_id] $parent_node_id] db_transaction { - set parent_node [site_node [site_node::get_url_from_node_id [site_node::get_parent_id [site_node::get_node_id_from_url $url]]]] - set parent_id $parent_node(node_id) + set node_id [db_string get_next_seq_val { + select acs_object_id_seq.nextval from dual + }] + array set parent_node [site_node \ + [site_nodes::get_url_from_node_id -node_id $parent_node_id] + ] set parent_package_id $parent_node(object_id) set node_id [db_exec_plsql mount_package { begin :1 := site_node.new( - node_id => acs_object_id_seq.nextval, - parent_id => :parent_id, + node_id => :node_id, + parent_id => :parent_node_id, name => :url, directory_p => :directory_p ); end; - } + }] return [site_node_create_package_instance $node_id $package_key $parent_package_id $package_key] }