Index: openacs-4/packages/dotlrn/dotlrn.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/dotlrn.info,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/dotlrn/dotlrn.info 5 Dec 2001 22:30:21 -0000 1.18
+++ openacs-4/packages/dotlrn/dotlrn.info 6 Dec 2001 20:50:51 -0000 1.19
@@ -72,6 +72,15 @@
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/dotlrn/sql/oracle/dotlrn-clubs-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/sql/oracle/Attic/dotlrn-clubs-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn/sql/oracle/dotlrn-clubs-create.sql 25 Sep 2001 19:01:42 -0000 1.1
+++ openacs-4/packages/dotlrn/sql/oracle/dotlrn-clubs-create.sql 6 Dec 2001 20:50:51 -0000 1.2
@@ -10,10 +10,87 @@
-- started August 18th, 2001
--
-create table dotlrn_clubs (
- club_id constraint dotlrn_club_id_fk
- references dotlrn_communities(community_id)
- constraint dotlrn_club_id_pk
- primary key
+create table dotlrn_clubs(
+ club_id constraint dotlrn_clubs_club_id_fk
+ references dotlrn_communities (community_id)
+ constraint dotlrn_clubs_pk
+ primary key
);
+create or replace package dotlrn_club
+is
+ function new(
+ club_id in dotlrn_clubs.club_id%TYPE default null,
+ community_key in dotlrn_communities.community_key%TYPE,
+ pretty_name in dotlrn_communities.pretty_name%TYPE,
+ description in dotlrn_communities.description%TYPE,
+ package_id in dotlrn_communities.package_id%TYPE default null,
+ portal_id in dotlrn_communities.portal_id%TYPE default null,
+ portal_template_id in dotlrn_communities.portal_template_id%TYPE default null,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE default null,
+ creation_ip in acs_objects.creation_ip%TYPE default null,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return dotlrn_clubs.club_id%TYPE;
+
+ procedure delete(
+ club_id in dotlrn_clubs.club_id%TYPE
+ );
+end;
+/
+show errors
+
+create or replace package body dotlrn_club
+is
+ function new(
+ club_id in dotlrn_clubs.club_id%TYPE default null,
+ community_key in dotlrn_communities.community_key%TYPE,
+ pretty_name in dotlrn_communities.pretty_name%TYPE,
+ description in dotlrn_communities.description%TYPE,
+ package_id in dotlrn_communities.package_id%TYPE default null,
+ portal_id in dotlrn_communities.portal_id%TYPE default null,
+ portal_template_id in dotlrn_communities.portal_template_id%TYPE default null,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE default null,
+ creation_ip in acs_objects.creation_ip%TYPE default null,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return dotlrn_clubs.club_id%TYPE
+ is
+ v_club_id integer;
+ begin
+ v_club_id := dotlrn_community.new(
+ community_id => club_id,
+ community_type => 'dotlrn_club',
+ community_key => community_key,
+ pretty_name => pretty_name,
+ description => description,
+ package_id => package_id,
+ portal_id => portal_id,
+ portal_template_id => portal_template_id,
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ insert
+ into dotlrn_clubs (club_id)
+ values (v_club_id);
+
+ return v_club_id;
+ end;
+
+ procedure delete(
+ club_id in dotlrn_clubs.club_id%TYPE
+ )
+ is
+ begin
+ delete
+ from dotlrn_clubs
+ where club_id = dotlrn_club.delete.club_id;
+
+ dotlrn_community.delete(community_id => club_id);
+ end;
+end;
+/
+show errors
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.15 -r1.16
--- openacs-4/packages/dotlrn/tcl/class-procs.tcl 5 Dec 2001 22:05:23 -0000 1.15
+++ openacs-4/packages/dotlrn/tcl/class-procs.tcl 6 Dec 2001 20:50:51 -0000 1.16
@@ -27,28 +27,15 @@
ad_proc -public is_initialized {} {
is dotlrn_class initialized with the right community_type?
} {
- set community_type [community_type]
- return [db_string is_dotlrn_class_initialized {
- select count(*)
- from dotlrn_community_types
- where community_type = :community_type
- and package_id is not null
- }]
+ dotlrn_community::is_initialized -community_type [community_type]
}
ad_proc -public init {} {
- create base community_type for dotlrn_class
+ create base community_type for dotlrn_clubs
} {
- db_transaction {
- set dotlrn_classes_url "[dotlrn::get_url][dotlrn_class::get_url]/"
- if {![dotlrn::is_instantiated_here -url $dotlrn_classes_url]} {
- set package_id [dotlrn::mount_package \
- -package_key [dotlrn::package_key] \
- -url [dotlrn_class::get_url_part] \
- -directory_p "t"]
- dotlrn_community::set_type_package_id [community_type] $package_id
- }
- }
+ dotlrn_community::init \
+ -community_type [community_type] \
+ -community_type_url_part [get_url_part]
}
ad_proc -public new {
Index: openacs-4/packages/dotlrn/tcl/club-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/club-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn/tcl/club-procs.tcl 5 Dec 2001 22:29:01 -0000 1.1
+++ openacs-4/packages/dotlrn/tcl/club-procs.tcl 6 Dec 2001 20:50:51 -0000 1.2
@@ -36,29 +36,15 @@
ad_proc -public is_initialized {} {
is dotlrn_class initialized with the right community_type?
} {
- set community_type [community_type]
- return [db_string is_dotlrn_class_initialized {
- select count(*)
- from dotlrn_community_types
- where community_type = :community_type
- and package_id is not null
- }]
+ dotlrn_community::is_initialized -community_type [community_type]
}
ad_proc -public init {} {
create base community_type for dotlrn_clubs
} {
- db_transaction {
- set dotlrn_clubs_url "[dotlrn::get_url][dotlrn_club::get_url]/"
- if {![dotlrn::is_instantiated_here -url $dotlrn_clubs_url]} {
- set package_id [dotlrn::mount_package \
- -package_key [dotlrn::package_key] \
- -url [dotlrn_club::get_url_part] \
- -directory_p "t"]
-
- dotlrn_community::set_type_package_id [community_type] $package_id
- }
- }
+ dotlrn_community::init \
+ -community_type [community_type] \
+ -community_type_url_part [get_url_part]
}
ad_proc -public new {
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.37 -r1.38
--- openacs-4/packages/dotlrn/tcl/community-procs.tcl 5 Dec 2001 22:05:23 -0000 1.37
+++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 6 Dec 2001 20:50:51 -0000 1.38
@@ -10,610 +10,643 @@
#
ad_library {
-
+
Procs to manage DOTLRN Communities
-
+
@author ben@openforce.net
@author arjun@openforce.net
@creation-date 2001-09-28
@cvs-id $Id$
-
+
}
namespace eval dotlrn_community {
+ ad_proc -public is_initialized {
+ {-community_type:required}
+ } {
+ is this dotlrn_community type initialized correctly?
+ } {
+ return [db_string is_dotlrn_community_type_initialized {
+ select count(*)
+ from dotlrn_community_types
+ where community_type = :community_type
+ and package_id is not null
+ }]
+ }
+
+ ad_proc -public init {
+ {-community_type:required}
+ {-community_type_url_part:required}
+ } {
+ create base community_type for dotlrn_community type
+ } {
+ db_transaction {
+ if {![dotlrn::is_instantiated_here -url "[dotlrn::get_url]/${community_type_url_part}/"]} {
+ set package_id [dotlrn::mount_package \
+ -package_key [dotlrn::package_key] \
+ -url $community_type_url_part \
+ -directory_p "t"]
+
+ dotlrn_community::set_type_package_id $community_type $package_id
+
+ ad_parameter -package_id $package_id -set 0 dotlrn_level_p
+ ad_parameter -package_id $package_id -set 1 community_type_level_p
+ ad_parameter -package_id $package_id -set 0 community_level_p
+ }
+ }
+ }
+
ad_proc -public one_community_package_key {} {
- return "dotlrn"
+ return "dotlrn"
}
ad_proc -public one_community_type_package_key {} {
- return "dotlrn"
+ return "dotlrn"
}
ad_proc -public new_type {
- {-description ""}
- {-community_type_key:required}
- {-parent_type "dotlrn_community"}
- {-pretty_name:required}
+ {-description ""}
+ {-community_type_key:required}
+ {-parent_type "dotlrn_community"}
+ {-pretty_name:required}
{-url_part ""}
} {
- Create a new community type.
+ Create a new community type.
} {
- # Figure out parent_node_id
+ # Figure out parent_node_id
set parent_node_id [get_type_node_id $parent_type]
array set parent_node [site_node [site_nodes::get_url_from_node_id -node_id $parent_node_id]]
- db_transaction {
- # Create the class directly using PL/SQL API
- set community_type_key [db_exec_plsql create_community_type {}]
+ db_transaction {
+ # Create the class directly using PL/SQL API
+ set community_type_key [db_exec_plsql create_community_type {}]
- # Create the node
- set new_node_id [site_node_create $parent_node_id [ad_decode $url_part "" $community_type_key $url_part]]
+ # Create the node
+ set new_node_id [site_node_create $parent_node_id [ad_decode $url_part "" $community_type_key $url_part]]
- # Instantiate the package
- set package_id [site_node_create_package_instance $new_node_id $pretty_name $parent_node(object_id) [one_community_type_package_key]]
+ # Instantiate the package
+ set package_id [site_node_create_package_instance $new_node_id $pretty_name $parent_node(object_id) [one_community_type_package_key]]
- # Set some parameters
- ad_parameter -package_id $package_id -set 0 dotlrn_level_p
- ad_parameter -package_id $package_id -set 1 community_type_level_p
- ad_parameter -package_id $package_id -set 0 community_level_p
+ # Set some parameters
+ ad_parameter -package_id $package_id -set 0 dotlrn_level_p
+ ad_parameter -package_id $package_id -set 1 community_type_level_p
+ ad_parameter -package_id $package_id -set 0 community_level_p
- # Set the site node
- dotlrn_community::set_type_package_id $community_type_key $package_id
- }
-
- return $community_type_key
+ # Set the site node
+ dotlrn_community::set_type_package_id $community_type_key $package_id
+ }
+
+ return $community_type_key
}
-
+
ad_proc -public set_type_package_id {
- community_type
- package_id
+ community_type
+ package_id
} {
- Update the package ID for the community type
+ Update the package ID for the community type
} {
- # Exec the statement, easy
- db_dml update_package_id {}
+ # Exec the statement, easy
+ db_dml update_package_id {}
}
ad_proc -public get_type_node_id {
- community_type
+ community_type
} {
- get the node ID of a community type
+ get the node ID of a community type
} {
- return [db_string select_node_id {}]
+ return [db_string select_node_id {}]
}
ad_proc -public new {
- {-description ""}
- {-community_type:required}
- {-object_type "dotlrn_community"}
- {-community_key:required}
- {-pretty_name:required}
- {-extra_vars ""}
+ {-description ""}
+ {-community_type:required}
+ {-object_type "dotlrn_community"}
+ {-community_key:required}
+ {-pretty_name:required}
+ {-extra_vars ""}
} {
- create a new community
+ create a new community
} {
- # Set up extra vars
- if {[empty_string_p $extra_vars]} {
- set extra_vars [ns_set create]
- }
-
- # Add core vars
- ns_set put $extra_vars community_type $community_type
- ns_set put $extra_vars community_key $community_key
- ns_set put $extra_vars pretty_name $pretty_name
- ns_set put $extra_vars pretty_plural $pretty_name
- ns_set put $extra_vars description $description
+ # Set up extra vars
+ if {[empty_string_p $extra_vars]} {
+ set extra_vars [ns_set create]
+ }
- db_transaction {
- # Insert the community
- set community_id [package_instantiate_object \
- -extra_vars $extra_vars $object_type]
+ # Add core vars
+ ns_set put $extra_vars community_type $community_type
+ ns_set put $extra_vars community_key $community_key
+ ns_set put $extra_vars pretty_name $pretty_name
+ ns_set put $extra_vars pretty_plural $pretty_name
+ ns_set put $extra_vars description $description
- set user_id [ad_conn user_id]
-
- # Create portal template page
- set portal_template_id \
- [portal::create \
- -portal_template_p "t" \
- -name "$pretty_name Portal Template" \
- -context_id $community_id \
- $user_id ]
+ db_transaction {
+ # Insert the community
+ set community_id [package_instantiate_object \
+ -extra_vars $extra_vars $object_type]
- # Create the non-member page
- set portal_id \
- [portal::create \
- -template_id $portal_template_id \
- -name "$pretty_name Non-Member Portal" \
- -context_id $community_id \
- $user_id]
+ set user_id [ad_conn user_id]
- # update the portal_template_id and non_member_portal_id
- db_dml update_portal_ids {}
+ # Create portal template page
+ set portal_template_id \
+ [portal::create \
+ -portal_template_p "t" \
+ -name "$pretty_name Portal Template" \
+ -context_id $community_id \
+ $user_id ]
- # Set up the rel segments
- dotlrn_community::create_rel_segments -community_id $community_id
+ # Create the non-member page
+ set portal_id \
+ [portal::create \
+ -template_id $portal_template_id \
+ -name "$pretty_name Non-Member Portal" \
+ -context_id $community_id \
+ $user_id]
- # Set up the node
- set parent_node_id [get_type_node_id $community_type]
-
- # Create the node
- set new_node_id [site_node_create $parent_node_id $community_key]
+ # update the portal_template_id and non_member_portal_id
+ db_dml update_portal_ids {}
- # Instantiate the package
- set package_id [site_node_create_package_instance $new_node_id $pretty_name $community_id [one_community_package_key]]
+ # Set up the rel segments
+ dotlrn_community::create_rel_segments -community_id $community_id
- # Set the right parameters
- ad_parameter -package_id $package_id -set 0 dotlrn_level_p
- ad_parameter -package_id $package_id -set 0 community_type_level_p
- ad_parameter -package_id $package_id -set 1 community_level_p
-
- # Set up the node
- dotlrn_community::set_package_id $community_id $package_id
-
- # Assign proper permissions to the site node
- # NOT CERTAIN what to do here yet
- }
+ # Set up the node
+ set parent_node_id [get_type_node_id $community_type]
- return $community_id
+ # Create the node
+ set new_node_id [site_node_create $parent_node_id $community_key]
+
+ # Instantiate the package
+ set package_id [site_node_create_package_instance $new_node_id $pretty_name $community_id [one_community_package_key]]
+
+ # Set the right parameters
+ ad_parameter -package_id $package_id -set 0 dotlrn_level_p
+ ad_parameter -package_id $package_id -set 0 community_type_level_p
+ ad_parameter -package_id $package_id -set 1 community_level_p
+
+ # Set up the node
+ dotlrn_community::set_package_id $community_id $package_id
+
+ # Assign proper permissions to the site node
+ # NOT CERTAIN what to do here yet
+ }
+
+ return $community_id
}
ad_proc set_package_id {
- community_id
- package_id
+ community_id
+ package_id
} {
- Update the node ID for the community
+ Update the node ID for the community
} {
- db_dml update_package_id {}
+ db_dml update_package_id {}
}
-
+
ad_proc admin_access_p {
- community_id
+ community_id
} {
- Checks admin access to a community
+ Checks admin access to a community
} {
- # HACK FOR NOW!! (ben) FIXIT
- return 1
+ # HACK FOR NOW!! (ben) FIXIT
+ return 1
}
-
+
ad_proc -public get_url {
- {-current_node_id ""}
- {-package_id ""}
+ {-current_node_id ""}
+ {-package_id ""}
} {
- This gets the relative URL for a package_id under a particular node_id
+ This gets the relative URL for a package_id under a particular node_id
} {
- if {[empty_string_p $current_node_id]} {
- set current_node_id [site_node_id [ad_conn url]]
- }
+ if {[empty_string_p $current_node_id]} {
+ set current_node_id [site_node_id [ad_conn url]]
+ }
- return [db_string select_node_url {} -default ""]
+ return [db_string select_node_url {} -default ""]
}
ad_proc -public get_url_from_package_id {
- {-package_id ""}
+ {-package_id ""}
} {
- This gets the relative URL for a package_id.
+ This gets the relative URL for a package_id.
} {
- return [db_string select_node_url {} -default ""]
+ return [db_string select_node_url {} -default ""]
}
-
+
ad_proc set_attribute {
- community_id
- attribute_name
- attribute_value
+ community_id
+ attribute_name
+ attribute_value
} {
- Set an attribute for a community
+ Set an attribute for a community
} {
- # Not sure what to do here yet
+ # Not sure what to do here yet
}
ad_proc -public get_allowed_rel_types {
- { -community_type "" }
- { -community_id "" }
+ { -community_type "" }
+ { -community_id "" }
} {
- if {[empty_string_p $community_type]} {
- set community_type [get_toplevel_community_type_from_community_id $community_id]
- }
-
- if {$community_type == "dotlrn_class_instance"} {
- return {
- {dotlrn_student_rel Student}
- {dotlrn_ta_rel TA}
- {dotlrn_instructor_rel Instructor}
- {dotlrn_admin_rel Admin}
- }
- }
+ if {[empty_string_p $community_type]} {
+ set community_type [get_toplevel_community_type_from_community_id $community_id]
+ }
- if {$community_type == "dotlrn_club"} {
- return {
- {dotlrn_member_rel Member}
- {dotlrn_admin_rel Admin}
- }
- }
+ if {$community_type == "dotlrn_class_instance"} {
+ return {
+ {dotlrn_student_rel Student}
+ {dotlrn_ta_rel TA}
+ {dotlrn_instructor_rel Instructor}
+ {dotlrn_admin_rel Admin}
+ }
+ }
- return {}
+ if {$community_type == "dotlrn_club"} {
+ return {
+ {dotlrn_member_rel Member}
+ {dotlrn_admin_rel Admin}
+ }
+ }
+
+ return {}
}
-
ad_proc -public get_pretty_rel_type {
- rel_type
+ rel_type
} {
- Returns a pretty version of the rel_type
+ Returns a pretty version of the rel_type
} {
- set pretty_name [db_string select_pretty_name "select pretty_name from acs_object_types where object_type=:rel_type"]
- return $pretty_name
+ set pretty_name [db_string select_pretty_name "select pretty_name from acs_object_types where object_type=:rel_type"]
+ return $pretty_name
}
ad_proc -public get_rel_segment_id {
- {-community_id:required}
- {-rel_type:required}
+ {-community_id:required}
+ {-rel_type:required}
} {
- get the relational segment ID for a community and a rel type
+ get the relational segment ID for a community and a rel type
} {
- return [db_string select_rel_segment_id {} -default ""]
+ return [db_string select_rel_segment_id {} -default ""]
}
ad_proc -public create_rel_segments {
- {-community_id:required}
+ {-community_id:required}
} {
- create all the relational segments for a community
+ create all the relational segments for a community
} {
- # Get some information about the community
- set community_name [get_community_name $community_id]
+ # Get some information about the community
+ set community_name [get_community_name $community_id]
- db_transaction {
- # Create a rel segment for Admins
- set member_segment_id [rel_segments_new $community_id dotlrn_member_rel "Members of $community_name"]
- set admin_segment_id [rel_segments_new $community_id dotlrn_admin_rel "Admins of $community_name"]
+ db_transaction {
+ # Create a rel segment for Admins
+ set member_segment_id [rel_segments_new $community_id dotlrn_member_rel "Members of $community_name"]
+ set admin_segment_id [rel_segments_new $community_id dotlrn_admin_rel "Admins of $community_name"]
- # Grant permissions
- ad_permission_grant $member_segment_id $community_id read
- ad_permission_grant $member_segment_id $community_id write
- ad_permission_grant $admin_segment_id $community_id admin
- }
+ # Grant permissions
+ ad_permission_grant $member_segment_id $community_id read
+ ad_permission_grant $member_segment_id $community_id write
+ ad_permission_grant $admin_segment_id $community_id admin
+ }
}
ad_proc -public delete_rel_segments {
- {-community_id:required}
+ {-community_id:required}
} {
- remove the rel segments for a community
+ remove the rel segments for a community
} {
- # Take care of the admins
- set admin_segment_id [get_rel_segment_id -community_id $community_id -rel_type dotlrn_admin_rel]
- ad_permission_revoke $admin_segment_id $community_id admin
- rel_segments_delete $admin_segment_id
+ # Take care of the admins
+ set admin_segment_id [get_rel_segment_id -community_id $community_id -rel_type dotlrn_admin_rel]
+ ad_permission_revoke $admin_segment_id $community_id admin
+ rel_segments_delete $admin_segment_id
- # Take care of the members
- set member_segment_id [get_rel_segment_id -community_id $community_id -rel_type dotlrn_member_rel]
- ad_permission_revoke $member_segment_id $community_id edit
- rel_segments_delete $member_segment_id
+ # Take care of the members
+ set member_segment_id [get_rel_segment_id -community_id $community_id -rel_type dotlrn_member_rel]
+ ad_permission_revoke $member_segment_id $community_id edit
+ rel_segments_delete $member_segment_id
}
-
+
ad_proc -public list_admin_users {
- community_id
+ community_id
} {
- Returns list of admin users
+ Returns list of admin users
} {
- return [list_users -rel_type "dotlrn_admin_rel" $community_id]
+ return [list_users -rel_type "dotlrn_admin_rel" $community_id]
}
-
+
ad_proc -public list_users {
- {-rel_type "dotlrn_member_rel"}
- community_id
+ {-rel_type "dotlrn_member_rel"}
+ community_id
} {
- Returns the list of users with a membership_id, a user_id, first name, last name, email, and role
+ Returns the list of users with a membership_id, a user_id, first name, last name, email, and role
} {
- return [db_list_of_lists select_users {}]
+ return [db_list_of_lists select_users {}]
}
-
+
ad_proc -public member_p {
- community_id
- user_id
+ community_id
+ user_id
} {
- check membership
+ check membership
} {
- return [db_string select_count_membership {}]
+ return [db_string select_count_membership {}]
}
-
+
ad_proc -public add_user {
- {-rel_type "dotlrn_member_rel"}
- community_id
- user_id
+ {-rel_type "dotlrn_member_rel"}
+ community_id
+ user_id
} {
- Assigns a user to a particular role for that class. Roles in DOTLRN can be student, prof, ta, admin
+ Assigns a user to a particular role for that class. Roles in DOTLRN can be student, prof, ta, admin
} {
- db_transaction {
- # Set up a portal page for that user and that community
- set portal_id [portal::create \
- -name "Your [get_community_name $community_id] page" \
- -template_id [get_portal_template_id $community_id] \
- $user_id]
-
- # Create the form with the portal_id
- set extra_vars [ns_set create]
- ns_set put $extra_vars portal_id $portal_id
- ns_set put $extra_vars user_id $user_id
- ns_set put $extra_vars community_id $community_id
- ns_set put $extra_vars class_instance_id $community_id
+ db_transaction {
+ # Set up a portal page for that user and that community
+ set portal_id [portal::create \
+ -name "Your [get_community_name $community_id] page" \
+ -template_id [get_portal_template_id $community_id] \
+ $user_id]
- # Set up the relationship
- set rel_id [relation_add -extra_vars $extra_vars -member_state approved $rel_type $community_id $user_id]
-
- # do the callbacks
- applets_dispatch $community_id AddUserToCommunity [list $community_id $user_id]
- }
+ # Create the form with the portal_id
+ set extra_vars [ns_set create]
+ ns_set put $extra_vars portal_id $portal_id
+ ns_set put $extra_vars user_id $user_id
+ ns_set put $extra_vars community_id $community_id
+ ns_set put $extra_vars class_instance_id $community_id
+
+ # Set up the relationship
+ set rel_id [relation_add -extra_vars $extra_vars -member_state approved $rel_type $community_id $user_id]
+
+ # do the callbacks
+ applets_dispatch $community_id AddUserToCommunity [list $community_id $user_id]
+ }
}
ad_proc -public remove_user {
- community_id
- user_id
+ community_id
+ user_id
} {
- Removes a user from a class
+ Removes a user from a class
} {
- db_transaction {
- # Callbacks
- applets_dispatch $community_id RemoveUser [list $community_id $user_id]
-
- # Get a few important things, like rel_id and portal portal_id
- db_1row select_rel_info {}
+ db_transaction {
+ # Callbacks
+ applets_dispatch $community_id RemoveUser [list $community_id $user_id]
- # Remove it
- relation_remove $rel_id
+ # Get a few important things, like rel_id and portal portal_id
+ db_1row select_rel_info {}
- # Remove the page
- portal::delete $portal_id
- }
+ # Remove it
+ relation_remove $rel_id
+
+ # Remove the page
+ portal::delete $portal_id
+ }
}
-
+
ad_proc -public get_portal_id {
- community_id
- user_id
+ community_id
+ user_id
} {
- Get the page ID for a particular community and user
+ Get the page ID for a particular community and user
} {
- return [db_string select_portal_id {}]
+ return [db_string select_portal_id {}]
}
ad_proc -public get_community_non_members_portal_id {
- community_id
+ community_id
} {
- Get the community page ID for non-members
+ Get the community page ID for non-members
} {
- return [db_string select_community_portal_id {}]
+ return [db_string select_community_portal_id {}]
}
ad_proc -public get_all_communities_by_user {
- user_id
+ user_id
} {
- returns all communities for a user
+ returns all communities for a user
} {
- set return_list [db_list_of_lists select_communities_by_user {}]
+ set return_list [db_list_of_lists select_communities_by_user {}]
- ns_log Notice "return list: $return_list"
+ ns_log Notice "return list: $return_list"
- return $return_list
+ return $return_list
}
ad_proc -public get_communities_by_user {
- community_type
- user_id
+ community_type
+ user_id
} {
- Return a datasource of the communities that a user belongs to in a particular type
+ Return a datasource of the communities that a user belongs to in a particular type
} {
- set list_of_communities [list]
+ set list_of_communities [list]
- db_foreach select_communities {} {
- lappend list_of_communities [list $community_id $community_type $pretty_name $description [get_url -package_id $package_id]]
- }
-
- return $list_of_communities
+ db_foreach select_communities {} {
+ lappend list_of_communities [list $community_id $community_type $pretty_name $description [get_url -package_id $package_id]]
+ }
+
+ return $list_of_communities
}
-
+
ad_proc -public get_active_communities {
- community_type
+ community_type
} {
- Returns a list of active communities for a given type.
+ Returns a list of active communities for a given type.
} {
- set list_of_communities [list]
+ set list_of_communities [list]
- db_foreach select_active_communities {} {
- lappend list_of_communities [list $community_id $community_type $pretty_name $description [get_url -package_id $package_id]]
- }
+ db_foreach select_active_communities {} {
+ lappend list_of_communities [list $community_id $community_type $pretty_name $description [get_url -package_id $package_id]]
+ }
- return $list_of_communities
+ return $list_of_communities
}
ad_proc -public get_all_communities {
- community_type
+ community_type
} {
- Returns a list of all communities, and whether or not they are active.
+ Returns a list of all communities, and whether or not they are active.
} {
- return [db_list_of_lists select_all_communities {}]
+ return [db_list_of_lists select_all_communities {}]
}
ad_proc -public get_toplevel_community_type_from_community_id {
- community_id
+ community_id
} {
- returns the community type from community_id
+ returns the community type from community_id
} {
- return [db_string select_community_type {}]
+ return [db_string select_community_type {}]
}
ad_proc -public get_community_type_from_community_id {
- community_id
+ community_id
} {
- returns the community type from community_id
+ returns the community type from community_id
} {
- return [db_string select_community_type {}]
+ return [db_string select_community_type {}]
}
ad_proc -public get_community_type {
} {
- Returns the community type key depending on the node we're at
+ Returns the community type key depending on the node we're at
} {
- set package_id [ad_conn package_id]
+ set package_id [ad_conn package_id]
- return [db_string select_community_type {} -default ""]
+ return [db_string select_community_type {} -default ""]
}
ad_proc -public get_community_id {
} {
- Returns the community id depending on the node we're at
+ Returns the community id depending on the node we're at
} {
- set package_id [ad_conn package_id]
+ set package_id [ad_conn package_id]
- return [db_string select_community {} -default ""]
+ return [db_string select_community {} -default ""]
}
ad_proc -public get_community_type_url {
- community_type
+ community_type
} {
- Get the URL for a community type
+ Get the URL for a community type
} {
- return [get_url_from_package_id -package_id [get_community_type_package_id $community_type]]
+ return [get_url_from_package_id -package_id [get_community_type_package_id $community_type]]
}
ad_proc -public get_community_url {
- community_id
+ community_id
} {
- Get the URL for a community
+ Get the URL for a community
} {
- return [get_url_from_package_id -package_id [get_package_id $community_id]]
+ return [get_url_from_package_id -package_id [get_package_id $community_id]]
}
ad_proc -public get_community_type_package_id {
- community_type
+ community_type
} {
- get the package id for a particular community type
+ get the package id for a particular community type
} {
- return [db_string select_package_id {} -default ""]
+ return [db_string select_package_id {} -default ""]
}
ad_proc -public get_package_id {
- community_id
+ community_id
} {
- get the package ID for a particular community
+ get the package ID for a particular community
} {
- return [db_string select_package_id {} -default ""]
+ return [db_string select_package_id {} -default ""]
}
ad_proc -public get_applet_package_id {
- community_id
- applet_key
+ community_id
+ applet_key
} {
- get the package ID for a particular community
+ get the package ID for a particular community
} {
- return [db_string select_package_id {} -default ""]
+ return [db_string select_package_id {} -default ""]
}
ad_proc -public get_community_type_name {
- community_type
+ community_type
} {
- get the name for a community type
+ get the name for a community type
} {
- return [db_string select_community_type_name {} -default ""]
+ return [db_string select_community_type_name {} -default ""]
}
ad_proc -public get_community_name {
- community_id
+ community_id
} {
- get the name for a community
+ get the name for a community
} {
- return [db_string select_community_name {} -default ""]
+ return [db_string select_community_name {} -default ""]
}
ad_proc -public get_portal_template_id {
- community_id
+ community_id
} {
- get the id of the portal template for a community
+ get the id of the portal template for a community
} {
- return [db_string select_portal_template_id {} -default ""]
+ return [db_string select_portal_template_id {} -default ""]
}
-
+
ad_proc -public add_applet {
- community_id
- applet_key
+ community_id
+ applet_key
} {
- Adds an applet to the community
+ Adds an applet to the community
} {
- db_transaction {
- # Callback
- set package_id [applet_call $applet_key AddAppletToCommunity [list $community_id]]
+ db_transaction {
+ # Callback
+ set package_id [applet_call $applet_key AddAppletToCommunity [list $community_id]]
- # Insert in the DB
- db_dml insert_applet {}
+ # Insert in the DB
+ db_dml insert_applet {}
- # Go through current users and make sure they are added!
- foreach user [list_users $community_id] {
- set user_id [lindex $user 2]
+ # Go through current users and make sure they are added!
+ foreach user [list_users $community_id] {
+ set user_id [lindex $user 2]
- # do the callbacks
- applet_call $applet_key AddUserToCommunity [list $community_id $user_id]
- }
- }
+ # do the callbacks
+ applet_call $applet_key AddUserToCommunity [list $community_id $user_id]
+ }
+ }
}
ad_proc -public remove_applet {
- community_id
- applet_key
+ community_id
+ applet_key
} {
- Removes an applet from a community
+ Removes an applet from a community
} {
- # Get the package_id
- set package_id [get_package_id $community_id]
+ # Get the package_id
+ set package_id [get_package_id $community_id]
- db_transaction {
- # Take care of all existing users
- foreach user [list_users $community_id] {
- set user_id [lindex $user 2]
+ db_transaction {
+ # Take care of all existing users
+ foreach user [list_users $community_id] {
+ set user_id [lindex $user 2]
- # do the callbacks
- applet_call $applet_key RemoveUser [list $community_id $user_id]
- }
-
- # Callback
- applet_call $applet_key RemoveApplet [list $community_id $package_id]
-
- # Delete from the DB
- db_dml delete_applet {}
- }
+ # do the callbacks
+ applet_call $applet_key RemoveUser [list $community_id $user_id]
+ }
+
+ # Callback
+ applet_call $applet_key RemoveApplet [list $community_id $package_id]
+
+ # Delete from the DB
+ db_dml delete_applet {}
+ }
}
ad_proc -public list_applets {
- {community_id ""}
+ {community_id ""}
} {
- Lists the applets associated with a community
+ Lists the applets associated with a community
} {
- if {[empty_string_p $community_id]} {
- # List all applets
- return [db_list select_all_applets {}]
- } else {
- # List from the DB
- return [db_list select_community_applets {}]
- }
+ if {[empty_string_p $community_id]} {
+ # List all applets
+ return [db_list select_all_applets {}]
+ } else {
+ # List from the DB
+ return [db_list select_community_applets {}]
+ }
}
ad_proc -public applets_dispatch {
- community_id
- op
- list_args
+ community_id
+ op
+ list_args
} {
- Dispatch an operation to every applet
+ Dispatch an operation to every applet
} {
- foreach applet [list_applets $community_id] {
- # Callback on applet
- applet_call $applet $op $list_args
- }
+ foreach applet [list_applets $community_id] {
+ # Callback on applet
+ applet_call $applet $op $list_args
+ }
}
ad_proc -public applet_call {
- applet_key
- op
- {list_args {}}
+ applet_key
+ op
+ {list_args {}}
} {
- Call a particular applet op
+ Call a particular applet op
} {
- acs_sc_call dotlrn_applet $op $list_args $applet_key
+ acs_sc_call dotlrn_applet $op $list_args $applet_key
}
-
}
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.23 -r1.24
--- openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl 5 Dec 2001 22:05:23 -0000 1.23
+++ openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl 6 Dec 2001 20:50:51 -0000 1.24
@@ -61,11 +61,19 @@
} {
returns 1 if dotlrn is instantiaed under the url specified, 0
otherwise
-
- url is expected to match that in the nsv array "site_nodes"
} {
set result 0
+# XXX this is much cleaner but it doesn't work because [site_node $url] will
+# eat through the url to try to find a match up the hierarchy. we want
+# an exact match
+#
+# if {[catch {array set site_node [site_node $url]}] == 0} {
+# if {[string equal [package_key] $site_node(package_key)]} {
+# set result 1
+# }
+# }
+
if {[catch {nsv_array get site_nodes $url} site_node_list] == 0} {
for {set x 0} {$x < [llength $site_node_list]} {incr x 2} {
if {[string match $url [lindex $site_node_list $x]]} {
@@ -75,7 +83,7 @@
break
} else {
# XXX need to figure out how to error out of here, this
- # really bad
+ # really bad
}
}
}
@@ -152,7 +160,8 @@
node_id => :node_id,
parent_id => :parent_node_id,
name => :url,
- directory_p => :directory_p
+ directory_p => :directory_p,
+ pattern_p => 't'
);
end;
}]
Index: openacs-4/packages/dotlrn/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/index.tcl,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/dotlrn/www/index.tcl 1 Dec 2001 23:16:27 -0000 1.11
+++ openacs-4/packages/dotlrn/www/index.tcl 6 Dec 2001 20:50:51 -0000 1.12
@@ -7,16 +7,23 @@
} {
}
+ns_log notice "XXX0"
+
# Check if this is a community type level thing
if {[ad_parameter community_type_level_p] == 1} {
+ ns_log notice "XXX0.5"
ad_returnredirect "one-community-type"
- return
+ ns_log notice "XXX0.55"
+ ad_script_abort
+ ns_log notice "XXX0.60"
}
+ns_log notice "XXX1"
+
# Check if this is a community level thing
if {[ad_parameter community_level_p] == 1} {
ad_returnredirect "one-community"
- return
+ ad_script_abort
}
# Make sure user is logged in
@@ -34,5 +41,4 @@
set rendered_page [dotlrn::render_page $portal_id]
}
-
ad_return_template
Index: openacs-4/packages/dotlrn/www/one-community-type.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/one-community-type.adp,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/dotlrn/www/one-community-type.adp 1 Dec 2001 23:16:27 -0000 1.10
+++ openacs-4/packages/dotlrn/www/one-community-type.adp 6 Dec 2001 20:50:51 -0000 1.11
@@ -1,3 +1,4 @@
+<% ns_log notice "XXX ADP" %>
@context_bar@
dotLRN: @pretty_name@
Index: openacs-4/packages/dotlrn/www/one-community-type.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/one-community-type.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/dotlrn/www/one-community-type.tcl 1 Dec 2001 23:16:27 -0000 1.6
+++ openacs-4/packages/dotlrn/www/one-community-type.tcl 6 Dec 2001 20:50:51 -0000 1.7
@@ -1,4 +1,3 @@
-
ad_page_contract {
Displays a community type
@@ -7,10 +6,12 @@
} {
}
+ns_log notice "XXX0.6"
+
# Check that this is a community type
if {[ad_parameter community_type_level_p] != 1} {
- ns_returnredirect "./"
- return
+ ad_returnredirect "./"
+ ad_script_abort
}
set user_id [ad_conn user_id]