Index: openacs-4/packages/dotlrn-admin/dotlrn-admin.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/dotlrn-admin.info,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/dotlrn-admin.info	20 Aug 2004 14:44:20 -0000	1.1
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!-- Generated by the OpenACS Package Manager -->
+
+<package key="dotlrn-admin" url="http://openacs.org/repository/apm/packages/dotlrn-admin" type="apm_application">
+    <package-name>dotLRN Admin</package-name>
+    <pretty-plural>dotlrn Admins</pretty-plural>
+    <initial-install-p>f</initial-install-p>
+    <singleton-p>t</singleton-p>
+
+    <version name="0.1d" url="http://openacs.org/repository/download/apm/dotlrn-admin-0.1d.apm">
+        <owner url="mailto:aegrumet@mit.edu">Andrew Grumet</owner>
+        <summary>.LRN-wide admin pages.  Initially created as a singleton with automount at /dotlrn/dotlrn-admin.  These can be changed if and when .LRN supports multiple instances.</summary>
+        <description format="text/plain">Contains pages and scripts for configuring .LRN --- managing users, departments, terms, classes and so on.</description>
+
+        <requires url="dotlrn" version="2.1.0a"/>
+
+        <callbacks>
+        </callbacks>
+        <parameters>
+        <!-- No version parameters -->
+        </parameters>
+
+    </version>
+</package>
Index: openacs-4/packages/dotlrn-admin/tcl/dotlrn-admin-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/tcl/dotlrn-admin-procs.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/tcl/dotlrn-admin-procs.tcl	20 Aug 2004 14:44:21 -0000	1.1
@@ -0,0 +1,5 @@
+namespace eval dotlrn_admin {
+    ad_proc -public mount_point {} {} {
+	return dotlrn-admin
+    }
+}
\ No newline at end of file
Index: openacs-4/packages/dotlrn-admin/www/index.vuh
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/index.vuh,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/index.vuh	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,8 @@
+# This is a temporary navigational workaround.  The admin pages used
+# to live directly in the dotlrn package and a lot of existing
+# navigation still assumes that.
+set return_url [dotlrn::get_url]/[ad_conn path_info]
+if { [string length [ad_conn query]] > 0 } {
+    append return_url ?[ad_conn query]
+}
+ad_returnredirect $return_url
Index: openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,38 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.dotLRN_Admin#</property>
+<property name="context_bar">@context_bar@</property>
+
+<p>#dotlrn.lt_The_results_of_your_s#</p>
+<ul>
+  <multiple name="users">
+    <li>
+      <a href="add-instructor-3?user_id=@users.user_id@&community_id=@community_id@&referer=@referer@">@users.last_name@, @users.first_names@ (@users.email@)
+    </li>
+  </multiple>
+</ul>
+
+
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,38 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/add-instructor-2.tcl
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date Jan 10, 2002
+    @version $Id: add-instructor-2.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    community_id:integer,notnull
+    {search_text ""}
+    {referer ""}
+} -properties {
+    users:multirow
+}
+
+set context_bar [list [_ dotlrn.Add_a_Professor]]
+
+# LARS 2003-10-21: We should probably limit this in some way, so you can't get 30000 hits.
+
+db_multirow users select_users {}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/add-instructor-2.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_users">
+        <querytext>
+            select user_id,
+                   first_names,
+                   last_name,
+                   email
+            from   registered_users
+            where  lower(last_name) like lower('%' || :search_text || '%')
+                   or lower(email) like lower('%' || :search_text || '%')
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/add-instructor-3.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/add-instructor-3.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/add-instructor-3.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,41 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/add-instructor-3.tcl
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date Jan 10, 2002
+    @version $Id: add-instructor-3.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    user_id:integer,notnull
+    community_id:integer,notnull
+    {referer ""}
+}
+
+set is_dotlrn_user [db_string is_dotlrn_user {}]
+
+# if the user isn't already a dotLRN user make him so
+if {!${is_dotlrn_user}} {
+    dotlrn::user_add -user_id $user_id -type professor -can_browse
+    dotlrn_privacy::set_user_is_non_guest -user_id $user_id -value t
+}
+
+# Add the relation
+dotlrn_community::add_user -rel_type dotlrn_instructor_rel $community_id $user_id
+
+ad_returnredirect $referer
+
Index: openacs-4/packages/dotlrn-admin/www/admin/add-instructor-3.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/add-instructor-3.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/add-instructor-3.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="is_dotlrn_user">
+        <querytext>
+            select count(*)
+            from dual
+            where exists (select 1
+                          from dotlrn_users
+                          where user_id = :user_id)
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/add-instructor.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/add-instructor.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/add-instructor.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,35 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.dotLRN_Admin#</property>
+<property name="context_bar">@context_bar@</property>
+
+<h3>#dotlrn.Add_a_Professor#</h3>
+
+<form method="get" action="add-instructor-2">
+  <input type="hidden" name="referer" value="@referer@"></input>
+  <input type="hidden" name="community_id" value="@community_id@"></input>
+  #dotlrn.Add_a_Professor_2# <input type="text" name="search_text"><input type="submit" value="#dotlrn.search#"></input>
+</form>
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/add-instructor.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/add-instructor.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/add-instructor.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,31 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/add-instructor.tcl
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date Jan 10, 2002
+    @version $Id: add-instructor.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    community_id:integer,notnull
+    {referer "./"}
+}
+
+set context_bar [list [_ dotlrn.Add_a_Professor]]
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/admin-add-2.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/admin-add-2.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/admin-add-2.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,24 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master>
+<property name="title">#dotlrn.Add_A_Member#</property>
+<property name="context">#dotlrn.Add_A_Member#</property>
+
Index: openacs-4/packages/dotlrn-admin/www/admin/admin-add-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/admin-add-2.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/admin-add-2.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,55 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Search for a new user for dotLRN
+
+    @author Ben Adida (ben@openforce.net)
+    @author yon (yon@openforce.net)
+    @author Hector Amado (hr_amado@galileo.edu)
+    @creation-date 2004-07-02
+    @cvs-id $Id: admin-add-2.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    user_id
+    {referer "dotlrn-admins"}
+} -properties {
+
+}
+
+
+# Get user information
+db_1row select_user_info {
+    select first_names,
+           last_name,
+           email
+    from dotlrn_users
+    where user_id = :user_id
+}
+
+# See if the user is already in the dotlrn-admin 
+set member_p [group::member_p -group_name "dotlrn-admin" -user_id $user_id ]
+
+set group_id [db_string group_id_from_name "
+            select group_id from groups where group_name='dotlrn-admin'" -default ""]
+
+if {!$member_p} {
+    if {![empty_string_p $group_id] } {
+        group::add_member -group_id $group_id -user_id $user_id
+    }
+}
+            
+template::forward dotlrn-admins
+
Index: openacs-4/packages/dotlrn-admin/www/admin/admin-add-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/admin-add-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/admin-add-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_users">
+        <querytext>
+            select user_id,
+                   first_names,
+                   last_name,
+                   email
+            from dotlrn_users
+            where lower(last_name) like lower('%' || :search_text || '%')
+            or lower(email) like lower('%' || :search_text || '%')
+            and user_id not in (select user_id
+                                from dotlrn_member_rels_full
+                                where community_id = :community_id)
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/admin-add-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/admin-add-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/admin-add-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_users">
+        <querytext>
+            select user_id,
+                   first_names,
+                   last_name,
+                   email
+            from dotlrn_users
+            where lower(last_name) like lower('%' || :search_text || '%')
+            or lower(first_names) like lower('%' || :search_text || '%')
+            or lower(email) like lower('%' || :search_text || '%')
+            and user_id not in (select user_id
+                                from dotlrn_member_rels_full
+                                where community_id = :community_id)
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/admin-add.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/admin-add.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/admin-add.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,41 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master>
+<property name="title">#dotlrn.Add_A_Member#</property>
+<property name="context_bar">@context_bar@</property>
+
+<if @users:rowcount@ eq 0>
+     #dotlrn.there_are_no_users_matching#
+  </tr>
+</if>
+<else>
+#dotlrn.lt_The_results_of_your_s#
+</else>
+
+<ul>
+<multiple name="users">
+  <li><a href="admin-add-2?user_id=@users.user_id@&referer=@referer@">@users.last_name@, @users.first_names@ (@users.email@)</a> 
+ 
+  </li>
+</multiple>
+</ul>
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/admin-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/admin-add.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/admin-add.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,39 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Search for a new user for dotLRN
+
+    @author Ben Adida (ben@openforce.net)
+    @author yon (yon@openforce.net)
+    @author Hector Amado (hr_amado@galileo.edu)
+    @creation-date 2004-07-02
+    @cvs-id $Id: admin-add.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    search_text
+    {referer "dotlrn-admins"}
+}
+
+set search_text [string trim $search_text]
+set community_id [dotlrn_community::get_community_id]
+
+# Just search
+db_multirow users select_users {}
+
+set context_bar [list [list "dotlrn-admins" [_ dotlrn.Admin]] [_ dotlrn.New_User]]
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/admin-remove.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/admin-remove.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/admin-remove.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,34 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+ad_maybe_redirect_for_registration
+ad_page_contract {
+    Remove dotLRN Administrators 
+
+    @author Hector Amado (hr_amado@galileo.edu)
+    @creation-date 2004-07-02
+    @cvs-id $Id: admin-remove.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} {
+    user_id
+}
+
+set group_id [db_string group_id_from_name "
+            select group_id from groups where group_name='dotlrn-admin'" -default ""]
+        if {![empty_string_p $group_id] } {
+           group::remove_member -group_id $group_id -user_id $user_id
+        }
+
+template::forward dotlrn-admins
+
Index: openacs-4/packages/dotlrn-admin/www/admin/archived-communities-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/archived-communities-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/archived-communities-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <!-- AEG: This query has gotten pretty nasty.  Basically we need
+         to provide the site-wide admin more information about
+         communities than just the name.  Time information is key,
+         so we try to associate classes with a term.  If the
+         community is not a class, we look to see if the parent
+         is a class.  We don't do the full recursion for
+         sub-subgroups etc.  We could push that into some expensive
+         plsql if the current version turns out to be too hackish.
+         Or maybe creation date is all we need, and we can throw
+         the rest out?
+    -->
+    <fullquery name="select_archived_comms">
+        <querytext>
+            select child.community_id,
+                   child.pretty_name, 
+                   child.description,
+                   dotlrn_community.url(child.community_id) as url,
+                   parent.community_id as parent_community_id,
+                   parent.pretty_name as parent_pretty_name,
+                   case when parent.community_id is null then null
+                     else dotlrn_community.url(parent.community_id) end
+                     as parent_url,
+                   class.term_name,
+                   class.term_year,
+                   parent_class.term_name as parent_term_name,
+                   parent_class.term_year as parent_term_year,
+                   to_char(o.creation_date, 'Mon YYYY') as creation_date,
+                   to_char(o.last_modified, 'Mon YYYY') as last_modified
+            from dotlrn_communities_all child,
+                 dotlrn_communities_all parent,
+                 (select i.class_instance_id,
+                         t.term_name,
+                         t.term_year
+                  from dotlrn_class_instances i,
+                       dotlrn_terms t
+                  where t.term_id = i.term_id) class,
+                 (select i.class_instance_id,
+                         t.term_name,
+                         t.term_year
+                  from dotlrn_class_instances i,
+                       dotlrn_terms t
+                  where t.term_id = i.term_id) parent_class,
+                  acs_objects o
+            where child.archived_p = 't'
+              and child.parent_community_id = parent.community_id(+)
+              and child.community_id = class.class_instance_id(+)
+              and child.parent_community_id = parent_class.class_instance_id(+)
+              and o.object_id = child.community_id
+            order by child.pretty_name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/archived-communities-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/archived-communities-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/archived-communities-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>postgres</type><version>7.2</version></rdbms>
+
+    <!-- AEG: This query has gotten pretty nasty.  Basically we need
+         to provide the site-wide admin more information about
+         communities than just the name.  Time information is key,
+         so we try to associate classes with a term.  If the
+         community is not a class, we look to see if the parent
+         is a class.  We don't do the full recursion for
+         sub-subgroups etc.  We could push that into some expensive
+         plsql if the current version turns out to be too hackish.
+         Or maybe creation date is all we need, and we can throw
+         the rest out?
+    -->
+    <fullquery name="select_archived_comms">
+        <querytext>
+            select child.community_id,
+            	   child.pretty_name, 
+                   child.description,
+                   dotlrn_community__url(child.community_id) as url,
+                   parent.community_id as parent_community_id,
+                   parent.pretty_name as parent_pretty_name,
+                   case when parent.community_id is null then null
+                     else dotlrn_community__url(parent.community_id) end
+                     as parent_url,
+                   class.term_name,
+                   class.term_year,
+                   parent_class.term_name as parent_term_name,
+                   parent_class.term_year as parent_term_year,
+                   to_char(o.creation_date, 'Mon YYYY') as creation_date,
+                   to_char(o.last_modified, 'Mon YYYY') as last_modified
+            from dotlrn_communities_all child left outer join
+                 dotlrn_communities_all parent using (community_id),
+                 dotlrn_communities_all child left outer join
+                 (select i.class_instance_id,
+                         t.term_name,
+                         t.term_year
+                  from dotlrn_class_instances i,
+                       dotlrn_terms t
+                  where t.term_id = i.term_id) class using (class_instance_id),
+                 dotlrn_communities_all child left outer join
+                 (select i.class_instance_id,
+                         t.term_name,
+                         t.term_year
+                  from dotlrn_class_instances i,
+                       dotlrn_terms t
+                  where t.term_id = i.term_id) parent_class using (class_instance_id),
+                  acs_objects o
+            where child.archived_p = 't'
+              and o.object_id = child.community_id
+            order by child.pretty_name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/archived-communities.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/archived-communities.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/archived-communities.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,61 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+
+<if @archived_comms:rowcount@ gt 0>
+<p><small><font color="red">#dotlrn.Note_the_term_column#</font></small></p>
+<table width="100%">
+  <tr>
+    <th align="left" width="25%">#dotlrn.Parent#</th>
+    <th align="left" width="50%">#dotlrn.Name#</th>
+    <th align="left">#dotlrn.Description#</th>
+    <th align="left">#dotlrn.Term#</th>
+    <th align="left">#dotlrn.Created#</th>
+    <th align="left">#dotlrn.Unarchive#</th>
+  </tr>
+<multiple name="archived_comms">
+<if @archived_comms.rownum@ odd>
+  <tr class="odd">
+</if><else>
+  <tr class="even">
+</else>
+    <td>
+      <if @archived_comms.parent_community_id@ not eq ""><a href="@archived_comms.parent_url@">@archived_comms.parent_pretty_name@</a></if>
+    </td>
+    <td>
+      <a href="@archived_comms.url@">@archived_comms.pretty_name@</a></td>
+    <td>@archived_comms.description@</td>
+    <td>
+        @archived_comms.term_name@ @archived_comms.term_year@
+        <% # look for a parent term if no child term is found %>
+        <if @archived_comms.term_name@ eq "">@archived_comms.parent_term_name@ @archived_comms.parent_term_year@</if>
+    </td>
+    <td><em>@archived_comms.creation_date@</em></td>
+    <td><em><a href="@archived_comms.unarchive_url@">#dotlrn.unarchive#</a></em></td>
+  </tr>
+</multiple>
+</table>
+</if>
+<else>
+  #dotlrn.no_arhived_groups#
+</else>
Index: openacs-4/packages/dotlrn-admin/www/admin/archived-communities.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/archived-communities.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/archived-communities.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,40 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    displays archived communities
+
+    @author arjun (arjun@openforce.net)
+    @version $Id: archived-communities.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+    archived_comms:multirow
+}
+
+set groups_pretty_plural "[parameter::get -localize -parameter class_instances_pretty_plural] / [parameter::get -localize -parameter clubs_pretty_plural]"
+
+set title "[_ dotlrn.archived_groups]"
+set context_bar [list $title]
+
+db_multirow -extend { unarchive_url } archived_comms select_archived_comms {} {
+    set description [ad_quotehtml $description]
+    set unarchive_url "unarchive?community_id=$community_id"
+}
+
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/browse-toggle.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/browse-toggle.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/browse-toggle.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,36 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/browse-toggle.tcl
+
+ad_page_contract {
+    @author Caroline Meeks (caroline@meekshome.com)
+    @creation-date November 19, 2002
+    @version $Id: browse-toggle.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    user_id
+    can_browse_p
+    {referer "users"}
+}
+
+
+#update can_browse_p
+dotlrn::set_can_browse -user_id $user_id -can_browse\=$can_browse_p
+
+util_memoize_flush_regexp  $user_id
+ad_returnredirect $referer
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/class-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-edit.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-edit.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,28 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+
+<formtemplate id="edit_class"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/class-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-edit.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-edit.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,82 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    edit a class
+
+    @author yon (yon@openforce.net)
+    @creation-date 2001-03-14
+    @version $Id: class-edit.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    class_key:notnull
+    {referer classes}
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+}
+
+if {![db_0or1row select_class_info {}]} {
+    ad_return_complaint 1 "<li>[_ dotlrn.Invalid] class_key $class_key</li>"
+    ad_script_abort
+}
+
+set title "[_ dotlrn.Edit] [parameter::get -localize -parameter classes_pretty_name] $pretty_name"
+set context_bar [list [list classes [parameter::get -localize -parameter classes_pretty_plural]] [_ dotlrn.Edit]]
+
+form create edit_class
+
+element create edit_class class_key \
+    -label "[_ dotlrn.lt_Class_Key_a_short_nam]" \
+    -datatype text \
+    -widget hidden \
+    -value $class_key
+
+element create edit_class pretty_name \
+    -label [_ dotlrn.Name] \
+    -datatype text \
+    -widget text \
+    -html {size 60 maxlength 100}
+
+element create edit_class description \
+    -label [_ dotlrn.Description] \
+    -datatype text \
+    -widget textarea \
+    -html {rows 5 cols 60 wrap soft} \
+    -optional
+
+element create edit_class referer \
+    -label [_ dotlrn.Referer] \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_request edit_class]} {
+    element set_properties edit_class pretty_name -value $pretty_name
+    element set_properties edit_class description -value $description
+}
+
+if {[form is_valid edit_class]} {
+    form get_values edit_class \
+        class_key pretty_name description referer
+
+    db_dml update_community_type {}
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/class-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-edit.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-edit.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_class_info">
+        <querytext>
+            select pretty_name,
+                   description
+            from dotlrn_classes_full
+            where class_key = :class_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="update_community_type">
+        <querytext>
+            update dotlrn_community_types
+            set pretty_name = :pretty_name,
+                description = :description
+            where community_type = :class_key
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/class-instance-new-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-instance-new-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-instance-new-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_terms_for_select_widget">
+        <querytext>
+            select dotlrn_terms.term_name || ' ' || dotlrn_terms.term_year as term,
+                   dotlrn_terms.term_id
+            from dotlrn_terms
+            where dotlrn_terms.end_date > sysdate
+            order by dotlrn_terms.start_date
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/class-instance-new-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-instance-new-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-instance-new-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_terms_for_select_widget">
+        <querytext>
+            select dotlrn_terms.term_name || ' ' || dotlrn_terms.term_year as term,
+                   dotlrn_terms.term_id
+            from dotlrn_terms
+            where dotlrn_terms.end_date > now()
+            order by dotlrn_terms.start_date
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,26 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.new_class_of_type_class_name#</property>
+<property name="context_bar">@context_bar@</property>
+<property name="focus">add_class_instance.term</property>
+
+<formtemplate id="add_class_instance"></formtemplate>
Index: openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,114 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Create a New Class Instance
+
+    @author Ben Adida (ben@openforce.net)
+    @creation-date 2001-10-05
+    @version $Id: class-instance-new.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    class_key:notnull
+    {referer ""}
+}
+
+if {![db_0or1row select_class_info {}]} {
+    set class_name ""
+    set class_description ""
+}
+
+form create add_class_instance
+
+element create add_class_instance term \
+    -label [_ dotlrn.Term] \
+    -datatype integer \
+    -widget select \
+    -options [db_list_of_lists select_terms_for_select_widget {}]
+
+element create add_class_instance pretty_name \
+    -label [_ dotlrn.Name] \
+    -datatype text \
+    -widget text \
+    -html {size 60} \
+    -value $class_name \
+    -optional
+
+element create add_class_instance description \
+    -label [_ dotlrn.Description] \
+    -datatype text \
+    -widget textarea \
+    -html {rows 5 cols 60 wrap soft} \
+    -value $class_description \
+    -optional
+
+element create add_class_instance join_policy \
+    -label "[_ dotlrn.Join_Policy]" \
+    -datatype text \
+    -widget select \
+    -options [list [list [_ dotlrn.Open] open] [list "[_ dotlrn.Needs_Approval]" "needs approval"] [list [_ dotlrn.Closed] closed]]
+
+element create add_class_instance class_key \
+    -label "[parameter::get -localize -parameter classes_pretty_name] [_ dotlrn.Key]" \
+    -datatype text \
+    -widget hidden \
+    -value $class_key
+
+element create add_class_instance add_instructor \
+    -label "[_ dotlrn.Add_Professor]" \
+    -datatype text \
+    -widget radio \
+    -options [list [list [_ dotlrn.Yes] 1] [list [_ dotlrn.No] 0]] \
+    -value 1
+
+element create add_class_instance referer \
+    -label [_ dotlrn.Referer] \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid add_class_instance]} {
+    form get_values add_class_instance \
+        class_key term pretty_name description join_policy add_instructor referer
+
+    set class_instance_id [dotlrn_class::new_instance \
+        -class_key $class_key \
+        -term_id $term \
+        -pretty_name $pretty_name \
+        -description $description \
+        -join_policy $join_policy \
+    ]
+
+    if {[empty_string_p $referer]} {
+        set referer "class?class_key=$class_key"
+    }
+
+    if {${add_instructor}} {
+        ad_returnredirect "add-instructor?community_id=$class_instance_id&referer=$referer"
+        ad_script_abort
+    }
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+# Used by en_US version of new_class_instance message
+set class_instances_pretty_name [parameter::get -localize -parameter class_instances_pretty_name]
+
+set context_bar [list \
+                     [list classes [parameter::get -localize -parameter classes_pretty_plural]] \
+                     [list "class?class_key=$class_key" $class_name] \
+                     [_ dotlrn.new_class_instance]]
+
Index: openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-instance-new.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_class_info">
+        <querytext>
+            select pretty_name as class_name,
+                   description as class_description
+            from dotlrn_classes_full
+            where class_key = :class_key
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/class-new.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-new.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-new.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,26 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+<property name="focus">add_class.department_key</property>
+
+<formtemplate id="add_class"></formtemplate>
Index: openacs-4/packages/dotlrn-admin/www/admin/class-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-new.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-new.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,78 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Create a New Class - input form
+
+    @author Ben Adida (ben@openforce.net)
+    @author yon (yon@openforce.net)
+    @creation-date 2001-08-20
+    @version $Id: class-new.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {department_key ""}
+    {referer classes}
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+}
+
+# Used in en_US title
+set classes_pretty_name [parameter::get -localize -parameter classes_pretty_name]
+set title "[_ dotlrn.new_class_1]"
+set context_bar [list [list classes [parameter::get -localize -parameter classes_pretty_plural]] [_ dotlrn.new_class_navbar_name]]
+
+form create add_class
+
+element create add_class department_key \
+    -label [parameter::get -localize -parameter departments_pretty_name] \
+    -datatype text \
+    -widget select \
+    -options [dotlrn_department::select_as_list] \
+    -value $department_key
+
+element create add_class pretty_name \
+    -label [_ dotlrn.Name] \
+    -datatype text \
+    -widget text \
+    -html {size 60 maxlength 100}
+
+element create add_class description \
+    -label [_ dotlrn.Description] \
+    -datatype text \
+    -widget textarea \
+    -html {rows 5 cols 60 wrap soft} \
+    -optional
+
+element create add_class referer \
+    -label [_ dotlrn.Referer] \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid add_class]} {
+    form get_values add_class \
+        department_key pretty_name description referer
+
+    set class_key [dotlrn_class::new \
+        -department_key $department_key \
+        -pretty_name $pretty_name \
+        -description $description]
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/class-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_terms_for_select_widget">
+        <querytext>
+    select dotlrn_terms.term_name || ' ' || dotlrn_terms.term_year,
+           dotlrn_terms.term_id
+    from dotlrn_terms
+    where dotlrn_terms.end_date > (sysdate - 360)
+    and dotlrn_terms.start_date < (sysdate + 360)
+    order by dotlrn_terms.start_date,
+             dotlrn_terms.end_date
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/class-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_terms_for_select_widget">
+        <querytext>
+    select dotlrn_terms.term_name || ' ' || dotlrn_terms.term_year,
+           dotlrn_terms.term_id
+    from dotlrn_terms
+    where dotlrn_terms.end_date > (cast(current_timestamp as date) - 360)
+      and dotlrn_terms.start_date < (cast(current_timestamp as date) + 360)
+    order by dotlrn_terms.start_date,
+             dotlrn_terms.end_date
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/class.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,130 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@pretty_name@</property>
+<property name="context_bar">@context_bar@</property>
+
+<ul>
+
+  <li>
+    #dotlrn.description#:
+<if @description@ not nil>
+    @description@
+</if>
+<else>
+    &lt;#dotlrn.no_description#&gt;
+</else>
+  </li>
+
+  <br>
+
+  <li>
+    <a href="class-edit?class_key=@class_key@&referer=@referer@">#dotlrn.edit_subject_properties#</a>
+  </li>
+
+</ul>
+
+<br>
+
+<center>
+
+<if @can_instantiate@>
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left">
+        <nobr>
+          <small>[
+            <a href="class-instance-new?class_key=@class_key@">#dotlrn.new_class_instance#</a>
+          ]</small>
+        </nobr>
+      </td>
+    </tr>
+  </table>
+
+  <br>
+</if>
+<else>
+<include src="need-term-note">
+</else>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+    <tr bgcolor="#eeeeee">
+      <th align="left" width="50%">
+  <formtemplate id="term_form">
+        #dotlrn.term#:&nbsp;<formwidget id="term_id">
+  </formtemplate>
+      </th>
+    </tr>
+  </table>
+
+  <br>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+    <tr>
+      <th align="left" width="15%">#dotlrn.term#</th>
+      <th align="left">
+        #dotlrn.class_name_header#
+      </th>
+      <th align="center" width="5%">#dotlrn.members#</th>
+      <th align="center" width="10%">#dotlrn.actions#</th>
+    </tr>
+
+<if @class_instances:rowcount@ gt 0>
+
+<multiple name="class_instances">
+
+<if @class_instances.rownum@ odd>
+    <tr bgcolor="#eeeeee">
+</if>
+<else>
+    <tr bgcolor="#d9e4f9">
+</else>
+      <td align="left"><a href="term?term_id=@class_instances.term_id@">@class_instances.term_name@&nbsp;@class_instances.term_year@</a></td>
+      <td align="left"><a href="@class_instances.url@">@class_instances.pretty_name@</a></td>
+      <td align="center">@class_instances.n_members@</td>
+      <td align="center">
+        <nobr>
+        <small>
+           <a href="@class_instances.url@one-community-admin">#dotlrn.administer_link#</a> 
+        </small>
+        </nobr>
+      </td>
+    </tr>
+
+</multiple>
+
+</if>
+<else>
+    <tr bgcolor="#eeeeee">
+      <td align="left" colspan="4">
+        <i>#dotlrn.no_class_instances#</i>
+      </td>
+    </tr>
+</else>
+
+  </table>
+
+</center>
+
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/class.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,82 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays single dotLRN class page
+
+    @author Ben Adida (ben@openforce.net)
+    @author yon (yon@openforce.net)
+    @creation-date 2001-11-07
+    @version $Id: class.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    class_key:notnull
+    {term_id -1}
+} -properties {
+    pretty_name:onevalue
+    description:onevalue
+    class_instances:multirow
+    can_instantiate:onevalue
+}
+
+# Get information about that class
+if {![db_0or1row select_class_info {}]} {
+    ad_returnredirect classes
+    ad_script_abort
+}
+
+set description [ad_quotehtml $description]
+
+set terms [db_list_of_lists select_terms_for_select_widget {}]
+set terms [linsert $terms 0 {All -1}]
+
+form create term_form
+
+element create term_form term_id \
+    -label [_ dotlrn.Term] \
+    -datatype integer \
+    -widget select \
+    -options $terms \
+    -html {onChange document.term_form.submit()} \
+    -value $term_id
+
+element create term_form class_key \
+    -label "[_ dotlrn.Class_Key]" \
+    -datatype text \
+    -widget hidden \
+    -value $class_key
+
+if {[form is_valid term_form]} {
+    form get_values term_form term_id class_key
+}
+
+set query select_class_instances
+if {$term_id == -1} {
+    set query select_all_class_instances
+}
+
+db_multirow class_instances $query {}
+
+set can_instantiate [dotlrn_class::can_instantiate]
+
+set context_bar [list [list classes [parameter::get -localize -parameter classes_pretty_plural]] $pretty_name]
+set referer "[ns_conn url]?[ns_conn query]"
+
+# Used by some en_US messages on the adp page
+set classes_pretty_name [parameter::get -localize -parameter classes_pretty_name]
+set class_instances_pretty_name [parameter::get -localize -parameter class_instances_pretty_name]
+set class_instances_pretty_plural [parameter::get -localize -parameter class_instances_pretty_plural]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/class.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/class.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/class.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_class_info">
+        <querytext>
+            select pretty_name,
+                   description,
+                   supertype
+            from dotlrn_classes_full
+            where class_key = :class_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_all_class_instances">
+        <querytext>
+            select dotlrn_class_instances_full.*,
+                   (select count(*)
+                    from dotlrn_member_rels_approved
+                    where dotlrn_member_rels_approved.community_id = dotlrn_class_instances_full.class_instance_id) as n_members
+            from dotlrn_class_instances_full
+            where dotlrn_class_instances_full.class_key = :class_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_class_instances">
+        <querytext>
+            select dotlrn_class_instances_full.*,
+                   (select count(*)
+                    from dotlrn_member_rels_approved
+                    where dotlrn_member_rels_approved.community_id = dotlrn_class_instances_full.class_instance_id) as n_members
+            from dotlrn_class_instances_full
+            where dotlrn_class_instances_full.class_key = :class_key
+            and dotlrn_class_instances_full.term_id = :term_id
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,110 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<center>
+
+<if @can_create@>
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left">
+        <nobr>
+          <small>[
+            <a href="class-new?department_key=@department_key@&referer=@referer@">#dotlrn.new_class_1#</a>
+          ]</small>
+        </nobr>
+      </td>
+    </tr>
+  </table>
+
+  <br>
+</if>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+    <tr bgcolor="#eeeeee">
+      <th align="left" width="50%">
+<formtemplate id="department_form">
+        <%= [parameter::get -localize -parameter departments_pretty_name] %>:&nbsp;<formwidget id="department_key">
+</formtemplate>
+      </th>
+    </tr>
+  </table>
+
+  <br>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+
+    <tr>
+      <th align="left" width="30%"><%= [parameter::get -localize -parameter departments_pretty_name] %></th>
+      <th align="left">#dotlrn.class_name#</th>
+      <th align="center" width="5%"><%= [parameter::get -localize -parameter class_instances_pretty_plural] %></th>
+      <th align="center" width="10%">#dotlrn.Actions#</th>
+    </tr>
+
+<if @classes:rowcount@ gt 0>
+<multiple name="classes">
+
+<if @classes.rownum@ odd>
+    <tr bgcolor="#eeeeee">
+</if>
+<else>
+    <tr bgcolor="#d9e4f9">
+</else>
+      <td align="left"><a href="department?department_key=@classes.department_key@">@classes.department_name@</a></td>
+      <td align="left"><a href="class?class_key=@classes.class_key@">@classes.pretty_name@</a></td>
+      <td align="center">@classes.n_instances@</td>
+      <td align="center">
+<if @can_instantiate@>
+        <nobr>
+          <small>[
+            <a href="class-instance-new?class_key=@classes.class_key@">#dotlrn.new_class_instance#</a>
+          ]</small>
+        </nobr>
+</if>
+    </td>
+  </tr>
+
+</multiple>
+</if>
+<else>
+  <tr bgcolor="#eeeeee">
+    <td align="left" colspan="4">
+      <i>#dotlrn.no_classes#</i>
+    </td>
+  </tr>
+</else>
+  </table>
+
+<if @can_create@ and @classes:rowcount@ gt 10>
+  <br>
+
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left">
+        <nobr>
+          <small>[
+            <a href="class-new?department_key=@department_key@&referer=@referer@">#dotlrn.new_class_1#</a>
+          ]</small>
+        </nobr>
+      </td>
+    </tr>
+  </table>
+</if>
+
+</center>
Index: openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,75 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays dotLRN classes admin page
+
+    @author Ben Adida (ben@openforce.net)
+    @author yon (yon@openforce.net)
+    @creation-date 2001-11-04
+    @version $Id: classes-chunk.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+} -properties {
+    classes:multirow
+}
+
+if {![exists_and_not_null department_key]} {
+    set department_key ""
+}
+
+set departments [db_list_of_lists select_departments_for_select_widget {
+    select dotlrn_departments_full.pretty_name,
+           dotlrn_departments_full.department_key
+    from dotlrn_departments_full
+    order by dotlrn_departments_full.pretty_name,
+             dotlrn_departments_full.department_key
+}]
+set departments [linsert $departments 0 [list [_ dotlrn.All] ""]]
+
+form create department_form
+
+element create department_form department_key \
+    -label [_ dotlrn.Department] \
+    -datatype text \
+    -widget select \
+    -options $departments \
+    -html {onChange document.department_form.submit()} \
+    -value $department_key
+
+if {[form is_valid department_form]} {
+    form get_values department_form department_key
+}
+
+if {![exists_and_not_null referer]} {
+    set referer "classes?[export_vars department_key]"
+}
+
+set query select_classes
+if {![empty_string_p $department_key]} {
+    set query select_classes_by_department
+}
+
+db_multirow classes $query {}
+
+set can_create [dotlrn_class::can_create]
+set can_instantiate [dotlrn_class::can_instantiate]
+
+# Used in the en_US versions of some of the messages in the adp
+set classes_pretty_name [parameter::get -localize -parameter classes_pretty_name]
+set classes_pretty_plural [parameter::get -localize -parameter classes_pretty_plural]
+set class_instances_pretty_name [parameter::get -localize -parameter class_instances_pretty_name]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/classes-chunk.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_classes">
+        <querytext>
+            select dotlrn_classes_full.class_key,
+                   dotlrn_classes_full.pretty_name,
+                   dotlrn_classes_full.description,
+                   dotlrn_classes_full.department_key,
+                   dotlrn_departments_full.pretty_name as department_name,
+                   (select count(*)
+                     from dotlrn_class_instances, dotlrn_communities_all
+                    where dotlrn_class_instances.class_key = dotlrn_classes_full.class_key
+                      and dotlrn_class_instances.class_instance_id = dotlrn_communities_all.community_id
+                      and dotlrn_communities_all.archived_p = 'f') as n_instances
+            from dotlrn_classes_full,
+                 dotlrn_departments_full
+            where dotlrn_classes_full.department_key = dotlrn_departments_full.department_key
+            order by lower(dotlrn_departments_full.pretty_name),
+                     lower(dotlrn_classes_full.pretty_name),
+                     dotlrn_classes_full.class_key
+
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_classes_by_department">
+        <querytext>
+            select dotlrn_classes_full.class_key,
+                   dotlrn_classes_full.pretty_name,
+                   dotlrn_classes_full.description,
+                   dotlrn_classes_full.department_key,
+                   dotlrn_departments_full.pretty_name as department_name,
+                   (select count(*)
+                    from dotlrn_class_instances, dotlrn_communities_all
+                    where dotlrn_class_instances.class_key = dotlrn_classes_full.class_key
+                      and dotlrn_class_instances.class_instance_id = dotlrn_communities_all.community_id
+                      and dotlrn_communities_all.archived_p = 'f') as n_instances
+            from dotlrn_classes_full,
+                 dotlrn_departments_full
+            where dotlrn_classes_full.department_key = :department_key
+            and dotlrn_classes_full.department_key = dotlrn_departments_full.department_key
+            order by lower(dotlrn_classes_full.pretty_name), dotlrn_classes_full.class_key
+                     
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/classes.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/classes.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/classes.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,28 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+
+<include src="classes-chunk">
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/classes.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/classes.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/classes.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,34 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays dotLRN classes admin page
+
+    @author Ben Adida (ben@openforce.net)
+    @author yon (yon@openforce.net)
+    @creation-date 2001-11-04
+    @version $Id: classes.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+}
+
+set title [parameter::get -localize -parameter classes_pretty_plural]
+set context_bar $title
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/club-new.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/club-new.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/club-new.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,26 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+<property name="focus">add_club.pretty_name</property>
+
+<formtemplate id="add_club"></formtemplate>
Index: openacs-4/packages/dotlrn-admin/www/admin/club-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/club-new.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/club-new.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,74 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    create a new club - input form
+
+    @author yon (yon@openforce.net)
+    @creation-date 2001-12-03
+    @version $Id: club-new.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {referer "clubs"}
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+}
+
+form create add_club
+
+element create add_club pretty_name \
+    -label "[_ dotlrn.Name]" \
+    -datatype text \
+    -widget text \
+    -html {size 60 maxlength 100}
+
+element create add_club description \
+    -label "[_ dotlrn.Description]" \
+    -datatype text \
+    -widget textarea \
+    -html {rows 5 cols 60 wrap soft} \
+    -optional
+
+element create add_club join_policy \
+    -label "[_ dotlrn.Join_Policy]" \
+    -datatype text \
+    -widget select \
+    -options [list [list [_ dotlrn.Open] open] [list "[_ dotlrn.Needs_Approval]" "needs approval"] [list [_ dotlrn.Closed] closed]]
+
+element create add_club referer \
+    -label "[_ dotlrn.Referer]" \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid add_club]} {
+    form get_values add_club \
+         pretty_name description join_policy referer
+
+    set key [dotlrn_club::new \
+        -description $description \
+        -pretty_name $pretty_name \
+        -join_policy $join_policy]
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+set clubs_pretty_name [parameter::get -localize -parameter clubs_pretty_name]
+set title "[_ dotlrn.new_community]"
+set context_bar [list [list clubs [parameter::get -localize -parameter clubs_pretty_plural]] $title]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/club-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/club-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/club-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<queryset>
+  <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_club">
+        <querytext>
+            select dotlrn_communities.pretty_name,
+                   dotlrn_communities.description,
+                   dotlrn_community.url(:club_id) as url
+            from dotlrn_communities
+            where dotlrn_communities.community_id = :club_id
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/club-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/club-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/club-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<queryset>
+  <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_club">
+        <querytext>
+            select dotlrn_communities.pretty_name,
+                   dotlrn_communities.description,
+                   dotlrn_community__url(:club_id) as url
+            from dotlrn_communities
+            where dotlrn_communities.community_id = :club_id
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/club.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/club.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/club.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,29 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@pretty_name@</property>
+<property name="context_bar">@context_bar@</property>
+
+@pretty_name@ - <pre>@description@</pre>
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/club.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/club.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/club.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,42 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/club.tcl
+
+ad_page_contract {
+    displays single dotLRN club page
+
+    @author yon (yon@openforce.net)
+    @creation-date 2001-12-03
+    @version $Id: club.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    club_id:naturalnum,notnull
+} -errors {
+    club_id:naturalnum,notnull {must provide a valid club_id}
+} -properties {
+    context_bar:onevalue
+    pretty_name:onevalue
+    description:onevalue
+}
+
+db_1row select_club {}
+
+set description [ad_quotehtml $description]
+
+set context_bar [list [list clubs [parameter::get -localize -parameter clubs_pretty_plural]] $pretty_name]
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/clubs.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/clubs.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/clubs.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,100 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+
+<center>
+
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left">
+        <nobr>
+          <small>[
+            <a href="club-new">#dotlrn.new_community#</a>
+          ]</small>
+        </nobr>
+      </td>
+    </tr>
+  </table>
+
+  <br>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+
+    <tr>
+      <th align="left" width="30%">#dotlrn.community_header_name#</th>
+      <th align="left">#dotlrn.Description#</th>
+      <th align="center" width="5%">#dotlrn.Members#</th>
+      <th align="center" width="10%">#dotlrn.Actions#</th>
+    </tr>
+
+<if @clubs:rowcount@ gt 0>
+
+<multiple name="clubs">
+
+<if @clubs.rownum@ odd>
+    <tr bgcolor="#eeeeee">
+</if>
+<else>
+    <tr bgcolor="#d9e4f9">
+</else>
+      <td align="left"><a href="@clubs.url@">@clubs.pretty_name@</a></td>
+      <td align="left">@clubs.description@</td>
+      <td align="center">@clubs.n_members@</td>
+      <td align="center">
+        <nobr>
+          <small>
+             <a href="@clubs.url@one-community-admin">#dotlrn.administer_link#</a> 
+          </small>
+        </nobr>
+      </td>
+    </tr>
+
+</multiple>
+
+</if>
+<else>
+  <tr bgcolor="#eeeeee">
+    <td align="left" colspan="4">
+      <i>#dotlrn.no_communities#</i>
+    </td>
+  </tr>
+</else>
+  </table>
+
+<if @clubs:rowcount@ gt 10>
+  <br>
+
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left">
+        <nobr>
+          <small>[
+            <a href="club-new">#dotlrn.new_community#</a>
+          ]</small>
+        </nobr>
+      </td>
+    </tr>
+  </table>
+</if>
+
+</center>
Index: openacs-4/packages/dotlrn-admin/www/admin/clubs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/clubs.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/clubs.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,43 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/clubs.tcl
+
+ad_page_contract {
+    displays dotLRN clubs admin page
+
+    @author yon (yon@openforce.net)
+    @creation-date 2001-12-03
+    @version $Id: clubs.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+    clubs:multirow
+}
+
+set title [parameter::get -localize -parameter clubs_pretty_plural]
+set context_bar [list $title]
+
+db_multirow clubs select_clubs {} {
+    set description [ad_quotehtml $description]
+}
+
+# Some of the en_US messages in the adp use these variables
+set clubs_pretty_name [parameter::get -localize -parameter clubs_pretty_name]
+set clubs_pretty_plural [parameter::get -localize -parameter clubs_pretty_plural]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/clubs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/clubs.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/clubs.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_clubs">
+        <querytext>
+            select dotlrn_clubs_full.*,
+                   (select count(*)
+                    from dotlrn_member_rels_approved
+                    where dotlrn_member_rels_approved.community_id = dotlrn_clubs_full.club_id) as n_members
+            from dotlrn_clubs_full
+            order by dotlrn_clubs_full.pretty_name,
+                     dotlrn_clubs_full.description
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/cockpit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/cockpit.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/cockpit.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,209 @@
+<master>
+<% set user_id [ad_maybe_redirect_for_registration] %>
+<% permission::require_permission -object_id $user_id -privilege admin %>
+<h2>#dotlrn.Administration_Cockpit#</h2>
+<table width="90%" id="context-bar">
+<tr>
+<td width="40%" VALIGN="top">
+<listtemplate name="online_users"></listtemplate>
+#dotlrn.Total_count# @count@
+</td>
+<td width="20%" VALIGN="top">
+<ul>
+<li><h2>@admin_pretty_name@</h2>
+<ul>
+<li><a href="/dotlrn/?">My Space</a>
+<li><a href="/acs-admin/">OpenACS Admin</a>
+<li><a href="/dotlrn/admin">DotLRN Admin</a>
+<ul>
+  <li><a href="/dotlrn/admin/terms">#dotlrn.Terms#</a></li>
+  <li><a href="/dotlrn/admin/departments">#dotlrn.departments_pretty_plural#</a></li>
+  <li><a href="/dotlrn/admin/classes">#dotlrn.classes_pretty_plural#</a></li>
+  <li><a href="/dotlrn/admin/term?term_id=-1">#dotlrn.class_instances_pretty_plural#</a></li>
+  <li><a href="/dotlrn/admin/clubs">#dotlrn.clubs_pretty_plural#</a></li>
+  <li><a href="/dotlrn/admin/portal-templates">#dotlrn.portal_templates#</a></li>
+  <li><a href="/dotlrn/admin/archived-communities">#dotlrn.Archive#</a></li>
+  <li><a href="/dotlrn/admin/edit-preapproved-emails">#dotlrn.lt_Pre-approved_Email_Se#</a></li>
+</ul>
+</ul>
+<li><h2>Packages</h2>
+<ul>
+<li><a href="/acs-admin/install">Install Packages</a>
+<li><a href="/admin/applications/">Installed Applications</a>
+<li><a href="/acs-service-contract/">Service Contracts</a>
+</ul>
+<li><h2>Site Structure</h2>
+<ul>
+<li><a href="/admin/site-map/">Site Map</a>
+</ul>
+</ul>
+
+</td>
+<td width="20%" VALIGN="top">
+<ul>
+<li><h2>Documentation</h2>
+<ul>
+<li><a href="/doc/">Open ACS Documentation</a>
+<li><a href="/dotlrn/help">DotLRN Documentation</a>
+<li><a href="http://openacs.org/doc/openacs-HEAD/">CVS Head</a>
+<li><a href="http://openacs.org/packages/">Packages</a>
+</ul>
+<li><h2>User Managment</h2>
+<ul>
+<li><a href="/acs-admin/auth">Authorities</a>
+<li><a href="/acs-admin/users/">ACS Users</a>
+	<table width="100%" border="0" cellspacing="0" cellpadding="0">
+	<tr>
+		<td width="50%">
+			<form method="post" action="/acs-admin/users/one">
+			<input type="text" size="6" name="user_id" value="" />
+			<input type="submit" name="formbutton:ok" value="OK" />
+			</form>
+		</td>
+		<td width="50%">
+			<FORM METHOD="get" ACTION="/acs-admin/users/search">
+    			<input type="hidden" name="target" value="one" />
+    			<input type="hidden" name="only_authorized_p" value="0" />
+    			<input type="text" size="6" name="keyword" />
+                  	<input type="submit" value="Find" />
+  			</FORM>
+		</td>
+	</tr>
+	</table>
+<li><a href="/dotlrn/admin/users">DotLRN Users</a>
+	<table border="0" cellspacing="0" cellpadding="0">
+	<tr>
+		<td>
+			<form method="post" action="/dotlrn/admin/user">
+			<input type="text" size="6" name="user_id" value="" />
+			<input type="submit" name="formbutton:ok" value="OK" />
+			</form>
+		</td>
+	</tr>
+	</table>
+<li><a href="/members/">Members</a>
+</ul>
+<li><h2>User Monitoring</h2>
+<ul>
+<li><a href="/acs-admin/monitor">Active HTTP-Connections</a> | <a href="/monitor/monitor">Current Requests</a>
+<li><a href="/shared/whos-online">User Online</a>
+</ul>
+<li><h2>System Monitor</h2>
+<ul>
+<li><a href="/procs-chunk.adp">Scheduled Procs</a>
+<li><a href="/acs-admin/cache">Cache Info</a>
+<li><a href="/acs-admin/cache/index">Util Memoize Caches</a>
+<li><a href="/acs-service-contract/">Service Contracts</a>
+<if @monitor_exists_p@>
+	<li><a href="@monitor_url@scheduled-procs">Scheduled Procs</a>
+	<li>Watch Errors - Last
+		<table><tr><td>
+		<FORM ACTION=@monitor_url@watchdog/index>    
+		<INPUT NAME=kbytes SIZE=4 value="200"><INPUT TYPE=SUBMIT VALUE="KB">
+		</FORM>
+		</td>
+		<td>
+		<FORM ACTION=@monitor_url@watchdog/index>
+		<INPUT NAME=num_minutes SIZE=4 value=""><INPUT TYPE=SUBMIT VALUE="min">
+		</FORM>
+		</td></tr></table>
+<li><a href="@monitor_url@filters">Filters</a>
+<li><a href="@monitor_url@top/">Set Monitor System</a>
+</if>
+<li><a href="http://uptime.openacs.org/">Uptime Monitor</a>
+</ul>
+</ul>
+</ul>
+</td>
+<td width="20%" VALIGN="top">
+<ul>
+<li><h2>Development</h2>
+<ul>
+<if @ds_exists_p@>
+	<li><a href="@ds_url@">Developer Support</a>(<a href="@ds_url@shell">Shell</a>)
+</if>
+<li><a href="http://openacs.org/bugtracker/openacs/">Bug Tracker</a>
+<li><a href="/acs-admin/apm">Package Manager</a>
+<li><a href="/api-doc/">API Browser</a>
+		<table width="100%" border="0" cellspacing="0" cellpadding="0">
+		<tr>
+			<td width="50%">
+				   <table>
+				     <tr bgcolor="#DDDDDD">
+				      <form action="/api-doc/proc-search" method="get">
+				      <td valign="top">
+				       <b>OpenACS Tcl API Search</b>
+				       <input type="text" size="16" name="query_string" value=""/><br />
+				       <input type="submit" value="All" name="search_type" />
+				       <input type="submit" value="Best" name="search_type" />
+				       <p><a href="/api-doc/proc-browse">Browse OpenACS Tcl API</a></p>
+				      </td>
+				      <td>       
+				       <table cellspacing="0" cellpadding="0">
+				         <tr><td align="right">Name contains:</td>
+				           <td><input type="radio" name="name_weight" value="5" checked="checked" /> </td></tr>
+				         <tr><td align="right">Exact name:</td>
+				           <td><input type="radio" name="name_weight" value="exact" /></td></tr>
+				         <tr><td align="right">&nbsp;</td><td>&nbsp;</td></tr>
+				         <tr><td align="right">Parameters:</td>
+				           <td><input type="checkbox" name="param_weight" value="3" checked="checked" /></td></tr>
+				         <tr><td align="right">Documentation:</td>
+				           <td><input type="checkbox" name="doc_weight" value="2" checked="checked" /></td></tr>
+				         <tr><td align="right">Source:</td>
+				           <td><input type="checkbox" name="source_weight" value="1" /></td></tr>
+				       </table>
+				      </td>
+				      </form>
+				     </tr>				
+				  <tr bgcolor="#DDDDDD">
+				   <form action="/api-doc/tcl-proc-view" method="get">
+				   <td colspan="2">
+				    <b>AOLserver Tcl API Search</b>
+				    <input type="text" size="6" name="tcl_proc" />
+				    <input type="submit" value="Go" /><br />
+				    (enter <em>exact</em> procedure name)<br />
+				    <a href="http://www.aolserver.com/docs/devel/tcl/api/">Browse AOLserver Tcl API</a>
+				   </td>
+				   </form>
+				  </tr>
+				  <tr bgcolor="#DDDDDD">
+				  <form action="/api-doc/tcl-doc-search" method="get">
+				   <td colspan="2">
+				    <b>Tcl Documentation Search</b>
+				    <input type="text" size="6" name="tcl_proc" />
+				    <input type="submit" value="Go" /><br />
+				    (enter <em>exact</em> procedure name)<br />
+				    <a href="http://tcl.tk/man/tcl8.3/TclCmd/contents.htm">Browse the Tcl documentation</a>
+				   </td>
+				   </form>
+				  </tr>				 
+				   <tr bgcolor="#DDDDDD">
+				   <form action="http://www.postgresql.org/search.cgi" method="get">
+				    <td colspan="2">
+				       <b>PostgreSQL 7.3 Search</b>
+				       <input type="hidden" name="ul" value="http://www.postgresql.org/docs/7.3/static/" />
+				       <input type="text" size="6" name="q" />
+				       <input type="submit" value="Go" /><br />
+				     	<a href="http://www.postgresql.org/docs/7.3/interactive/index.html">Browse the PostgreSQL 7.3 documentation</a>
+				    </td>
+				    </form>
+				   </tr>
+				</table>
+			</td>
+		</tr>
+		</table>
+<li><a href="/acs-lang/admin/">i18n Administration</a>
+<li><a href="http://translate.openacs.org">Translation Server</a>
+<li><a href="/test/admin">Automated Testing</a>
+<li><a href="http://test.openacs.org/">Test Servers</a>
+<li><a href="http://openacs.org/projects/dotlrn/download/">DotLRN-Download</a>
+<li><a href="http://openacs.org/forums/">Forums</a>
+<ul>
+<li><a href="http://openacs.org/forums/forum-view?forum_id=14013">OpenACS Forum</a>
+<li><a href="http://openacs.org/forums/forum-view?forum_id=14017">dotLRN Forum</a>
+</ul>
+</ul>
+</ul>
+</td>
+</tr>
+</table>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-admin/www/admin/cockpit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/cockpit.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/cockpit.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,117 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Figure out if ds and monitoring exists and lists the active users
+
+    @author Nima Mazloumi (mazloumi@uni-mannheim.d)
+    @creation-date 2004-08-09
+    @version $Id: cockpit.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+}
+
+set admin_pretty_name [parameter::get -localize -parameter dotlrn_admin_pretty_name]
+
+# Does Developer support exists
+set ds_exists_p 0
+set ds_url "/ds/"
+
+if { [site_node::exists_p -url "/ds"] } {
+   set ds_exists_p 1
+} else {
+   set url [site_node::get_package_url -package_key "acs-developer-support"]
+   if { $url != "" } {
+       set ds_exists_p 1
+   }
+}
+
+# Does monitoring exists
+set monitor_exists_p 0
+set monitor_url "/monitor/"
+
+if { [site_node::exists_p -url "/monitor"] } {
+   set monitor_exists_p 1
+} else {
+   set monitor_url [site_node::get_package_url -package_key "monitoring"]
+   if { $monitor_url != "" } {
+       set monitor_exists_p 1
+   }
+}
+
+# Who is currently online
+set whos_online_interval [whos_online::interval]
+
+template::list::create \
+    -name online_users \
+    -multirow online_users \
+    -elements {
+        name {
+            label "[_ dotlrn.Name]"
+            html { align left }
+            link_url_col url
+        }
+        online_time_pretty {
+            label "[_ dotlrn.Minutes]"
+            html { align right }
+        }
+        username {
+            label "[_ dotlrn.Email_1]"
+            link_url_col email
+            html { align left nowrap }
+        }
+        user_id {
+            label "[_ dotlrn.User_ID_1]"
+            link_url_col id_url
+            html { align right }
+        }
+    }
+
+
+set users [list]
+
+set count 0
+
+foreach user_id [whos_online::user_ids] {
+    acs_user::get -user_id $user_id -array user
+
+    set first_request_minutes [expr [whos_online::seconds_since_first_request $user_id] / 60]
+    lappend users [list \
+                       "$user(first_names) $user(last_name)" \
+                       [acs_community_member_url -user_id $user_id] \
+                       "$first_request_minutes" \
+                       "$user(username)" \
+                       "mailto:$user(email)" \
+                       "$user(user_id)" \
+                       "/acs-admin/users/one?user_id=$user(user_id)" ]
+    incr count
+}
+
+
+set users [lsort -index 0 $users]
+
+multirow create online_users name url online_time_pretty username email user_id id_url
+
+foreach elm $users {
+    multirow append online_users \
+        [lindex $elm 0] \
+        [lindex $elm 1] \
+        [lindex $elm 2] \
+        [lindex $elm 3] \
+        [lindex $elm 4] \
+        [lindex $elm 5] \
+        [lindex $elm 6]
+}
+
+ad_return_template
\ No newline at end of file
Index: openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,31 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.lt_Add_community_name_Me#</property>
+<property name="context_bar">@context_bar@</property>
+
+<strong><font color=red>#dotlrn.Note#</font></strong> 
+
+#dotlrn.lt_This_action_will_take_1#
+
+<p></p>
+
+<formtemplate id="select_community"></formtemplate>
Index: openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,117 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+ad_page_contract {
+    Add a members of one community to another
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-02-10
+    @param source_community_id The community_id for the source community.  The members of the source community will be added to the target community the user selects.
+    @param referer The url for the administration page of the source community.
+    @version $Id: community-members-add-to-community.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    source_community_id:integer
+    referer 
+} -properties {
+    context_bar:onevalue
+}
+
+
+set community_name [db_string select_community_info {}]
+set users [dotlrn_community::list_users $source_community_id]
+
+set context_bar [list [list $referer $community_name]  "[_ dotlrn.lt_Add_Members_to_Anothe]"]
+
+form create select_community
+
+element create select_community source_community_id \
+    -label "&nbsp;" \
+    -datatype text \
+    -widget hidden \
+    -value $source_community_id
+
+element create select_community referer \
+        -label "[_ dotlrn.Referer]" \
+        -datatype text \
+        -widget hidden \
+        -value $referer
+
+set communities [db_list_of_lists select_all_communities {
+    select dotlrn_communities.pretty_name,
+           dotlrn_communities.community_id
+    from dotlrn_communities
+    where dotlrn_communities.portal_id is not NULL
+    order by dotlrn_communities.pretty_name,
+             dotlrn_communities.community_id
+}]
+
+if {[llength $communities]} {
+    element create select_community community_id \
+        -label "[_ dotlrn.Add_users_to]" \
+        -datatype text \
+        -widget select \
+        -options "{{} {}} $communities"
+} else {
+    element create select_community community_id \
+        -label "[_ dotlrn.No_groups_to_add_to]" \
+        -datatype text \
+        -widget hidden \
+        -value ""
+}
+
+if {[form is_valid select_community]} {
+    form get_values select_community \
+        source_community_id community_id
+
+    if {![empty_string_p $community_id]} {
+        db_transaction {
+            foreach user $users {
+		set user_id [ns_set get $user user_id]
+		if {![dotlrn_community::member_p $community_id $user_id]} {
+                    # now we know user isn't an approved member of the new community
+                    if {![dotlrn_community::member_pending_p -community_id $community_id -user_id $user_id]} {
+
+                        # they aren't awaiting approval either, so we can go ahead and create them
+                        if {[catch {
+                            # There is still a danger that a double
+                            # click will cause a failure.
+                            dotlrn_community::add_user $community_id $user_id
+                        } errmsg]} {
+                            if {[dotlrn_community::member_p $community_id $user_id]} {
+                                # assume this was a double click
+                                ad_returnredirect $referer
+                                ad_script_abort
+                            } else {
+                                ns_log Error "community-members-add-to_community.tcl failed: $errmsg"
+                                ReturnHeaders
+                                ad_return_error "[_ dotlrn.lt_Error_adding_user_to_]"  "[_ dotlrn.lt_An_error_occured_whil]"
+                            }
+                        }
+                    } else {
+                        # they are already there and awaiting approval, so just approve them.
+                        dotlrn_community::membership_approve -user_id $user_id -community_id $community_id
+                    }
+		}
+            }
+        }
+    }
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+set estimated_number_of_seconds [expr [llength $users] * 3]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/community-members-add-to-community.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_community_info">
+        <querytext>
+            select pretty_name 
+ 	    from dotlrn_communities
+	    where community_id = :source_community_id
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/department-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department-delete.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department-delete.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,33 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="context_bar">@context_bar@</property>
+
+<property name="title">@title@</property>
+
+#dotlrn.lt_Are_you_sure_you_want# <strong>@pretty_name@</strong>?
+<br>
+
+<formtemplate id="delete_department"></formtemplate>
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/department-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department-delete.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department-delete.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,85 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    delete an empty department
+
+    @author arjun (arjun@openforce.net)
+    @version $Id: department-delete.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {referer "departments"}
+    {department_key:notnull}
+    {pretty_name:notnull}
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+}
+
+set departments_pretty_name [parameter::get -localize -parameter departments_pretty_name]
+set title "[_ dotlrn.Delete_Empty]"
+set context_bar [list [list departments [parameter::get -localize -parameter departments_pretty_plural]] Delete]
+
+form create delete_department
+
+# this is lame, but the button hack is not ready yet
+set yes_label "[_ dotlrn.Yes_delete] $pretty_name"
+set no_label "[_ dotlrn.No_dont_delete_it]"
+
+element create delete_department no_button \
+    -label $no_label \
+    -datatype text \
+    -widget submit \
+    -value "1"
+
+element create delete_department yes_button \
+    -label $yes_label  \
+    -datatype text \
+    -widget submit
+
+element create delete_department department_key \
+    -datatype text \
+    -widget hidden \
+    -value $department_key
+
+element create delete_department pretty_name \
+    -datatype text \
+    -widget hidden \
+    -value $pretty_name
+
+element create delete_department referer \
+    -label "[_ dotlrn.Referer]" \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid delete_department]} {
+    form get_values delete_department department_key pretty_name referer no_button yes_button
+
+    if {[string equal $yes_button $yes_label]} {
+
+        db_transaction {
+            set subcomm_id [dotlrn_department::delete \
+                -department_key $department_key
+            ]
+        }
+    }
+
+    ad_returnredirect "$referer"
+    ad_script_abort
+} 
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/department-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department-edit.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department-edit.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,28 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+
+<formtemplate id="edit_department"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/department-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department-edit.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department-edit.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,93 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    edit a department
+
+    @author yon (yon@openforce.net)
+    @creation-date 2001-03-14
+    @version $Id: department-edit.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    department_key:notnull
+    {referer "departments"}
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+}
+
+if {![db_0or1row select_department_info {}]} {
+    ad_return_complaint 1 "<li>[_ dotlrn.Invalid] department_key $department_key</li>"
+    ad_script_abort
+}
+
+set title "[_ dotlrn.Edit] [parameter::get -localize -parameter departments_pretty_name] $pretty_name"
+set context_bar [list [list departments [parameter::get -localize -parameter departments_pretty_plural]] [_ dotlrn.Edit]]
+
+form create edit_department
+
+element create edit_department department_key \
+    -label "[parameter::get -localize -parameter departments_pretty_name] [_ dotlrn.lt_Key_a_short_name_no_s]" \
+    -datatype text \
+    -widget hidden \
+    -value $department_key
+
+element create edit_department pretty_name \
+    -label "[_ dotlrn.Name]" \
+    -datatype text \
+    -widget text \
+    -html {size 60 maxlength 100}
+
+element create edit_department description \
+    -label "[_ dotlrn.Description]" \
+    -datatype text \
+    -widget textarea \
+    -html {rows 5 cols 60 wrap soft} \
+    -optional
+
+element create edit_department external_url \
+    -label "[_ dotlrn.External_URL]" \
+    -datatype text \
+    -widget text \
+    -html {size 60} \
+    -optional
+
+element create edit_department referer \
+    -label "[_ dotlrn.Referer]" \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_request edit_department]} {
+    element set_properties edit_department pretty_name -value $pretty_name
+    element set_properties edit_department description -value $description
+    element set_properties edit_department external_url -value $external_url
+}
+
+if {[form is_valid edit_department]} {
+    form get_values edit_department \
+        department_key pretty_name description external_url referer
+
+    db_transaction {
+        db_dml update_department {}
+        db_dml update_community_type {}
+    }
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/department-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department-edit.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department-edit.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_department_info">
+        <querytext>
+            select pretty_name,
+                   description,
+                   external_url
+            from dotlrn_departments_full
+            where department_key = :department_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="update_department">
+        <querytext>
+            update dotlrn_departments
+            set external_url = :external_url
+            where department_key = :department_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="update_community_type">
+        <querytext>
+            update dotlrn_community_types
+            set pretty_name = :pretty_name,
+                description = :description
+            where community_type = :department_key
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/department-new.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department-new.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department-new.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,28 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+<property name="focus">add_department.pretty_name</property>
+
+<formtemplate id="add_department"></formtemplate>
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/department-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department-new.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department-new.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,75 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    create a new department
+
+    @author yon (yon@openforce.net)
+    @creation-date 2001-01-20
+    @version $Id: department-new.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {referer "departments"}
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+}
+
+set title "[_ dotlrn.New] [parameter::get -localize -parameter departments_pretty_name]"
+set context_bar [list [list departments [parameter::get -localize -parameter departments_pretty_plural]] [_ dotlrn.New]]
+
+form create add_department
+
+element create add_department pretty_name \
+    -label "[_ dotlrn.Name]" \
+    -datatype text \
+    -widget text \
+    -html {size 60 maxlength 100}
+
+element create add_department description \
+    -label "[_ dotlrn.Description]" \
+    -datatype text \
+    -widget textarea \
+    -html {rows 5 cols 60 wrap soft} \
+    -optional
+
+element create add_department external_url \
+    -label "[_ dotlrn.External_URL]" \
+    -datatype text \
+    -widget text \
+    -html {size 60} \
+    -optional
+
+element create add_department referer \
+    -label "[_ dotlrn.Referer]" \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid add_department]} {
+    form get_values add_department \
+         pretty_name description external_url referer
+
+    set department_key [dotlrn_department::new \
+        -pretty_name $pretty_name \
+        -description $description \
+        -external_url $external_url]
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/department.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,58 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@pretty_name@</property>
+<property name="context_bar">@context_bar@</property>
+
+<ul>
+
+  <li>
+    #dotlrn.External_URL_1#
+<if @external_url@ not nil>
+    <a href="@external_url@">@external_url@</a>
+</if>
+<else>
+    &lt;#dotlrn.none_set_up#&gt;
+</else>
+  </li>
+
+  <li>
+    #dotlrn.Description_1#
+<if @description@ not nil>
+    @description@
+</if>
+<else>
+    &lt;#dotlrn.none_set_up#&gt;
+</else>
+  </li>
+
+  <br>
+
+  <li>
+    <a
+    href="department-edit?department_key=@department_key@&referer=@referer@">#dotlrn.lt_Edit_department_prope#</a>
+  </li>
+
+</ul>
+
+<br>
+
+<include src="classes-chunk" department_key="@department_key@">
Index: openacs-4/packages/dotlrn-admin/www/admin/department.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,49 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays single dotLRN class page
+
+    @author Ben Adida (ben@openforce.net)
+    @author yon (yon@openforce.net)
+    @creation-date 2001-11-07
+    @version $Id: department.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {department_key ""}
+} -properties {
+    pretty_name:onevalue
+    external_url:onevalue
+    description:onevalue
+    classes:multirow
+}
+
+if {[empty_string_p $department_key]} {
+    ad_returnredirect "[dotlrn::get_admin_url]/classes"
+    ad_script_abort
+}
+
+# Get information about that class
+if {![db_0or1row select_departments_info {}]} {
+    ad_returnredirect departments
+    ad_script_abort
+}
+
+set description [ad_quotehtml $description]
+
+set context_bar [list [list departments [parameter::get -localize -parameter departments_pretty_plural]] $pretty_name]
+set referer "[ns_conn url]?[ns_conn query]"
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/department.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/department.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/department.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_departments_info">
+        <querytext>
+            select pretty_name,
+                   description,
+                   external_url
+            from dotlrn_departments_full
+            where department_key = :department_key
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/departments.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/departments.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/departments.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,108 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+
+<center>
+
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left" style="white-space: nowrap; font-size: x-small;">
+        [
+          <a href="department-new?referer=@referer@">#dotlrn.new_department#</a>
+        ]
+      </td>
+    </tr>
+  </table>
+
+  <br>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+
+    <tr>
+      <th align="left">#dotlrn.department_name#</th>
+      <th align="center" width="10%">#dotlrn.Actions#</th>
+    </tr>
+
+    <if @departments:rowcount@ gt 0>
+
+      <multiple name="departments">
+
+        <if @departments.rownum@ odd>
+          <tr bgcolor="#eeeeee">
+        </if>
+        <else>
+          <tr bgcolor="#d9e4f9">
+        </else>
+        
+        <td align="left">
+          <a href="department?department_key=@departments.department_key@">@departments.pretty_name@</a>
+        </td>
+        
+        <td align="center" style="white-space: nowrap; font-size: x-small;">
+        
+          <if @can_create@>
+            [
+              <a href="class-new?department_key=@departments.department_key@&referer=department?department_key=@departments.department_key@">#dotlrn.new_class_1#</a>
+            
+            <if @departments.n_classes@ eq 0>
+            |
+              <a href="department-delete?department_key=@departments.department_key@&pretty_name=@departments.pretty_name@&referer=departments">#dotlrn.Delete#</a>
+            </if>
+            ]
+          </if>
+        </td>
+
+          </tr>
+      
+      </multiple>
+
+    </if>
+    <else>
+      <tr bgcolor="#eeeeee">
+        <td align="left" colspan="2">
+          <em>#dotlrn.no_departments#</em>
+        </td>
+      </tr>
+    </else>
+  </table>
+
+<if @departments:rowcount@ gt 10>
+  <br>
+
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left">
+        <nobr>
+          <small>[
+            <a href="department-new?referer=@referer@">#dotlrn.new_department#</a>
+          ]</small>
+        </nobr>
+      </td>
+    </tr>
+  </table>
+</if>
+
+</center>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/departments.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/departments.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/departments.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,41 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays dotLRN departments admin page
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-01-20
+    @version $Id: departments.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+    departments:multirow
+}
+
+set title [parameter::get -localize -parameter departments_pretty_plural]
+set context_bar [parameter::get -localize -parameter departments_pretty_plural]
+set referer departments
+set can_create [dotlrn_class::can_create]
+set departments_pretty_name [parameter::get -localize -parameter departments_pretty_name]
+set departments_pretty_plural [parameter::get -localize -parameter departments_pretty_plural]
+set classes_pretty_name [parameter::get -localize -parameter classes_pretty_name]
+
+db_multirow departments select_departments {}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/departments.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/departments.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/departments.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_departments">
+        <querytext>
+            select department_key,
+                   pretty_name,
+                   (select count(*)
+                    from dotlrn_classes
+                    where department_key = dotlrn_departments_full.department_key) as n_classes
+            from dotlrn_departments_full
+            order by pretty_name,
+                     department_key
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admin-master.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admin-master.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admin-master.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,30 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master>
+  <property name="title">@title@</property>
+  <property name="link_all">1</property>
+  <if @focus@ not nil><property name="focus">@focus;noquote@</property></if>
+  <if @context@ not nil><property name="context">@context;noquote@</property></if>
+    <else><if @context_bar@ not nil><property name="context">@context_bar;noquote@</property></if></else>
+  <if @doc_type@ not nil><property name="doc_type">@doc_type;noquote@</property></if>
+
+<slave>
+
Index: openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,45 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<!--
+  @author Hector Amado (hr_amado@galileo.edu)
+  @creation-date 2004-06-28
+-->
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Administrators#</property>
+<property name="context_bar">@context_bar@</property>
+
+
+ <form method="get" action="admin-add">
+   #dotlrn.Add_A_Member# <input type="text" name="search_text"><input type="submit" value="#dotlrn.search#">
+   <input type="hidden" name="referer" value="@referer@">
+</form>
+
+
+<blockquote>
+    <center>
+         <listtemplate name="dotlrn_admins"></listtemplate>
+    </center>
+</blockquote>
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,68 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays Administrators dotLRN admin page
+
+    @author Hector Amado (hr_amado@galileo.edu)
+    @creation-date 2004-06-28
+    @cvs-id $Id: dotlrn-admins.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+}
+
+set context_bar "[_ dotlrn.Administrators]"
+set referer [ns_conn url]
+
+set dotlrn_admins_group [db_string group_id_from_name "
+            select group_id from groups where group_name='dotlrn-admin'" -default ""]
+
+set admin_id [ad_verify_and_get_user_id]
+
+set elements [list user \
+		  [list label "User" \
+                   link_url_col user_url ] \
+                   remove \
+                  [list label "Remove" \
+                   link_url_col remove_url \
+		       display_template { <if @dotlrn_admins.no_auto_remove@ true><center><img src="/resources/acs-subsite/Delete16.gif" width="16" height="16" border="0"></center></if> } \
+                       sub_class narrow ] \
+		  ]
+
+set multirow_name dotlrn_admins
+set actions ""
+
+template::list::create \
+     -name dotlrn_admins \
+     -multirow $multirow_name \
+     -actions $actions \
+     -no_data "No dotlrn-admins." \
+     -elements $elements
+
+db_multirow \
+    -extend {
+       user
+       remove_url
+       user_url
+       no_auto_remove 
+    } dotlrn_admins dotlrn_admins_select {} {
+        append user $last_name ", " $first_names " (" $email " )"
+	set remove_url [export_vars -base "admin-remove" {user_id}]
+        set user_url [export_vars -base "user" {user_id}] 
+       if { $user_id == $admin_id } {
+            set no_auto_remove 0
+	} else {
+            set no_auto_remove 1
+	}  
+ }
Index: openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/dotlrn-admins.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+   <fullquery name="dotlrn_admins_select">
+       <querytext>
+          select
+             registered_users.user_id,
+             registered_users.last_name,
+             registered_users.first_names,
+             registered_users.email
+          from 
+            registered_users,
+            group_member_map 
+          where
+            registered_users.user_id = group_member_map.member_id
+          AND
+            group_member_map.group_id = :dotlrn_admins_group 
+
+       </querytext>
+   </fullquery>
+
+</queryset>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-admin/www/admin/edit-preapproved-emails.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/edit-preapproved-emails.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/edit-preapproved-emails.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,56 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<!--
+
+  Copyright (C) 2001, 2002 MIT
+
+  This file is part of dotLRN.
+
+  dotLRN is free software; you can redistribute it and/or modify it under the
+  terms of the GNU General Public License as published by the Free Software
+  Foundation; either version 2 of the License, or (at your option) any later
+  version.
+
+  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+  details.
+
+-->
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.lt_Edit_Pre-approved_Ema#</property>
+<property name="context_bar">{#dotlrn.lt_Edit_Pre-approved_Ema#}</property>
+
+<p>
+  #dotlrn.lt_Email_suffixes_listed#
+</p>
+
+<p>
+  #dotlrn.the_format_of_email_domains#
+  <code>*@openforce.net,*@dotlrn.openforce.net</code>
+</p>
+
+<formtemplate id="edit_emails"></formtemplate>
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/edit-preapproved-emails.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/edit-preapproved-emails.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/edit-preapproved-emails.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,51 @@
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/edit-preapproved-emails.tcl
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date 2002-03-05
+    @version $Id: edit-preapproved-emails.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {referer [dotlrn::get_admin_url]}
+} -properties {
+    context_bar:onevalue
+}
+
+form create edit_emails
+
+element create edit_emails emails \
+    -label "[_ dotlrn.lt_Pre-approved_Email_Se]" \
+    -datatype text \
+    -widget text \
+    -html {size 50} \
+    -value [parameter::get -parameter auto_dotlrn_user_email_patterns]
+
+element create edit_emails referer \
+    -label [_ dotlrn.Referer] \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid edit_emails]} {
+    form get_values edit_emails \
+        emails referer
+
+    parameter::set_value -parameter auto_dotlrn_user_email_patterns -value $emails
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/guest-toggle.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/guest-toggle.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/guest-toggle.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,38 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/site-wide-admin-toggle.tcl
+
+ad_page_contract {
+    @author Caroline Meeks (caroline@meekshome.com)
+    @creation-date November 19, 2002
+    @version $Id: guest-toggle.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    user_id
+    guest_p
+    {referer "users"}
+}
+
+# Update permissions
+dotlrn_privacy::set_user_guest_p \
+        -user_id $user_id \
+        -value $guest_p
+
+
+util_memoize_flush_regexp  $user_id
+ad_returnredirect $referer
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/index.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/index.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,51 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<!--
+  @author Ben Adida (ben@openforce.net)
+  @author yon (yon@openforce.net)
+  @version $Id: index.adp,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+-->
+
+<master src="dotlrn-admin-master">
+<property name="title">@admin_pretty_name@</property>
+<property name="context_bar">@context_bar@</property>
+
+<ul>
+  <li><a href="dotlrn-admins">#dotlrn.Administrators#</a></li> 
+  <li><a href="users">#dotlrn.users#</a></li>
+  <li><a href="terms">#dotlrn.terms#</a></li>
+  <li><a href="departments"><%= [parameter::get -localize -parameter departments_pretty_plural] %></a></li>
+  <li><a href="classes"><%= [parameter::get -localize -parameter classes_pretty_plural] %></a></li>
+  <li><a href="term?term_id=-1"><%= [parameter::get -localize -parameter class_instances_pretty_plural] %></a></li>
+  <li><a href="clubs"><%= [parameter::get -localize -parameter clubs_pretty_plural] %></a></li> 
+  <li><a href="portal-templates">#dotlrn.portal_templates#</a></li>
+  <li><a href="archived-communities">#dotlrn.archived_classes_and_communities#</a></li>
+  <li><a href="edit-preapproved-emails">#dotlrn.edit_approved_email_servers#</a></li>
+  <li><a href="@parameters_url@">#dotlrn.edit_parameters#</a></li>
+  <li><a href="@parameters_d_url@">#dotlrn.edit_community_parameters#</a></li>
+  <p>
+  <if @oacs_site_wide_admin_p@ true>
+    <li><a href="/acs-admin/">OpenACS Site-Wide Administration</a></li>
+  </if>
+  </p>
+</ul>
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/index.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/index.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,37 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays main dotLRN admin page
+
+    @author Ben Adida (ben@openforce.net)
+    @creation-date 2001-11-04
+}
+
+set oacs_site_wide_admin_p [acs_user::site_wide_admin_p]
+
+set admin_pretty_name [parameter::get -localize -parameter dotlrn_admin_pretty_name]
+set context_bar {}
+
+# Some en_US messages reuse these configurable pretty names
+set class_instances_pretty_plural [parameter::get -localize -parameter class_instances_pretty_plural]
+set clubs_pretty_plural [parameter::get -localize -parameter clubs_pretty_plural]
+
+set parameters_url [export_vars -base /shared/parameters { { package_id {[dotlrn::get_package_id]} } { return_url [ad_return_url] } }] 
+
+set parameters_d_url [export_vars -base /shared/parameters { { package_id {[apm_package_id_from_key dotlrn-portlet]} } { return_url [ad_return_url] } }]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/need-term-note.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/need-term-note.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/need-term-note.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,23 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<i>
+  #dotlrn.you_need_to_create_terms_to_create_classes#
+</i>
Index: openacs-4/packages/dotlrn-admin/www/admin/need-term-note.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/need-term-note.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/need-term-note.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,5 @@
+
+# Used by the en_US version of the message in the adp file
+set terms_url "terms"
+set terms_pretty_plural [_ dotlrn.terms]
+set class_instances_pretty_plural [parameter::get -localize -parameter class_instances_pretty_plural]
Index: openacs-4/packages/dotlrn-admin/www/admin/password-update-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/password-update-2.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/password-update-2.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,63 @@
+ad_page_contract {
+    Updates the users password if password_1 matches password_2
+   
+    @cvs-id $Id: password-update-2.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} {
+    user_id:integer,notnull
+    password_1:notnull
+    password_2:notnull
+    {return_url ""}
+
+} -validate {
+    confirm_password -requires {password_2:notnull} {
+        if {[empty_string_p $password_2]} {
+            ad_complain "[_ dotlrn.lt_You_need_to_confirm_t]"
+        }
+    }
+    new_password_match -requires {password_1:notnull password_2:notnull confirm_password} {
+        if {![string equal $password_1 $password_2]} {
+            ad_complain "[_ dotlrn.lt_Your_passwords_dont_m]"
+        }
+    }
+}
+
+ad_change_password $user_id $password_1
+
+
+set system_owner [ad_system_owner]
+set system_name [ad_system_name]
+
+set subject "[_ dotlrn.lt_Your_password_on_syst]"
+set change_password_url "[ad_url]/user/password-update?[export_vars {user_id {password_old $password_1}}]"
+set body "[_ dotlrn.lt_Please_follow_the_fol]"
+
+set email [acs_user::get_element -user_id $user_id -element email]
+
+# Send email
+if [catch {ns_sendmail $email $system_owner $subject $body} errmsg] {
+	ns_log Error "[_ dotlrn.lt_Error_sending_email_t]" $errmsg
+	ad_return_error \
+        "[_ dotlrn.Error_sending_mail]" \
+        "[_ dotlrn.lt_There_was_an_error_se]" 
+} else {
+
+    set system_name [ad_system_name]
+    set admin_subject "[_ dotlrn.lt_The_following_email_w]"
+    set admin_message "[_ dotlrn.lt_The_following_email_w_1]"
+
+
+    if [catch {ns_sendmail $system_owner $system_owner $admin_subject $admin_message} errmsg] {
+	
+	ns_log Error "Error sending email from password-update-2.tcl" $errmsg
+	ad_return_error \
+		"[_ dotlrn.Error_sending_mail]" \
+		"[_ dotlrn.lt_There_was_an_error_se_1]"
+    }
+}
+
+
+if {[empty_string_p $return_url]} {
+    set return_url "user?user_id=$user_id"
+}
+
+ad_returnredirect $return_url
Index: openacs-4/packages/dotlrn-admin/www/admin/password-update.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/password-update.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/password-update.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,29 @@
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Update_Password#</property>
+<property name="context_bar">@context_bar@</property>
+
+
+<form method="post" action="password-update-2">
+  <input type="hidden" name="user_id" value="@user_id@">
+  <input type="hidden" name="return_url" value="@return_url@">
+
+<table>
+  <tr>
+    <th>#dotlrn.New_Password#</th>
+    <td><input type="password" name="password_1" size="15"></td>
+  </tr>
+
+  <tr>
+    <th>#dotlrn.Confirm_1#</th>
+    <td><input type="password" name="password_2" size="15"></td>
+  </tr>
+</table>
+
+<br>
+<br>
+
+<center>
+  <input type="submit" value="Update">
+</center>
+</form>
+
Index: openacs-4/packages/dotlrn-admin/www/admin/password-update.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/password-update.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/password-update.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,18 @@
+ad_page_contract {
+    Let's the admin change a user's password.
+   
+
+    @version $Id: password-update.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} {
+    {user_id:integer}
+    {return_url ""}
+    {password_old ""}
+} 
+
+db_1row user_information {}
+
+set context_bar [list [list users Users] [list "user.tcl?user_id=$user_id" "$first_names $last_name"] "[_ dotlrn.Update_Password]"]
+
+set site_link [ad_site_home_link]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/password-update.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/password-update.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/password-update.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<queryset>
+
+    <fullquery name="user_information">      
+        <querytext>
+            select first_names, 
+                   last_name,
+                   email,
+                   url
+            from cc_users
+            where user_id = :user_id
+        </querytext>
+    </fullquery>
+ 
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/portal-templates.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/portal-templates.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/portal-templates.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,45 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+
+<table width="50%" cellpadding="3" cellspacing="3">
+  <tr>
+    <th align="left">#dotlrn.Template#</th>
+    <th align="left">#dotlrn.Actions#</th>
+  </tr>
+<multiple name=templates>
+  <tr>
+    <td>
+      <a href="@url@/portal-show.tcl?portal_id=@templates.portal_id@&referer=@referer@">@templates.name@</a>
+    </td>
+    <td>
+      [<small>
+        <a href="@url@/portal-config?portal_id=@templates.portal_id@&referer=@referer@">#dotlrn.Edit#</a>
+      </small>]
+    </td>
+  </tr>
+</multiple>
+</table>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/portal-templates.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/portal-templates.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/portal-templates.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,37 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays dotLRN portal templates admin page
+
+    @author arjun (arjun@openforce.net)
+    @version $Id: portal-templates.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+    departments:multirow
+}
+
+set title [_ dotlrn.Templates]
+set context_bar $title
+set url "[portal::mount_point]admin"
+set referer [ad_conn url]
+
+db_multirow templates select_portal_templates {} {
+    set name [lang::util::localize $name]
+}
+
Index: openacs-4/packages/dotlrn-admin/www/admin/portal-templates.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/portal-templates.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/portal-templates.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_portal_templates">
+        <querytext>
+            select dptm.portal_id, p.name
+            from portals p, dotlrn_portal_types_map dptm
+            where p.portal_id = dptm.portal_id
+            order by p.name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/site-wide-admin-toggle.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/site-wide-admin-toggle.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/site-wide-admin-toggle.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,47 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/site-wide-admin-toggle.tcl
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date Jan 12, 2002
+    @version $Id: site-wide-admin-toggle.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    user_id
+    value
+    {referer "users"}
+}
+
+if { ![acs_user::site_wide_admin_p] } {
+             ns_log notice "user has tried to site-wide-admin-toggle  without permission"
+        ad_return_forbidden \
+               "Permission Denied" \
+               "<blockquote>
+                You don't have permission to see this page.
+               </blockquote>"
+}
+
+if {[string equal $value "grant"] == 1} {
+    ad_permission_grant $user_id [acs_magic_object "security_context_root"] "admin"
+} elseif {[string equal $value "revoke"] == 1} {
+    ad_permission_revoke $user_id [acs_magic_object "security_context_root"] "admin"
+}
+
+util_memoize_flush_regexp  $user_id
+ad_returnredirect $referer
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/term-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/term-edit.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/term-edit.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,28 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Edit_Term#</property>
+<property name="context_bar">@context_bar@</property>
+
+<formtemplate id="edit_term"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/term-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/term-edit.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/term-edit.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,76 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+
+    edit a term
+
+    @author yon (yon@openforce.net)
+    @author Don Baccus (dhogaza@pacifier.com)
+
+    @creation-date 2002-03-14
+    @version $Id: term-edit.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+
+} -query {
+    term_id:integer,notnull
+} -properties {
+    context_bar:onevalue
+}
+
+if {![db_0or1row select_term_info {}]} {
+    ad_return_complaint 1 "<li>[_ dotlrn.Invalid] term_key $term_id</li>"
+    ad_script_abort
+}
+
+set referer "term?[export_vars {term_id}]"
+set context_bar [list [list terms [_ dotlrn.Terms]] [list $referer "$term_name $term_year"] [_ dotlrn.Edit]]
+
+ad_form -name edit_term -export term_pretty_name -select_query_name select_term_info -form {
+
+    term_id:key
+
+    {term_name:text               {label "Term (e.g. Spring, Fall)"}
+                                  {html {size 30}}}
+
+    {term_year:text               {label "Year (e.g. 2003, 2003/2004)"}
+                                  {html {size 9 maxlength 9}}}
+
+    {start_date:date              {label "Start Date"}
+                                  {format {MONTH DD YYYY}}}
+
+    {end_date:date                {label "End Date"}
+                                  {format {MONTH DD YYYY}}}
+
+} -validate {
+    {start_date
+        { [template::util::date::compare $start_date $end_date] <= 0 }
+        "The term must start before it ends"
+    }
+} -edit_data {
+
+    dotlrn_term::edit \
+        -term_id $term_id \
+        -term_name $term_name \
+        -term_year [string trim $term_year] \
+        -start_date $start_date \
+        -end_date $end_date
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/term-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/term-edit.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/term-edit.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_term_info">
+        <querytext>
+            select term_name,
+                   term_year,
+                   to_char(start_date, 'YYYY MM DD') as start_date,
+                   to_char(end_date, 'YYYY MM DD') as end_date
+            from dotlrn_terms
+            where term_id = :term_id
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/term-new.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/term-new.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/term-new.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,29 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.New_Term#</property>
+<property name="context_bar">@context_bar@</property>
+<property name="focus">add_term.term_name</property>
+
+<formtemplate id="add_term"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/term-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/term-new.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/term-new.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,68 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    create a new term - input form
+
+    @author yon (yon@openforce.net)
+    @creation-date 2001-12-13
+    @version $Id: term-new.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {referer "terms"}
+} -properties {
+    context_bar:onevalue
+}
+
+ad_form -name add_term -export referer -form {
+
+    {term_name:text          {label "Term (e.g. Spring, Fall)"} {maxlength 20}
+    {html {size 30}}}
+
+    {start_date:date
+                             {label "Start Date"}
+                             {format {MONTH DD YYYY}}}
+
+    {end_date:date
+                             {label "End Date"}
+                             {format {MONTH DD YYYY}}}
+} -validate {
+    {start_date
+        { [template::util::date::compare $start_date $end_date] <= 0 }
+        "The term must start before it ends"
+    }
+} -on_submit {
+
+    set term_year [dotlrn_term::start_end_dates_to_term_year \
+        -start_date $start_date \
+        -end_date $end_date
+    ]
+
+#    error [string bytelength $term_name]
+
+    dotlrn_term::new \
+        -term_name $term_name \
+        -term_year $term_year \
+        -start_date $start_date \
+        -end_date $end_date
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+set context_bar [list [list terms [_ dotlrn.Terms]] [_ dotlrn.New]]
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/term.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/term.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/term.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,134 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@title@</property>
+<property name="context_bar">@context_bar@</property>
+
+<if @term_id@ ne -1>
+<ul>
+
+  <li>
+    #dotlrn.Name#
+    @term_name@
+  </li>
+
+  <li>
+    #dotlrn.Year#
+    @term_year@
+  </li>
+
+  <li>
+    #dotlrn.Start_date#
+    @start_date@
+  </li>
+
+  <li>
+    #dotlrn.End_date#
+    @end_date@
+  </li>
+
+  <br>
+
+  <li>
+    <a href="term-edit?term_id=@term_id@&referer=@referer@">#dotlrn.Edit#</a> #dotlrn.term_properties#
+  </li>
+
+</ul>
+
+<br>
+</if>
+
+<center>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+    <tr bgcolor="#eeeeee">
+      <th align="left" width="50%">
+<formtemplate id="department_form">
+        <%= [parameter::get -localize -parameter departments_pretty_name] %>:&nbsp;<formwidget id="department_key">
+</formtemplate>
+      </th>
+      <th align="left" width="50%">
+<formtemplate id="term_form">
+        #dotlrn.term#:&nbsp;<formwidget id="term_id">
+</formtemplate>
+      </th>
+    </tr>
+  </table>
+
+  <br>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+    <tr>
+      <th align="left" width="20%"><%= [parameter::get -localize -parameter departments_pretty_name] %></th>
+      <th align="left" width="20%"><%= [parameter::get -localize -parameter classes_pretty_name] %></th>
+<if @term_id@ eq -1>
+      <th align="left" width="10%">#dotlrn.term#</th>
+</if>
+      <th align="left" width="25%"><%= [parameter::get -localize -parameter class_instances_pretty_name] %></th>
+      <th align="center" width="10%">#dotlrn.members#</th>
+      <th align="center">#dotlrn.actions#</th>
+    </tr>
+
+<if @classes:rowcount@ gt 0>
+
+<multiple name="classes">
+
+<if @classes.rownum@ odd>
+    <tr bgcolor="#eeeeee">
+</if>
+<else>
+    <tr bgcolor="#d9e4f9">
+</else>
+      <td align="left"><a href="department?department_key=@classes.department_key@">@classes.department_name@</a></td>
+      <td align="left"><a href="class?class_key=@classes.class_key@">@classes.class_name@</a></td>
+<if @term_id@ eq -1>
+      <td align="left">@classes.term_name@ @classes.term_year@</td>
+</if>
+      <td align="left"><a href="@classes.url@">@classes.pretty_name@</a></td>
+      <td align="center">@classes.n_members@</td>
+      <td align="center">
+        <nobr>
+          <small>
+            <a href="@classes.url@one-community-admin">#dotlrn.administer_link#</a>
+          </small>
+        </nobr>
+      </td>
+    </tr>
+
+</multiple>
+
+</if>
+<else>
+  <tr bgcolor="#eeeeee">
+<if @term_id@ eq -1>
+    <td align="left" colspan="6">
+</if>
+<else>
+    <td align="left" colspan="5">
+</else>
+      <i>#dotlrn.no_class_instances#</i>
+    </td>
+  </tr>
+</else>
+
+  </table>
+
+</center>
Index: openacs-4/packages/dotlrn-admin/www/admin/term.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/term.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/term.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,122 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays class instances of a term
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-03-07
+    @version $Id: term.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    term_id:integer,notnull
+    {department_key ""}
+} -properties {
+    classes:multirow
+}
+
+set departments [db_list_of_lists select_departments_for_select_widget {
+    select dotlrn_departments_full.pretty_name,
+           dotlrn_departments_full.department_key
+    from dotlrn_departments_full
+    order by dotlrn_departments_full.pretty_name,
+             dotlrn_departments_full.department_key
+}]
+set departments [linsert $departments 0 {All ""}]
+
+form create department_form
+
+element create department_form department_key \
+    -label "[_ dotlrn.Department]" \
+    -datatype text \
+    -widget select \
+    -options $departments \
+    -html {onChange document.department_form.submit()} \
+    -value $department_key
+
+element create department_form term_id \
+    -label "[_ dotlrn.Term_ID]" \
+    -datatype integer \
+    -widget hidden \
+    -value $term_id
+
+if {[form is_valid department_form]} {
+    form get_values department_form department_key term_id
+}
+
+set terms [db_list_of_lists select_terms_for_select_widget {
+    select dotlrn_terms.term_name || ' ' || dotlrn_terms.term_year,
+           dotlrn_terms.term_id
+    from dotlrn_terms
+    order by dotlrn_terms.start_date,
+             dotlrn_terms.end_date
+}]
+set terms [linsert $terms 0 {All -1}]
+
+form create term_form
+
+element create term_form term_id \
+    -label "[_ dotlrn.Term]" \
+    -datatype integer \
+    -widget select \
+    -options $terms \
+    -html {onChange document.term_form.submit()} \
+    -value $term_id
+
+element create term_form department_key \
+    -label "[_ dotlrn.Department]" \
+    -datatype text \
+    -widget hidden \
+    -value $department_key
+
+if {[form is_valid term_form]} {
+    form get_values term_form term_id department_key
+
+    if {$term_id != -1} {
+        ad_returnredirect "term?[export_vars {term_id department_key}]"
+    }
+}
+
+if {![exists_and_not_null referer]} {
+    set referer "terms"
+}
+
+set query "select_classes"
+if {$term_id == -1} {
+    set query "select_all_classes"
+}
+if {![empty_string_p $department_key]} {
+    append query "_by_department"
+}
+
+db_multirow classes $query {}
+
+if {$term_id == -1} {
+    set title "[_ dotlrn.All_Terms]"
+    set context_bar [list [list terms [_ dotlrn.Terms]] "[_ dotlrn.All_Terms]"]
+} else {
+    if {[db_0or1row select_term_info {}]} {
+        set title "$term_name $term_year ($start_date - $end_date)"
+        set context_bar [list [list terms [_ dotlrn.Terms]] "$term_name $term_year"]
+    } else {
+        set title "[_ dotlrn.Unknown_Term]"
+        set context_bar [list [list terms [_ dotlrn.Terms]] "[_ dotlrn.Unknown_Term]"]
+    }
+}
+
+# Used by the en_US version of the no_class_instances message in the adp
+set class_instances_pretty_plural [parameter::get -localize -parameter class_instances_pretty_plural]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/term.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/term.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/term.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_term_info">
+        <querytext>
+            select term_name,
+                   term_year,
+                   to_char(start_date, 'Mon DD YYYY') as start_date,
+                   to_char(end_date, 'Mon DD YYYY') as end_date
+            from dotlrn_terms
+            where term_id = :term_id
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_classes">
+        <querytext>
+            select dotlrn_class_instances_full.*,
+                   (select count(*)
+                    from dotlrn_member_rels_approved
+                    where dotlrn_member_rels_approved.community_id = dotlrn_class_instances_full.class_instance_id) as n_members
+            from dotlrn_class_instances_full
+            where dotlrn_class_instances_full.term_id = :term_id
+            order by dotlrn_class_instances_full.department_name,
+                     dotlrn_class_instances_full.department_key,
+                     dotlrn_class_instances_full.class_name,
+                     dotlrn_class_instances_full.class_key,
+                     dotlrn_class_instances_full.pretty_name,
+                     dotlrn_class_instances_full.community_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_classes_by_department">
+        <querytext>
+            select dotlrn_class_instances_full.*,
+                   (select count(*)
+                    from dotlrn_member_rels_approved
+                    where dotlrn_member_rels_approved.community_id = dotlrn_class_instances_full.class_instance_id) as n_members
+            from dotlrn_class_instances_full
+            where dotlrn_class_instances_full.term_id = :term_id
+            and dotlrn_class_instances_full.department_key = :department_key
+            order by dotlrn_class_instances_full.department_name,
+                     dotlrn_class_instances_full.department_key,
+                     dotlrn_class_instances_full.class_name,
+                     dotlrn_class_instances_full.class_key,
+                     dotlrn_class_instances_full.pretty_name,
+                     dotlrn_class_instances_full.community_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_all_classes">
+        <querytext>
+            select dotlrn_class_instances_full.*,
+                   (select count(*)
+                    from dotlrn_member_rels_approved
+                    where dotlrn_member_rels_approved.community_id = dotlrn_class_instances_full.class_instance_id) as n_members
+            from dotlrn_class_instances_full
+            order by dotlrn_class_instances_full.department_name,
+                     dotlrn_class_instances_full.department_key,
+                     dotlrn_class_instances_full.class_name,
+                     dotlrn_class_instances_full.class_key,
+                     dotlrn_class_instances_full.pretty_name,
+                     dotlrn_class_instances_full.community_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_all_classes_by_department">
+        <querytext>
+            select dotlrn_class_instances_full.*,
+                   (select count(*)
+                    from dotlrn_member_rels_approved
+                    where dotlrn_member_rels_approved.community_id = dotlrn_class_instances_full.class_instance_id) as n_members
+            from dotlrn_class_instances_full
+            where dotlrn_class_instances_full.department_key = :department_key
+            order by dotlrn_class_instances_full.department_name,
+                     dotlrn_class_instances_full.department_key,
+                     dotlrn_class_instances_full.class_name,
+                     dotlrn_class_instances_full.class_key,
+                     dotlrn_class_instances_full.pretty_name,
+                     dotlrn_class_instances_full.community_key
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/terms.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/terms.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/terms.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,96 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Terms#</property>
+<property name="context_bar">@context_bar@</property>
+
+<center>
+
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left">
+        <nobr>
+          <small>[
+            <a href="term-new">#dotlrn.New_Term#</a>
+          ]</small>
+        </nobr>
+      </td>
+    </tr>
+  </table>
+
+  <br>
+
+  <table bgcolor="#cccccc" cellpadding="5" width="95%">
+    <tr>
+      <th align="left">#dotlrn.Term#</th>
+      <th align="center" width="15%">#dotlrn.Start_Date#</th>
+      <th align="center" width="15%">#dotlrn.End_Date#</th>
+      <th align="center" width="15%">#dotlrn.Classes#</th>
+    </tr>
+
+<if @terms:rowcount@ gt 0>
+
+<multiple name="terms">
+
+<if @terms.rownum@ odd>
+    <tr bgcolor="#eeeeee">
+</if>
+<else>
+    <tr bgcolor="#d9e4f9">
+</else>
+      <td align="left"><a href="term?term_id=@terms.term_id@">@terms.term_name@ @terms.term_year@</a></td>
+      <td align="center">@terms.start_date_pretty@</td>
+      <td align="center">@terms.end_date_pretty@</td>
+      <td align="center">@terms.n_classes@</td>
+    </tr>
+
+</multiple>
+
+</if>
+<else>
+  <tr bgcolor="#eeeeee">
+    <td align="left" colspan="4">
+      <i>#dotlrn.No_Terms#</i>
+    </td>
+  </tr>
+</else>
+  </table>
+
+<if @terms:rowcount@ gt 10>
+  <br>
+
+  <table cellpadding="5" width="95%">
+    <tr>
+      <td align="left">
+        <nobr>
+          <small>[
+            <a href="term-new">#dotlrn.New_Term#</a>
+          ]</small>
+        </nobr>
+      </td>
+    </tr>
+  </table>
+</if>
+
+</center>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/terms.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/terms.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/terms.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,37 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/terms.tcl
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date Dec 13, 2001
+    @version $Id: terms.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+} -properties {
+    context_bar:onevalue
+    terms:multirow
+}
+
+set context_bar "[_ dotlrn.Terms]"
+
+db_multirow -extend { start_date_pretty end_date_pretty } terms select_terms {} {
+    set start_date_pretty [lc_time_fmt $start_date_ansi "%q"]
+    set end_date_pretty [lc_time_fmt $end_date_ansi "%q"]
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/terms.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/terms.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/terms.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_terms">
+        <querytext>
+            select dotlrn_terms.term_id,
+                   dotlrn_terms.term_name,
+                   dotlrn_terms.term_year,
+                   to_char(dotlrn_terms.start_date, 'YYYY-MM-DD') as start_date_ansi,
+                   to_char(dotlrn_terms.end_date, 'YYYY-MM-DD') as end_date_ansi,
+                   (select count(*)
+                    from dotlrn_class_instances
+                    where dotlrn_class_instances.term_id = dotlrn_terms.term_id) as n_classes
+            from dotlrn_terms
+            order by dotlrn_terms.start_date
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/unarchive.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/unarchive.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/unarchive.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,39 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Unarchive a Community
+
+    @author Nima Mazloumi
+    @creation-date 2004-04-25
+    @version $Id: unarchive.tcl
+} -query {
+    {community_id ""}
+    {referer "."}
+}
+
+if { [exists_and_not_null community_id] } {
+    set is_archived_p [db_0or1row select_is_archived "select archived_p from dotlrn_communities_all where community_id = :community_id"]
+    if { $is_archived_p } {
+        ns_log Notice "Unarchiving $community_id"
+        dotlrn_community::unarchive -community_id $community_id
+    } else {
+        ad_return -code error "community must be archived to get unarchived"
+    }
+} else {
+    ad_return -code error "community id expected to unarchive a community"
+}
+ad_returnredirect $referer
Index: openacs-4/packages/dotlrn-admin/www/admin/user-edit-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-edit-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-edit-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_user_info">
+        <querytext>
+            select dotlrn_users.id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_users.type,
+                   dotlrn_privacy.guest_p(:user_id) as guest_p
+            from dotlrn_users
+            where dotlrn_users.user_id = :user_id
+        </querytext>
+  </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/user-edit-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-edit-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-edit-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_user_info">
+        <querytext>
+            select dotlrn_users.id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_users.type,
+                   dotlrn_privacy__guest_p(:user_id) as guest_p
+            from dotlrn_users
+            where dotlrn_users.user_id = :user_id
+        </querytext>
+  </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/user-edit-verify.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-edit-verify.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-edit-verify.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,34 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Edit_a_User#</property>
+<property name="context_bar">@context_bar@</property>
+
+#dotlrn.Youre_editing# <strong>@first_names@ @last_name@</strong>.
+
+<p></p>
+
+#dotlrn.lt_Youre_asking_to_chang#
+
+<formtemplate id="verif_edit_user"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/user-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-edit.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-edit.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,34 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Edit_a_User#</property>
+<property name="context_bar">@context_bar@</property>
+
+#dotlrn.Youre_editing# <strong>@first_names@ @last_name@</strong>.
+<p>
+<font color=red>#dotlrn.Note_if_you_make#</font>
+
+<p></p>
+
+<formtemplate id="edit_user"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/user-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-edit.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-edit.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,105 @@
+
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Edit a dotLRN user
+
+    @author Ben Adida (ben@openforce.net)
+    @author yon (yon@openforce.net)
+    @creation-date 2001-12-10
+    @version $Id: user-edit.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {return_url "[dotlrn::get_admin_url]/users"}
+    user_id
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [_ dotlrn.Edit]]
+set dotlrn_package_id [dotlrn::get_package_id]
+
+db_1row select_user_info {}
+set can_browse_p [dotlrn::user_can_browse_p -user_id $user_id]
+
+form create edit_user
+
+element create edit_user user_id \
+    -label "[_ dotlrn.User_ID_1]" \
+    -datatype integer \
+    -widget hidden \
+    -value $user_id
+
+element create edit_user id \
+    -label [_ dotlrn.ID_1] \
+    -datatype text \
+    -widget text \
+    -html {size 30} \
+    -value $id \
+    -optional
+
+element create edit_user type \
+    -label "[_ dotlrn.User_Type]" \
+    -datatype text \
+    -widget select \
+    -options [dotlrn::get_user_types_as_options] \
+    -value $type
+
+element create edit_user can_browse_p \
+    -label "[_ dotlrn.Access_Level]" \
+    -datatype text \
+    -widget select \
+    -options [list [list [_ dotlrn.Full] 1] [list [_ dotlrn.Limited] 0]] \
+    -value $can_browse_p
+
+element create edit_user guest_p \
+    -label "[_ dotlrn.Guest_1]" \
+    -datatype text \
+    -widget select \
+    -options [list [list [_ dotlrn.No] f] [list [_ dotlrn.Yes] t]] \
+    -value $guest_p
+
+element create edit_user return_url \
+    -label "[_ dotlrn.Return_URL]" \
+    -datatype text \
+    -widget hidden \
+    -value $return_url
+
+if {[form is_valid edit_user]} {
+    form get_values edit_user \
+        user_id id type can_browse_p guest_p return_url
+
+    db_transaction {
+        # remove the user
+        dotlrn::user_remove -user_id $user_id
+
+        # add the user
+        dotlrn::user_add \
+            -id $id \
+            -type $type \
+            -can_browse\=$can_browse_p \
+            -user_id $user_id
+
+        # Update permissions
+        dotlrn_privacy::set_user_guest_p \
+            -user_id $user_id \
+            -value $guest_p
+    }
+
+    # redirect
+    ad_returnredirect $return_url
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/user-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-edit.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-edit.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="update_user">
+        <querytext>
+            update dotlrn_user_profile_rels
+            set id = :id
+            where rel_id = (select rel_id
+                            from dotlrn_users
+                            where user_id = :user_id)
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/user-new-2.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-new-2.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-new-2.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,32 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Add_a_User#</property>
+<property name="context_bar">@context_bar@</property>
+
+#dotlrn.Youve_chosen_to_add# <strong>@first_names@ @last_name@</strong>.
+
+<p></p>
+
+<formtemplate id="add_user"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/user-new-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-new-2.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-new-2.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,140 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Create a dotLRN user
+
+    @author Ben Adida (ben@openforce.net)
+    @creation-date 2001-11-04
+    @version $Id: user-new-2.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    user_id
+    {referer "[dotlrn::get_admin_url]/users"}
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [_ dotlrn.New]]
+
+db_1row select_user_info {
+    select email,
+           first_names,
+           last_name
+    from registered_users
+    where user_id = :user_id
+}
+
+form create add_user
+
+element create add_user user_id \
+    -label "[_ dotlrn.User_ID_1]" \
+    -datatype integer \
+    -widget hidden \
+    -value $user_id
+
+element create add_user id \
+    -label [_ dotlrn.ID_1] \
+    -datatype text \
+    -widget text \
+    -html {size 30} \
+    -value $email \
+    -optional
+
+element create add_user type \
+    -label "[_ dotlrn.User_Type]" \
+    -datatype text \
+    -widget select \
+    -options [dotlrn::get_user_types_as_options]
+
+element create add_user can_browse_p \
+    -label "[_ dotlrn.Access_Level]" \
+    -datatype text \
+    -widget select \
+    -options [list [list "[_ dotlrn.Full_Access]" 1] [list "[_ dotlrn.Limited_Access]" 0]]
+
+element create add_user guest_p \
+    -label "[_ dotlrn.Guest_1]" \
+    -datatype text \
+    -widget select \
+    -options [list [list [_ dotlrn.No] f] [list [_ dotlrn.Yes] t]]
+
+element create add_user referer \
+    -label [_ dotlrn.Referer] \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+
+if {[form is_valid add_user]} {
+
+    form get_values add_user \
+        user_id id type can_browse_p guest_p referer
+
+    set subject "Your [ad_system_name] membership has been approved"
+    set message "Your [ad_system_name] membership has been approved. Please return to [ad_url] to log into [ad_system_name]."
+
+    set email_from [ad_parameter -package_id [ad_acs_kernel_id] SystemOwner]
+
+    db_transaction {
+
+        dotlrn::user_add \
+            -id $id \
+            -type $type \
+            -can_browse\=$can_browse_p \
+            -user_id $user_id
+
+        dotlrn_privacy::set_user_guest_p \
+            -user_id $user_id \
+            -value $guest_p
+    }
+    
+    
+    if [catch {ns_sendmail $email $email_from $subject $message} errmsg] {
+	
+	ns_log Error "Error sending email from user-new-2.tcl" $errmsg
+	ad_return_error \
+        "Error sending mail" \
+        "There was an error sending email to $email."
+    } else {
+
+	set admin_subject "The following email was just sent from [ad_system_name]"
+
+	set admin_message "The following email was just sent from [ad_system_name]
+
+Sent by: $email_from
+Sent to: $email
+Subject: $subject
+Message: $message"
+
+
+        if [catch {ns_sendmail $email_from $email_from $admin_subject $admin_message} errmsg] {
+	
+	    ns_log Error "Error sending email from user-new-2.tcl" $errmsg
+	    ad_return_error \
+		    "Error sending mail" \
+		    "There was an error sending email to $email."
+	}
+
+    }
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [_ dotlrn.New]]
+
+ad_return_template
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/user-new.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-new.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-new.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,34 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Add_a_User#</property>
+<property name="context_bar">@context_bar@</property>
+
+#dotlrn.lt_The_results_of_your_s#
+<ul>
+<multiple name="users">
+  <li><a href=user-new-2?user_id=@users.user_id@>@users.last_name@, @users.first_names@ (@users.email@)</li>
+</multiple>
+</ul>
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/user-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-new.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-new.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,33 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Search for a new user for dotLRN
+
+    @author Ben Adida (ben@openforce.net)
+    @creation-date 2001-11-04
+} -query {
+    {referer "users"}
+    search_text
+}
+
+# Just search
+db_multirow users select_users {}
+
+set context_bar [list [list users [_ dotlrn.Users]] [_ dotlrn.New]]
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/user-new.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-new.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-new.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_users">
+        <querytext>
+            select user_id,
+                   first_names,
+                   last_name,
+                   email
+            from registered_users
+            where lower(last_name) like lower('%' || :search_text || '%')
+            or lower(email) like lower('%' || :search_text || '%')
+            and user_id not in (select user_id
+                                from dotlrn_users)
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/user-nuke-error.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-nuke-error.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-nuke-error.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,17 @@
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.lt_Error_Nuking_first_na#</property>
+<property name="context_bar">@context_bar@</property>
+
+<h3>#dotlrn.Sorry#</h3>
+
+<p>
+
+#dotlrn.lt_Well_we_tried_to_nuke#
+<p>
+<blockquote>
+<pre>
+@error_msg@
+</pre>
+</blockquote>
+<p>
+<a href="@referer@">#dotlrn.lt_Return_to_where_you_w#</a>
Index: openacs-4/packages/dotlrn-admin/www/admin/user-nuke-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-nuke-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-nuke-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="nuke_user">
+        <querytext>
+           begin 
+             acs.remove_user(:user_id); 
+           end; 
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/user-nuke-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-nuke-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-nuke-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="nuke_user">
+        <querytext>
+           select acs__remove_user(:user_id);
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/user-nuke.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-nuke.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-nuke.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,11 @@
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.lt_Nuke_first_names_last#</property>
+<property name="context_bar">@context_bar@</property>
+
+<h3>#dotlrn.Confirmation#</h3>
+
+<p>
+
+#dotlrn.lt_Please_confirm_that_y#
+
+<formtemplate id="confirm_delete"></formtemplate>
\ No newline at end of file
Index: openacs-4/packages/dotlrn-admin/www/admin/user-nuke.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-nuke.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-nuke.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,54 @@
+ad_page_contract {
+
+    Try to delete a pending user from the database.
+    
+    @author Andrew Grumet (aegrumet@alum.mit.edu)
+    @creation-date 2002-08-08
+    @version $Id: user-nuke.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} {
+    user_id:integer,notnull
+    {referer "[dotlrn::get_admin_url]/users"}
+}
+
+db_1row select_user_info {
+    select email,
+           first_names,
+           last_name
+    from cc_users
+    where user_id = :user_id
+}
+
+form create confirm_delete
+
+element create confirm_delete user_id \
+    -label "[_ dotlrn.User_ID_1]" \
+    -datatype integer \
+    -widget hidden \
+    -value $user_id
+
+element create confirm_delete confirmed_p \
+    -label "[_ dotlrn.Are_you_sure]" \
+    -datatype text \
+    -widget radio \
+    -options [list [list [_ dotlrn.No] f] [list [_ dotlrn.Yes] t]] \
+    -value f
+
+set context_bar [list [list users [_ dotlrn.Users]] [_ dotlrn.Nuke]]
+
+if [form is_valid confirm_delete] {
+    form get_values confirm_delete user_id confirmed_p
+    if [string equal $confirmed_p t] {
+	if [catch { dotlrn::remove_user_completely -user_id $user_id } errMsg ] {
+        set error_msg $errMsg
+	    ad_return_template user-nuke-error
+	} else {
+	    # Nuke was successful.
+	    ad_returnredirect $referer
+	    ad_script_abort
+	}
+    } else {
+	# Nuke cancelled
+	ad_returnredirect $referer
+	ad_script_abort
+    }
+}
Index: openacs-4/packages/dotlrn-admin/www/admin/user-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_dotlrn_user_info">
+        <querytext>
+            select dotlrn_users.*, guest_p
+            from dotlrn_users, dotlrn_guest_status
+            where dotlrn_users.user_id = :user_id
+              and dotlrn_guest_status.user_id(+) = dotlrn_users.user_id
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_portrait_info">      
+        <querytext>
+            select cr_items.live_revision as revision_id,
+                   nvl(cr_revisions.title, 'view this portrait') as portrait_title
+            from acs_rels,
+                 cr_items,
+                 cr_revisions
+            where acs_rels.object_id_two = cr_items.item_id
+            and cr_items.live_revision = cr_revisions.revision_id
+            and acs_rels.object_id_one = :user_id
+            and acs_rels.rel_type = 'user_portrait_rel'
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_member_classes">
+        <querytext>
+            select dotlrn_class_instances_full.*,
+                   dotlrn_member_rels_approved.rel_type,
+                   dotlrn_member_rels_approved.role,
+                   '' as role_pretty_name
+            from dotlrn_class_instances_full,
+                 dotlrn_member_rels_approved
+            where dotlrn_member_rels_approved.user_id = :user_id
+            and dotlrn_member_rels_approved.community_id = dotlrn_class_instances_full.class_instance_id
+            order by dotlrn_class_instances_full.department_name,
+                     dotlrn_class_instances_full.department_key,
+                     dotlrn_class_instances_full.pretty_name,
+                     dotlrn_class_instances_full.community_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_member_clubs">
+        <querytext>
+            select dotlrn_clubs_full.*,
+                   dotlrn_member_rels_approved.rel_type,
+                   dotlrn_member_rels_approved.role,
+                   '' as role_pretty_name
+            from dotlrn_clubs_full,
+                 dotlrn_member_rels_approved
+            where dotlrn_member_rels_approved.user_id = :user_id
+            and dotlrn_member_rels_approved.community_id = dotlrn_clubs_full.club_id
+            order by dotlrn_clubs_full.pretty_name,
+                     dotlrn_clubs_full.community_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_member_subgroups">
+        <querytext>
+            select dotlrn_communities.*,
+                   dotlrn_community.url(dotlrn_communities.community_id) as url,
+                   dotlrn_member_rels_approved.rel_type,
+                   dotlrn_member_rels_approved.role,
+                   '' as role_pretty_name
+            from dotlrn_communities,
+                 dotlrn_member_rels_approved
+            where dotlrn_member_rels_approved.user_id = :user_id
+            and dotlrn_member_rels_approved.community_id = dotlrn_communities.community_id
+            and dotlrn_communities.community_type = 'dotlrn_community'
+            order by dotlrn_communities.pretty_name,
+                     dotlrn_communities.community_key
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/user-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_dotlrn_user_info">
+        <querytext>
+            select dotlrn_users.*, guest_p
+            from dotlrn_users left outer join dotlrn_guest_status
+              on dotlrn_guest_status.user_id = dotlrn_users.user_id
+            where dotlrn_users.user_id = :user_id
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_portrait_info">      
+        <querytext>
+            select cr_items.live_revision as revision_id,
+                   coalesce(cr_revisions.title, 'view this portrait') as portrait_title
+            from acs_rels,
+                 cr_items,
+                 cr_revisions
+            where acs_rels.object_id_two = cr_items.item_id
+            and cr_items.live_revision = cr_revisions.revision_id
+            and acs_rels.object_id_one = :user_id
+            and acs_rels.rel_type = 'user_portrait_rel'
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_member_classes">
+        <querytext>
+            select dotlrn_class_instances_full.*,
+                   dotlrn_member_rels_approved.rel_type,
+                   dotlrn_member_rels_approved.role,
+                   '' as role_pretty_name
+            from dotlrn_class_instances_full,
+                 dotlrn_member_rels_approved
+            where dotlrn_member_rels_approved.user_id = :user_id
+            and dotlrn_member_rels_approved.community_id = dotlrn_class_instances_full.class_instance_id
+            order by dotlrn_class_instances_full.department_name,
+                     dotlrn_class_instances_full.department_key,
+                     dotlrn_class_instances_full.pretty_name,
+                     dotlrn_class_instances_full.community_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_member_clubs">
+        <querytext>
+            select dotlrn_clubs_full.*,
+                   dotlrn_member_rels_approved.rel_type,
+                   dotlrn_member_rels_approved.role,
+                   '' as role_pretty_name
+            from dotlrn_clubs_full,
+                 dotlrn_member_rels_approved
+            where dotlrn_member_rels_approved.user_id = :user_id
+            and dotlrn_member_rels_approved.community_id = dotlrn_clubs_full.club_id
+            order by dotlrn_clubs_full.pretty_name,
+                     dotlrn_clubs_full.community_key
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_member_subgroups">
+        <querytext>
+            select dotlrn_communities.*,
+                   dotlrn_community__url(dotlrn_communities.community_id) as url,
+                   dotlrn_member_rels_approved.rel_type,
+                   dotlrn_member_rels_approved.role,
+                   '' as role_pretty_name
+            from dotlrn_communities,
+                 dotlrn_member_rels_approved
+            where dotlrn_member_rels_approved.user_id = :user_id
+            and dotlrn_member_rels_approved.community_id = dotlrn_communities.community_id
+            and dotlrn_communities.community_type = 'dotlrn_community'
+            order by dotlrn_communities.pretty_name,
+                     dotlrn_communities.community_key
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/user.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,201 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">@first_names@ @last_name@</property>
+<property name="context_bar">@context_bar@</property>
+
+<h3>#dotlrn.General_Information#</h3>
+
+<ul>
+
+  <li>
+    #dotlrn.Person_name#
+    @first_names@ @last_name@
+  <if @oacs_site_wide_admin_p@ true> 
+    [<small> <a href="/user/basic-info-update?@export_edit_vars@">#dotlrn.Edit#</a> </small>]
+  </if>
+  </li>
+
+  <li>
+    #dotlrn.Email#
+    <a href="mailto:@email@">@email@</a>
+  <if @oacs_site_wide_admin_p@ true>
+    [<small> <a href="/user/basic-info-update?@export_edit_vars@">#dotlrn.Edit#</a> </small>]
+  </if> 
+  </li>
+
+  <li>
+    #dotlrn.Screen_name#
+    @screen_name@
+  <if @oacs_site_wide_admin_p@ true>
+    [<small> <a href="/user/basic-info-update?@export_edit_vars@">#dotlrn.Edit#</a> </small>]
+  </if>
+  </li>
+
+  <li>
+    #dotlrn.User_ID#
+    @user_id@
+  </li>
+
+  <li>
+    #dotlrn.Registration_date#
+    @registration_date@
+  </li>
+
+<if @last_visit@ not nil>
+  <li>
+    #dotlrn.Last_Visit#
+    @last_visit@
+  </li>
+</if>
+<else>
+  <li>
+    #dotlrn.lt_Last_Visit_None_#: @remove_user_url;noquote@
+  </li>
+</else>
+
+<if @portrait_p@ eq 1>
+  <li>
+    #dotlrn.Portrait# <a href="/shared/portrait?user_id=@user_id@">@portrait_title@</a>
+  </li>
+</if>
+
+  <li>
+    #dotlrn.Member_state#
+    @member_state@
+  <if @oacs_site_wide_admin_p@ true> 
+    @change_state_links;noquote@
+  </if>
+  </li>
+
+</ul>
+
+<h3>#dotlrn.dotLRN_Information#</h3>
+
+<if @dotlrn_user_p@>
+
+<ul>
+
+  <li>
+    #dotlrn.User_type#
+    <%= [lang::util::localize @pretty_type@] %>
+  </li>
+
+  <li>
+    #dotlrn.Access_level#
+    <if @can_browse_p@>#dotlrn.Full# [ <small><a href="browse-toggle?user_id=@user_id@&can_browse_p=0&referer=@return_url@">#dotlrn.Limited#</a> </small>]</if><else>#dotlrn.Limited# [ <small><a href="browse-toggle?user_id=@user_id@&can_brow
+se_p=1&referer=@return_url@">#dotlrn.Full#</a> </small>]</else>
+  </li>
+
+  <li>
+    #dotlrn.Guest#
+    <if @guest_p@ eq t>#dotlrn.Yes# [ <small><a href="guest-toggle?user_id=@user_id@&guest_p=f&referer=@return_url@">#dotlrn.No#</a> </small>]</if><else>#dotlrn.No# [ <small><a href="guest-toggle?user_id=@user_id@&guest_p=t&referer=@return_url@">#dotlrn.Yes#</a> </small>]</else>
+  </li>
+
+  <li>
+    #dotlrn.ID#
+    <if @id@ nil>#dotlrn.ltnone_set_upgt#</if><else>@id@</else>
+  </li>
+
+  <br>
+
+  <li>
+    <a href="user-edit?@export_edit_vars@">#dotlrn.Edit#</a> #dotlrn.lt_dotLRN_properties_for#
+  </li>
+
+</ul>
+
+<if @member_classes:rowcount@ gt 0>
+  <blockquote>
+    <h4>#dotlrn.class_memberships#</h4>
+
+    <ul>
+<multiple name="member_classes">
+      <li>
+        <a href="@member_classes.url@">@member_classes.pretty_name@</a>
+        @member_classes.term_name@ @member_classes.term_year@
+        (@member_classes.role_pretty_name@)
+      </li>
+</multiple>
+    </ul>
+  </blockquote>
+</if>
+
+<if @member_clubs:rowcount@ gt 0>
+  <blockquote>
+    <h4>#dotlrn.community_memberships#</h4>
+
+    <ul>
+<multiple name="member_clubs">
+      <li>
+        <a href="@member_clubs.url@">@member_clubs.pretty_name@</a>
+        (@member_clubs.role_pretty_name@)
+      </li>
+</multiple>
+    </ul>
+  </blockquote>
+</if>
+
+<if @member_subgroups:rowcount@ gt 0>
+  <blockquote>
+    <h4>#dotlrn.subcommunity_memberships#</h4>
+
+    <ul>
+<multiple name="member_subgroups">
+      <li>
+        <a href="@member_subgroups.url@">@member_subgroups.pretty_name@</a>
+        (@member_subgroups.role_pretty_name@)
+      </li>
+</multiple>
+    </ul>
+  </blockquote>
+</if>
+
+  <ul>
+    <li>
+      <a href="users-add-to-community?users=@user_id@&referer=@return_url@">#dotlrn.add_to_another_group#</a>
+    </li>
+  </ul>
+
+</if>
+<else>
+<p>
+<if @member_state@ eq "approved">
+  <a href="user-new-2?user_id=@user_id@&referer=@return_url@">#dotlrn.add_to_dotlrn#</a>
+</if>
+<else>
+#dotlrn.lt_This_user_is_currentl#.
+</else>
+</p>
+</else>
+
+<h3>#dotlrn.lt_Administrative_Action#</h3>
+
+<ul>
+  <li><a href="password-update?@export_edit_vars@">#dotlrn.lt_Update_this_users_pas#</a></li>
+  <if @portrait_p@>
+    <li><a href="/user/portrait/index.tcl?@export_edit_vars@">#dotlrn.lt_Manage_this_users_por#</a></li>
+  </if>
+
+ <if @oacs_site_wide_admin_p@ true>
+  <li><a href="/acs-admin/users/become?user_id=@user_id@">#dotlrn.Become_this_user#</a></li>
+ </if> 
+</ul>
Index: openacs-4/packages/dotlrn-admin/www/admin/user.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,108 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    One user view by a dotLRN admin
+    
+    @author yon (yon@openforce.net)
+    @creation-date 2002-03-13
+    @version $Id: user.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} {
+    user_id:integer,notnull
+} -properties {
+    context_bar:onevalue
+    first_names:onevalue
+    last_name:onevalue
+    email:onevalue
+    screen_name:onevalue
+    user_id:onevalue
+    registration_date:onevalue
+    last_visit:onevalue
+    export_edit_vars:onevalue
+    portrait_p:onevalue
+    portrait_title:onevalue
+    change_state_links:onevalue
+    return_url:onevalue
+    dotlrn_user_p:onevalue
+    member_classes:multirow
+    member_clubs:multirow
+}
+
+set oacs_site_wide_admin_p [acs_user::site_wide_admin_p]
+
+set return_url "[ad_parameter -package_id [ad_acs_kernel_id] CommunityMemberAdminURL]?user_id=$user_id"
+set export_edit_vars "user_id=$user_id&return_url=$return_url"
+
+set dotlrn_url [dotlrn::get_url]
+set root_object_id [acs_magic_object security_context_root]
+if {![db_0or1row select_user_info {}]} {
+    ad_return_complaint 1 "<li>[_ dotlrn.couldnt_find_user_id [list user_id $user_id]]</li>"
+    ad_script_abort
+}
+if {[empty_string_p $screen_name]} {
+    set screen_name "&lt;[_ dotlrn.none_set_up]&gt;"
+}
+set registration_date [lc_time_fmt $registration_date "%q"]
+if {![empty_string_p $last_visit]} {
+    set last_visit [lc_time_fmt $last_visit "%q"]
+}
+
+set dotlrn_package_id [dotlrn::get_package_id]
+set dotlrn_user_p 0
+if {[db_0or1row select_dotlrn_user_info {}]} {
+    set dotlrn_user_p 1
+}
+set can_browse_p [dotlrn::user_can_browse_p -user_id $user_id]
+
+set portrait_p 0
+if {[ad_parameter "show_portrait_p" dotlrn] && [db_0or1row select_portrait_info {}]} {
+    set portrait_p 1
+}
+
+set change_state_links "\[<small>[join [ad_registration_finite_state_machine_admin_links $member_state $email_verified_p $user_id $return_url] " | "]</small>\]"
+
+db_multirow member_classes select_member_classes {} {
+    set role_pretty_name [dotlrn_community::get_role_pretty_name -community_id $class_instance_id -rel_type $rel_type]
+}
+db_multirow member_clubs select_member_clubs {} {
+    set role_pretty_name [dotlrn_community::get_role_pretty_name -community_id $club_id -rel_type $rel_type]
+}
+db_multirow member_subgroups select_member_subgroups {} {
+    set role_pretty_name [dotlrn_community::get_role_pretty_name -community_id $community_id -rel_type $rel_type]
+}
+
+set site_wide_admin_p [permission::permission_p \
+        -party_id $user_id \
+        -object_id [acs_magic_object "security_context_root"] \
+        -privilege admin \
+        ]
+
+set context_bar [list [list users [_ dotlrn.Users]] "$first_names $last_name"]
+
+set dual_approve_return_url [ns_urlencode [dotlrn::get_admin_url]/user-new-2?user_id=$user_id&referer=$return_url]
+
+set approve_user_url "/acs-admin/users/member-state-change?user_id=$user_id&member_state=approved&return_url=$dual_approve_return_url"
+
+set remove_user_url "\[<small><a href=\"[export_vars -base user-nuke {user_id}]\">Nuke</a></small>\]"
+
+# Used in some en_US messages in the adp file
+set class_instances_pretty_name [parameter::get -localize -parameter class_instances_pretty_name]
+set clubs_pretty_name [parameter::get -localize -parameter clubs_pretty_name]
+set subcommunities_pretty_name [parameter::get -localize -parameter subcommunities_pretty_name]
+
+set dual_approve_return_url [ns_urlencode [dotlrn::get_admin_url]/user-new-2?user_id=$user_id&referer=$return_url]
+
+ad_return_template
Index: openacs-4/packages/dotlrn-admin/www/admin/user.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/user.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/user.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_user_info">      
+        <querytext>
+            select first_names,
+                   last_name,
+                   email,
+                   screen_name,
+                   creation_date as registration_date,
+                   creation_ip,
+                   last_visit,
+                   member_state,
+                   email_verified_p
+            from cc_users
+            where user_id = :user_id
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-add-to-community.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-add-to-community.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-add-to-community.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,34 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Add_Users_to_Group#</property>
+<property name="context_bar">@context_bar@</property>
+
+
+<strong><font color=red>#dotlrn.Note#</font></strong> 
+#dotlrn.lt_This_action_will_take# <strong><%= [expr [llength $users] * 3] %></strong> #dotlrn.seconds#
+
+<p></p>
+
+<formtemplate id="select_community"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-add-to-community.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-add-to-community.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-add-to-community.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,109 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Add a set of users to a community
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-02-10
+    @version $Id: users-add-to-community.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    users
+    {referer "users-search"}
+} -properties {
+    context_bar:onevalue
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [list users-search [_ dotlrn.User_Search]] [_ dotlrn.Add_Users_to_Group]]
+
+form create select_community
+
+element create select_community users \
+    -label "&nbsp;" \
+    -datatype text \
+    -widget hidden \
+    -value $users
+
+element create select_community referer \
+        -label "[_ dotlrn.Referer]" \
+        -datatype text \
+        -widget hidden \
+        -value $referer
+
+set communities [db_list_of_lists select_all_communities {
+    select dotlrn_communities.pretty_name,
+           dotlrn_communities.community_id
+    from dotlrn_communities
+    where dotlrn_communities.portal_id is not NULL
+    order by dotlrn_communities.pretty_name,
+             dotlrn_communities.community_id
+}]
+
+if {[llength $communities]} {
+    element create select_community community_id \
+        -label "[_ dotlrn.Add_users_to]" \
+        -datatype text \
+        -widget select \
+        -options "{{} {}} $communities"
+} else {
+    element create select_community community_id \
+        -label "[_ dotlrn.No_groups_to_add_to]" \
+        -datatype text \
+        -widget hidden \
+        -value ""
+}
+
+if {[form is_valid select_community]} {
+    form get_values select_community \
+        users community_id
+
+    if {![empty_string_p $community_id]} {
+        db_transaction {
+            foreach user $users {
+                dotlrn_community::add_user $community_id $user
+            }
+        }
+
+        # Now notify the users that they've been added to the community.
+
+        set sender_email [cc_email_from_party [ad_conn user_id]]
+        foreach {community} $communities {
+            if { $community_id == [lindex $community 1] } {
+                set community_name [lindex $community 0]
+                break
+            }
+        }
+
+        set subject "You have been added to the \"$community_name\" community at [ad_parameter -package_id [ad_acs_kernel_id] SystemURL]"
+        set message "To visit the community's home page, point your browser at [ad_parameter -package_id [ad_acs_kernel_id] SystemURL],
+log in, and click on the \"$community_name\" link in the \"Groups\" portlet.
+"
+
+        spam::send \
+          -recepients $users \
+          -from $sender_email \
+          -real_from $sender_email \
+          -subject $subject \
+          -message $message \
+          -message_values [list]
+    }
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload-2.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload-2.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,168 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Process the upload
+
+    @author ben (ben@openforce.net)
+    @creation-date 2002-03-05
+    @version $Id: users-bulk-upload-2.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+}
+
+# get location of the file
+set file_location [ns_queryget users_csv_file.tmpfile]
+
+# Prepare stuff
+set headers {first_names last_name email}
+
+set admin_user_id [ad_verify_and_get_user_id]
+set admin_email [db_string select_admin_email {
+    select email
+    from parties
+    where party_id = :admin_user_id
+}]
+
+doc_body_append "[_ dotlrn.Bulk_Uploading]<p>"
+
+set list_of_user_ids [list]
+set list_of_addresses_and_passwords [list]
+
+# Do the stuff
+# We can't do this too generically, so we'll just do the CSV stuff right here
+db_transaction {
+
+    oacs_util::csv_foreach -file $file_location -array_name row {
+
+        # First make sure the required data is there
+        if { ![info exists row(email)] || ![info exists row(first_names)] || ![info exists row(last_name)] } {
+            doc_body_append "<br>Datafile must include at least the email, first_names and last_name fields<br>"
+            db_abort_transaction
+            return
+        }
+
+        # We need to insert the ACS user
+        set password [ad_generate_random_string]
+
+        # Check if this user already exists
+        set user_id [cc_lookup_email_user $row(email)]
+        if {![empty_string_p $user_id]} {
+            doc_body_append [_ dotlrn.user_email_already_exists [list user_email $row(email)]]
+            lappend list_of_user_ids $user_id
+        } else {
+
+	    set user_id [db_nextval acs_object_id_seq]
+
+	    auth::create_user \
+		-user_id $user_id \
+		-username "" \
+		-email $row(email) \
+		-first_names $row(first_names) \
+		-last_name $row(last_name) \
+		-password $password
+
+            
+            lappend list_of_user_ids $user_id
+            
+            if {![info exists row(type)]} {
+                set row(type) student
+            }
+            
+            if {![info exists row(access_level)]} {
+                set row(access_level) full
+            }
+            
+            if {![info exists row(guest)]} {
+                set row(guest) f
+            }
+
+            if {![info exists row(id)]} {
+                set row(id) $row(email)
+            }
+            
+            doc_body_append "Creating user $row(email)...."
+
+            # Now we make them a dotLRN user
+            switch -exact $row(access_level) {
+                limited {
+                    dotlrn::user_add -user_id $user_id -id $row(id) -type $row(type)
+                }
+                full -
+                default {
+                    dotlrn::user_add -user_id $user_id -id $row(id) -type $row(type) -can_browse
+                }
+            }
+            
+            # Set the privacy
+            dotlrn_privacy::set_user_guest_p -user_id $user_id -value $row(guest)
+            
+            doc_body_append [_ dotlrn.user_email_created [list user_email $row(email)]]
+            set msg_subst_list [list system_name [ad_system_name] \
+                                     system_url [ad_parameter SystemUrl] \
+                                     user_email $row(email) \
+                                     user_password $password]
+            set message [_ dotlrn.user_add_confirm_email_body $msg_subst_list] 
+            set subject [_ dotlrn.user_add_confirm_email_subject $msg_subst_list] 
+
+            # Send note to new user
+            if [catch {ns_sendmail "$row(email)" "$admin_email" "$subject" "$message"} errmsg] {
+                doc_body_append "[_ dotlrn.lt_emailing_this_user_fa]"
+                set fail_p 1
+            } else {
+                doc_body_append "[_ dotlrn.email_sent]"
+            }
+
+            lappend list_of_addresses_and_passwords $row(email) $password
+        }
+
+        doc_body_append "<br>"
+        
+    }
+} on_error {
+    doc_body_append "<p>The database choked while trying to create the last user in the list above!<br>  The transaction has been aborted, no users have been entered, and no e-mail notifications have been sent.<p>"
+    ad_script_abort
+}
+
+set fail_p 0
+
+doc_body_append "<p>Sending email notifications to users...<p>"
+
+foreach {email password} $list_of_addresses_and_passwords {
+    if { ![string equal $password ""] } {
+        set message "
+You have been added as a user to [ad_system_name] at [ad_parameter -package_id [ad_acs_kernel_id] SystemURL].
+            
+Login: $email
+Password: $password
+"
+        # Send note to new user
+        if [catch {ns_sendmail "$email" "$admin_email" "You have been added as a user to [ad_system_name] at [ad_parameter -package_id [ad_acs_kernel_id] SystemURL]" "$message"} errmsg] {
+            doc_body_append "emailing \"$email\" failed!<br>"
+            set fail_p 1
+        } else {
+            doc_body_append "email sent to \"$email\"<br>"
+        }
+    }
+}
+
+if {$fail_p} {
+    doc_body_append "<p>[_ dotlrn.lt_Some_of_the_emails_fa]<p>"
+}
+
+doc_body_append "<FORM method=post action=users-add-to-community>
+<INPUT TYPE=hidden name=users value=\"$list_of_user_ids\">
+<INPUT TYPE=hidden name=referer values=users>
+[_ dotlrn.lt_You_may_now_choose_to] <INPUT TYPE=submit value=\"[_ dotlrn.lt_Add_These_Users_To_A_]\"></FORM><p>"
+doc_body_append "[_ dotlrn.or_return_to] <a href=\"users\">[_ dotlrn.User_Management]</a>."
Index: openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,108 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Users_Bulk_Upload#</property>
+<property name="context_bar">@context_bar@</property>
+
+#dotlrn.lt_Here_you_can_create_s#
+
+<p>
+
+<strong>#dotlrn.Be_sure#</strong> #dotlrn.lt_to_use_vaild_email_ad#
+
+</p>
+
+
+<div style="font-size: large; font-weight: bold;">#dotlrn.CSV_File_Format#</div>
+
+<p style="text-indent: 1em">
+  
+  <strong>#dotlrn.First_Line#</strong>
+
+  <p style="text-indent: 2em">
+  
+    #dotlrn.first_line_of_file_must_be#
+    
+    <div style="text-indent: 3em; font-family: monospace">
+      first_names,last_name,email,id,type,access_level,guest
+    </div>
+   
+  </p>
+
+</p>
+
+<p style="text-indent: 1em">
+
+  <strong>#dotlrn.Fields#</strong>
+  
+  <ul>
+    <li><tt>first_names</tt> - <em>#dotlrn.required#</em>
+    <li><tt>last_name</tt> - <em>#dotlrn.required#</em>
+    <li><tt>email</tt> - <em>#dotlrn.required#</em>
+    <li><tt>id</tt> - <em>#dotlrn.optional_defaults_to# email</em> #dotlrn.lt_a_secondary#
+    <li><tt>type</tt> - <em>#dotlrn.required#</em> #dotlrn.must_have_values# 
+      <ul>
+        <li>professor
+        <li>student
+        <li>admin
+        <li>external
+      </ul>
+    <li><tt>access_level</tt> - <em>#dotlrn.optional_defaults_to# full</em> - 
+        <em>#dotlrn.must_have_values#</em> <tt>full</tt>, <tt>limited</tt>
+    <li><tt>guest</tt> - <em>#dotlrn.optional_defaults_to# guest</em> -
+        <em>#dotlrn.must_have_values#</em> <tt>t</tt>, <tt>f</tt>
+  </ul>
+  
+</p>
+
+<p style="text-indent: 1em">
+
+  <strong>#dotlrn.Example_File#</strong>
+  
+  <pre>
+    first_names,last_name,email,id,type,access_level,guest
+    Joe,Student,joe@_somewhere_.net,123-456-7890,student,full,f
+    Albert,Einstein,al@_school_.edu,al,professor,full,f
+    Systems,Hacker,syshacker@_company_.com,,admin,,,
+    Intersted,Onlooker,onlooker@_somewhere_.net,,external,,limited,t
+  </pre>
+  
+</p>
+
+<p style="text-indent: 1em">
+
+#dotlrn.lt_Note_you_will_have_th#
+
+</p>
+
+<div style="padding-left: 1em">
+
+  <FORM enctype=multipart/form-data method=post action=users-bulk-upload-2>
+  <INPUT TYPE=file name=users_csv_file>
+  <br>
+  <br>
+  <INPUT TYPE=submit value="#dotlrn.upload#">
+  </FORM>
+</div>
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-bulk-upload.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,28 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Display the page for bulk uploading of a bunch of users
+
+    @author ben (ben@openforce.net)
+    @creation-date 2002-03-05
+    @version $Id: users-bulk-upload.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [_ dotlrn.Bulk_Upload]]
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_dotlrn_users">
+        <querytext>
+            select dotlrn_users.user_id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_privacy.guest_p(dotlrn_users.user_id) as guest_p,
+                   acs_permission.permission_p(:root_object_id, dotlrn_users.user_id, 'admin') as site_wide_admin_p
+            from dotlrn_users
+            where dotlrn_users.type = :type
+            and (
+                lower(dotlrn_users.last_name) like lower('%' || :search_text || '%')
+             or lower(dotlrn_users.first_names) like lower('%' || :search_text || '%')
+             or lower(dotlrn_users.email) like lower('%' || :search_text || '%')
+            )
+            order by dotlrn_users.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_non_dotlrn_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission.permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+	    and member_state not in ('banned','deleted','rejected')
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs.magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and users.email_verified_p = 't'
+            and not exists (select 1
+                            from acs_rels a,
+                                 dotlrn_user_types
+                            where a.object_id_one = dotlrn_user_types.group_id
+                            and a.object_id_two = acs_rels.object_id_two)
+            and (
+                lower(persons.last_name) like lower('%' || :search_text || '%')
+             or lower(persons.first_names) like lower('%' || :search_text || '%')
+             or lower(parties.email) like lower('%' || :search_text || '%')
+            )
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission.permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs.magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+            and (
+                lower(persons.last_name) like lower('%' || :search_text || '%')
+             or lower(persons.first_names) like lower('%' || :search_text || '%')
+             or lower(parties.email) like lower('%' || :search_text || '%')
+            )
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_dotlrn_users">
+        <querytext>
+            select dotlrn_users.user_id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_privacy__guest_p(dotlrn_users.user_id) as guest_p,
+                   acs_permission__permission_p(:root_object_id, dotlrn_users.user_id, 'admin') as site_wide_admin_p
+            from dotlrn_users
+            where dotlrn_users.type = :type
+            and (
+                lower(dotlrn_users.last_name) like lower('%' || :search_text || '%')
+             or lower(dotlrn_users.first_names) like lower('%' || :search_text || '%')
+             or lower(dotlrn_users.email) like lower('%' || :search_text || '%')
+            )
+            order by dotlrn_users.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_non_dotlrn_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission__permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and member_state not in ('banned','deleted','rejected')
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs__magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and users.email_verified_p = 't'
+            and not exists (select 1
+                            from acs_rels a,
+                                 dotlrn_user_types
+                            where a.object_id_one = dotlrn_user_types.group_id
+                            and a.object_id_two = acs_rels.object_id_two)
+            and (
+                lower(persons.last_name) like lower('%' || :search_text || '%')
+             or lower(persons.first_names) like lower('%' || :search_text || '%')
+             or lower(parties.email) like lower('%' || :search_text || '%')
+            )
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission__permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs__magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+            and (
+                lower(persons.last_name) like lower('%' || :search_text || '%')
+             or lower(persons.first_names) like lower('%' || :search_text || '%')
+             or lower(parties.email) like lower('%' || :search_text || '%')
+            )
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,40 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<formtemplate id="user_search">
+  <formwidget id="type">
+  <formwidget id="referer">
+
+<table cellspacing="3" cellpadding="3">
+
+  <tr>
+    <th align="left">#dotlrn.Search_Text#</th>
+    <td><formwidget id="search_text"></td>
+    <td><input type="submit" value="#dotlrn.Search#"></td>
+  </tr>
+
+</table>
+
+</formtemplate>
+
+<include src="users-chunk" type=@type@ &users="users" referer=@referer@>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-large.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,91 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date 2002-01-30
+    @version $Id: users-chunk-large.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {search_text ""}
+} -properties {
+    user_id:onevalue
+    users:multirow
+}
+
+if {![exists_and_not_null type]} {
+    set type admin
+}
+
+if {![exists_and_not_null referer]} {
+    set referer "[dotlrn::get_admin_url]/users"
+}
+
+set user_id [ad_conn user_id]
+
+form create user_search
+
+element create user_search search_text \
+    -label [_ dotlrn.Search] \
+    -datatype text \
+    -widget text \
+    -value $search_text
+
+element create user_search type \
+    -label [_ dotlrn.Type] \
+    -datatype text \
+    -widget hidden \
+    -value $type
+
+element create user_search referer \
+    -label [_ dotlrn.Referer] \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid user_search]} {
+    form get_values user_search search_text referer
+
+    set user_id [ad_conn user_id]
+    set dotlrn_package_id [dotlrn::get_package_id]
+    set root_object_id [acs_magic_object security_context_root]
+    set i 1
+
+    if {[string equal $type deactivated] == 1} {
+        db_multirow users select_deactivated_users {} {
+            set users:${i}(access_level) Limited
+            incr i
+        }
+    } elseif {[string equal $type pending] == 1} {
+        db_multirow users select_non_dotlrn_users {} {
+            set users:${i}(access_level) N/A
+            incr i
+        }
+    } else {
+        db_multirow users select_dotlrn_users {} {
+            if {[dotlrn::user_can_browse_p -user_id $user_id]} {
+                set users:${i}(access_level) Full
+            } else {
+                set users:${i}(access_level) Limited
+            }
+            incr i
+        }
+    }
+} else {
+    multirow create users dummy
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,142 @@
+<?xml version="1.0"?>
+
+<queryset>
+  <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_dotlrn_users">
+        <querytext>
+            select dotlrn_users.user_id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_privacy.guest_p(dotlrn_users.user_id) as guest_p,
+                   acs_permission.permission_p(:root_object_id, dotlrn_users.user_id, 'admin') as site_wide_admin_p
+            from dotlrn_users
+            where dotlrn_users.type = :type
+            and upper(substr(dotlrn_users.last_name, 1, 1)) = :section
+            order by dotlrn_users.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_dotlrn_users_other">
+        <querytext>
+            select dotlrn_users.user_id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_privacy.guest_p(dotlrn_users.user_id) as guest_p,
+                   acs_permission.permission_p(:root_object_id, dotlrn_users.user_id, 'admin') as site_wide_admin_p
+            from dotlrn_users
+            where dotlrn_users.type = :type
+            and upper(substr(dotlrn_users.last_name, 1, 1)) not in ('[join $dimension_list "\', \'"]')
+            order by dotlrn_users.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_non_dotlrn_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission.permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+	    and member_state not in ('banned','deleted','rejected')
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+	    and acs_rels.object_id_one =  acs.magic_object_id('registered_users')	
+            and acs_rels.rel_id = membership_rels.rel_id
+            and users.email_verified_p = 't'
+            and not exists (select 1
+                            from acs_rels a,
+                                 dotlrn_user_types
+                            where a.object_id_one = dotlrn_user_types.group_id
+                            and a.object_id_two = acs_rels.object_id_two)
+            and upper(substr(persons.last_name, 1, 1)) = :section
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_non_dotlrn_users_other">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission.permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'approved'
+            and not exists (select 1
+                            from acs_rels a,
+                                 dotlrn_user_types
+                            where a.object_id_one = dotlrn_user_types.group_id
+                            and a.object_id_two = acs_rels.object_id_two)
+            and upper(substr(person.last_name, 1, 1)) not in ('[join $dimension_list "\', \'"]')
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission.permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs.magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+            and upper(substr(persons.last_name, 1, 1)) = :section
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users_other">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission.permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs.magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+            and upper(substr(person.last_name, 1, 1)) not in ('[join $dimension_list "\', \'"]')
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,142 @@
+<?xml version="1.0"?>
+
+<queryset>
+  <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_dotlrn_users">
+        <querytext>
+            select dotlrn_users.user_id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_privacy__guest_p(dotlrn_users.user_id) as guest_p,
+                   acs_permission__permission_p(:root_object_id, dotlrn_users.user_id, 'admin') as site_wide_admin_p
+            from dotlrn_users
+            where dotlrn_users.type = :type
+            and upper(substr(dotlrn_users.last_name, 1, 1)) = :section
+            order by dotlrn_users.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_dotlrn_users_other">
+        <querytext>
+            select dotlrn_users.user_id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_privacy__guest_p(dotlrn_users.user_id) as guest_p,
+                   acs_permission__permission_p(:root_object_id, dotlrn_users.user_id, 'admin') as site_wide_admin_p
+            from dotlrn_users
+            where dotlrn_users.type = :type
+            and upper(substr(dotlrn_users.last_name, 1, 1)) not in ('[join $dimension_list "\', \'"]')
+            order by dotlrn_users.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_non_dotlrn_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission__permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and member_state not in ('banned','deleted','rejected')
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one =  acs__magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and users.email_verified_p = 't'
+            and not exists (select 1
+                            from acs_rels a,
+                                 dotlrn_user_types
+                            where a.object_id_one = dotlrn_user_types.group_id
+                            and a.object_id_two = acs_rels.object_id_two)
+            and upper(substr(persons.last_name, 1, 1)) = :section
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_non_dotlrn_users_other">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission__permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'approved'
+            and not exists (select 1
+                            from acs_rels a,
+                                 dotlrn_user_types
+                            where a.object_id_one = dotlrn_user_types.group_id
+                            and a.object_id_two = acs_rels.object_id_two)
+            and upper(substr(person.last_name, 1, 1)) not in ('[join $dimension_list "\', \'"]')
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission__permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs__magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+            and upper(substr(persons.last_name, 1, 1)) = :section
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users_other">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission__permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs__magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+            and upper(substr(person.last_name, 1, 1)) not in ('[join $dimension_list "\', \'"]')
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,25 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<p>@control_bar;noquote@</p>
+
+<include src="users-chunk" type=@type@ &users="users" referer=@referer@>
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-medium.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,84 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date 2002-01-30
+    @version $Id: users-chunk-medium.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {section A}
+} -properties {
+    user_id:onevalue
+    control_bar:onevalue
+    users:multirow
+}
+
+set user_id [ad_conn user_id]
+set dotlrn_package_id [dotlrn::get_package_id]
+set root_object_id [acs_magic_object security_context_root]
+
+if {![exists_and_not_null type]} {
+    set type admin
+}
+
+if {![exists_and_not_null referer]} {
+    set referer "[dotlrn::get_admin_url]/users"
+}
+
+set dimension_list {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
+foreach dimension $dimension_list {
+    lappend dimensions [list $dimension $dimension {}]
+}
+lappend dimensions [list Other Other {}]
+
+set control_bar [portal::dimensional -no_bars [list [list section {} $section $dimensions]]]
+
+set i 1
+if {[string equal $type deactivated] == 1} {
+    set query select_deactivated_users
+    if {[string match Other $section]} {
+        append query "_other"
+    }
+    db_multirow users $query {} {
+        set users:${i}(access_level) Limited
+        incr i
+    }
+} elseif {[string equal $type pending] == 1} {
+    set query select_non_dotlrn_users
+    if {[string match Other $section]} {
+        append query "_other"
+    }
+    db_multirow users $query {} {
+        set users:${i}(access_level) N/A
+        incr i
+    }
+} else {
+    set query select_dotlrn_users
+    if {[string match Other $section]} {
+        append query "_other"
+    }
+    db_multirow users $query {} {
+        if {[dotlrn::user_can_browse_p -user_id $user_id]} {
+            set users:${i}(access_level) Full
+        } else {
+            set users:${i}(access_level) Limited
+        }
+        incr i
+    }
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+
+<queryset>
+  <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_dotlrn_users">
+        <querytext>
+            select dotlrn_users.user_id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_privacy.guest_p(dotlrn_users.user_id) as guest_p,
+                   acs_permission.permission_p(:root_object_id, dotlrn_users.user_id, 'admin') as site_wide_admin_p
+            from dotlrn_users
+            where dotlrn_users.type = :type
+            order by dotlrn_users.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_non_dotlrn_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission.permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p, member_state
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+	    and member_state not in ('banned','deleted','rejected')
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs.magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and users.email_verified_p = 't'
+            and not exists (select 1
+                            from acs_rels a,
+                                 dotlrn_user_types
+                            where a.object_id_one = dotlrn_user_types.group_id
+                            and a.object_id_two = acs_rels.object_id_two)
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission.permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs.magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+
+<queryset>
+  <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_dotlrn_users">
+        <querytext>
+            select dotlrn_users.user_id,
+                   dotlrn_users.first_names,
+                   dotlrn_users.last_name,
+                   dotlrn_users.email,
+                   dotlrn_privacy__guest_p(dotlrn_users.user_id) as guest_p,
+                   acs_permission__permission_p(:root_object_id,dotlrn_users.user_id, 'admin') as site_wide_admin_p
+            from dotlrn_users
+            where dotlrn_users.type = :type
+            order by dotlrn_users.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_non_dotlrn_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission__permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p,
+                   member_state
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and member_state not in ('banned','deleted','rejected')
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs__magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and users.email_verified_p = 't'
+            and not exists (select 1
+                            from acs_rels a,
+                                 dotlrn_user_types
+                            where a.object_id_one = dotlrn_user_types.group_id
+                            and a.object_id_two = acs_rels.object_id_two)
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users">
+        <querytext>
+            select users.user_id,
+                   persons.first_names,
+                   persons.last_name,
+                   parties.email,
+                   'f' as guest_p,
+                   acs_permission__permission_p(:root_object_id, users.user_id, 'admin') as site_wide_admin_p
+            from parties,
+                 users,
+                 persons,
+                 acs_rels,
+                 membership_rels
+            where parties.party_id = users.user_id
+            and users.user_id = persons.person_id
+            and persons.person_id = acs_rels.object_id_two
+            and acs_rels.object_id_one = acs__magic_object_id('registered_users')
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+            order by persons.last_name
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,21 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<include src="users-chunk" type=@type@ &users="users" referer=@referer@>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk-small.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,63 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date 2002-01-30
+    @version $Id: users-chunk-small.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+} -properties {
+    user_id:onevalue
+    users:multirow
+}
+
+set user_id [ad_conn user_id]
+set dotlrn_package_id [dotlrn::get_package_id]
+set root_object_id [acs_magic_object security_context_root]
+
+if {![exists_and_not_null type]} {
+    set type admin
+}
+
+if {![exists_and_not_null referer]} {
+    set referer "[dotlrn::get_admin_url]/users"
+}
+
+# Currently, just present a list of dotLRN users
+set i 1
+if {[string equal $type deactivated] == 1} {
+    db_multirow users select_deactivated_users {} {
+        set users:${i}(access_level) Limited
+        incr i
+    }
+} elseif {[string equal $type pending] == 1} {
+    db_multirow users select_non_dotlrn_users {} {
+        set users:${i}(access_level) N/A
+        incr i
+    }
+} else {
+    db_multirow users select_dotlrn_users {} {
+        if {[dotlrn::user_can_browse_p -user_id $user_id]} {
+            set users:${i}(access_level) Full
+        } else {
+            set users:${i}(access_level) Limited
+        }
+        incr i
+    }
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,124 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<%
+    # The structure of this table is determined by the type of user we
+    # are displaying.  It doesn't make much sense to display access
+    # level, guest status, and admin status for pending users.  Instead we
+    # will offer links to common actions. 
+
+    # Note: There is some redundant logic inside the table and in
+    # other files that display access and guest status fields as N/A
+    # for pending users.  Previous to the change, this page was
+    # displaying "Limited" and "Yes", respectively, which are wrong
+    # and confused our site administrator.
+    # The N/A logic is a failsafe in case these columns come back for
+    # some reason.  aegrumet@mit.edu 2002-08-08.
+
+%>
+
+<center>
+<table bgcolor="#cccccc" cellpadding="5" cellspacing="3" width="95%">
+  <tr>
+    <th align="left" width="50%">#dotlrn.User#</th>
+    <if @type@ eq "pending">
+    <th align="left">#dotlrn.Actions#</th>
+    </if>
+    <else>
+    <th align="left">#dotlrn.Access#</th>
+    <th align="left">#dotlrn.Guest#</th>
+    <if @oacs_site_wide_admin_p@ true>
+    <th align="left">#dotlrn.Site-wide_Admin#</th>
+    </if>
+    </else>
+  </tr>
+
+<if @users:rowcount@ gt 0>
+<multiple name="users">
+
+<if @users.rownum@ odd>
+  <tr bgcolor="#eeeeee">
+</if>
+<else>
+  <tr bgcolor="#d9e4f9">
+</else>
+    <td align="left">
+  <if @type@ eq "deactivated">
+      <a href="user?user_id=@users.user_id@">@users.last_name@, @users.first_names@</a> (<a href="mailto:@users.email@">@users.email@</a>)
+  </if>
+  <else>
+    <if @type@ eq "pending">
+      <a href="user?user_id=@users.user_id@">@users.last_name@, @users.first_names@</a> (<a href="mailto:@users.email@">@users.email@</a>)
+    </if>
+    <else>
+      <a href="user?user_id=@users.user_id@">@users.last_name@, @users.first_names@</a> (<a href="mailto:@users.email@">@users.email@</a>)
+    </else>
+  </else>
+    </td>
+<if @type@ eq "pending">
+    <td align="left">
+
+    <if @oacs_site_wide_admin_p@ true>
+    <% # We had to escape to Tcl to get the desired behavior. AG %>
+    <small><a href="/acs-admin/users/member-state-change?user_id=@users.user_id@&member_state=approved&return_url=<%= [ns_urlencode [dotlrn::get_admin_url]/user-new-2?user_id=$users(user_id)&referer=$referer] %>">#dotlrn.lt_approve_and_add_to_do#</a> | </if>
+    <a href="user-nuke?user_id=@users.user_id@&referer=@referer@">#acs-kernel.common_delete#</small>
+    </td>
+</if>
+<else>
+    <td align="center">@users.access_level@</td>
+    <td align="center">
+     <if @type@ eq "pending">
+     #dotlrn.NA#
+     </if>
+     <else>
+     <if @users.guest_p@ eq t>#dotlrn.Yes#</if><else>#dotlrn.No#</else>
+     </else>
+    </td>
+
+<if @oacs_site_wide_admin_p@ true>
+ <td align="center">
+  <if @user_id@ ne @users.user_id@>
+    <if @users.site_wide_admin_p@ true>
+      <b>#dotlrn.Yes#</b> | <a href="site-wide-admin-toggle?user_id=@users.user_id@&value=revoke&referer=@referer@" title="#dotlrn.Revoke_site_wide_admin#">#dotlrn.No#</a>
+    </if>
+    <else>
+      <a href="site-wide-admin-toggle?user_id=@users.user_id@&value=grant&referer=@referer@" title="#dotlrn.Grant_site_wide_admin#">#dotlrn.Yes#</a> | <b>#dotlrn.No#</b>
+    </else>
+  </if>
+      <else>#dotlrn.Yes#</else>
+    </td>
+</if>
+</else>
+  </tr>
+
+</multiple>
+</if>
+<else>
+  <tr bgcolor="#eeeeee">
+    <td align="left" colspan="4"><i>#dotlrn.No_Users#</i></td>
+  </tr>
+</else>
+
+</table>
+</center>
+
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-chunk.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-chunk.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,35 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    @author yon (yon@openforce.net)
+    @creation-date 2002-01-30
+    @version $Id: users-chunk.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {section ""}
+} -properties {
+    user_id:onevalue
+}
+
+set oacs_site_wide_admin_p [acs_user::site_wide_admin_p]
+set user_id [ad_conn user_id]
+
+if {![exists_and_not_null referer]} {
+    set referer "[dotlrn::get_admin_url]/users"
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-deactivate.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-deactivate.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-deactivate.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,32 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Deactivate_Users#</property>
+<property name="context_bar">@context_bar@</property>
+
+<p>
+  #dotlrn.lt_Are_you_sure_you_want#
+</p>
+
+<formtemplate id="confirm_deactivate"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-deactivate.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-deactivate.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-deactivate.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,55 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/users-deactivate.tcl
+
+ad_page_contract {
+    Deactivate a set of users.
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-02-14
+    @version $Id: users-deactivate.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    users
+    {referer "users-search"}
+} -properties {
+    context_bar:onevalue
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [list users-search [_ dotlrn.User_Search]] [_ dotlrn.Deactivate_Users]]
+
+form create confirm_deactivate
+
+element create confirm_deactivate users \
+    -label "&nbsp;" \
+    -datatype text \
+    -widget hidden \
+    -value $users
+
+if {[form is_valid confirm_deactivate]} {
+    form get_values confirm_deactivate \
+        users
+
+    foreach user $users {
+        acs_user::ban -user_id $user
+    }
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-delete.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-delete.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,32 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Nuke_Users#</property>
+<property name="context_bar">@context_bar@</property>
+
+<p>
+  #dotlrn.lt_Are_you_sure_you_want_nuke_users#
+</p>
+
+<formtemplate id="confirm_delete"></formtemplate>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-delete.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-delete.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,59 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/users-delete.tcl
+
+ad_page_contract {
+    Nuke a set of users.
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-02-14
+    @version $Id: users-delete.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    users
+    {referer "users-search"}
+} -properties {
+    context_bar:onevalue
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [list users-search [_ dotlrn.User_Search]] [_ dotlrn.Nuke_Users]]
+
+form create confirm_delete
+
+element create confirm_delete users \
+    -label "&nbsp;" \
+    -datatype text \
+    -widget hidden \
+    -value $users
+
+element create confirm_delete referer \
+    -label "&nbsp;" \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid confirm_delete]} {
+    form get_values confirm_delete \
+        users
+
+    dotlrn::remove_users_completely -users $users
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-oracle.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-oracle.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>oracle</type><version>8.1.6</version></rdbms>
+
+    <fullquery name="select_non_dotlrn_users_count">
+        <querytext>
+            select count(*)
+            from (select acs_rels.object_id_two
+                  from acs_rels, membership_rels
+                  where acs_rels.object_id_one = (select acs.magic_object_id('registered_users') from dual)
+		  and acs_rels.rel_id = membership_rels.rel_id
+		  and membership_rels.member_state 
+	              not in ('banned','deleted','rejected')
+                 minus
+                  select acs_rels.object_id_two
+                  from acs_rels, dotlrn_user_types
+                  where acs_rels.object_id_one = dotlrn_user_types.group_id)
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users_count">
+        <querytext>
+            select count(*)
+            from persons,
+                 acs_rels,
+                 membership_rels
+            where acs_rels.object_id_one = (select acs.magic_object_id('registered_users') from dual)
+            and acs_rels.object_id_two = persons.person_id
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-postgresql.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+
+<queryset>
+    <rdbms><type>postgresql</type><version>7.1</version></rdbms>
+
+    <fullquery name="select_non_dotlrn_users_count">
+        <querytext>
+            select count(*)
+            from (select acs_rels.object_id_two
+                  from acs_rels, membership_rels
+                  where acs_rels.object_id_one = (select acs__magic_object_id('registered_users') from dual)
+                  and acs_rels.rel_id = membership_rels.rel_id
+                  and membership_rels.member_state
+                      not in ('banned','deleted','rejected')
+                  and acs_rels.object_id_two not in (                  
+                      select acs_rels.object_id_two
+                             from acs_rels,
+                             dotlrn_user_types
+                       where acs_rels.object_id_one = dotlrn_user_types.group_id)) as foo
+        </querytext>
+    </fullquery>
+
+    <fullquery name="select_deactivated_users_count">
+        <querytext>
+            select count(*)
+            from persons,
+                 acs_rels,
+                 membership_rels
+            where acs_rels.object_id_one = (select acs__magic_object_id('registered_users') from dual)
+            and acs_rels.object_id_two = persons.person_id
+            and acs_rels.rel_id = membership_rels.rel_id
+            and membership_rels.member_state = 'banned'
+        </querytext>
+    </fullquery>
+
+</queryset>
Index: openacs-4/packages/dotlrn-admin/www/admin/users-search.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-search.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-search.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,100 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Users_Search#</property>
+<property name="context_bar">@context_bar;noquote@</property>
+
+<p></p>
+
+<if @is_request@ ne 0>
+    <table width="60%" cellspacing="3" cellpadding="3">
+    <formtemplate id="user_search">
+
+      <tr>
+        <th align="left">#dotlrn.Name__Email#</th>
+        <td><formwidget id="name"></td>
+      </tr>
+
+      <tr>
+        <th align="left">#dotlrn.ID#</th>
+        <td><formwidget id="id"></td>
+      </tr>
+
+      <tr>
+        <th align="left">#dotlrn.User_Type#</th>
+        <td><formwidget id="type"></td>
+      </tr>
+
+      <tr>
+        <th align="left">#dotlrn.Access_Level#</th>
+        <td><formwidget id="can_browse_p"></td>
+      </tr>
+
+      <tr>
+        <th align="left">#dotlrn.Guest#</th>
+        <td><formwidget id="guest_p"></td>
+      </tr>
+
+      <tr>
+        <th align="left">#dotlrn.Role#</th>
+        <td>
+          <formgroup id="role">
+            @formgroup.widget;noquote@&nbsp;@formgroup.label@&nbsp;&nbsp;
+          </formgroup>
+        </td>
+      </tr>
+
+      <tr>
+        <th align="left">#dotlrn.Last_visit_over#</th>
+        <th align="left"><formwidget id="last_visit_greater"></th>
+      </tr>
+
+      <tr>
+        <th align="left">#dotlrn.Last_visit_under#</th>
+        <th align="left"><formwidget id="last_visit_less"></th>
+      </tr>
+
+      <tr>
+        <th align="left">#dotlrn.lt_Join_the_above_criter#</th>
+        <td><formwidget id="join_criteria"></td>
+      </tr>
+
+      <tr align="center">
+        <td colspan="2"><input type="submit" value="#dotlrn.Search#"></td>
+      </tr>
+
+    </formtemplate>
+  </table>
+</if>
+<else>
+  <if @n_users@ gt 0>
+    <formtemplate id="user_search_results">
+    </formtemplate>
+  </if>
+  <else>
+    <p>
+      #dotlrn.lt_Your_search_returned_#
+    </p>
+  </else>
+</else>
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-search.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-search.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,270 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Replicate User Management Page
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-02-10
+    @version $Id: users-search.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {type "any"}
+    {can_browse_p "any"}
+    {guest_p "any"}
+    {join_criteria "and"}
+    {n_users 0}
+    {action "none"}
+} -properties {
+    context_bar:onevalue
+    is_request:onevalue
+    n_users:onevalue
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [_ dotlrn.User_Search]]
+
+set package_id [ad_conn package_id]
+
+form create user_search_results
+
+element create user_search_results selected_users \
+    -label "&nbsp;" \
+    -datatype text \
+    -widget checkbox
+
+element create user_search_results search_action \
+    -label "[_ dotlrn.Action]" \
+    -datatype text \
+    -widget radio \
+    -options [list \
+        [list [_ dotlrn.None] none] \
+        [list [_ dotlrn.Spam_] spam] \
+        [list [_ dotlrn.Add_to_group_] add_to_community] \
+        [list [_ dotlrn.Deactivate_] deactivate] \
+        [list [_ dotlrn.Nuke_] delete] \
+    ] \
+    -value $action
+
+if {[form is_valid user_search_results]} {
+    form get_values user_search_results search_action
+
+    set selected_users [element get_values user_search_results selected_users]
+
+    switch -exact $search_action {
+        "spam" {
+            ad_returnredirect "users-spam?[export_vars {{users $selected_users}}]"
+        }
+        "add_to_community" {
+            ad_returnredirect "users-add-to-community?[export_vars {{users $selected_users}}]"
+        }
+        "deactivate" {
+            ad_returnredirect "users-deactivate?[export_vars {{users $selected_users}}]"
+        }
+        "delete" {
+            ad_returnredirect "users-delete?[export_vars {{users $selected_users}}]"
+        }
+    }
+}
+
+form create user_search
+
+element create user_search name \
+    -label "[_ dotlrn.Name__Email]" \
+    -datatype text \
+    -widget text \
+    -html {size 30} \
+    -optional
+
+element create user_search id \
+    -label "[_ dotlrn.ID_1]" \
+    -datatype text \
+    -widget text \
+    -html {size 10} \
+    -optional
+
+element create user_search type \
+    -label "[_ dotlrn.Type]" \
+    -datatype text \
+    -widget select \
+    -options "[list [_ dotlrn.Any] any] [dotlrn::get_user_types_as_options]" \
+    -value $type
+
+element create user_search can_browse_p \
+    -label "[_ dotlrn.Access_Level]" \
+    -datatype text \
+    -widget select \
+    -options [list [list [_ dotlrn.Any] any] [list [_ dotlrn.Limited] 0] [list [_ dotlrn.Full] 1]] \
+    -value $can_browse_p
+
+element create user_search guest_p \
+    -label "[_ dotlrn.Guest_1]" \
+    -datatype text \
+    -widget select \
+    -options [list [list [_ dotlrn.Any] any] [list [_ dotlrn.Yes] t] [list [_ dotlrn.No] f]] \
+    -value $guest_p
+
+element create user_search role \
+    -label "[_ dotlrn.Role]" \
+    -datatype text \
+    -widget checkbox \
+    -options [dotlrn_community::get_all_roles_as_options] \
+    -optional
+
+element create user_search last_visit_greater \
+    -label "[_ dotlrn.lt_Last_Visit_Over_in_da]" \
+    -datatype text \
+    -widget text \
+    -html {size 10} \
+    -optional
+
+element create user_search last_visit_less \
+    -label "[_ dotlrn.lt_Last_Visit_Within_in_]" \
+    -datatype text \
+    -widget text \
+    -html {size 10} \
+    -optional
+
+element create user_search join_criteria \
+    -label "[_ dotlrn.lt_Join_the_above_criter_1]" \
+    -datatype text \
+    -widget select \
+    -options [list [list [_ dotlrn.And] and] [list [_ dotlrn.Or] or]] \
+    -value $join_criteria
+
+set is_request [form is_request user_search]
+
+if {[form is_valid user_search]} {
+    form get_values user_search \
+        id type can_browse_p guest_p last_visit_greater last_visit_less name join_criteria
+
+    if {([string equal "and" $join_criteria] == 0) && ([string equal "or" $join_criteria] == 0)} {
+        ad_return_error \
+            "[_ dotlrn.lt_There_was_a_bug_in_th]" \
+            "[_ dotlrn.lt_There_was_a_bug_in_th_1]"
+    }
+
+    set context_bar [list [list users [_ dotlrn.Users]] [list users-search [_ dotlrn.User_Search]] [_ dotlrn.Results]]
+
+    set tables [list "dotlrn_users"]
+    set cols [list \
+        "distinct dotlrn_users.user_id" \
+        "dotlrn_users.id" \
+        "dotlrn_users.first_names" \
+        "dotlrn_users.last_name" \
+        "dotlrn_users.email" \
+        "dotlrn_users.type" \
+    ]
+    set wheres [list]
+
+    if {![empty_string_p $name]} {
+        lappend wheres "(lower(dotlrn_users.last_name) like lower('%' || :name || '%') or lower(dotlrn_users.first_names) like lower('%' || :name || '%') or lower(dotlrn_users.email) like lower('%' || :name || '%'))"
+    }
+
+    if {![empty_string_p $id]} {
+        lappend wheres "(lower(dotlrn_users.id) like lower('%' || :id || '%'))"
+    }
+
+    if {![empty_string_p $type]} {
+        if {[string equal "any" $type] == 1} {
+            lappend wheres "dotlrn_users.type in (\'[join [dotlrn::get_user_types] \',\']\')"
+        } else {
+            lappend wheres "dotlrn_users.type = :type"
+        }
+    }
+
+    switch -exact $can_browse_p {
+        any {}
+        1 {
+            lappend wheres "exists (select 1 from acs_permissions where object_id = :package_id and grantee_id = dotlrn_users.user_id and privilege = 'dotlrn_browse')"
+        }
+        0 {
+            lappend wheres "not exists (select 1 from acs_permissions where object_id = :package_id and grantee_id = dotlrn_users.user_id and privilege = 'dotlrn_browse')"
+        }
+    }
+
+    switch -exact $guest_p {
+        any {}
+        t {
+            lappend wheres "exists (select 1 from dotlrn_guest_status where dotlrn_guest_status.user_id = dotlrn_users.user_id and guest_p = 't')"
+        }
+        f {
+            lappend wheres "exists (select 1 from dotlrn_guest_status where dotlrn_guest_status.user_id = dotlrn_users.user_id and guest_p = 'f')"
+        }
+    }
+
+    if {![empty_string_p $last_visit_greater]} {
+        if {[lsearch -exact $tables "users"] == -1} {
+            lappend tables "users"
+        }
+        lappend wheres "(dotlrn_users.user_id = users.user_id and users.last_visit <= (sysdate - :last_visit_greater))"
+    }
+
+    if {![empty_string_p $last_visit_less]} {
+        if {[lsearch -exact $tables "users"] == -1} {
+            lappend tables "users"
+        }
+        lappend wheres "(dotlrn_users.user_id = users.user_id and users.last_visit >= (sysdate - :last_visit_less))"
+    }
+
+    set role_list [element get_values user_search role]
+    set role_list_length [llength $role_list]
+
+    if {$role_list_length} {
+        if {[lsearch -exact $tables "acs_rels"] == -1} {
+            lappend tables "acs_rels"
+        }
+        set in_clause "(dotlrn_users.user_id = acs_rels.object_id_two and acs_rels.rel_type in ("
+
+        set in_elements [list]
+        for {set i 0} {$i < $role_list_length} {incr i} {
+            set in_element__${i} [lindex $role_list $i]
+            lappend in_elements ":in_element__${i}"
+        }
+
+        append in_clause [join $in_elements ", "]
+        append in_clause "))"
+
+        lappend wheres $in_clause
+    }
+
+    set sql "select "
+    append sql [join $cols ", "]
+
+    append sql " from "
+    append sql [join $tables ", "]
+
+    if {[llength $wheres]} {
+        append sql " where "
+        append sql [join $wheres " $join_criteria "]
+	append sql "order by last_name, first_names"
+    }
+
+    set referer [ns_conn url]
+    set selected_users_options [list]
+    set selected_users_values [list]
+    db_foreach select_users $sql {
+        lappend selected_users_options [list "<a href=\"user?[export_vars user_id]\">$last_name, $first_names</a> ($email)" $user_id]
+        lappend selected_users_values $user_id
+    }
+
+    element set_properties user_search_results selected_users \
+        -options $selected_users_options \
+        -values $selected_users_values
+
+    set n_users [llength $selected_users_values]
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-spam.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-spam.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-spam.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,30 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Spam_Users#</property>
+<property name="context_bar">@context_bar@</property>
+
+<formtemplate id="spam_message"></formtemplate>
+
+<include src="/packages/dotlrn/www/spam-variables">
+
+
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users-spam.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users-spam.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users-spam.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,102 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+# dotlrn/www/admin/users-spam.tcl
+
+ad_page_contract {
+    Spam a set of users.
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-02-14
+    @version $Id: users-spam.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    users
+    {referer "users-search"}
+} -properties {
+    context_bar:onevalue
+}
+
+set context_bar [list [list users [_ dotlrn.Users]] [list users-search [_ dotlrn.User_Search]] [_ dotlrn.Spam_Users]]
+
+set sender_id [ad_conn user_id]
+
+db_1row select_sender_info {
+    select parties.email as sender_email,
+           persons.first_names as sender_first_names,
+           persons.last_name as sender_last_name
+    from parties,
+         persons
+    where parties.party_id = :sender_id
+    and persons.person_id = :sender_id
+}
+
+form create spam_message
+
+element create spam_message users \
+    -label "&nbsp;" \
+    -datatype text \
+    -widget hidden \
+    -value $users
+
+element create spam_message from \
+    -label [_ dotlrn.From] \
+    -datatype text \
+    -widget text \
+    -html {size 60} \
+    -value $sender_email
+
+element create spam_message subject \
+    -label [_ dotlrn.Subject] \
+    -datatype text \
+    -widget text \
+    -html {size 60}
+
+element create spam_message message \
+    -label [_ dotlrn.Message] \
+    -datatype text \
+    -widget textarea \
+    -html {rows 10 cols 80 wrap soft}
+
+element create spam_message referer \
+    -label [_ dotlrn.Referer] \
+    -datatype text \
+    -widget hidden \
+    -value $referer
+
+if {[form is_valid spam_message]} {
+    form get_values spam_message \
+        users from subject message referer
+
+    # YON: should redirect and close the connection here so that the user
+    #      doesn't have to wait for the emails to get sent out.
+
+    set message_values [list]
+    lappend message_values [list {<sender_email>} $from]
+
+    spam::send \
+        -recepients $users \
+        -from $from \
+        -real_from $sender_email \
+        -subject $subject \
+        -message $message \
+        -message_values $message_values
+
+    ad_returnredirect $referer
+    ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users.adp	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,62 @@
+<%
+
+    #
+    #  Copyright (C) 2001, 2002 MIT
+    #
+    #  This file is part of dotLRN.
+    #
+    #  dotLRN is free software; you can redistribute it and/or modify it under the
+    #  terms of the GNU General Public License as published by the Free Software
+    #  Foundation; either version 2 of the License, or (at your option) any later
+    #  version.
+    #
+    #  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+    #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+    #  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+    #  details.
+    #
+
+%>
+
+<master src="dotlrn-admin-master">
+<property name="title">#dotlrn.Users#</property>
+<property name="context_bar">@context_bar;noquote@</property>
+
+<% set referer "[dotlrn::get_admin_url]/users" %>
+
+[<small>
+  <a href="../../user-add?add_membership_p=f&dotlrn_interactive_p=1&referer=@referer@"><small>#dotlrn.Create_A_New_User#</small></a> 
+  |
+  <a href="users-search"><small>#dotlrn.Search_Users#</small></a>
+  |
+  <a href="users-bulk-upload"><small>#dotlrn.Bulk_Upload#</small></a>
+</small>]
+
+<p></p>
+
+<form method="get" action="users-search">
+  #dotlrn.lt_Search_dotLRN_users_f# <input type="text" name="name"><input type="submit" value="#dotlrn.search#">
+
+  <input type="hidden" name="form:id" value="user_search">
+
+</form>
+
+<form method="get" action="user-new">
+  #dotlrn.lt_Add_a_new_dotLRN_user# <input type="text" name="search_text"><input type="submit" value="#dotlrn.search#">
+</form>
+
+<p></p>
+
+<p>@control_bar;noquote@</p>
+
+<if @n_users@ gt 500>
+  <include src="users-chunk-large" type=@type@ referer="@referer@?type=@type@">
+</if>
+<else>
+  <if @n_users@ gt 50>
+    <include src="users-chunk-medium" type=@type@ referer="@referer@?type=@type@">
+  </if>
+  <else>
+    <include src="users-chunk-small" type=@type@ referer="@referer@?type=@type@">
+  </else>
+</else>
Index: openacs-4/packages/dotlrn-admin/www/admin/users.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users.tcl	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,67 @@
+#
+#  Copyright (C) 2001, 2002 MIT
+#
+#  This file is part of dotLRN.
+#
+#  dotLRN is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or (at your option) any later
+#  version.
+#
+#  dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+#  details.
+#
+
+ad_page_contract {
+    Displays the admin users page
+
+    @author yon (yon@openforce.net)
+    @creation-date 2002-01-30
+    @version $Id: users.tcl,v 1.1 2004/08/20 14:44:22 andrewg Exp $
+} -query {
+    {type "pending"}
+} -properties {
+    context_bar:onevalue
+    control_bar:onevalue
+    n_users:onevalue
+}
+
+set context_bar [_ dotlrn.Users]
+
+set dotlrn_roles [db_list_of_lists select_dotlrn_roles {
+    select dotlrn_user_types.type,
+           dotlrn_user_types.pretty_name || ' (' || (select count(*)
+                                                     from dotlrn_users
+                                                     where dotlrn_users.type = dotlrn_user_types.type) || ')',
+           ''
+    from dotlrn_user_types
+    order by dotlrn_user_types.pretty_name
+}]
+
+# The roles are stored as message keys in the database so we need to localize them
+# on the fly here
+set dotlrn_roles_localized [list]
+foreach role_pair $dotlrn_roles {
+    lappend dotlrn_roles_localized [list [lindex $role_pair 0] [lang::util::localize [lindex $role_pair 1]]]
+}
+
+set n_pending_users [db_string select_non_dotlrn_users_count {}]
+lappend dotlrn_roles_localized [list pending "[_ dotlrn.Pending] ($n_pending_users)" {}]
+
+set n_deactivated_users [db_string select_deactivated_users_count {}]
+lappend dotlrn_roles_localized [list deactivated "[_ dotlrn.Deactivated] ($n_deactivated_users)" {}]
+
+set control_bar [ad_dimensional [list [list type "[_ dotlrn.User_Type]:" $type $dotlrn_roles_localized]]]
+
+if {[string equal $type "deactivated"] == 1} {
+    set n_users $n_deactivated_users
+} elseif {[string equal $type "pending"] == 1} {
+    set n_users $n_pending_users
+} else {
+    set n_users [db_string select_dotlrn_users_count {}]
+}
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn-admin/www/admin/users.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-admin/www/admin/users.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-admin/www/admin/users.xql	20 Aug 2004 14:44:22 -0000	1.1
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+
+<queryset>
+
+    <fullquery name="select_dotlrn_users_count">
+        <querytext>
+            select count(*)
+            from dotlrn_users
+            where dotlrn_users.type = :type
+        </querytext>
+    </fullquery>
+
+</queryset>