Index: openacs-4/packages/dotlrn/tcl/community-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.tcl,v diff -u -r1.42 -r1.43 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 17 Dec 2001 23:02:56 -0000 1.42 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 10 Jan 2002 00:11:38 -0000 1.43 @@ -414,10 +414,14 @@ # Set up the relationship set rel_id [relation_add -extra_vars $extra_vars $rel_type $community_id $user_id] - - # do the callbacks - applets_dispatch $community_id AddUserToCommunity [list $community_id $user_id] } + + # do the callbacks, can't be in the transaction since the portal_id must exist + applets_dispatch -community_id $community_id \ + -op AddUserToCommunity \ + -list_args [list $community_id $user_id] + + } ad_proc -public remove_user { @@ -428,7 +432,10 @@ } { db_transaction { # Callbacks - applets_dispatch $community_id RemoveUser [list $community_id $user_id] + applets_dispatch \ + -community_id $community_id \ + -op RemoveUser \ + -list_args [list $community_id $user_id] # Get a few important things, like rel_id and portal portal_id db_1row select_rel_info {} @@ -592,18 +599,64 @@ return [db_string select_portal_template_id {} -default ""] } - ad_proc -public add_applet { + ad_proc -public add_applet_to_dotlrn { + {-applet_key:required} + {-activate_p "t"} + } { + dotlrn-init.tcl calls AddApplet on all applets using acs_sc directly. + The add_applet proc in the applet (e.g. dotlrn-calendar) calls this + proc to tell dotlrn to register and/or activate itself. This _must_ + be able to be run multiple times! + } { + + if {![empty_string_p [get_applet_id_from_key -applet_key $applet_key]]} { + # there's already a dotlrn applet registered with this key, abort + return + } + + if {$activate_p == "t"} { + set status "active" + } else { + set status "inactive" + } + + ns_log notice "aks debug add_applet_to_dotlrn called with $applet_key" + + db_transaction { + set applet_id [db_nextval acs_object_id_seq] + db_dml insert {} + } + } + + ad_proc -public get_applet_id_from_key { + {-applet_key:required} + } { + get the id of the dotlrn applet from the applet key or the null + string if the key dosent exist + } { + return [db_string select {} -default ""] + } + + + ad_proc -public add_applet_to_community { community_id applet_key } { Adds an applet to the community } { + + ns_log notice "aks debug add_applet_to_comm called with $applet_key" + db_transaction { # Callback set package_id [applet_call $applet_key AddAppletToCommunity [list $community_id]] + set applet_id [get_applet_id_from_key -applet_key $applet_key] + # auto activate for now + set active_p "t" + # Insert in the DB - db_dml insert_applet {} + db_dml insert {} # Go through current users and make sure they are added! foreach user [list_users $community_id] { @@ -615,6 +668,7 @@ } } + ad_proc -public remove_applet { community_id applet_key @@ -642,9 +696,9 @@ } ad_proc -public list_applets { - {community_id ""} + {-community_id ""} } { - Lists the applets associated with a community + Lists the applets associated with a community or all the dotlrn applets } { if {[empty_string_p $community_id]} { # List all applets @@ -655,14 +709,39 @@ } } + ad_proc -public list_active_applets { + {-community_id ""} + } { + Lists the applets associated with a community or only the active dotlrn + applets + } { + + ns_log notice "aks debug list_active_applets called with comm_id = $community_id" + + if {[empty_string_p $community_id]} { + # List all applets + return [db_list select_all_active_applets {}] + } else { + # List from the DB + return [db_list select_community_active_applets {}] + } + } + ad_proc -public applets_dispatch { - community_id - op - list_args + {-community_id ""} + {-op:required} + {-list_args {}} } { - Dispatch an operation to every applet + Dispatch an operation to every applet, either in one communtiy or + on all the active dotlrn applets } { - foreach applet [list_applets $community_id] { + + ns_log notice "aks 20 debug applets_dispatch called with comm_id = $community_id, op $op, + list args $list_args length is [llength $list_args]" + + set list_of_applets [list_active_applets -community_id $community_id] + + foreach applet $list_of_applets { # Callback on applet applet_call $applet $op $list_args } @@ -678,3 +757,4 @@ acs_sc_call dotlrn_applet $op $list_args $applet_key } } + Index: openacs-4/packages/dotlrn/tcl/community-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.xql,v diff -u -r1.18 -r1.19 --- openacs-4/packages/dotlrn/tcl/community-procs.xql 17 Dec 2001 23:02:56 -0000 1.18 +++ openacs-4/packages/dotlrn/tcl/community-procs.xql 10 Jan 2002 00:11:38 -0000 1.19 @@ -147,7 +147,11 @@ -select package_id from dotlrn_community_applets where community_id= :community_id and applet_key= :applet_key +select package_id +from dotlrn_community_applets dca, dotlrn_applets da +where community_id= :community_id +and applet_key= :applet_key +and dca.applet_id = da.applet_id @@ -169,13 +173,28 @@ + + +select applet_id from dotlrn_applets where applet_key = :applet_key + + - + + +insert into dotlrn_applets +(applet_id, applet_key, status) +values +(:applet_id, :applet_key, :status) + + + + + insert into dotlrn_community_applets -(community_id, applet_key, package_id) +(community_id, applet_id, package_id, active_p) values -(:community_id, :applet_key, :package_id) +(:community_id, :applet_id, :package_id, :active_p) @@ -198,10 +217,32 @@ -select applet_key from dotlrn_community_applets where community_id= :community_id +select applet_key +from dotlrn_community_applets dca, dotlrn_applets da +where community_id= :community_id +and dca.applet_id = da.applet_id + + +select applet_key from dotlrn_applets where status = 'active' + + + + + +select applet_key +from dotlrn_community_applets dca, dotlrn_applets da +where community_id= :community_id +and active_p = 't' +and dca.applet_id = da.applet_id +and status = 'active' + + + + + select count(*) 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.12 -r1.13 --- openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl 13 Dec 2001 21:26:59 -0000 1.12 +++ openacs-4/packages/dotlrn/tcl/dotlrn-init.tcl 10 Jan 2002 00:11:38 -0000 1.13 @@ -18,17 +18,23 @@ # We check to see if dotLRN has been installed, and if so, if permissions # have been granted +ns_log notice "aks: dotlrn-init: starting" + # if installed if {[dotlrn::is_instantiated]} { + ns_log notice "aks: dotlrn-init: got here 1" if {![dotlrn::is_initialized]} { dotlrn::init } + + ns_log notice "aks: dotlrn-init: got here 2" + if {![dotlrn_class::is_initialized]} { dotlrn_class::init } + + ns_log notice "aks: dotlrn-init: got here 3" + if {![dotlrn_club::is_initialized]} { dotlrn_club::init } - set portal_package_key "new-portal" - if {![dotlrn::is_instantiated_here -url [portal::automount_point] -package_key $portal_package_key]} { - dotlrn::mount_package -parent_node_id [site_node_id "/"] -package_key $portal_package_key -url "portal" -directory_p "t" - } + ns_log notice "aks: dotlrn-init: got here 4" # Grantee set grantee_id [dotlrn::get_full_users_rel_segment_id] @@ -51,6 +57,16 @@ # Callback on all applets dotlrn_community::applet_call $applet "AddApplet" [list] } + + set portal_package_key "new-portal" + if {[site_nodes::mount_count -package_key $portal_package_key] == 0} { + ns_log notice "aks: dotlrn-init: new-portal being automounted" + + dotlrn::mount_package -parent_node_id [site_node_id "/"] -package_key $portal_package_key -url "portal" -directory_p "t" + } else { + ns_log notice "aks: dotlrn-init: new-portal NOT being automounted" + } + } # 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.27 -r1.28 --- openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl 11 Dec 2001 03:47:53 -0000 1.27 +++ openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl 10 Jan 2002 00:11:38 -0000 1.28 @@ -62,6 +62,9 @@ } { returns 1 if dotlrn is instantiaed under the url specified, 0 otherwise + + XXX - aks - I think there a bug in here somewhere - use the + procs in site_nodes:: instead. Thanks. } { set result 0 Index: openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl 3 Dec 2001 19:33:03 -0000 1.10 +++ openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl 10 Jan 2002 00:11:38 -0000 1.11 @@ -55,12 +55,19 @@ # Update the user and set the portal page correctly ns_set put $extra_vars portal_id $portal_id + } # Add the relation (no need to feed in anything for object_id_one, or two for that matter). set rel_id [relation_add -extra_vars $extra_vars -member_state approved $rel_type "" $user_id] } + # must be here since wsp must exist in the dotlrn_full_users table, + #do the callbacks on the active dotlrn-wide applets + dotlrn_community::applets_dispatch \ + -op AddUser \ + -list_args [list $user_id] + return $rel_id } Index: openacs-4/packages/dotlrn/www/community-applet-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/community-applet-add.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn/www/community-applet-add.tcl 28 Nov 2001 00:11:48 -0000 1.2 +++ openacs-4/packages/dotlrn/www/community-applet-add.tcl 10 Jan 2002 00:11:38 -0000 1.3 @@ -17,7 +17,7 @@ } # Add the applet -dotlrn_community::add_applet $community_id $applet_key +dotlrn_community::add_applet_to_community $community_id $applet_key # Get back to where you once belonged ns_returnredirect community-applets?community_id=$community_id Index: openacs-4/packages/dotlrn/www/community-applets.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/community-applets.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn/www/community-applets.tcl 29 Nov 2001 06:05:37 -0000 1.3 +++ openacs-4/packages/dotlrn/www/community-applets.tcl 10 Jan 2002 00:11:38 -0000 1.4 @@ -16,7 +16,7 @@ db_1row select_community_info {} # Get active applets -set list_of_active_applets [dotlrn_community::list_applets $community_id] +set list_of_active_applets [dotlrn_community::list_applets -community_id $community_id] template::multirow create active_applets applet_key applet_pretty_name