Index: openacs-4/packages/dotlrn-catalog/dotlrn-catalog.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/dotlrn-catalog.info,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/dotlrn-catalog.info	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!-- Generated by the OpenACS Package Manager -->
+
+<package key="dotlrn-catalog" url="http://openacs.org/repository/apm/packages/dotlrn-catalog" type="apm_application">
+    <package-name>dotLRN Catalog</package-name>
+    <pretty-plural>dotLRN Catalog's</pretty-plural>
+    <initial-install-p>f</initial-install-p>
+    <singleton-p>t</singleton-p>
+    <auto-mount>dotlrn-catalog</auto-mount>
+
+    <version name="0.1a4" url="http://openacs.org/repository/download/apm/dotlrn-catalog-1.0d.apm">
+        <owner url="mailto:miguelmarin@viaro.net">Miguel Marin</owner>
+        <release-date>2005-02-02</release-date>
+        <vendor url="http://www.viaro.net">Viaro Networks</vendor>
+        <maturity>0</maturity>
+
+        <provides url="dotlrn-catalog" version="0.1a4"/>
+        <requires url="acs-content-repository" version="5.1.5d3"/>
+        <requires url="acs-subsite" version="5.1.4"/>
+        <requires url="assessment" version="0.10d5"/>
+	<requires url="categories" version="1.0d7"/>
+        <requires url="dotlrn" version="2.1.1"/>
+
+        <callbacks>
+            <callback type="after-install"  proc="dotlrn-catalog::package_install"/>
+            <callback type="after-mount"  proc="dotlrn-catalog::package_mount"/>
+            <callback type="before-uninstall"  proc="dotlrn-catalog::package_uninstall"/>
+        </callbacks>
+        <parameters>
+        <!-- No version parameters -->
+        </parameters>
+
+    </version>
+</package>
Index: openacs-4/packages/dotlrn-catalog/catalog/dotlrn-catalog.en_US.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/catalog/dotlrn-catalog.en_US.ISO-8859-1.xml,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/catalog/dotlrn-catalog.en_US.ISO-8859-1.xml	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<message_catalog package_key="dotlrn-catalog" package_version="0.1a4" locale="en_US" charset="ISO-8859-1">
+
+  <msg key="add_course_to">Add this course to one category.</msg>
+  <msg key="admin_categories">Manage Category Tree</msg>
+  <msg key="and_has">and has</msg>
+  <msg key="asm">Assessment</msg>
+  <msg key="associate">Associate</msg>
+  <msg key="associate_this">Associate this course</msg>
+  <msg key="associate_to_class">Associate to this class</msg>
+  <msg key="associate_to_com">Associate to this community</msg>
+  <msg key="associated">Already Associated</msg>
+  <msg key="categories">Categories</msg>
+  <msg key="categorize">Categorize</msg>
+  <msg key="categorized">Categorized Courses</msg>
+  <msg key="class">Class</msg>
+  <msg key="class_name">Class Name</msg>
+  <msg key="com_name">Community Name:</msg>
+  <msg key="community">Community</msg>
+  <msg key="confirm_delete">Confirm Delete Of </msg>
+  <msg key="course_admin">Course Administration</msg>
+  <msg key="course_catalog">DotLRN Catalog Index</msg>
+  <msg key="course_info">Course Info:</msg>
+  <msg key="course_key">Course Key:</msg>
+  <msg key="course_list">Your Course List</msg>
+  <msg key="course_name">Course Name:</msg>
+  <msg key="courses">Courses</msg>
+  <msg key="create_new_ver">Create a new version of</msg>
+  <msg key="delete">Delete</msg>
+  <msg key="delete_course">Delete Course</msg>
+  <msg key="delete_this">Delete This Course</msg>
+  <msg key="dep_name">Department Name</msg>
+  <msg key="description">Description</msg>
+  <msg key="do_you_still">Do you Still want to delete it?</msg>
+  <msg key="dotlrn">DotLRN</msg>
+  <msg key="dotlrn_classes">DotLRN Classes</msg>
+  <msg key="dotlrn_com">DotLRN Communities</msg>
+  <msg key="dotlrn_list">DotLRN List</msg>
+  <msg key="edit_course">New Course Version</msg>
+  <msg key="email">Email:</msg>
+  <msg key="enroll">Enroll</msg>
+  <msg key="enroll_not">Enroll Not Available</msg>
+  <msg key="grant">Grant</msg>
+  <msg key="grant_list">Grant List</msg>
+  <msg key="grant_per">Grant Permissions</msg>
+  <msg key="grant_to_others">Grant permissions to other users</msg>
+  <msg key="granted">Granted</msg>
+  <msg key="grantrevoke">Grant/Revoke</msg>
+  <msg key="has_no">and has &lt;b&gt;No&lt;/b&gt; associations to dotLRN class or community</msg>
+  <msg key="has_one">has one association to dotLRN class or community</msg>
+  <msg key="is_assoc">is associated to:</msg>
+  <msg key="label_title">Check/uncheck all rows</msg>
+  <msg key="make_live">Make This Course Live</msg>
+  <msg key="manage_per">Manage Permissions</msg>
+  <msg key="name_already">&lt;b&gt;The course key is already taken&lt;/b&gt;</msg>
+  <msg key="new_course">New Course</msg>
+  <msg key="new_ver">New Course Version</msg>
+  <msg key="no">No</msg>
+  <msg key="not_allowed">Not Allowed</msg>
+  <msg key="not_associate">Not Associate</msg>
+  <msg key="not_associated">Not Associated</msg>
+  <msg key="one_course_info">One Course Information</msg>
+  <msg key="permission">Permission:</msg>
+  <msg key="rev_list">Revision List</msg>
+  <msg key="revisions">Revisions</msg>
+  <msg key="revoke">Revoke</msg>
+  <msg key="revoke_per">Revoke Permissions</msg>
+  <msg key="search_email_help">search for entire email or just part of it</msg>
+  <msg key="search_help">search for one first name or last name.</msg>
+  <msg key="search_u">Search Users</msg>
+  <msg key="search_user">Search User Name:</msg>
+  <msg key="search_user_email">Search for user Email:</msg>
+  <msg key="search_users_to">Search Users To Grant Permissions On</msg>
+  <msg key="see_all_rev">See All Versions</msg>
+  <msg key="subject_name">Subject Name</msg>
+  <msg key="term_name">Term Name</msg>
+  <msg key="this_course">This course has</msg>
+  <msg key="title">Check/uncheck this row, and select an action to perform below</msg>
+  <msg key="to">To</msg>
+  <msg key="to_dotlrn">associations to dotLRN classes or communities</msg>
+  <msg key="uncategorized">Uncategorized Courses</msg>
+  <msg key="user_name">User Name:</msg>
+  <msg key="users_to_grant">users to grant permissions that match that search</msg>
+  <msg key="version">Version</msg>
+  <msg key="versions">Versions</msg>
+  <msg key="watch">Watch</msg>
+  <msg key="watch_assoc">Watch Association</msg>
+  <msg key="yes">Yes</msg>
+</message_catalog>
Index: openacs-4/packages/dotlrn-catalog/lib/community-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/community-chunk.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/community-chunk.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,5 @@
+<table>
+<tr><td><b>#dotlrn-catalog.com_name#</b></td><td><a href="@url@">@pretty_name;noquote@</a></td></tr>
+<tr><td><b>#dotlrn-catalog.description#:</b></td><td>@description;noquote@</td></tr>
+</table>
+<br>
Index: openacs-4/packages/dotlrn-catalog/lib/community-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/community-chunk.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/community-chunk.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,10 @@
+ad_page_contract {
+    Displays the information of one dotLRN community
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   08-01-2005
+} {
+
+}
+
+db_1row get_community_info { }
Index: openacs-4/packages/dotlrn-catalog/lib/community-chunk.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/community-chunk.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/community-chunk.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<queryset>
+
+    <fullquery name="get_community_info">
+        <querytext>
+	     select pretty_name, description, url from dotlrn_clubs_full
+	     where community_id = :community_id
+        </querytext>
+    </fullquery>
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/lib/course-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/course-chunk.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/course-chunk.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,91 @@
+<table>
+<tr>
+   <td>
+   <if @edit@ eq yes>
+   <div align="right">
+	<a href=course-add-edit?course_id=@course_id@&return_url=@return_url@&mode=edit \
+	title="#dotlrn-catalog.new_ver#"><img border=0 src=/resources/Edit16.gif></a>
+   </div>
+   </if>
+   </td>
+  <td>
+    <b>#dotlrn-catalog.course_key#</b>
+  </td>
+  <td>
+    <if @edit@ eq yes>
+    <a href="revision-list?course_key=@course_key@&return_url=$return_url&course_id=@course_id@" title="#dotlrn-catalog.see_all_rev#">@course_key@</a></if><else>@course_key@</else>
+   </td>
+</tr>
+<tr><td></td>
+    <td><b>#dotlrn-catalog.course_name#</b></td><td>@name@</td>
+</tr>
+<tr><td></td>
+    <td><b>#dotlrn-catalog.course_info#</b></td><td>@info@</td>
+</tr>
+<tr><td></td>
+    <td><b>#dotlrn-catalog.asm#:</b></td><td>@asm@</td>
+</tr>
+<tr><td></td>
+    <td>
+	<b>#dotlrn-catalog.dotlrn#:</b>
+    </td>
+    <td>
+	<if @rel@ eq 0>
+	   #dotlrn-catalog.no# 
+	  <if @edit@ eq "yes">
+	     <if @dotlrn_url@ eq "/dotlrn">
+             (<a href="dotlrn-list?course_id=@course_id@&course_key=@course_key@&course_name=@name@&return_url=@return_url@" title="#dotlrn-catalog.associate_this#"><i>#dotlrn-catalog.associate#</i></a>)</if>
+          </if>
+	</if>
+	<else>
+	   <if @index@ eq "yes">
+	       #dotlrn-catalog.yes# (<a href="cc-admin/watch-association?course_id=@course_id@&course_key=@course_key@&return_url=@return_url@&course_name=@name@" title="#dotlrn-catalog.watch_assoc#"><i>#dotlrn-catalog.watch#</i></a>)
+	   </if>
+	   <else>
+	       #dotlrn-catalog.yes# (<a href="watch-association?course_id=@course_id@&course_key=@course_key@&return_url=@return_url@&course_name=@name@" title="#dotlrn-catalog.watch_assoc#"><i>#dotlrn-catalog.watch#</i></a>)
+	   </else>
+	</else>
+    </td>
+</tr>
+<if @category_p@ eq "1">
+    <if @index@ not eq "yes">
+        <tr><td></td>
+	   <td>
+	       <b>#dotlrn-catalog.categorize#:</b>
+	   </td>
+    	   <td>#dotlrn-catalog.yes# (@category_name@)</td>
+        </tr>
+    </if>
+</if>
+<tr><td></td><td></td>
+<td>
+   <if @edit@ eq no>
+      <if @index@ eq "yes">
+	<if @asmid@ gt "-1">
+	    <a class="button" href="/assessment/assessment?assessment_id=@asmid@">#dotlrn-catalog.enroll#</a>
+	</if>
+	<else>
+	   <br>
+	   <b>#dotlrn-catalog.enroll_not#</b>
+	</else>
+      </if>
+      <else>
+         <if @course_id@ eq @live_revision@>
+	     <img border=0 src="/dotlrn-catalog/images/live.gif">   
+         </if>
+         <else>
+	     <a href="go-live?course_key=@course_key@&revision_id=@course_id@" title="#dotlrn-catalog.make_live#"><img border=0 src="/dotlrn-catalog/images/golive.gif"></a>
+         </else>
+      </else>
+   </if>
+   <else>
+	<a class=button href="grant-user-list?object_id=@item_id@&creation_user=@creation_user@&course_key=@course_key@" title="#dotlrn-catalog.grantrevoke#">#dotlrn-catalog.manage_per#</a>
+         <a class=button href="course-delete?object_id=@item_id@&creation_user=@creation_user@&course_key=@course_key@" title="#dotlrn-catalog.delete_this#">#dotlrn-catalog.delete#</a>
+	<if @category_p@ eq "-1">
+	   <a class=button href="course-categorize?course_id=@course_id@&name=@name@">#dotlrn-catalog.categorize#</a>
+	</if>
+   </td>
+   </else>
+</tr>
+</table>
+<br>
Index: openacs-4/packages/dotlrn-catalog/lib/course-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/course-chunk.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/course-chunk.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,25 @@
+ad_page_contract {
+    Displays the information of one course
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   08-01-2005
+} {
+
+}
+
+set dotlrn_url [dotlrn::get_url]
+if { ![info exists index] } {
+    set index ""
+}
+
+if { ![info exists asmid] } {
+    set asmid "-1"
+}
+
+set category_p [db_string get_category { } -default -1]
+
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+set tree_id [db_string get_tree_id { } -default "-1"]
+
+# Get the category name
+set category_name "[category::get_name [category::get_mapped_categories $course_id]]"
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/lib/course-chunk.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/course-chunk.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/course-chunk.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<queryset>
+
+    <fullquery name="get_category">
+        <querytext>
+	     select 1 from category_object_map where object_id = :course_id
+        </querytext>
+    </fullquery>
+
+    <fullquery name="get_tree_id">      
+        <querytext>
+      	    select tree_id from category_tree_map where object_id = :cc_package_id
+        </querytext>
+    </fullquery>
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,8 @@
+<table>
+<tr><td><b>#dotlrn-catalog.dep_name#:</b></td><td>@department_name;noquote@</td></tr>
+<tr><td><b>#dotlrn-catalog.term_name#:</b></td><td>@term_name;noquote@</td></tr>
+<tr><td><b>#dotlrn-catalog.subject_name#:</b></td><td>@class_name;noquote@</td></tr>
+<tr><td><b>#dotlrn-catalog.class_name#:</b></td><td><a href="@url@">@pretty_name;noquote@</a></td></tr>
+<tr><td><b>#dotlrn-catalog.description#:</b></td><td>@description;noquote@</td></tr>
+</table>
+<br>
Index: openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,10 @@
+ad_page_contract {
+    Displays the information of one dotLRN class
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   08-01-2005
+} {
+
+}
+
+db_1row get_class_info { }
Index: openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/dotlrn-chunk.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<queryset>
+
+    <fullquery name="get_class_info">
+        <querytext>
+            select department_name, term_name, class_name, pretty_name, description, url
+	    from dotlrn_class_instances_full 
+	    where class_instance_id = :class_id
+        </querytext>
+    </fullquery>
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/lib/tree-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/tree-chunk.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/tree-chunk.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,11 @@
+<h3>#dotlrn-catalog.categorized#:</h3>
+@tree_view;noquote@
+<br>
+<if @uncat_p@ eq 1>
+   <h3>#dotlrn-catalog.uncategorized#:</h3>
+</if>
+<ul>
+<multiple name="uncat">
+    <li><a href="course-info?course_id=@course_id@&course_key=@course_key@&course_name=@course_name@">(@uncat.course_key@) @uncat.course_name@</a>
+</multiple>
+</ul>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/lib/tree-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/tree-chunk.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/tree-chunk.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,42 @@
+ad_page_contract {
+    Display an ident tree of categories and courses.
+    @author          Miguel Marin (miguelmarin@viaro.net)
+    @author          Viaro Networks www.viaro.net
+    @creation-date   11-02-2005
+
+} {
+
+}
+
+
+set tree_list [category_tree::get_tree -all $tree_id]
+set tree_view ""
+
+set cat_obj_list [dotlrn_catalog::get_categories_from_tree -tree_id $tree_id]
+
+# Display all courses associated to one category
+foreach element $tree_list {
+    set level [lindex $element 3]
+    set spacer ""
+    for { set i 0 } { $i < $level } { incr i } {
+        append spacer "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
+    }
+    if { [string equal $level 1] } {
+        append tree_view "<b>${spacer}[lindex $element 1]<br></b>"
+    } else {
+        append tree_view "${spacer}[lindex $element 1]<br>"
+    }
+    foreach item $cat_obj_list {
+	if { [string equal [lindex $item 0] [lindex $element 0] ]} {
+	    set course_id "[lindex $item 1]"
+	    db_0or1row get_course_info { }
+	    append tree_view "${spacer}&nbsp;&nbsp&nbsp;&nbsp;<a href=\"course-info?course_id=$course_id&course_key=$course_key&course_name=$course_name\">($course_key) $course_name</a><br>"
+	}
+    }
+}
+
+# Display courses without category
+set uncat_p 0
+db_multirow uncat get_courses_uncat { } {
+    set uncat_p 1
+}
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/lib/tree-chunk.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/tree-chunk.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/lib/tree-chunk.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="get_course_info">
+      <querytext>
+            select dc.course_id, dc.course_key, dc.course_name
+            from dotlrn_catalog dc, cr_items ci
+            where dc.course_id = ci.live_revision and dc.course_id = :course_id
+      </querytext>
+</fullquery>
+
+
+<fullquery name="get_courses_uncat">
+      <querytext>
+            select dc.course_id, dc.course_key, dc.course_name
+            from dotlrn_catalog dc, cr_items ci
+            where dc.course_id = ci.live_revision and dc.course_id not in (
+		select object_id from category_object_map where category_id in (
+	 	    select category_id from categories where tree_id =:tree_id
+	    	)	
+	    )	
+      </querytext>
+</fullquery>
+
+
+</queryset>
Index: openacs-4/packages/dotlrn-catalog/sql/oracle/dotlrn-catalog-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/sql/oracle/dotlrn-catalog-create.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/sql/oracle/dotlrn-catalog-create.sql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,13 @@
+-- dotLRN Catalog Data Model
+-- author  Miguel Marin (miguelmarin@viaro.net) Viaro Networks (www.viaro.net)
+-- creation-date 2005-01-31
+
+begin
+  acs_rel_type.create_role(''d_catalog_role'', ''DotLRN Course Catalog Role'', ''DotLRN Course Catalog Role'');
+  acs_rel_type.create_role(''dotlrn_class_role'', ''dotLRN Class Role'', ''dotLRN Class Role'');
+  acs_rel_type.create_role(''dotlrn_com_role'', ''dotLRN Community Role'', ''dotLRN Community Role'');
+
+  commit;
+end;
+/
+show errors
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/sql/oracle/dotlrn-catalog-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/sql/oracle/dotlrn-catalog-drop.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/sql/oracle/dotlrn-catalog-drop.sql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,10 @@
+--
+-- author  Miguel Marin (miguelmarin@viaro.net) Viaro Networks (www.viaro.net)
+-- creation-date 2005-01-31
+--
+
+begin
+  acs_rel_type.drop_type('dotlrn_catalog_rel');
+end;
+/
+show errors
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/sql/postgresql/dotlrn-catalog-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/sql/postgresql/dotlrn-catalog-create.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/sql/postgresql/dotlrn-catalog-create.sql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,18 @@
+-- DotLRN Catalog Relation Model
+-- author Miguel Marin (miguelmarin@viaro.net) Viaro Networks (www.viaro.net)
+-- creation-date 2005-01-31
+
+
+create function inline_0 ()
+returns integer as '
+begin
+  PERFORM acs_rel_type__create_role(''d_catalog_role'', ''DotLRN Catalog Role'', ''DotLRN Catalog Role'');
+  PERFORM acs_rel_type__create_role(''dotlrn_class_role'', ''dotLRN Class Role'', ''dotLRN Class Role'');
+  PERFORM acs_rel_type__create_role(''dotlrn_com_role'', ''dotLRN Community Role'', ''dotLRN Community Role'');
+
+  return 0;		
+end;' language 'plpgsql';
+
+select inline_0 ();
+
+drop function inline_0 ();
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/sql/postgresql/dotlrn-catalog-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/sql/postgresql/dotlrn-catalog-drop.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/sql/postgresql/dotlrn-catalog-drop.sql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,8 @@
+--
+--
+-- author Miguel Marin (miguelmarin@viaro.net) Viaro Networks (www.viaro.net)
+-- creation-date 2005-01-31
+--
+
+drop table c_catalog;
+select acs_rel_type__drop_type('dotlrn_catalog_rel', 'f');
Index: openacs-4/packages/dotlrn-catalog/tcl/apm-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/tcl/apm-callback-procs.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/tcl/apm-callback-procs.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,105 @@
+# packages/course-catalog/tcl/apm-callbacks-procs.tcl 
+
+ad_library {
+    
+    APM callback for dotlrn catalog
+    
+    @author Miguel Marin (miguelmarin@viaro.net) Viaro Networks (www.viaro.net)
+    @creation-date 2005-01-27
+}
+
+namespace eval dotlrn-catalog {}
+
+ad_proc -private dotlrn-catalog::package_install {
+} {
+    create the CR type datamodel for the course catalog
+    
+    @author Miguel Marin (miguelmarin@viaro.net) Viaro Networks (www.viaro.net)
+    @creation-date 2005-01-27
+} {
+ 
+    # lets create the CR type tables to support the course catalog
+    
+    content::type::new -content_type "dotlrn_catalog" \
+	-pretty_name "DotLRN Catalog" \
+	-pretty_plural "DotLRN Catalog" \
+ 	-table_name "dotlrn_catalog" \
+	-id_column "course_id"
+
+    # now set up the attributes that by default we need for the course
+    content::type::attribute::new \
+	-content_type "dotlrn_catalog" \
+	-attribute_name "course_key" \
+	-datatype "string" \
+	-pretty_name "Course Key" \
+	-pretty_plural "Course Key" \
+	-sort_order 1 \
+	-column_spec "varchar(50)"
+
+    content::type::attribute::new \
+	-content_type "dotlrn_catalog" \
+	-attribute_name "course_name" \
+	-datatype "string" \
+	-pretty_name "Course Name" \
+	-sort_order 2 \
+	-column_spec "varchar(200)"
+
+    content::type::attribute::new \
+	-content_type "dotlrn_catalog" \
+	-attribute_name "course_info" \
+	-datatype "text" \
+	-pretty_name "Course Information" \
+	-sort_order 3 \
+	-column_spec "text"
+
+    content::type::attribute::new \
+	-content_type "dotlrn_catalog" \
+	-attribute_name "assessment_id" \
+	-datatype "integer" \
+	-pretty_name "Assessment ID" \
+	-sort_order 4 \
+	-column_spec "integer"
+
+    # To store the courses in the content repository
+    set folder_id [content::folder::new -name "DotLRN Catalog" -label "DotLRN Catalog"]
+    content::folder::register_content_type -folder_id $folder_id -content_type "dotlrn_catalog" 
+    
+    # To associate one course to dotlrn class
+    rel_types::new -role_one d_catalog_role -role_two dotlrn_class_role dotlrn_catalog_class_rel \
+	"DotLRN Catalog Class" "DotLRN Catalog Class" dotlrn_catalog 0 1 dotlrn_class_instance 0 1
+    # To associate one course to dotrln community
+    rel_types::new -role_one d_catalog_role -role_two dotlrn_com_role dotlrn_catalog_dotcom_rel \
+	"DotLRN Catalog Community" "DotLRN Catalog Community" dotlrn_catalog 0 1 dotlrn_club 0 1
+}
+
+
+ad_proc -private dotlrn-catalog::package_mount {
+    -package_id
+    -node_id
+} {
+    create the category tree for dotlrn catalog
+    
+    @author Miguel Marin (miguelmarin@viaro.net) Viaro Networks (www.viaro.net)
+    @creation-date 11-02-2005
+} {
+    # To categorize courses
+    set tree_id [category_tree::add -name "dotlrn-course-catalog"]
+    category_tree::map -tree_id $tree_id -object_id $package_id -assign_single_p "t"
+}
+
+ad_proc -private dotlrn-catalog::package_uninstall {
+} {
+    drops the CR type datamodel for the course catalog
+    
+    @author Miguel Marin (miguelmarin@viaro.net) Viaro Networks (www.viaro.net)
+    @creation-date 2005-01-27
+} {
+    content::type::attribute::delete -content_type "dotlrn_catalog" -attribute_name "course_key" 
+    content::type::attribute::delete -content_type "dotlrn_catalog" -attribute_name "course_name" 
+    content::type::attribute::delete -content_type "dotlrn_catalog" -attribute_name "course_info" 
+    content::type::attribute::delete -content_type "dotlrn_catalog" -attribute_name "assessment_id" 
+    set folder_id [dotlrn_catalog::get_folder_id]
+    content::folder::unregister_content_type -folder_id $folder_id -content_type "dotlrn_catalog"
+    content::folder::delete -folder_id $folder_id -cascade_p "t"
+    content::type::delete -content_type "dotlrn_catalog" 
+}
Index: openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs-oracle.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<queryset>
+<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+<fullquery name="dotlrn_catalog::add_relation.add_relation">
+     <querytext>
+        begin
+          :1 := acs_rel.new (
+                 rel_type => :type,
+                 object_id_one => :course_id,
+                 object_id_two => :class_id);
+        end;
+     </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::delete_relation.remove_relation">
+     <querytext>
+        begin
+          :1 := acs_rel.delete (
+                 rel_id => :rel_id);
+        end;
+     </querytext>
+</fullquery>
+
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs-postgresql.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<queryset>
+<rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+<fullquery name="dotlrn_catalog::add_relation.add_relation">
+     <querytext>
+	select acs_rel__new (
+        null,
+        :type,
+        :course_id,
+        :object_id,
+        null,
+        null,
+        null
+        )
+     </querytext>
+</fullquery>
+
+
+<fullquery name="dotlrn_catalog::delete_relation.remove_relation">
+     <querytext>
+	select acs_rel__delete (
+	    :rel_id
+        )
+     </querytext>
+</fullquery>
+
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,244 @@
+ad_library {
+
+    Tcl API for dotlrn_catalog store and manipulation
+
+    @author Miguel Marin (miguelmarin@viaro.net) 
+    @Viaro Networks (href=www.viaro.net>www.viaro.net)    
+}
+
+namespace eval dotlrn_catalog {}
+
+ad_proc -private dotlrn_catalog::get_folder_id { } {
+    Returns the folder_id of the folder with the name "DotLRN Catalog"
+} {
+    return [db_string check_folder_name { } ]
+}
+
+ad_proc -private dotlrn_catalog::get_item_id { 
+    -revision_id:required
+ } {
+    Returns the item_id in the CR with the name @name@ under folder dotlrn_catalog
+    @revision_id@  The revision_id to get the item id in the CR
+} {
+    return [db_string get_item_from_revision { } ]
+}
+
+ad_proc -public dotlrn_catalog::get_creation_user { 
+    -object_id:required
+} {
+    Returns the creation_user of the object_id, returns -1 otherwise
+    @object_id@    
+} {
+    return [db_string get_creation_user { } -default -1]
+}
+
+ad_proc -private dotlrn_catalog::set_live {
+    -revision_id:required
+} {
+    Sets the live_revision to @revision_id@.
+    @revision_id@ The revision to set as live
+} {
+    db_transaction {
+	db_dml set_live_revision { }
+    }
+}
+
+
+ad_proc -private dotlrn_catalog::check_name {
+    -name:required
+} {
+    Checks if @name@ already exists in dotlrn_catalog table
+    @name@        The name of the course_key
+} {
+    if { [string equal [db_string check_item_name { } -default -1] "-1"] } {
+	return 1
+    } else {
+	return 0
+    }
+}
+
+
+ad_proc -private dotlrn_catalog::add_relation {
+    -course_id:required
+    -object_id:required
+    -type:required
+} {
+    Add a new relation between course_id from dotlrn_catalog and object_id where relation type is type
+    @course_id The id of the course in dotlrn_catalog
+    @class_id  The class_instance_id of the class in dotlrn
+    @type@     The type of the relation
+} {
+    db_exec_plsql add_relation { }
+}
+
+ad_proc -private dotlrn_catalog::has_relation_rel_id {
+    -course_id:required
+} {
+    Returns  the class_id of dotlrn_class_instance related to course_id, returns 0 otherwise.
+    @course_id The id of the course in dotlrn_catalog
+} {
+    return [db_string has_relation_rel_id { } -default 0]
+}
+
+ad_proc -private dotlrn_catalog::has_relation {
+    -course_id:required
+} {
+    Returns 1 if there is a class_id of dotlrn_class_instance related to course_id, returns 0 otherwise.
+    @course_id The id of the course in dotlrn_catalog
+} {
+    if { [db_string has_relation { } -default 0] == 0 } {
+	return 0
+    } else {
+	return 1
+    }
+}
+
+ad_proc -private dotlrn_catalog::relation_between {
+    -object_one:required
+    -object_two:required
+} {
+    Returns 1 if object_one is related to object_two, returns 0 otherwise.
+    @object_one
+    @object_two
+} {
+    if { [db_string relation_between { } -default 0] == 0 } {
+	return 0
+    } else {
+	return 1
+    }
+}
+
+
+ad_proc -private dotlrn_catalog::com_has_relation {
+    -community_id:required
+} {
+    Returns 1 if there is a community of dotlrn related to course_id, returns 0 otherwise.
+    @community_id The id of the community in dotlrn
+} {
+    if { [db_string com_has_relation { } -default 0] == 0 } {
+	return 0
+    } else {
+	return 1
+    }
+}
+
+
+ad_proc -private dotlrn_catalog::check_live_latest {
+    -revision_id:required
+} {
+    Checks if @revision_id@ is the live revision or the latest revision in cr_items
+    @revision_id@
+} {
+    set live [db_string check_live { } -default 0]
+    set latest [db_string check_latest { } -default 0] 
+    if { [string equal $live "0"] && [string equal $latest "0"] } {
+	return 1
+    } else {
+	return 0
+    }
+}
+
+ad_proc -private dotlrn_catalog::delete_row {
+    -course_id:required
+} {
+    Deletes the row of dotlrn_catalog table and cr_revisions table where revision_id  = @course_id@
+    @course_id The id of the course in dotlrn_catalog
+} {
+    if { [dotlrn_catalog::check_live_latest -revision_id $course_id] } {
+	db_transaction {
+	    db_dml delete_row { }
+	    db_dml delete_rev { }
+	}
+	dotlrn_catalog::delete_relation -course_id $course_id
+    }
+}
+
+ad_proc -private dotlrn_catalog::delete_relation {
+    -rel_id:required
+} {
+    Deletes the relation of dotlrn_catalog and dotrln class or community
+    @rel_id The id of the realtion
+} {
+    db_exec_plsql remove_relation { }
+}
+
+ad_proc -private dotlrn_catalog::grant_permissions {
+    -party_id:required
+    -object_id:required
+    -creation_user:required
+} {
+    Gives admin permission to @party_id@ over @object_id@ and over all assessment_id created
+    by @creation_user@
+    @party_id@       The user_id to give permissions
+    @object_id@      The course_id that the @party_id@ will have permissions on
+    @creation_user@  The user_id of the user that creates the course_id
+} {
+    permission::grant -party_id $party_id -object_id $object_id  -privilege "admin"
+    set asm_package_id [apm_package_id_from_key assessment]
+
+    db_foreach assessment { } {
+    	if {[permission::permission_p -party_id $creation_user -object_id $assessment_id -privilege "admin"] == 1} {
+	    permission::grant -party_id $party_id -object_id $assessment_id  -privilege "admin"
+	}
+    } 
+}
+
+ad_proc -private dotlrn_catalog::revoke_permissions {
+    -party_id:required
+    -object_id:required
+    -creation_user:required
+} {
+    Revokes  admin permission to @party_id@ over @object_id@ and over all assessment_id created
+    by @creation_user@
+    @party_id@       The user_id to revoke permissions
+    @object_id@      The course_id over wich @party_id@ has permissions on
+    @creation_user@  The user_id of the user that creates the course_id
+} {
+    permission::revoke -party_id $party_id -object_id $object_id  -privilege "admin"
+    set asm_package_id [apm_package_id_from_key assessment]
+    
+    db_foreach assessment { } {
+	if { [permission::permission_p -party_id $creation_user -object_id $assessment_id -privilege admin] == 1 } {
+	    permission::revoke -party_id $party_id -object_id $assessment_id  -privilege "admin"
+	}
+    }
+}
+
+ad_proc -private dotlrn_catalog::check_rev_assoc {
+    -item_id:required
+} {
+    Returns a list with number of revisions, number of associations to item_id
+    @item_id@ The item_id to check
+} {
+    set rev_num [db_string revision_count { } -default 0]
+    set assoc_num [db_string association_count { } -default 0]
+    set return_list [list]
+    lappend return_list $rev_num
+    lappend return_list $assoc_num
+    return $return_list
+}
+
+ad_proc -private dotlrn_catalog::course_delete {
+    -item_id:required
+} {
+    Deletes item_id and all the associations to that item_id (revisions, relations)
+    @item_id@ The item_id to delete
+} {
+    db_foreach relation { } {
+	dotlrn_catalog::delete_relation -rel_id $rel_id
+    } 
+    content::item::delete -item_id $item_id
+}
+
+ad_proc -private dotlrn_catalog::get_categories_from_tree {
+    -tree_id:required
+} {
+    Returns a list of all objects associated to one category under tree_id
+    @tree_id@ The tree_id that holds the objects
+} {
+    set return_list ""
+    db_foreach get_categories { } {
+	lappend return_list "[list "$category_id" "$object_id"]"
+    }
+    return $return_list
+}
Index: openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/tcl/dotlrn-catalog-procs.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="dotlrn_catalog::get_folder_id.check_folder_name">
+  <querytext>
+        select folder_id from cr_folders
+        where label = 'DotLRN Catalog'
+  </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::get_item_id.get_item_from_revision">
+  <querytext>
+        select item_id from cr_revisions
+        where revision_id = :revision_id
+  </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::get_creation_user.get_creation_user">
+  <querytext>
+        select creation_user from acs_objects
+        where object_id = :object_id
+  </querytext>
+</fullquery>
+
+
+<fullquery name="dotlrn_catalog::set_live.set_live_revision">      
+      <querytext>
+            update cr_items
+            set live_revision = :revision_id
+	    where item_id = ( select item_id from cr_revisions where revision_id = :revision_id )
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::check_name.check_item_name">      
+      <querytext>
+	    select course_id from dotlrn_catalog where course_key = :name
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::has_relation.has_relation">      
+      <querytext>
+            select count (rel_id)
+	    from acs_rels where object_id_one = :course_id 
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::relation_between.relation_between">      
+      <querytext>
+            select rel_id
+	    from acs_rels where object_id_one = :object_one and object_id_two = :object_two
+      </querytext>
+</fullquery>
+
+
+<fullquery name="dotlrn_catalog::com_has_relation.com_has_relation">      
+      <querytext>
+            select count (rel_id)
+	    from acs_rels where rel_type = 'dotlrn_catalog_com_rel'
+	    and object_id_two = :community_id
+      </querytext>
+</fullquery>
+
+
+<fullquery name="dotlrn_catalog::has_relation_rel_id.has_relation_rel_id">      
+      <querytext>
+            select rel_id
+	    from acs_rels where
+	    (rel_type = 'dotlrn_catalog_class_rel' or rel_type = 'dotlrn_catalog_com_rel')
+	    and object_id_one = :course_id
+      </querytext>
+</fullquery>
+
+
+<fullquery name="dotlrn_catalog::delete_row.delete_row">      
+      <querytext>
+	   delete from dotlrn_catalog where course_id = :course_id
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::delete_row.delete_rev">      
+      <querytext>
+	   delete from cr_revisions where revision_id = :course_id
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::check_live_latest.check_live">      
+      <querytext>
+	   select 1 from cr_items where live_revision = :revision_id
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::check_live_latest.check_latest">      
+      <querytext>
+	   select 1 from cr_items where latest_revision = :revision_id
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::grant_permissions.assessment">
+      <querytext>
+            select ci.item_id as assessment_id from
+            cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a
+            where cr.revision_id = ci.latest_revision and a.assessment_id = cr.revision_id and
+            ci.parent_id = cf.folder_id and cf.package_id = :asm_package_id 
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::revoke_permissions.assessment">
+      <querytext>
+            select ci.item_id as assessment_id from
+            cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a
+            where cr.revision_id = ci.latest_revision and a.assessment_id = cr.revision_id and
+            ci.parent_id = cf.folder_id and cf.package_id = :asm_package_id 
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::check_rev_assoc.revision_count">
+      <querytext>
+	    select count(revision_id) from cr_revisions where item_id = :item_id
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::check_rev_assoc.association_count">
+      <querytext>
+	    select count(rel_id) from acs_rels where object_id_one in (
+		select revision_id from cr_revisions where item_id = :item_id )
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::course_delete.relation">
+      <querytext>
+	    select rel_id from acs_rels where object_id_one in (
+		select revision_id from cr_revisions where item_id = :item_id )
+      </querytext>
+</fullquery>
+
+<fullquery name="dotlrn_catalog::get_categories_from_tree.get_categories">
+      <querytext>
+	   select om.category_id, om.object_id from category_object_map om where
+	   om.category_id in (select category_id from categories where tree_id =:tree_id)
+	   and om.object_id in (select live_revision from cr_items where content_type = 'dotlrn_catalog')
+      </querytext>
+</fullquery>
+
+
+</queryset>
Index: openacs-4/packages/dotlrn-catalog/www/course-info.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/course-info.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/course-info.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,6 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+<br>
+<include src="/packages/dotlrn-catalog/lib/course-chunk" course_id=@course_id@ course_key=@course_key@ name=@course_name@ info=@course_info@ asm=@asm_name@ rel=@rel@ return_url=@return_url@ edit="no" live_revision="" item_id=@item_id@ creation_user=@creation_user@ index="yes" asmid=@assessment_id@>
+
Index: openacs-4/packages/dotlrn-catalog/www/course-info.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/course-info.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/course-info.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,23 @@
+ad_page_contract {
+    Displays information of one course
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   09-02-2005
+} {
+    course_id:notnull
+    course_key:notnull
+    course_name:notnull
+}
+set page_title "$course_key [_ dotlrn-catalog.course_info]"
+set context [list "[_ dotlrn-catalog.one_course_info]"]
+
+set return_url "index"
+set asm_package_id [apm_package_id_from_key assessment]
+
+db_1row get_course_info { } 
+
+set asm_name [db_string get_asm_name { } -default "[_ dotlrn-catalog.not_associated]"]
+set item_id [dotlrn_catalog::get_item_id -revision_id $course_id]
+set creation_user [dotlrn_catalog::get_creation_user -object_id $item_id]
+set rel [dotlrn_catalog::has_relation -course_id $course_id]
+
Index: openacs-4/packages/dotlrn-catalog/www/course-info.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/course-info.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/course-info.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="get_course_info">      
+      <querytext>
+            select dc.course_info, dc.assessment_id, cr.item_id
+	    from dotlrn_catalog dc, cr_revisions cr
+ 	    where cr.revision_id = :course_id and dc.course_id = :course_id
+      </querytext>
+</fullquery>
+
+<fullquery name="get_asm_name">
+      <querytext>
+            select cr.title from
+            cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a
+            where cr.revision_id = ci.latest_revision and a.assessment_id = cr.revision_id and
+            ci.parent_id = cf.folder_id and cf.package_id = :asm_package_id and
+            ci.item_id = :assessment_id order by cr.title
+      </querytext>
+</fullquery>
+
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/index.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/index.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,8 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+<if @create_p@ eq 1>
+    <div align="right"><a href="cc-admin/course-list"><img border=0 src=images/admin.gif></a></div>
+</if>
+
+<include src="/packages/dotlrn-catalog/lib/tree-chunk" tree_id=@tree_id@>
Index: openacs-4/packages/dotlrn-catalog/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/index.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/index.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,29 @@
+ad_page_contract {
+    Index for course administration
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   31-01-2005
+
+} {
+
+}
+set page_title "[_ dotlrn-catalog.course_catalog]"
+set context ""
+set return_url "cc-admin/course-list"
+
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+
+set user_id [ad_conn user_id]
+
+if {[permission::permission_p -party_id $user_id -object_id $cc_package_id -privilege "create"]} {
+    set create_p 1
+} else {
+    set create_p 0
+}
+
+set tree_id [db_string get_tree_id { } -default "-1"]
+
+
+
+
+ 
Index: openacs-4/packages/dotlrn-catalog/www/index.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/index.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/index.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="get_tree_id">      
+      <querytext>
+      	    select tree_id from category_tree_map where object_id = :cc_package_id
+      </querytext>
+</fullquery>
+
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/admin/grant-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/admin/grant-list.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/admin/grant-list.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,5 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+<formtemplate id="search_user"></formtemplate>
+<listtemplate name=grant_list></listtemplate>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/admin/grant-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/admin/grant-list.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/admin/grant-list.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,97 @@
+ad_page_contract {
+    Displays a list of all users to grant permissions
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   28-01-2005
+} {
+    { return_url "" }
+    { user_name "" }
+    { user_email "" }
+
+}
+
+set user_id [ad_conn user_id]
+# dotlrn-catalog package_id
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+
+set page_title "[_ dotlrn-catalog.grant_list]"
+if {[string equal $return_url ""]} {
+    set return_url "grant-list"
+}
+
+set context [list [list "../cc-admin/course-list" "[_ dotlrn-catalog.course_list]"] $page_title]
+
+# To search for users
+ad_form -name search_user -form {
+    {user_name:text(text),optional
+	{label "[_ dotlrn-catalog.search_user]"}
+	{help_text "[_ dotlrn-catalog.search_help]"}
+    }
+    {user_email:text(text),optional
+	{label "[_ dotlrn-catalog.search_user_email]"}
+	{help_text "[_ dotlrn-catalog.search_email_help]"}
+    }
+}
+
+
+# Establish what query to use in order to the values of the form elements
+if {![string equal $user_name ""]} {
+    set query select_users_name
+    if {![string equal $user_email ""]} {
+	set query select_users_name_email
+    }
+} else {
+    set query select_users
+    if {![string equal $user_email ""]} {
+	    set query select_users_email
+    }
+}
+
+db_multirow -extend { privilege email } grant_list $query {} {
+    set privilege [permission::permission_p -party_id $p_user_id -object_id $cc_package_id -privilege "create"]
+    if { [catch { set email [email_image::get_user_email -user_id $p_user_id] } errmsg] } {
+	set email $db_email
+    } else {
+	set email [email_image::get_user_email -user_id $p_user_id]
+    }
+}
+
+template::list::create \
+    -name grant_list \
+    -multirow grant_list \
+    -key p_user_id \
+    -bulk_actions {"\#dotlrn-catalog.grant\#" "grant-users?" "\#dotlrn-catalog.grant_per\#"\
+		       "\#dotlrn-catalog.revoke\#" "revoke-users?" "\#dotlrn-catalog.revoke_per\#" }\
+    -bulk_action_method post \
+    -bulk_action_export_vars {
+	user_name
+	user_email
+    }\
+    -row_pretty_plural "[_ dotlrn-catalog.users_to_grant]" \
+    -elements {
+	name {
+	    label "[_ dotlrn-catalog.user_name]"
+	    display_template {
+		@grant_list.first_names@ @grant_list.last_name@
+	    }
+	}
+	email {
+	    label "[_ dotlrn-catalog.email]"
+	    display_template {
+		@grant_list.email;noquote@
+	    }
+	}
+	permission {
+	    label "[_ dotlrn-catalog.permission]"
+	    display_template {
+		<if @grant_list.privilege@ eq 1>
+		   [_ dotlrn-catalog.granted]
+		</if>
+		<else>
+		   <i>[_ dotlrn-catalog.not_allowed]</i>
+		</else>
+	    }
+	}
+    }
+
Index: openacs-4/packages/dotlrn-catalog/www/admin/grant-list.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/admin/grant-list.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/admin/grant-list.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="select_users">      
+      <querytext>
+	  select first_names, last_name, user_id as p_user_id, email as db_email
+	  from cc_users where user_id in ( 
+	      select grantee_id from acs_permissions where object_id = :cc_package_id
+		  and privilege = 'create')
+		
+      </querytext>
+</fullquery>
+
+<fullquery name="select_users_name">      
+      <querytext>
+	  select first_names, last_name, user_id as p_user_id, email as db_email
+	  from cc_users where user_id <> :user_id and lower(first_names) like lower('%$user_name%')
+	  or lower(last_name) like lower('%$user_name%') order by first_names, last_name
+      </querytext>
+</fullquery>
+
+<fullquery name="select_users_email">      
+      <querytext>
+	  select first_names, last_name, user_id as p_user_id, email as db_email
+	  from cc_users where user_id <> :user_id and lower(email) like lower('%$user_email%')
+	  order by email
+      </querytext>
+</fullquery>
+
+<fullquery name="select_users_name_email">      
+      <querytext>
+	  select first_names, last_name, user_id as p_user_id, email as db_email
+	  from cc_users where user_id <> :user_id and (
+	  lower(first_names) like lower('%$user_name%') or lower(last_name) like lower('%$user_name%'))
+	  and lower(email) like lower('%$user_email%')
+	  order by email
+      </querytext>
+</fullquery>
+
+
+</queryset>
Index: openacs-4/packages/dotlrn-catalog/www/admin/grant-users.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/admin/grant-users.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/admin/grant-users.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,33 @@
+ad_page_contract {
+    Gives users admin permissions on dotlrn_catalog
+
+    @author          Miguel Marin (miguelmarin@viaro.net)
+    @author          Viaro Networks www.viaro.net
+    @creation-date   29-01-2005
+} {
+    p_user_id:multiple
+    { user_name "" }
+    { user_email "" }
+} 
+
+# dotlrn_catalog package_id
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+
+# The tree id from categories
+set tree_list [category_tree::get_mapped_trees $cc_package_id]
+if { [string equal [lindex [lindex $tree_list 0] 1] "dotlrn-course-catalog"] } {
+    set tree_id [lindex [lindex $tree_list 0] 0]
+} else {
+    set tree_id ""
+}
+
+
+# Grants Permission for all the users in p_user_id
+foreach user $p_user_id {
+    permission::grant -party_id $user -object_id $cc_package_id  -privilege "create"
+    permission::grant -party_id $user -object_id $tree_id -privilege category_tree_read
+    permission::grant -party_id $user -object_id $tree_id -privilege category_tree_write
+}
+
+
+ad_returnredirect "grant-list?user_name=$user_name&user_email=$user_email"
Index: openacs-4/packages/dotlrn-catalog/www/admin/revoke-users.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/admin/revoke-users.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/admin/revoke-users.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,33 @@
+ad_page_contract {
+    Revokes users admin permissions on dotlrn_catalog
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation date   29-01-2005
+} {
+    p_user_id:multiple
+    { user_name "" }
+    { user_email "" }
+}
+
+# dotlrn_catalog package_id
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+
+# The tree id from categories
+set tree_list [category_tree::get_mapped_trees $cc_package_id]
+if { [string equal [lindex [lindex $tree_list 0] 1] "dotlrn-course-catalog"] } {
+    set tree_id [lindex [lindex $tree_list 0] 0]
+} else {
+    set tree_id ""
+}
+
+
+# Grants Permission for all the users in p_user_id
+foreach user $p_user_id {
+    permission::revoke -party_id $user -object_id $cc_package_id  -privilege "create"
+    permission::revoke -party_id $user -object_id $tree_id -privilege "category_tree_read"
+    permission::revoke -party_id $user -object_id $tree_id -privilege "category_tree_write"
+}
+
+
+ad_returnredirect "grant-list?user_name=$user_name&user_email=$user_email"
Index: openacs-4/packages/dotlrn-catalog/www/doc/index.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/doc/index.html,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/doc/index.html	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>Course Catalog Documentation</title>
+</head>
+
+<body>
+<img src="/doc/images/alex.jpg" width="184" height="80" alt="alex-logo">
+<hr>
+<h2>Course-Catalog:</h2>
+<hr>
+<b>"Under Construction"<b>
+<!--ul>
+<li><a href="requirements.html">Requirements</a>
+</ul-->
+<hr>
+</body>
+</html>
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/associate-course.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/associate-course.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/associate-course.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,28 @@
+ad_page_contract {
+    Associates dotlrn_catalog's course_id with dotlrn's class_instance_id or community
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation date   31-01-2005
+} {
+    course_id:notnull
+    type:notnull
+    object_id:multiple
+    { return_url ""}
+}
+
+if { [string equal $type "class"] } {
+    set type "dotlrn_catalog_class_rel"
+} else {
+    set type "dotlrn_catalog_dotcom_rel"
+}
+
+foreach object $object_id {
+    dotlrn_catalog::add_relation -course_id $course_id -object_id $object -type $type
+}
+
+if { [string equal $return_url ""] } {
+    ad_returnredirect "dotlrn-list?course_id=$course_id"
+} else {
+    ad_returnredirect "$return_url"
+}
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,5 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+
+<formtemplate id="add_course"></formtemplate>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,169 @@
+ad_page_contract {
+    Displays a form to add a course or add a new revision of a course (edit)
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   27-01-2005
+
+} {
+    course_id:optional
+    mode:optional
+    { return_url "" }
+}
+
+if { [string equal $return_url ""]} {
+    set return_url "course-list"
+}
+
+set page_title ""
+set context ""
+
+set user_id [ad_conn user_id]
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+
+# Check for create permissions over dotlrn-catalog package
+permission::require_permission -party_id $user_id -object_id $cc_package_id -privilege "create"
+
+if { [info exists mode] } {
+    # Check if users has admin permission to edit the course
+    permission::require_permission -object_id $course_id -privilege "create"
+    # To disable the element course_key
+    set mode display
+} else {
+    set mode edit
+}
+
+
+# Get assessments
+set asm_package_id [apm_package_id_from_key assessment]
+set asm_list [list [list "[_ dotlrn-catalog.not_associate]" "-1"]]
+db_foreach assessment { } {
+    if { [permission::permission_p -object_id $assessment_id -privilege "admin"] == 1 } {
+	lappend asm_list [list $title $assessment_id] 
+    }
+}
+
+# Get a list of all the attributes asociated to dotlrn_catalog
+set attribute_list [package_object_attribute_list -start_with dotlrn_catalog dotlrn_catalog]
+set elements ""
+
+
+# Creates the elements to show with ad_form
+
+foreach attribute $attribute_list {
+    set element_mode ""
+    set aditional_type ""
+    set aditional_elements ""
+    switch [lindex $attribute 4] {
+	string {
+	    if { [string equal [lindex $attribute 2] "assessment_id"]} {
+		set aditional_type "(select)"
+		set aditional_elements [list options $asm_list]
+	    } else {
+		if { [string equal [lindex $attribute 2] "course_key"]} {
+		    set element_mode [list mode edit]
+		} 
+	    }
+	}
+	text {
+	    set aditional_type "(textarea)"
+	    set aditional_elements "{html  {rows 7 cols 35}}"
+	}
+	integer {
+	    if { [string equal [lindex $attribute 2] "assessment_id"]} {
+		set aditional_type "(select)"
+		set aditional_elements [list options $asm_list]
+	    }
+	}
+    }
+    set element [list [lindex $attribute 2]:text${aditional_type} [list label [lindex $attribute 3]] $aditional_elements $element_mode]
+
+    lappend elements $element
+
+}
+
+
+# Create the form
+ad_form -name add_course -export {return_url $return_url } -form {
+    course_id:key
+}
+
+
+ad_form -extend -name add_course -form $elements
+
+ad_form -extend -name add_course -form {
+    {category_ids:integer(category),multiple,optional
+	{label "[_ dotlrn-catalog.categories]"}
+	{html {size 4}}
+	{value "-1"}
+    }
+}
+
+ad_form -extend -name add_course -validate {
+    { course_key
+	{ [dotlrn_catalog::check_name -name $course_key] }
+	"[_ dotlrn-catalog.name_already]"
+    }
+} -new_data {
+    # New item and revision in the CR
+    set folder_id [dotlrn_catalog::get_folder_id]
+    set attribute_list [package_object_attribute_list -start_with dotlrn_catalog dotlrn_catalog]
+    set form_attributes [list]
+    foreach attribute $attribute_list {
+	set attr_name [lindex $attribute 2]
+	lappend form_attributes [list $attr_name [set $attr_name]]
+    }
+
+    set item_id [content::item::new -name $course_key -parent_id $folder_id \
+		     -content_type "dotlrn_catalog" -creation_user $user_id \
+		     -attributes $form_attributes -is_live t]
+
+    # Grant admin privileges to the user over the item in the CR
+    permission::grant -party_id $user_id -object_id $item_id  -privilege "admin"
+    
+    set revision_id [db_string get_revision_id { } -default "-1"]
+    if { ![string equal $category_ids "-1"] } {
+	category::map_object -object_id $revision_id $category_ids
+    }
+} -edit_data {
+    # New revision in the CR
+    set folder_id [dotlrn_catalog::get_folder_id]
+    set item_id [dotlrn_catalog::get_item_id -revision_id $course_id]
+    set attribute_list [package_object_attribute_list -start_with dotlrn_catalog dotlrn_catalog]
+    set form_attributes [list]
+    foreach attribute $attribute_list {
+	set attr_name [lindex $attribute 2]
+	lappend form_attributes [list $attr_name [set $attr_name]]
+    }
+
+    set course_id [content::revision::new -item_id $item_id -attributes $form_attributes -content_type "dotlrn_catalog"]
+
+    # Set the new revision live  
+    dotlrn_catalog::set_live -revision_id $course_id
+    if { ![string equal $category_ids "-1"] } {
+	category::map_object -object_id $course_id $category_ids
+    }
+} -new_request {
+    set context [list [list course-list "[_ dotlrn-catalog.course_list]"] "[_ dotlrn-catalog.new_course]"]
+    set page_title "[_ dotlrn-catalog.new_course]"
+    set return_url "$return_url"
+
+} -edit_request {
+    set context [list [list course-list "[_ dotlrn-catalog.course_list]"] "[_ dotlrn-catalog.edit_course]"]
+    set page_title "[_ dotlrn-catalog.edit_course]"
+    set return_url "$return_url"
+    db_1row get_course_info { }
+    db_string get_course_assessment { } -default "[_ dotlrn-catalog.not_associated]"
+
+} -after_submit {
+    ad_returnredirect "$return_url"
+}
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-add-edit.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="assessment">
+      <querytext>
+      	    select cr.title ,ci.item_id as assessment_id from 
+            cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a 
+            where cr.revision_id = ci.latest_revision and a.assessment_id = cr.revision_id and 
+            ci.parent_id = cf.folder_id and cf.package_id = :asm_package_id order by cr.title
+      </querytext>
+</fullquery>
+
+<fullquery name="get_course_info">      
+      <querytext>
+            select * from dotlrn_catalog where course_id = :course_id
+      </querytext>
+</fullquery>
+
+<fullquery name="get_course_assessment">
+      <querytext>
+      	    select cr.title from 
+            cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a 
+            where cr.revision_id = ci.latest_revision and a.assessment_id = cr.revision_id and 
+            ci.parent_id = cf.folder_id and cf.package_id = :asm_package_id and
+	    ci.item_id = :assessment_id order by cr.title
+      </querytext>
+</fullquery>
+
+<fullquery name="get_revision_id">      
+      <querytext>
+            select revision_id from cr_revisions where item_id = :item_id
+      </querytext>
+</fullquery>
+
+
+</queryset>
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-categorize.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-categorize.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-categorize.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,7 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+
+#dotlrn-catalog.add_course_to#
+<br><br>
+<formtemplate id="course_categorize"></formtemplate>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-categorize.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-categorize.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-categorize.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,34 @@
+ad_page_contract {
+    Categorize one course
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   10-02-2005
+} {
+    course_id:notnull
+    name:notnull
+}
+
+# Check for create permissions over dotlrn-catalog
+set user_id [ad_conn user_id]
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+permission::require_permission -party_id $user_id -object_id $cc_package_id -privilege "create"
+
+set context [list "[_ dotlrn-catalog.categorize] $name"]
+set page_title "[_ dotlrn-catalog.categorize] $name"
+set return_url "course-list"
+
+
+ad_form -export { name } -name course_categorize -cancel_url "course-list" -form {
+    {course_id:text(hidden) 
+	{ value $course_id }
+    }
+    {category_ids:integer(category),multiple
+	{label "[_ dotlrn-catalog.categories]"}
+	{html {size 4}}
+	{value "-1"}
+   }
+} -on_submit {
+    category::map_object -remove_old -object_id $course_id $category_ids
+} -after_submit {
+    ad_returnredirect "course-list"
+}
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-delete.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-delete.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,27 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+<br>
+#dotlrn-catalog.this_course# <b>@rev_num@</b> 
+<if @assoc_num@ eq 1>
+    #dotlrn-catalog.version#
+</if>
+<else>
+    #dotlrn-catalog.versions#
+</else>
+
+<if @assoc_num@ eq 0>
+   #dotlrn-catalog.has_no#
+</if>
+<else>
+   <if @assoc_num@ eq 1>
+       #dotlrn-catalog.and_has_one#
+   </if>
+   <else>
+       #dotlrn-catalog.and_has# <b>@assoc_num@</b> #dotlrn-catalog.to_dotlrn#
+   </else>
+</else>
+<br>
+<b>#dotlrn-catalog.do_you_still#</b>
+<br><br>
+<formtemplate id="delete_course"></formtemplate>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-delete.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-delete.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,33 @@
+ad_page_contract {
+    Displays a delete confirmation message and deletes the course
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   09-02-2005
+} {
+    object_id:notnull
+    course_key:notnull
+    creation_user:notnull
+}
+
+set page_title "[_ dotlrn-catalog.confirm_delete] $course_key"
+set context [list [list course-list "[_ dotlrn-catalog.course_list]"] "[_ dotlrn-catalog.delete_course]"]
+
+# Check for create permissions over dotlrn-catalog
+set user_id [ad_conn user_id]
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+permission::require_permission -party_id $user_id -object_id $cc_package_id -privilege "create"
+
+
+set rev_assoc [dotlrn_catalog::check_rev_assoc -item_id $object_id]
+set rev_num [lindex $rev_assoc 0]
+set assoc_num [lindex $rev_assoc 1]
+
+ad_form -name delete_course -export {course_key $course_key creation_user $creation_user } -cancel_url "course-list" -form {
+    {object_id:text(hidden) 
+	{ value $object_id }
+    }
+} -on_submit {
+    dotlrn_catalog::course_delete -item_id $object_id
+} -after_submit {
+    ad_returnredirect "course-list"
+}
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,14 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+ <a href="course-add-edit?return_url=@return_url@">#dotlrn-catalog.new_course#</a>
+<if @tree_id@ not eq ""> 
+| <a href="/categories/cadmin/tree-view?tree_id=@tree_id@">#dotlrn-catalog.admin_categories#</a>
+</if>
+<if @admin_p@ eq 1>
+| <a href="../admin/grant-list?return_url=@return_url@">#dotlrn-catalog.grant_per#</a>
+</if>
+<br><br>
+<multiple name="course_list">
+    <include src="/packages/dotlrn-catalog/lib/course-chunk" course_id=@course_list.course_id@ course_key=@course_list.course_key@ name=@course_list.course_name@ info=@course_list.course_info@ asm=@course_list.asm_name@ rel=@course_list.rel@ return_url=@return_url@ edit=yes live_revision="" item_id=@course_list.item_id@ creation_user=@course_list.creation_user@>
+</multiple>
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,49 @@
+ad_page_contract {
+    Displays a list of all courses
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation-date   28-01-2005
+} {
+
+}
+
+set user_id [ad_conn user_id]
+set context [list "[_ dotlrn-catalog.course_list]"]
+set page_title "[_ dotlrn-catalog.course_list]"
+set return_url "course-list"
+
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+
+permission::require_permission -party_id $user_id -object_id $cc_package_id -privilege "create"
+
+if {[permission::permission_p -party_id $user_id -object_id $cc_package_id -privilege "admin"]} {
+    set admin_p 1
+} else {
+    set admin_p 0
+}
+
+# The tree id from categories
+set tree_list [category_tree::get_mapped_trees $cc_package_id]
+if { [string equal [lindex [lindex $tree_list 0] 1] "dotlrn-course-catalog"] } {
+    set tree_id [lindex [lindex $tree_list 0] 0]
+} else {
+    set tree_id ""
+}
+
+
+set asm_package_id [apm_package_id_from_key assessment]
+
+if { [acs_user::site_wide_admin_p] } {
+    set query get_course_info_site_wide
+} else {
+    set query get_course_info
+}
+
+
+db_multirow -extend { asm_name rel item_id creation_user } course_list $query {} {
+    set asm_name [db_string get_asm_name { } -default "[_ dotlrn-catalog.not_associated]"]
+    set item_id [dotlrn_catalog::get_item_id -revision_id $course_id]
+    set creation_user [dotlrn_catalog::get_creation_user -object_id $item_id]
+    set rel [dotlrn_catalog::has_relation -course_id $course_id]
+}
+
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/course-list.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="get_course_info">      
+      <querytext>
+            select cc.course_id, cc.course_key, cc.course_name, cc.course_info, cc.assessment_id, ci.item_id
+	    from dotlrn_catalog cc, cr_items ci
+ 	    where cc.course_id = ci.live_revision and  
+	    ci.item_id in (
+		select object_id from acs_permissions where grantee_id = :user_id and
+		privilege = 'admin')
+         	
+      </querytext>
+</fullquery>
+
+<fullquery name="get_course_info_site_wide">      
+      <querytext>
+            select cc.course_id, cc.course_key, cc.course_name, cc.course_info, cc.assessment_id, ci.item_id
+	    from dotlrn_catalog cc, cr_items ci
+ 	    where cc.course_id = ci.live_revision
+      </querytext>
+</fullquery>
+
+<fullquery name="get_asm_name">
+      <querytext>
+            select cr.title from
+            cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a
+            where cr.revision_id = ci.latest_revision and a.assessment_id = cr.revision_id and
+            ci.parent_id = cf.folder_id and cf.package_id = :asm_package_id and
+            ci.item_id = :assessment_id order by cr.title
+      </querytext>
+</fullquery>
+
+
+</queryset>
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,20 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+
+<if @course_key@ not nil>
+	<h2>#dotlrn-catalog.associate# @course_key@ (@course_name@) #dotlrn-catalog.to# #dotlrn-catalog.class#:</h2> 
+</if>
+<else>
+        <h2>#dotlrn-catalog.associate# #dotlrn-catalog.to# #dotlrn-catalog.class#:</h2> 
+</else>
+
+<listtemplate name="dotlrn_classes"></listtemplate>
+
+<if @course_key@ not nil>
+	<h2>#dotlrn-catalog.associate# @course_key@ (@course_name@) #dotlrn-catalog.to# #dotlrn-catalog.community#:</h2> 
+</if>
+<else>
+        <h2>#dotlrn-catalog.associate# #dotlrn-catalog.to# #dotlrn-catalog.community#:</h2> 
+</else>
+<listtemplate name="dotlrn_communities"></listtemplate>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,144 @@
+ad_page_contract {
+    Displays a list of all dotlrn classes to associate to a dotlrn_catalog(course_id)
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation date   31-01-2005
+} {
+    course_id:notnull
+    { course_key ""}
+    { return_url "" }
+    { course_name ""}
+}
+
+set page_title "[_ dotlrn-catalog.dotlrn_list]"
+if {[string equal $return_url ""]} {
+    set return_url "dotlrn-catalog-list"
+}
+set user_id [ad_conn user_id]
+
+# Check if users has admin permission to edit dotlrn_catalog
+permission::require_permission -party_id $user_id -object_id $course_id -privilege "admin"
+
+set context [list [list course-list  "[_ dotlrn-catalog.course_list]"] "[_ dotlrn-catalog.dotlrn_list]"]
+
+set asm_package_id [apm_package_id_from_key assessment]
+
+db_multirow -extend { rel type } classes_list get_dotlrn_classes {} {
+    set rel [dotlrn_catalog::relation_between -object_one $course_id -object_two $object_id]
+    set type "class"
+}
+
+template::list::create \
+    -name dotlrn_classes \
+    -multirow classes_list \
+    -key object_id \
+    -has_checkboxes\
+    -bulk_actions {"\#dotlrn-catalog.associate\#" "associate-course" "\#dotlrn-catalog.associate_to_class\#" }\
+    -bulk_action_method post \
+    -bulk_action_export_vars {
+	course_id
+	type
+    }\
+    -row_pretty_plural "[_ dotlrn-catalog.dotlrn_classes]" \
+    -elements {
+	check_box {
+	    class "list-narrow"
+	    label "<input type=\"checkbox\" name=\"_dummy\" onclick=\"acs_ListCheckAll('dotlrn_classes', this.checked)\" \
+                   title=\"\#dotlrn-catalog.label_title\#\">"
+	    display_template {
+		<if @classes_list.rel@ eq 0>
+		    <input type="checkbox" name="object_id" value="@classes_list.object_id@" \
+		    id="dotlrn_classes,@classes_list.object_id@" \
+		    title="\#dotlrn-catalog.title\#">
+		</if>
+		<else>
+		    <input type="checkbox" checked disabled>
+		</else>
+	    }
+	}
+	class  {
+	    label "[_ dotlrn-catalog.class_name]"
+	    display_template {
+		<a href="@classes_list.url@">@classes_list.pretty_name@</a> 
+	    }
+	}
+	dep_name {
+	    label "[_ dotlrn-catalog.dep_name]"
+	    display_template {
+		@classes_list.department_name@
+	    }
+	}
+	term_name  {
+	    label "[_ dotlrn-catalog.term_name]"
+	    display_template {
+		    @classes_list.term_name@
+	    }
+	}
+	subject  {
+	    label "[_ dotlrn-catalog.subject_name]"
+	    display_template {
+		    @classes_list.class_name@
+	    }
+	}
+	associate {
+	    display_template {
+		<if @classes_list.rel@ eq 0>
+		<a href="associate-course?course_id=$course_id&object_id=@classes_list.object_id@&return_url=$return_url&type=@classes_list.type@" title="\#dotlrn-catalog.associate_to_class\#\">#dotlrn-catalog.associate#</a>
+		</if>
+		<else>
+		#dotlrn-catalog.associated#
+                </else>
+	    }
+	}
+    }
+
+db_multirow -extend { rel type } com_list get_dotlrn_communities { } {
+    set rel [dotlrn_catalog::relation_between -object_one $course_id -object_two $object_id]
+    set type "community"
+}
+
+template::list::create \
+    -name dotlrn_communities \
+    -multirow com_list \
+    -key object_id \
+    -has_checkboxes \
+    -bulk_actions {"\#dotlrn-catalog.associate\#" "associate-course" "\#dotlrn-catalog.associate_to_com\#" }\
+    -bulk_action_method post \
+    -bulk_action_export_vars {
+	course_id
+	type
+    }\
+    -row_pretty_plural "[_ dotlrn-catalog.dotlrn_com]" \
+    -elements {
+	check_box {
+	    class "list-narrow"
+	    label "<input type=\"checkbox\" name=\"_dummy\" onclick=\"acs_ListCheckAll('dotlrn_communities', this.checked)\"                  title=\"\#dotlrn-catalog.lable_title\#\">"
+	    display_template {
+		<if @com_list.rel@ eq 0>
+		    <input type="checkbox" name="object_id" value="@com_list.object_id@" \
+		    id="dotlrn_communities,@com_list.object_id@" \
+		    title="\#dotlrn-catalog.title\#">
+		</if>
+		<else>
+		    <input type="checkbox" checked disabled>
+		</else>
+	    }
+	}
+	community  {
+	    label "[_ dotlrn-catalog.com_name]"
+	    display_template {
+		<a href="@com_list.url@">@com_list.pretty_name@</a>
+	    }
+	}
+	associate {
+	    display_template {
+		<if @com_list.rel@ eq 0>
+	  	   <a href="associate-course?course_id=$course_id&object_id=@com_list.object_id@&return_url=$return_url&type=@com_list.type@" title="\#dotlrn-catalog.associate_to_class\#\">#dotlrn-catalog.associate#</a>
+		</if>
+		<else>
+		#dotlrn-catalog.associated#
+                </else>
+	    }
+	}
+    }
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/dotlrn-list.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<queryset>
+
+    <fullquery name="get_dotlrn_classes">
+        <querytext>
+            select class_instance_id as object_id, department_name, term_name, class_name, pretty_name, url
+	    from dotlrn_class_instances_full 
+	    order by department_name, term_name, class_name, pretty_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="get_dotlrn_communities">
+        <querytext>
+	    select community_id as object_id, pretty_name, url from dotlrn_clubs_full order by pretty_name
+        </querytext>
+    </fullquery>
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/go-live.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/go-live.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/go-live.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,13 @@
+ad_page_contract {
+    Makes one revision live
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation date   29-01-2005
+} {
+    revision_id:notnull
+}
+
+dotlrn_catalog::set_live -revision_id $revision_id
+
+ad_returnredirect "/dotlrn-catalog/cc-admin/course-list"
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-permission.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-permission.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-permission.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,21 @@
+ad_page_contract {
+    Gives users the same permissions that creation_users has over course_id and assessment_id
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation date   03-02-2005
+} {
+    p_user_id:multiple
+    { user_name "" }
+    { user_email "" }
+    object_id:notnull
+    creation_user:notnull
+    course_key:notnull
+} 
+
+# Grants Permission for all the users in p_user_id
+foreach user $p_user_id {
+    dotlrn_catalog::grant_permissions -party_id $user -object_id $object_id -creation_user $creation_user
+}
+
+ad_returnredirect "grant-user-list?user_name=$user_name&user_email=$user_email&object_id=$object_id&creation_user=$creation_user&course_key=$course_key"
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,5 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+<formtemplate id="search_user"></formtemplate>
+<listtemplate name=grant_list></listtemplate>
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,111 @@
+ad_page_contract {
+    Displays a list of all users that have create privile under dotlrn_catalog
+    to give them admin privileges over course_id and assessment_id
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation date   03-01-2005
+} {
+    { return_url "" }
+    { user_name "" }
+    { user_email "" }
+    course_key:notnull
+    object_id:notnull
+    creation_user:notnull
+}
+
+# Check for create permissions over dotlrn-catalog
+set user_id [ad_conn user_id]
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+permission::require_permission -party_id $user_id -object_id $cc_package_id -privilege "create"
+
+set page_title "[_ dotlrn-catalog.search_users_to] $course_key"
+set context [list [list course-list "[_ dotlrn-catalog.course_list]"] "[_ dotlrn-catalog.search_u]"]
+if {[string equal $return_url ""]} {
+    set return_url "grant-user-list"
+}
+
+# To search for users
+ad_form -name search_user -form {
+    {object_id:text(hidden)
+	{value "$object_id"}
+    }
+    {creation_user:text(hidden)
+	{value "$creation_user"}
+    }
+    {course_key:text(hidden)
+	{value "$course_key"}
+    }
+    {user_name:text(text),optional
+	{label "[_ dotlrn-catalog.search_user]"}
+	{help_text "[_ dotlrn-catalog.search_help]"}
+    }
+    {user_email:text(text),optional
+	{label "[_ dotlrn-catalog.search_user_email]"}
+	{help_text "[_ dotlrn-catalog.search_email_help]"}
+    }
+}
+
+# Establish what query to use in order to the values of the form elements
+if {![string equal $user_name ""]} {
+    set query select_users_name
+    if {![string equal $user_email ""]} {
+	set query select_users_name_email
+    }
+} else {
+    set query select_users
+    if {![string equal $user_email ""]} {
+	    set query select_users_email
+    }
+}
+
+db_multirow -extend { privilege email } grant_list $query {} {
+    set privilege [permission::permission_p -party_id $p_user_id -object_id $object_id -privilege "admin"]
+    if { [catch { set email [email_image::get_user_email -user_id $p_user_id] } errmsg] } {
+	set email $db_email
+    } else {
+	set email [email_image::get_user_email -user_id $p_user_id]
+    }
+}
+
+template::list::create \
+    -name grant_list \
+    -multirow grant_list \
+    -key p_user_id \
+    -bulk_actions {"\#dotlrn-catalog.grant\#" "grant-permission" "\#dotlrn-catalog.grant_per\#"\
+		       "\#dotlrn-catalog.revoke\#" "revoke-permission" "\#dotlrn-catalog.revoke_per\#" }\
+    -bulk_action_method post \
+    -bulk_action_export_vars {
+	user_name
+	user_email
+	object_id
+	creation_user
+	course_key
+    }\
+    -row_pretty_plural "[_ dotlrn-catalog.users_to_grant]" \
+    -elements {
+	name {
+	    label "[_ dotlrn-catalog.user_name]"
+	    display_template {
+		@grant_list.first_names@ @grant_list.last_name@
+	    }
+	}
+	email {
+	    label "[_ dotlrn-catalog.email]"
+	    display_template {
+		@grant_list.email;noquote@
+	    }
+	}
+	permission {
+	    label "[_ dotlrn-catalog.permission]"
+	    display_template {
+		<if @grant_list.privilege@ eq 1>
+		[_ dotlrn-catalog.granted]
+		</if>
+		<else>
+		<i>[_ dotlrn-catalog.not_allowed]</i>
+		</else>
+	    }
+	}
+    }
+
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/grant-user-list.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="select_users">      
+      <querytext>
+	  select first_names, last_name, user_id as p_user_id, email as db_email
+	  from cc_users where user_id in ( 
+	      select grantee_id from acs_permissions where object_id = :object_id
+		  and privilege = 'admin') and user_id <> :user_id
+      </querytext>
+</fullquery>
+
+<fullquery name="select_users_name">      
+      <querytext>
+	  select first_names, last_name, user_id as p_user_id, email as db_email
+	  from cc_users where user_id <> :user_id
+	  and (lower(first_names) like '%$user_name%'
+   	  or lower(last_name) like '%$user_name%') order by first_names, last_name
+      </querytext>
+</fullquery>
+
+<fullquery name="select_users_email">      
+      <querytext>
+	  select first_names, last_name, user_id as p_user_id, email as db_email
+	  from cc_users where user_id <> :user_id 
+	  and lower(email) like '%$user_email%' order by email
+      </querytext>
+</fullquery>
+
+<fullquery name="select_users_name_email">      
+      <querytext>
+	  select first_names, last_name, user_id as p_user_id, email as db_email
+	  from cc_users where user_id <> :user_id 
+	  lower(first_names) like '%$user_name%' or lower(last_name) like '%$user_name%')
+	  and lower(email) like '%$user_email%' order by email
+      </querytext>
+</fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,9 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+
+
+<multiple name="course_list">
+    <include src="/packages/dotlrn-catalog/lib/course-chunk" course_id=@course_list.course_id@ course_key=@course_list.course_key@ name=@course_list.course_name@ info=@course_list.course_info@ asm=@course_list.asm_name@ rel=@course_list.rel@ return_url=@return_url@ edit=no live_revision=@course_list.live_revision@>
+</multiple>
+
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,40 @@
+ad_page_contract {
+    Displays a list of all revisions for one course
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation date   28-01-2005
+} {
+    { return_url "" }
+    course_key:notnull
+    course_id:notnull
+}
+
+set page_title "[_ dotlrn-catalog.rev_list]"
+set context [list [list "course-list" "[_ dotlrn-catalog.course_list]" ] $page_title]
+if {[string equal $return_url ""]} {
+    set return_url "course-list"
+}
+
+set user_id [ad_conn user_id]
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+
+# Check for create permissions over dotlrn-catalog
+permission::require_permission -party_id $user_id -object_id $cc_package_id -privilege "create"
+
+
+
+# Check if users has admin permission to edit the course
+set item_id [dotlrn_catalog::get_item_id -revision_id $course_id]
+permission::require_permission -party_id $user_id -object_id $course_id -privilege "admin"
+
+
+set context [list [list "course-list"  "[_ dotlrn-catalog.course_list]"] "[_ dotlrn-catalog.rev_list]"]
+
+set asm_package_id [apm_package_id_from_key assessment]
+
+db_multirow -extend { asm_name rel } course_list get_course_info { } {
+    set asm_name [db_string get_asm_name { } -default "[_ dotlrn-catalog.not_associated]"]
+    set rel [dotlrn_catalog::has_relation -course_id $course_id]
+}
+
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/revision-list.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<queryset>
+
+<fullquery name="get_course_info">      
+      <querytext>
+	    select dc.course_id, dc.course_key, dc.course_name, dc.course_info, dc.assessment_id, ci.live_revision
+	    from dotlrn_catalog dc, cr_items ci
+	    where ci.item_id = :item_id and 
+	    dc.course_id in (select revision_id from cr_revisions where item_id = :item_id )
+      </querytext>
+</fullquery>
+
+<fullquery name="get_asm_name">
+      <querytext>
+            select cr.title from
+            cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a
+            where cr.revision_id = ci.latest_revision and a.assessment_id = cr.revision_id and
+            ci.parent_id = cf.folder_id and cf.package_id = :asm_package_id and
+            ci.item_id = :assessment_id order by cr.title
+      </querytext>
+</fullquery>
+
+    <fullquery name="get_class_info">
+        <querytext>
+            select pretty_name, url
+	    from dotlrn_class_instances_full 
+	    where class_instance_id = :class_id
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/revoke-permission.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/revoke-permission.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/revoke-permission.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,23 @@
+ad_page_contract {
+    Revokes users the same permissions that creation_users has over course_id and assessment_id
+
+    @author          Miguel Marin (miguelmarin@viaro.net) 
+    @author          Viaro Networks www.viaro.net
+    @creation date   03-01-2005
+} {
+    p_user_id:multiple
+    { user_name "" }
+    { user_email "" }
+    object_id:notnull
+    creation_user:notnull
+    course_key:notnull
+}
+
+
+# Revokes Permission for all the users in p_user_id
+foreach user $p_user_id {
+    dotlrn_catalog::revoke_permissions -party_id $user -object_id $object_id -creation_user $creation_user
+}
+
+
+ad_returnredirect "grant-user-list?user_name=$user_name&user_email=$user_email&object_id=$object_id&creation_user=$creation_user&course_key=$course_key"
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/watch-association.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/Attic/watch-association.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/watch-association.adp	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,16 @@
+<master>
+<property name=title>@page_title@</property>
+<property name="context">@context;noquote@</property>
+
+
+<h2>@course_key;noquote@ (@course_name@) #dotlrn-catalog.is_assoc#</h2>
+
+<multiple name="relations">
+    <if @relations.type@ eq "dotlrn_catalog_class_rel">
+    	<include src="/packages/dotlrn-catalog/lib/dotlrn-chunk" class_id=@relations.object_id@>
+    </if>
+    <else>
+    	<include src="/packages/dotlrn-catalog/lib/community-chunk" community_id=@relations.object_id@>
+    </else>
+</multiple>
+
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/watch-association.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/Attic/watch-association.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/watch-association.tcl	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,29 @@
+ad_page_contract {
+    Shows all associations that course_id has
+    @author          Miguel Marin (miguelmarin@viaro.net)
+    @author          Viaro Networks www.viaro.net
+    @creation date   28-01-2005
+} {
+    { return_url "" }
+    course_id:notnull
+    course_key:notnull
+    { course_name "" }
+}
+
+if { [string equal $return_url "index"] } {
+    set context [list [list ../course-info?course_id=$course_id&course_key=$course_key&course_name=$course_name  "[_ dotlrn-catalog.one_course_info]"] "[_ dotlrn-catalog.watch_assoc]"]
+} else {
+    set context [list [list course-list  "[_ dotlrn-catalog.course_list]"] "[_ dotlrn-catalog.watch_assoc]"]
+}
+
+set page_title "[_ dotlrn-catalog.watch_assoc]"
+set user_id [ad_conn user_id]
+
+# Allows that an unregiser user watch this page
+if { ![string equal $user_id "0"] } {
+    # Check if users has admin permission to edit dotlrn_catalog
+    permission::require_permission -party_id $user_id -object_id $course_id -privilege "admin"
+}
+
+db_multirow relations relation { }
+
Index: openacs-4/packages/dotlrn-catalog/www/dt-admin/watch-association.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/dt-admin/Attic/watch-association.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-catalog/www/dt-admin/watch-association.xql	14 Feb 2005 22:46:11 -0000	1.1
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<queryset>
+
+    <fullquery name="get_class_info">
+        <querytext>
+            select department_name, term_name, class_name, pretty_name, description, url
+	    from dotlrn_class_instances_full 
+	    where class_instance_id = :class_id
+        </querytext>
+    </fullquery>
+
+    <fullquery name="relation">
+        <querytext>
+            select object_id_two as object_id, rel_type as type from acs_rels
+	    where object_id_one = :course_id order by type
+        </querytext>
+    </fullquery>
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-catalog/www/images/admin.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/images/admin.gif,v
diff -u
Binary files differ
Index: openacs-4/packages/dotlrn-catalog/www/images/golive.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/images/golive.gif,v
diff -u
Binary files differ
Index: openacs-4/packages/dotlrn-catalog/www/images/live.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/www/images/live.gif,v
diff -u
Binary files differ