Index: openacs-4/packages/dotlrn/dotlrn.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/dotlrn.info,v diff -u -r1.5 -r1.6 --- openacs-4/packages/dotlrn/dotlrn.info 5 Oct 2001 15:39:53 -0000 1.5 +++ openacs-4/packages/dotlrn/dotlrn.info 5 Nov 2001 22:34:23 -0000 1.6 @@ -34,6 +34,8 @@ + + @@ -49,15 +51,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: openacs-4/packages/dotlrn/sql/oracle/dotlrn-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/sql/oracle/dotlrn-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn/sql/oracle/dotlrn-create.sql 3 Oct 2001 21:10:59 -0000 1.3 +++ openacs-4/packages/dotlrn/sql/oracle/dotlrn-create.sql 5 Nov 2001 22:34:23 -0000 1.4 @@ -10,6 +10,8 @@ -- started August 18th, 2001 -- +@dotlrn-users-create.sql +@dotlrn-users-package-create.sql @dotlrn-communities-create.sql @dotlrn-clubs-create.sql @dotlrn-classes-create.sql Index: openacs-4/packages/dotlrn/sql/oracle/dotlrn-main-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/sql/oracle/Attic/dotlrn-main-portlet-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/sql/oracle/dotlrn-main-portlet-create.sql 5 Nov 2001 22:34:23 -0000 1.1 @@ -0,0 +1,32 @@ +-- +-- packages/dotlrn/sql/oracle/dotlrn-main-portlet-create.sql +-- + +-- Creates a dotLRN datasource for including on a user's main portal page. + +-- Copyright (C) 2001 OpenForce, Inc. +-- @author Ben Adida (ben@openforce.net) +-- @creation-date 2001-11-05 + +-- $Id: dotlrn-main-portlet-create.sql,v 1.1 2001/11/05 22:34:23 ben Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License version 2 or higher. Full text of the license is available +-- from the GNU Project: http://www.fsf.org/copyleft/gpl.html + +declare + ds_id portal_datasources.datasource_id%TYPE; +begin + ds_id := portal_datasource.new( + data_type => 'tcl_proc', + mime_type => 'text/html', + name => 'dotlrn-main-portlet', + description => 'Displays the list of communities a user belongs to', + content => 'dotlrn_main_portlet::show', + configurable_p => 't' + ); + +end; +/ +show errors + Index: openacs-4/packages/dotlrn/sql/oracle/dotlrn-main-portlet-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/sql/oracle/Attic/dotlrn-main-portlet-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/sql/oracle/dotlrn-main-portlet-drop.sql 5 Nov 2001 22:34:23 -0000 1.1 @@ -0,0 +1,33 @@ + +-- Drops dotLRN main portlet datasources for portal portlets + +-- Copyright (C) 2001 Openforce, Inc. +-- @author Ben Adida (ben@openforce.net) +-- @creation-date 2001-11-04 + +-- $Id: dotlrn-main-portlet-drop.sql,v 1.1 2001/11/05 22:34:23 ben Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License version 2 or higher. Full text of the license is available +-- from the GNU Project: http://www.fsf.org/copyleft/gpl.html + +declare + ds_id portal_datasources.datasource_id%TYPE; +begin + + begin + select datasource_id into ds_id + from portal_datasources + where name = 'dotlrn-main-portlet'; + exception when no_data_found then + ds_id := null; + end; + + if ds_id is not null then + portal_datasource.delete(ds_id); + end if; + +end; +/ +show errors; + Index: openacs-4/packages/dotlrn/sql/oracle/dotlrn-users-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/sql/oracle/Attic/dotlrn-users-package-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn/sql/oracle/dotlrn-users-package-create.sql 30 Oct 2001 21:26:58 -0000 1.1 +++ openacs-4/packages/dotlrn/sql/oracle/dotlrn-users-package-create.sql 5 Nov 2001 22:34:23 -0000 1.2 @@ -39,6 +39,7 @@ is begin insert into dotlrn_users (user_id, role) values (user_id, role); + return user_id; end; procedure delete ( 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.11 -r1.12 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 30 Oct 2001 21:26:58 -0000 1.11 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 5 Nov 2001 22:34:23 -0000 1.12 @@ -125,7 +125,7 @@ # Set up the relationship set rel_id [relation_add -member_state approved $rel_type $community_id $user_id] - # Set up a portal page for that user + # Set up a portal page for that user and that community set page_id [portal::create $user_id] # Insert the membership @@ -169,6 +169,14 @@ return [db_string select_page_id {}] } + ad_proc -public get_workspace_page_id { + user_id + } { + Get the workspace page ID for a particular user + } { + return [db_string select_user_page_id {}] + } + ad_proc -public get_all_communities_by_user { user_id } { @@ -255,6 +263,14 @@ # 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 1] + + # do the callbacks + applet_call $applet_key AddUser [list $community_id $user_id] + } } } @@ -268,6 +284,14 @@ 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 1] + + # do the callbacks + applet_call $applet_key RemoveUser [list $community_id $user_id] + } + # Callback applet_call $applet_key RemoveApplet [list $community_id $package_id] 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.4 -r1.5 --- openacs-4/packages/dotlrn/tcl/community-procs.xql 12 Oct 2001 18:15:21 -0000 1.4 +++ openacs-4/packages/dotlrn/tcl/community-procs.xql 5 Nov 2001 22:34:23 -0000 1.5 @@ -73,6 +73,12 @@ + + +select page_id from dotlrn_users where user_id= :user_id + + + select dotlrn_communities.community_id as community_id, community_type, pretty_name, description, package_id Index: openacs-4/packages/dotlrn/tcl/dotlrn-main-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-main-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/tcl/dotlrn-main-portlet-procs.tcl 5 Nov 2001 22:34:23 -0000 1.1 @@ -0,0 +1,88 @@ +# /packages/dotlrn/tcl/dotlrn-main-portlet-procs.tcl +ad_library { + + Procedures to supports dotlrn main portlet + + Copyright Openforce, Inc. + Licensed under GNU GPL v2 + + @creation-date November 4 2001 + @author ben@openforce.net + @cvs-id $Id: dotlrn-main-portlet-procs.tcl,v 1.1 2001/11/05 22:34:23 ben Exp $ + +} + +namespace eval dotlrn_main_portlet { + + ad_proc -private my_name { + } { + return "dotlrn-main-portlet" + } + + ad_proc -public get_pretty_name { + } { + return "dotLRN" + } + + ad_proc -public add_self_to_page { + page_id + instance_id + } { + Adds a dotLRN PE to the given page with the instance key being + opaque data in the portal configuration. + + @return element_id The new element's id + @param page_id The page to add self to + @param instance_id The bboard instace to show + @author arjun@openforce.net + @creation-date Nov 2001 + } { + # Tell portal to add this element to the page + set element_id [portal::add_element $page_id [my_name]] + + return $element_id + } + + ad_proc -public show { + cf + } { + Display the PE + + @return HTML string + @param cf A config array + @author ben@openforce.net + @creation-date Nov 2001 + } { + + array set config $cf + + # Figure out what to show here (Ben) + return "" + + } + + ad_proc -public remove_self_from_page { + portal_id + instance_id + } { + Removes a bboard PE from the given page + + @param page_id The page to remove self from + @param instance_id + @author ben@openforce.net + @creation-date Nov 2001 + } { + # get the element IDs (could be more than one!) + set element_ids [portal::get_element_ids_by_ds $portal_id [my_name]] + + # remove all elements + db_transaction { + foreach element_id $element_ids { + portal::remove_element $element_id + } + } + } + +} + + Index: openacs-4/packages/dotlrn/tcl/dotlrn-security-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/Attic/dotlrn-security-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/tcl/dotlrn-security-procs-oracle.xql 5 Nov 2001 22:34:23 -0000 1.1 @@ -0,0 +1,15 @@ + + + +oracle8.1.6 + + + +declare +begin +:1 := dotlrn_user.new(:user_id, :role); +end; + + + + 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.1 -r1.2 --- openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl 30 Oct 2001 21:26:58 -0000 1.1 +++ openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl 5 Nov 2001 22:34:23 -0000 1.2 @@ -20,11 +20,23 @@ namespace eval dotlrn { ad_proc -public user_add { - user_id + {-role "user"} + user_id } { Add a user as a dotLRN user } { - db_dml add_user {} + db_transaction { + db_exec_plsql add_user {} + + # Create a portal page for this user + set page_id [portal::create $user_id] + + # Add the basic dotLRN class listing portlet + # NOT IMPLEMENTED YET! + + # Update the user and set the portal page correctly + db_dml update_user_page_id {} + } } ad_proc -public user_remove { Index: openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.xql 5 Nov 2001 22:34:23 -0000 1.1 @@ -0,0 +1,17 @@ + + + + + + +update dotlrn_users set page_id= :page_id + + + + + +dotlrn_user.remove(:user_id) + + + + Index: openacs-4/packages/dotlrn/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/index.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn/www/index.adp 9 Oct 2001 14:35:58 -0000 1.3 +++ openacs-4/packages/dotlrn/www/index.adp 5 Nov 2001 22:34:23 -0000 1.4 @@ -1,19 +1,6 @@ dotLRN - -There are no classes available.

- +Configure this page. - -

- - -

-

+@rendered_page@ Index: openacs-4/packages/dotlrn/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/index.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/dotlrn/www/index.tcl 9 Oct 2001 14:35:58 -0000 1.5 +++ openacs-4/packages/dotlrn/www/index.tcl 5 Nov 2001 22:34:23 -0000 1.6 @@ -1,6 +1,6 @@ ad_page_contract { - Displays a list of Classes on the site + Displays the personal home page @author Ben Adida (ben@openforce.net) @creation-date 2001-08-20 @@ -9,20 +9,18 @@ classes:multirow } -if {[ad_parameter community_type_level_p] == 1} { - ns_returnredirect one-community-type - return -} +# Make sure user is logged in +set user_id [ad_maybe_redirect_for_registration] -if {[ad_parameter community_level_p] == 1} { - ns_returnredirect one-community - return +# Get the page +set page_id [db_string select_page_id {} -default ""] + +# If there is no page_id, this user is either a guest or something else +if {[empty_string_p $page_id]} { + # do something +} else { + set rendered_page [portal::render $page_id] } -# Select communities this user is part of -set user_id [ad_get_user_id] -# Select the classes that exist -db_multirow classes select_classes {} - ad_return_template Index: openacs-4/packages/dotlrn/www/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/Attic/index.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn/www/index.xql 5 Oct 2001 15:14:29 -0000 1.2 +++ openacs-4/packages/dotlrn/www/index.xql 5 Nov 2001 22:34:23 -0000 1.3 @@ -2,9 +2,9 @@ - + -select class_key, node_id, site_node.url(node_id) from dotlrn_classes, dotlrn_community_types where dotlrn_community_types.community_type=dotlrn_classes.class_key order by class_key +select page_id from dotlrn_users where user_id= :user_id