Index: openacs-4/packages/dotlrn-tasks/dotlrn-tasks.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-tasks/dotlrn-tasks.info,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-tasks/dotlrn-tasks.info	28 Sep 2005 18:51:06 -0000	1.1
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!-- Generated by the OpenACS Package Manager -->
+
+<package key="dotlrn-tasks" url="http://openacs.org/repository/apm/packages/dotlrn-tasks" type="apm_application">
+    <package-name>dotLRN Tasks</package-name>
+    <pretty-plural>dotLRN Tasks</pretty-plural>
+    <initial-install-p>f</initial-install-p>
+    <singleton-p>t</singleton-p>
+    
+    <version name="0.1d" url="http://openacs.org/repository/download/apm/dotlrn-tasks-0.1d.apm">
+        <owner url="mailto:miguelmarin@viaro.net">Miguel Marin</owner>
+        <vendor url="http://www.viaro.net">Viaro Networks</vendor>
+        <maturity>0</maturity>
+
+        <provides url="dotlrn-tasks" version="0.1d"/>
+        <requires url="dotlrn" version="2.1.2d1"/>
+        <requires url="tasks" version="0.1d"/>
+        <requires url="tasks-portlet" version="0.1d"/>
+
+        <callbacks>
+            <callback type="after-install"  proc="dotlrn_tasks::register_portlet_in_templates"/>
+        </callbacks>
+        <parameters>
+        <!-- No version parameters -->
+        </parameters>
+
+    </version>
+</package>
Index: openacs-4/packages/dotlrn-tasks/sql/postgresql/dotlrn-tasks-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-tasks/sql/postgresql/dotlrn-tasks-create.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-tasks/sql/postgresql/dotlrn-tasks-create.sql	28 Sep 2005 18:53:24 -0000	1.1
@@ -0,0 +1,158 @@
+--
+--  Copyright (C) 2001, 2002 MIT
+--
+--  This file is part of dotLRN.
+--
+--  dotLRN is free software; you can redistribute it and/or modify it under the
+--  terms of the GNU General Public License as published by the Free Software
+--  Foundation; either version 2 of the License, or (at your option) any later
+--  version.
+--
+--  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+--  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+--  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+--  details.
+--
+
+-- create the implementation
+
+
+create function inline_0()
+returns integer as '
+declare
+	foo integer;
+begin
+	-- create the implementation
+	foo := acs_sc_impl__new (
+		''dotlrn_applet'',
+		''dotlrn_tasks'',
+		''dotlrn_tasks''
+	);
+
+	-- GetPrettyName
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''GetPrettyName'',
+	       ''dotlrn_tasks::get_pretty_name'',
+	       ''TCL''
+	);
+
+	-- AddApplet
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''AddApplet'',
+	       ''dotlrn_tasks::add_applet'',
+	       ''TCL''
+	);
+
+	-- RemoveApplet
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''RemoveApplet'',
+	       ''dotlrn_tasks::remove_applet'',
+	       ''TCL''
+	);
+
+	-- AddAppletToCommunity
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''AddAppletToCommunity'',
+	       ''dotlrn_tasks::add_applet_to_community'',
+	       ''TCL''
+	);
+
+	-- RemoveAppletFromCommunity
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''RemoveAppletFromCommunity'',
+	       ''dotlrn_tasks::remove_applet_from_community'',
+	       ''TCL''
+	);
+
+	-- AddUser
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''AddUser'',
+	       ''dotlrn_tasks::add_user'',
+	       ''TCL''
+	);
+
+	-- RemoveUser
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''RemoveUser'',
+	       ''dotlrn_tasks::remove_user'',
+	       ''TCL''
+	);
+
+	-- AddUserToCommunity
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''AddUserToCommunity'',
+	       ''dotlrn_tasks::add_user_to_community'',
+	       ''TCL''
+	);
+
+	-- RemoveUserFromCommunity
+	foo := acs_sc_impl_alias__new (
+	       ''dotlrn_applet'',
+	       ''dotlrn_tasks'',
+	       ''RemoveUserFromCommunity'',
+	       ''dotlrn_tasks::remove_user_from_community'',
+	       ''TCL''
+	);
+
+    -- AddPortlet
+    foo := acs_sc_impl_alias__new (
+        ''dotlrn_applet'',
+        ''dotlrn_tasks'',
+        ''AddPortlet'',
+        ''dotlrn_tasks::add_portlet'',
+        ''TCL''
+    );
+
+    -- RemovePortlet
+    foo := acs_sc_impl_alias__new (
+        ''dotlrn_applet'',
+        ''dotlrn_tasks'',
+        ''RemovePortlet'',
+        ''dotlrn_tasks::remove_portlet'',
+        ''TCL''
+    );
+
+    -- Clone
+    foo := acs_sc_impl_alias__new (
+        ''dotlrn_applet'',
+        ''dotlrn_tasks'',
+        ''Clone'',
+        ''dotlrn_tasks::clone'',
+        ''TCL''
+    );
+
+    foo := acs_sc_impl_alias__new (
+        ''dotlrn_applet'',
+        ''dotlrn_tasks'',
+        ''ChangeEventHandler'',
+        ''dotlrn_tasks::change_event_handler'',
+        ''TCL''
+    );
+
+	-- Add the binding
+	perform acs_sc_binding__new (
+	    ''dotlrn_applet'',
+	    ''dotlrn_tasks''
+	);
+
+	return 0;
+
+end;' language 'plpgsql';
+select inline_0();
+drop function inline_0();
Index: openacs-4/packages/dotlrn-tasks/sql/postgresql/dotlrn-tasks-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-tasks/sql/postgresql/dotlrn-tasks-drop.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-tasks/sql/postgresql/dotlrn-tasks-drop.sql	28 Sep 2005 18:53:24 -0000	1.1
@@ -0,0 +1,115 @@
+--
+--  Copyright (C) 2001, 2002 MIT
+--
+--  This file is part of dotLRN.
+--
+--  dotLRN is free software; you can redistribute it and/or modify it under the
+--  terms of the GNU General Public License as published by the Free Software
+--  Foundation; either version 2 of the License, or (at your option) any later
+--  version.
+--
+--  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+--  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+--  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+--  details.
+--
+
+
+select acs_sc_impl__delete(
+	   'dotlrn_applet',		-- impl_contract_name
+           'dotlrn_tasks'		-- impl_name
+);
+
+
+-- add all the hooks
+
+-- GetPrettyName
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'GetPrettyName'
+);
+
+-- AddApplet
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'AddApplet'
+);
+
+-- RemoveApplet
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'RemoveApplet'
+);
+
+-- AddAppletToCommunity
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'AddAppletToCommunity'
+);
+
+-- RemoveAppletFromCommunity
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'RemoveAppletFromCommunity'
+);
+
+-- AddUser
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'AddUser'
+);
+
+-- RemoveUser
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'RemoveUser'
+);
+
+-- AddUserToCommunity
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'AddUserToCommunity'
+);
+
+-- RemoveUserFromCommunity
+select acs_sc_impl_alias__delete (
+	       'dotlrn_applet',
+	       'dotlrn_tasks',
+	       'RemoveUserFromCommunity'
+);
+
+-- AddPortlet
+select acs_sc_impl_alias__delete (
+        'dotlrn_applet',
+        'dotlrn_tasks',
+        'AddPortlet'
+    );
+
+-- RemovePortlet
+select acs_sc_impl_alias__delete (
+        'dotlrn_applet',
+        'dotlrn_tasks',
+        'RemovePortlet'
+);
+
+-- Clone
+select acs_sc_impl_alias__delete (
+        'dotlrn_applet',
+        'dotlrn_tasks',
+        'Clone'
+);
+
+
+-- Add the binding
+select acs_sc_binding__delete (
+	    'dotlrn_applet',
+	    'dotlrn_tasks'
+);
Index: openacs-4/packages/dotlrn-tasks/tcl/dotlrn-tasks-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-tasks/tcl/dotlrn-tasks-procs.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-tasks/tcl/dotlrn-tasks-procs.tcl	28 Sep 2005 18:54:32 -0000	1.1
@@ -0,0 +1,243 @@
+#  Copyright (C) 2001, 2002 MIT
+#  This file is part of dotLRN.
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+
+ad_library {
+    
+    the dotlrn applet for calendar
+    
+    @author Miguel Marin (miguelmarin@viaro.net)
+    @author Viaro Networks www.viaro.net
+
+}
+
+namespace eval dotlrn_tasks {}
+
+ad_proc -public dotlrn_tasks::package_key {
+} {
+    What package does this applet deal with?
+} {
+    return "tasks"
+}
+
+ad_proc -public dotlrn_tasks::my_package_key {
+} {
+    What's my package key?
+} {
+    return "dotlrn-tasks"
+}
+
+ad_proc -public dotlrn_tasks::applet_key {
+} {
+    What's my applet key?
+} {
+    return "dotlrn_tasks"
+}
+
+ad_proc -public dotlrn_tasks::get_pretty_name {
+} {
+} {
+    return "Tasks"
+}
+
+ad_proc -public dotlrn_tasks::add_applet {
+} {
+    Called for one time init - must be repeatable!
+    @return new pkg_id or 0 on failure
+} {
+    
+    # FIXME: won't work with multiple dotlrn instances Use the package_key
+    # for the -url param - "/" are not allowed!
+    
+    set package_id 0
+    
+    if { ![dotlrn::is_package_mounted -package_key [package_key]] } {
+	set package_id [dotlrn::mount_package \
+			    -package_key [package_key] \
+			    -url [package_key] \
+			    -directory_p "t"]
+    }
+    
+    dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] -package_key [my_package_key]
+    
+}
+
+ad_proc -public dotlrn_tasks::remove_applet {
+} {
+    One-time destroy for when the entire applet is removed from dotlrn.
+} {
+    ad_return_complaint 1 "[applet_key] remove_applet not implimented!"
+}
+
+ad_proc -public dotlrn_tasks::tasks_create_helper {
+    {-community_id:required}
+    {-package_id:required}
+} {
+    A helper proc to create a tasks for a comm, returns the new calendar_id
+} {
+    return "00"
+}
+
+ad_proc -public dotlrn_tasks::add_applet_to_community {
+    community_id
+} {
+    Add the tasks applet to a specific dotlrn community
+} {
+    set results [add_applet_to_community_helper -community_id $community_id]
+    
+    return [lindex $results 0]
+}
+
+ad_proc -public dotlrn_tasks::add_applet_to_community_helper {
+    {-community_id:required}
+} {
+    Add the tasks applet to a specific dotlrn community
+    
+    @params community_id
+} {
+    
+    # Create and Mount the Tasks Package
+
+    set package_id [dotlrn::instantiate_and_mount \
+			-mount_point "tasks" \
+			$community_id \
+			[package_key] \
+		       ]
+    
+    # Set up the tasks portlet for this portal/community
+    
+    set portal_id [dotlrn_community::get_portal_id \
+		       -community_id $community_id]
+    
+    # Add the portlet to the Portal.
+    
+    tasks_portlet::add_self_to_page -portal_id $portal_id -package_id $package_id
+    
+    # this should return the package_id
+    return $package_id
+}
+
+ad_proc -public dotlrn_tasks::remove_applet_from_community {
+    community_id
+} {
+    remove the applet from the community
+} {
+    ad_return_complaint 1 "[applet_key] remove_applet_from_community not implimented!"
+}
+
+ad_proc -public dotlrn_tasks::add_user {
+    user_id
+} {
+    Called once when a user is added as a dotlrn user.
+} {
+}
+
+ad_proc -public dotlrn_tasks::remove_user {
+    user_id
+} {
+    Remove a user from dotlrn
+} {
+    
+    # Not yet implemented.
+}
+
+ad_proc -public dotlrn_tasks::add_user_to_community {
+    community_id
+    user_id
+} {
+    Add a user to 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]
+    
+    # use "append" here since we want to aggregate
+    set param_action append
+    
+    tasks_portlet::add_self_to_page \
+        -portal_id $portal_id \
+        -package_id $package_id \
+        -param_action $param_action
+}
+
+ad_proc -public dotlrn_tasks::remove_user_from_community {
+    community_id
+    user_id
+} {
+    Remove a user from a community
+} {
+}
+
+ad_proc -public dotlrn_tasks::add_portlet {
+    portal_id
+} {
+    Set up default params for templates about to call add_portlet_helper
+    
+    @param portal_id
+} {
+
+    tasks_portlet::add_self_to_page \
+	-portal_id $portal_id \
+	-package_id 0
+}
+
+ad_proc -public dotlrn_tasks::remove_portlet {
+    portal_id
+    args
+} {
+    A helper proc to remove the underlying portlet from the given portal.
+    This is alot simpler than add_portlet.
+    
+    @param portal_id
+} {
+    set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]]
+    tasks_portlet::remove_self_from_page \
+	-portal_id $portal_id \
+	-package_id $pacakge_id]
+}
+
+ad_proc -public dotlrn_tasks::clone {
+    old_community_id
+    new_community_id
+} {
+    Clone this applet's content from the old community to the new one
+} {
+}
+
+ad_proc -public dotlrn_tasks::change_event_handler {
+    community_id
+    event
+    old_value
+    new_value
+} {
+    listens for the following events: rename
+} {
+
+}
+
+# Some dotlrn_project_manager specific procs
+
+ad_proc -private dotlrn_tasks::register_portlet_in_templates {
+
+} {
+    Procedure that register the portal in the user, communities, classes and subcomunnities
+    Templates
+} {
+    # We are going to add the portlet of tasks to the
+    # templates
+    
+    db_foreach get_portal_templates { } {
+	tasks_portlet::add_self_to_page -portal_id $portal_id -package_id 0
+    }
+
+}
\ No newline at end of file
Index: openacs-4/packages/dotlrn-tasks/tcl/dotlrn-tasks-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-tasks/tcl/dotlrn-tasks-procs.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-tasks/tcl/dotlrn-tasks-procs.xql	28 Sep 2005 18:54:32 -0000	1.1
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="dotlrn_tasks::register_portlet_in_templates.get_portal_templates">
+  <querytext>
+        select
+                portal_id
+        from
+                portals
+        where
+                name in ('#dotlrn.user_portal_pretty_name# Portal','#dotlrn.subcommunities_pretty_plural# Portal','#dotlrn.class_instance_portal_pretty_name# Portal','#dotlrn.clubs_pretty_plural# Portal')
+                and template_id is null;
+  </querytext>
+</fullquery>
+
+</queryset>
+
+