Index: openacs-4/packages/dotlrn-xowiki/COPYRIGHT =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-xowiki/COPYRIGHT,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-xowiki/COPYRIGHT 27 Feb 2008 09:46:32 -0000 1.1 @@ -0,0 +1,23 @@ + * dotlrn-xowiki + * + * Copyright (C) 2005-2008 Gustaf Neumann, neumann@wu-wien.ac.at + * + * Vienna University of Economics and Business Administration + * Institute of Information Systems and New Media + * A-1090, Augasse 2-6 + * Vienna, Austria + * + * This is a BSD-Style license applicable for the files in this + * directory and below, except when stated explicitly different. + * + * Permission to use, copy, modify, distribute, and sell this + * software and its documentation for any purpose is hereby granted + * without fee, provided that the above copyright notice appear in + * all copies and that both that copyright notice and this permission + * notice appear in supporting documentation. We make no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + + Index: openacs-4/packages/dotlrn-xowiki/dotlrn-xowiki.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-xowiki/dotlrn-xowiki.info,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/dotlrn-xowiki/dotlrn-xowiki.info 31 Jan 2007 10:28:47 -0000 1.1 +++ openacs-4/packages/dotlrn-xowiki/dotlrn-xowiki.info 27 Feb 2008 09:46:32 -0000 1.2 @@ -7,17 +7,20 @@ f t - - Michael Totschnig + Gustaf Neumann - 2007-01-28 + Michael Totschnig + 2008-02-27 + BSD-Style 0 - + - + + + Index: openacs-4/packages/dotlrn-xowiki/sql/postgresql/dotlrn-xowiki-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-xowiki/sql/postgresql/Attic/dotlrn-xowiki-create.sql,v diff -u -N --- openacs-4/packages/dotlrn-xowiki/sql/postgresql/dotlrn-xowiki-create.sql 31 Jan 2007 10:28:47 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,131 +0,0 @@ - --- create the implementation -select acs_sc_impl__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'dotlrn_xowiki' -); - --- add all the hooks - --- GetPrettyName -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'GetPrettyName', - 'xowiki::get_pretty_name', - 'TCL' -); - --- AddApplet -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddApplet', - 'xowiki::add_applet', - 'TCL' -); - --- RemoveApplet -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemoveApplet', - 'xowiki::remove_applet', - 'TCL' -); - --- AddAppletToCommunity -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddAppletToCommunity', - 'xowiki::add_applet_to_community', - 'TCL' -); - --- RemoveAppletFromCommunity -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemoveAppletFromCommunity', - 'xowiki::remove_applet_from_community', - 'TCL' -); - --- AddUser -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddUser', - 'xowiki::add_user', - 'TCL' -); - --- RemoveUser -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemoveUser', - 'xowiki::remove_user', - 'TCL' -); - --- AddUserToCommunity -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddUserToCommunity', - 'xowiki::add_user_to_community', - 'TCL' -); - --- RemoveUserFromCommunity -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemoveUserFromCommunity', - 'xowiki::remove_user_from_community', - 'TCL' -); - --- AddPortlet -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddPortlet', - 'xowiki::add_portlet', - 'TCL' - ); - --- RemovePortlet -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemovePortlet', - 'xowiki::remove_portlet', - 'TCL' -); - --- Clone -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'Clone', - 'xowiki::clone', - 'TCL' -); - -select acs_sc_impl_alias__new ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'ChangeEventHandler', - 'xowiki::change_event_handler', - 'TCL' -); - --- Add the binding -select acs_sc_binding__new ( - 'dotlrn_applet', - 'dotlrn_xowiki' -); Index: openacs-4/packages/dotlrn-xowiki/sql/postgresql/dotlrn-xowiki-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-xowiki/sql/postgresql/Attic/dotlrn-xowiki-drop.sql,v diff -u -N --- openacs-4/packages/dotlrn-xowiki/sql/postgresql/dotlrn-xowiki-drop.sql 31 Jan 2007 10:28:47 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,99 +0,0 @@ - -select acs_sc_impl__delete( - 'dotlrn_applet', -- impl_contract_name - 'dotlrn_xowiki' -- impl_name -); - - --- add all the hooks - --- GetPrettyName -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'GetPrettyName' -); - --- AddApplet -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddApplet' -); - --- RemoveApplet -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemoveApplet' -); - --- AddAppletToCommunity -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddAppletToCommunity' -); - --- RemoveAppletFromCommunity -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemoveAppletFromCommunity' -); - --- AddUser -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddUser' -); - --- RemoveUser -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemoveUser' -); - --- AddUserToCommunity -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddUserToCommunity' -); - --- RemoveUserFromCommunity -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemoveUserFromCommunity' -); - --- AddPortlet -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'AddPortlet' - ); - --- RemovePortlet -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'RemovePortlet' -); - --- Clone -select acs_sc_impl_alias__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki', - 'Clone' -); - - --- Add the binding -select acs_sc_binding__delete ( - 'dotlrn_applet', - 'dotlrn_xowiki' -); Index: openacs-4/packages/dotlrn-xowiki/tcl/xowiki-applet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-xowiki/tcl/xowiki-applet-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/dotlrn-xowiki/tcl/xowiki-applet-procs.tcl 31 Jan 2007 10:28:47 -0000 1.1 +++ openacs-4/packages/dotlrn-xowiki/tcl/xowiki-applet-procs.tcl 27 Feb 2008 09:46:32 -0000 1.2 @@ -1,261 +1,321 @@ - ad_library { - Procs to set up the xowiki applet + Procedures to supports xowiki as an dotlrn applet + + @creation-date 2008-02-26 + @author Gustaf Neumann + @cvs-id $Id$ } -namespace eval xowiki { - - ad_proc -public applet_key { - } { - What's my applet key? - } { - return "dotlrn_xowiki" - } +# +# This is the first approach to make the applets +# +# (a) in an oo-style (the object below contains everything +# for the management of the portlet) and +# (b) independent from the database layer +# (supposed to work under postgres and Oracle) +# +# In the next steps, it would make sense to define a ::dotlrn::Applet +# class, which provides some of the common behavior defined here... +# - ad_proc -public my_package_key { - } { - What package do I deal with? - } { - return "dotlrn-xowiki" - } +Object xowiki_applet +xowiki_applet proc applet_key {} { + return "dotlrn_xowiki" +} - ad_proc -public package_key { - } { - What package do I deal with? - } { - return "xowiki" - } +xowiki_applet proc my_package_key {} { + return "dotlrn-xowiki" +} + +xowiki_applet ad_proc package_key { +} { + What package do I deal with? +} { + return "xowiki" +} - ad_proc -private node_name { - } { - returns the node name - } { - return "xowiki" - } +xowiki_applet ad_proc node_name { +} { + returns the node name +} { + return "xowiki" +} - ad_proc -public get_pretty_name { - } { - returns the pretty name - } { - return "XoWiki" - } +xowiki_applet ad_proc pretty_name { +} { + returns the pretty name +} { + return "XoWiki" +} - ad_proc -public add_applet { - } { - One time init - must be repeatable! - } { - dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] -package_key [my_package_key] - } +xowiki_applet ad_proc add_applet { +} { + One time init - must be repeatable! +} { + dotlrn_applet::add_applet_to_dotlrn \ + -applet_key [my applet_key] \ + -package_key [my my_package_key] +} - ad_proc -public remove_applet { - } { - One time destroy. - } { - ad_return_complaint 1 "[applet_key] remove_applet not implimented!" - } +xowiki_applet ad_proc remove_applet { +} { + One time destroy. +} { + ad_return_complaint 1 "[my applet_key] remove_applet not implemented!" +} - ad_proc -public add_applet_to_community { - community_id - } { - Add the xowiki applet to a specifc dotlrn community - } { - # get the community portal id - set portal_id [dotlrn_community::get_portal_id -community_id $community_id] - # get applet id - set applet_id [dotlrn_applet::get_applet_id_from_key -applet_key [applet_key]] +xowiki_applet ad_proc add_applet_to_community { + community_id +} { + Add the xowiki applet to a specifc dotlrn community +} { + # get the community portal id + set portal_id [dotlrn_community::get_portal_id -community_id $community_id] - # create the package instance - set package_id [dotlrn::instantiate_and_mount $community_id [package_key]] - # rename the sitenode - #set node_id [db_string get_data "select node_id from site_nodes where object_id = :package_id" -default 0] + # get applet id + set applet_id [dotlrn_applet::get_applet_id_from_key -applet_key [my applet_key]] + + # create the package instance + set package_id [dotlrn::instantiate_and_mount $community_id [my package_key]] - #if { $node_id != 0 } { -# site_node::rename -node_id $node_id -name [node_name] -# } + # set up the admin portlet + set admin_portal_id [dotlrn_community::get_admin_portal_id -community_id $community_id] + xowiki_admin_portlet add_self_to_page \ + -portal_id $admin_portal_id \ + -package_id $package_id + + # set up the xowiki portlet for this community + set portal_id [dotlrn_community::get_portal_id -community_id $community_id] - # mount an instance of xowiki - #set xowiki_package_id [dotlrn::instantiate_and_mount $community_id xowiki] + return $package_id +} - #site_node::instantiate_and_mount \ -# -parent_node_id $node(node_id) \ -# -node_name $instance_name \ -# -package_name xowiki \ -# -package_key xowiki - # set up the admin portlet - - set admin_portal_id [dotlrn_community::get_admin_portal_id -community_id $community_id] - xowiki_admin_portlet::add_self_to_page \ - -portal_id $admin_portal_id \ - -package_id $package_id +xowiki_applet ad_proc remove_applet_from_community { + community_id +} { + remove the applet from the community +} { + # get package id + set package_id [dotlrn_community::get_applet_package_id \ + -community_id $community_id \ + -applet_key [my applet_key]] - # set up the xowiki portlet for this community - set portal_id [dotlrn_community::get_portal_id -community_id $community_id] + set applet_id [dotlrn_applet::get_applet_id_from_key -applet_key [my applet_key]] + dotlrn::unmount_package -package_id $package_id + set url "[dotlrn_community::get_community_url $community_id][my node_name]/" + # delete site node + if { [site_node::exists_p -url $url] } { + # get site node of mounted xowiki instance + set node_id [site_node::get_node_id -url $url] + # unmount package + site_node::unmount -node_id $node_id + # delete site node + site_node::delete -node_id $node_id + } +} +xowiki_applet ad_proc add_user { + user_id +} { + one time user-specific init +} { + # noop +} - # else { - # # get the community node id - # set community_node_id [dotlrn_community::get_community_node_id $community_id] - # # create the node - # set node_id [site_node::new -name [node_name] -parent_id $community_node_id] - # # mount package to community - # site_node::mount -node_id $node_id -object_id $package_id - # # set permissions - # set members_segment_id [dotlrn_community::get_rel_segment_id \ - # -community_id $community_id \ - # -rel_type dotlrn_member_rel] - # permission::grant \ - # -party_id $members_segment_id \ - # -object_id $package_id \ - # -privilege "read" - # } +xowiki_applet ad_proc remove_user { + user_id +} { +} { + ad_return_complaint 1 "[my applet_key] remove_user not implimented!" +} - # add portlet to community portal - #set args [ns_set create] - #ns_set put $args package_id $package_id - #ns_set put $args param_action "overwrite" - #add_portlet_helper $portal_id $args - - return $package_id - } +xowiki_applet ad_proc add_user_to_community { + community_id + user_id +} { + Add a user to a specifc dotlrn community +} { + # nothing happens here +} - ad_proc -public remove_applet_from_community { - community_id - } { - remove the applet from the community - } { - # get package id - set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]] - set applet_id [dotlrn_applet::get_applet_id_from_key -applet_key [applet_key]] - dotlrn::unmount_package -package_id $package_id - set url "[dotlrn_community::get_community_url $community_id][node_name]/" - # delete site node - if { [site_node::exists_p -url $url] } { - # get site node of mounted xowiki instance - set node_id [site_node::get_node_id -url $url] - # unmount package - site_node::unmount -node_id $node_id - # delete site node - site_node::delete -node_id $node_id - } - } +xowiki_applet ad_proc remove_user_from_community { + community_id + user_id +} { + Remove a user from a community +} { + # nothing happens here +} + +xowiki_applet ad_proc add_portlet { + portal_id +} { + A helper proc to add the underlying portlet to the given portal. + + @param portal_id +} { + # simple, no type specific stuff, just set some dummy values - ad_proc -public add_user { - user_id - } { - one time user-specifuc init - } { - # noop - } + # nothing happens here +} - ad_proc -public remove_user { - user_id - } { - } { - ad_return_complaint 1 "[applet_key] remove_user not implimented!" - } +xowiki_applet ad_proc add_portlet_helper { + portal_id + args +} { + A helper proc to add the underlying portlet to the given portal. + @param portal_id +} { + #xowiki_portlet add_self_to_page \ + # -portal_id $portal_id \ + # -package_id [ns_set get $args "package_id"] \ + # -param_action [ns_set get $args "param_action"] +} + +xowiki_applet ad_proc remove_portlet { + portal_id + args +} { + A helper proc to remove the underlying portlet from the given portal. + + @param portal_id + @param args A list of key-value pairs (possibly user_id, community_id, and more) +} { +# xowiki_portlet remove_self_from_page \ +# -portal_id $portal_id \ +# -package_id [ns_set get $args "package_id"] +} - ad_proc -public add_user_to_community { - community_id - user_id - } { - Add a user to a specifc dotlrn community - } { -# set portal_id [dotlrn::get_portal_id -user_id $user_id] -# set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]] +xowiki_applet ad_proc clone { + old_community_id + new_community_id +} { + Clone this applet's content from the old community to the new one +} { + #ns_log notice "Cloning: [my applet_key]" + #set new_package_id [my add_applet_to_community $new_community_id] + #set old_package_id [dotlrn_community::get_applet_package_id \ + # -community_id $old_community_id \ + # -applet_key [my applet_key] \ + # ] + #db_exec_plsql clone_data {} + #return $new_package_id +} -# # use "append" here since we want to aggregate -# set args [ns_set create] -# ns_set put $args package_id $package_id -# ns_set put $args param_action append -# add_portlet_helper $portal_id $args -# # flush cache for this portal -# ::tlf_global flush_portal $portal_id - } +xowiki_applet ad_proc change_event_handler { + community_id + event + old_value + new_value +} { + listens for the following events: +} { + #; nothing +} - ad_proc -public remove_user_from_community { - community_id - user_id - } { - Remove a user from a community - } { -# set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]] -# set portal_id [dotlrn::get_portal_id -user_id $user_id] +xowiki_applet proc install {} { + set name [my applet_key] + db_transaction { -# set args [ns_set create] -# ns_set put $args package_id $package_id + # register the applet implementation + ::xo::db::sql::acs_sc_impl new \ + -impl_contract_name "dotlrn_applet" -impl_name $name \ + -impl_pretty_name "" -impl_owner_name $name -# remove_portlet $portal_id $args -# # flush cache for this portal -# ::tlf_global flush_portal $portal_id - } - - ad_proc -public add_portlet { - portal_id - } { - A helper proc to add the underlying portlet to the given portal. - - @param portal_id - } { - # simple, no type specific stuff, just set some dummy values + # add the operations -# set args [ns_set create] -# ns_set put $args package_id 0 -# add_portlet_helper $portal_id $args + foreach {operation call} { + GetPrettyName "xowiki_applet pretty_name" + AddApplet "xowiki_applet add_applet" + RemoveApplet "xowiki_applet remove_applet" + AddAppletToCommunity "xowiki_applet add_applet_to_community" + RemoveAppletFromCommunity "xowiki_applet remove_applet_from_community" + AddUser "xowiki_applet add_user" + RemoveUser "xowiki_applet remove_user" + AddUserToCommunity "xowiki_applet add_user_to_community" + RemoveUserFromCommunity "xowiki_applet remove_user_from_community" + AddPortlet "xowiki_applet add_portlet" + RemovePortlet "xowiki_applet remove_portlet" + Clone "xowiki_applet clone" + ChangeEventHandler "xowiki_applet change_event_handler" + } { + ::xo::db::sql::acs_sc_impl_alias new \ + -impl_contract_name "dotlrn_applet" -impl_name $name \ + -impl_operation_name $operation -impl_alias $call \ + -impl_pl "TCL" } - ad_proc -public add_portlet_helper { - portal_id - args - } { - A helper proc to add the underlying portlet to the given portal. - @param portal_id - } { - xowiki_portlet::add_self_to_page \ - -portal_id $portal_id \ - -package_id [ns_set get $args "package_id"] \ - -param_action [ns_set get $args "param_action"] - } + # Add the binding + ::xo::db::sql::acs_sc_binding new \ + -contract_name "dotlrn_applet" -impl_name $name + } +} + +xowiki_applet proc uninstall {} { + my log "--applet calling [self proc]" + # + # pretty similar "xowiki_portlet uninstall" + # + set name [my applet_key] + + db_transaction { + # + # get the datasource + # + + set ds_id [db_string dbqd..get_ds_id { + select datasource_id from portal_datasources where name = :name + } -default "0"] - ad_proc -public remove_portlet { - portal_id - args - } { - A helper proc to remove the underlying portlet from the given portal. - - @param portal_id - @param args A list of key-value pairs (possibly user_id, community_id, and more) - } { -# xowiki_portlet::remove_self_from_page \ -# -portal_id $portal_id \ -# -package_id [ns_set get $args "package_id"] + if {$ds_id == 0} { + error "No datasource id found for $name" } - - ad_proc -public clone { - old_community_id - new_community_id + # + # drop the datasource + # + ::xo::db::sql::portal_datasource delete -datasource_id $ds_id + # + # drop the operation + # + foreach operation { + GetPrettyName + AddApplet + RemoveApplet + AddAppletToCommunity + RemoveAppletFromCommunity + AddUser + RemoveUser + AddUserToCommunity + RemoveUserFromCommunity + AddPortlet + RemovePortlet + Clone } { - Clone this applet's content from the old community to the new one - } { - ns_log notice "Cloning: [applet_key]" - set new_package_id [add_applet_to_community $new_community_id] - set old_package_id [dotlrn_community::get_applet_package_id \ - -community_id $old_community_id \ - -applet_key [applet_key] - ] - - db_exec_plsql clone_data {} - return $new_package_id + ::xo::db::sql::acs_sc_impl_alias delete \ + -impl_contract_name "dotlrn_applet" -impl_name $name \ + -impl_operation_name $operation } + # + # drop the binding + # + ::xo::db::sql::acs_sc_binding delete \ + -contract_name "dotlrn_applet" -impl_name $name - ad_proc -public change_event_handler { - community_id - event - old_value - new_value - } { - listens for the following events: - } { - } + # + # drop the implementation + # + ::xo::db::sql::acs_sc_impl delete \ + -impl_contract_name "dotlrn_applet" -impl_name $name + } + my log "--applet end of [self proc]" +} +::xowiki_applet proc after-install {} { + ::xowiki_applet install } + +::xowiki_applet proc before-uninstall {} { + ::xowiki_applet uninstall +} +