Index: openacs-4/packages/dotlrn/dotlrn.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/dotlrn.info,v
diff -u -r1.85 -r1.86
--- openacs-4/packages/dotlrn/dotlrn.info 20 May 2002 20:12:41 -0000 1.85
+++ openacs-4/packages/dotlrn/dotlrn.info 21 May 2002 06:52:34 -0000 1.86
@@ -289,6 +289,8 @@
+
+
@@ -419,16 +421,16 @@
-
+
-
+
-
-
+
+
Index: openacs-4/packages/dotlrn/tcl/community-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.tcl,v
diff -u -r1.126 -r1.127
--- openacs-4/packages/dotlrn/tcl/community-procs.tcl 21 May 2002 01:08:39 -0000 1.126
+++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 21 May 2002 06:52:34 -0000 1.127
@@ -418,67 +418,139 @@
return [db_string select_node_url {} -default ""]
}
- ad_proc set_attribute {
- community_id
- attribute_name
- attribute_value
+ ad_proc -public get_default_roles {
+ {-community_id ""}
} {
- Set an attribute for a community
+ get default rel_type data for this community
} {
- # Not sure what to do here yet
+ if {[empty_string_p $community_id]} {
+ set community_id [get_community_id]
+ }
+ set community_type [get_community_type_from_community_id $community_id]
+
+ return [util_memoize "dotlrn_community::get_default_roles_not_cached -community_type $community_type"]
}
- ad_proc -public get_allowed_rel_types {
+ ad_proc -private get_default_roles_not_cached {
+ {-community_type:required}
+ } {
+ if {[string match $community_type dotlrn_club]} {
+ set community_type dotlrn_community
+ } elseif {![string match $community_type dotlrn_community]} {
+ set community_type dotlrn_class_instance
+ }
+
+ return [db_list_of_lists select_role_data {}]
+ }
+
+ ad_proc -private get_roles {
{-community_id:required}
} {
- set community_type [get_community_type_from_community_id $community_id]
+ set default_roles [eval concat [get_default_roles -community_id $community_id]]
+ set attributes [eval concat [get_attributes -community_id $community_id]]
- # Subcomm
- if {$community_type == "dotlrn_community"} {
- return {dotlrn_member_rel dotlrn_admin_rel}
- }
+ set roles [list]
+ foreach {rel_type role pretty_name pretty_plural} $default_roles {
+ set new_role [list]
- # club
- if {$community_type == "dotlrn_club"} {
- return {dotlrn_member_rel dotlrn_admin_rel}
+ lappend new_role $rel_type
+ lappend new_role $role
+
+ set i [lsearch -exact $attributes "${role}_pretty_name"]
+ if {$i > -1} {
+ lappend new_role [lindex $attributes [expr $i + 1]]
+ } else {
+ lappend new_role $pretty_name
+ }
+
+ set i [lsearch -exact $attributes "${role}_pretty_plural"]
+ if {$i > -1} {
+ lappend new_role [lindex $attributes [expr $i + 1]]
+ } else {
+ lappend new_role $pretty_plural
+ }
+
+ lappend roles $new_role
}
- # else, it's a class instance
- return {dotlrn_student_rel dotlrn_ta_rel dotlrn_instructor_rel dotlrn_ca_rel dotlrn_cadmin_rel}
+ return $roles
}
ad_proc -public get_all_roles {} {
return the list of roles used in dotLRN
} {
- return {dotlrn_admin_rel dotlrn_member_rel dotlrn_instructor_rel dotlrn_cadmin_rel dotlrn_ca_rel dotlrn_ta_rel dotlrn_student_rel}
+ return [util_memoize {dotlrn_community::get_all_roles_not_cached}]
}
+ ad_proc -private get_all_roles_not_cached {} {
+ return [db_list_of_lists select_all_roles {}]
+ }
+
ad_proc -public get_all_roles_as_options {} {
return the list of roles used in dotLRN
} {
- set roles [list]
+ set role_options [list]
- foreach role [get_all_roles] {
- lappend roles [list [get_role_pretty_name_from_rel_type -rel_type $role] $role]
+ foreach {rel_type role pretty_name pretty_plural} [eval concat [get_all_roles]] {
+ lappend role_options [list $pretty_name $rel_type]
}
- return $roles
+ return $role_options
}
- ad_proc -public get_role_from_rel_type {
- {-rel_type:required}
+ ad_proc -public set_roles_pretty_data {
+ {-community_id ""}
+ {-roles_data:required}
} {
- returns the role associated with this rel_type
+ set the pretty_name and pretty_plural for several roles
} {
- return [db_string select_role {} -default ""]
+ if {[empty_string_p $community_id]} {
+ set community_id [get_community_id]
+ }
+
+ foreach {rel_type role pretty_name pretty_plural} [eval concat $roles_data] {
+ set_role_pretty_data \
+ -community_id $community_id \
+ -rel_type $rel_type \
+ -role $role \
+ -pretty_name $pretty_name \
+ -pretty_plural $pretty_plural
+ }
}
- ad_proc -public get_role_pretty_name_from_rel_type {
+ ad_proc -public set_role_pretty_data {
+ {-community_id ""}
{-rel_type:required}
+ {-role:required}
+ {-pretty_name:required}
+ {-pretty_plural:required}
} {
- Returns the pretty version of the role
+ set the pretty_name and pretty_plural of a role for a community
} {
- return [db_string select_role_pretty_name {} -default ""]
+ if {[empty_string_p $community_id]} {
+ set community_id [get_community_id]
+ }
+
+ set roles [eval concat [get_roles -community_id $community_id]]
+ set i [lsearch -exact $roles $rel_type]
+
+ if {$i > -1} {
+ set old_pretty_name [lindex $roles [expr $i + 2]]
+ if {![string match $pretty_name $old_pretty_name]} {
+ set_attribute \
+ -community_id $community_id \
+ -attribute_name "${role}_pretty_name" \
+ -attribute_value $pretty_name
+ }
+
+ set old_pretty_plural [lindex $roles [expr $i + 3]]
+ if {![string match $pretty_plural $old_pretty_plural]} {
+ set_attribute \
+ -community_id $community_id \
+ -attribute_name "${role}_pretty_plural" \
+ -attribute_value $pretty_plural
+ }
+ }
}
ad_proc -public get_rel_segment_id {
@@ -493,21 +565,13 @@
ad_proc -private get_members_rel_id {
{-community_id:required}
} {
- } {
- return [get_rel_segment_id \
- -community_id $community_id \
- -rel_type "dotlrn_member_rel"
- ]
+ return [get_rel_segment_id -community_id $community_id -rel_type dotlrn_member_rel]
}
ad_proc -private get_admin_rel_id {
{-community_id:required}
} {
- } {
- return [get_rel_segment_id \
- -community_id $community_id \
- -rel_type "dotlrn_admin_rel"
- ]
+ return [get_rel_segment_id -community_id $community_id -rel_type dotlrn_admin_rel]
}
ad_proc -private rel_segments_grant_permission {
@@ -1813,7 +1877,7 @@
# acs_attribute_values.attr_value column does not have a "not null"
# constraint but we will enforce it via our api. if someone circumvents
# our api then they can die and rot in hell.
- if {[empty_string_p [get_attribute -community_id $community_id -attribute_name $attribute_name]} {
+ if {[empty_string_p [get_attribute -community_id $community_id -attribute_name $attribute_name]]} {
db_dml insert_attribute {}
} else {
db_dml update_attribute_value {}
@@ -1831,7 +1895,7 @@
foreach {attr_id attr_name} [eval concat [get_available_attributes]] {
if {[string match $attribute_name $attr_name]} {
- set attribute_id $attr_id]
+ set attribute_id $attr_id
break
}
}
Index: openacs-4/packages/dotlrn/tcl/community-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.xql,v
diff -u -r1.61 -r1.62
--- openacs-4/packages/dotlrn/tcl/community-procs.xql 21 May 2002 00:53:58 -0000 1.61
+++ openacs-4/packages/dotlrn/tcl/community-procs.xql 21 May 2002 06:52:34 -0000 1.62
@@ -95,21 +95,32 @@
-
+
- select role_two
- from acs_rel_types
- where rel_type = :rel_type
+ select acs_rel_types.rel_type,
+ acs_rel_roles.role,
+ acs_rel_roles.pretty_name,
+ acs_rel_roles.pretty_plural
+ from acs_rel_types,
+ acs_rel_roles
+ where acs_rel_types.object_type_one = :community_type
+ and acs_rel_types.role_two = acs_rel_roles.role
-
+
- select pretty_name
- from acs_rel_roles
- where role = (select role_two
- from acs_rel_types
- where rel_type = :rel_type)
+ select acs_rel_types.rel_type,
+ acs_rel_roles.role,
+ acs_rel_roles.pretty_name,
+ acs_rel_roles.pretty_plural
+ from acs_rel_types,
+ acs_rel_roles
+ where acs_rel_types.object_type_one in (select dotlrn_community_types.community_type
+ from dotlrn_community_types
+ where dotlrn_community_types.supertype is null
+ or dotlrn_community_types.supertype = 'dotlrn_community')
+ and acs_rel_types.role_two = acs_rel_roles.role
@@ -545,7 +556,8 @@
update acs_attribute_values
set attr_value = :attribute_value
- where object_id = :community_id
+ where attribute_id = :attribute_id
+ and object_id = :community_id
Index: openacs-4/packages/dotlrn/www/community-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/community-edit.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/community-edit.adp 21 May 2002 06:52:34 -0000 1.1
@@ -0,0 +1,29 @@
+
+
+
+@title@
+@context_bar@
+
+
+
+
+
+
+
+
Index: openacs-4/packages/dotlrn/www/community-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/community-edit.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/community-edit.tcl 21 May 2002 06:52:34 -0000 1.1
@@ -0,0 +1,115 @@
+#
+# Copyright (C) 2001, 2002 OpenForce, Inc.
+#
+# 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/community-edit.tcl
+
+ad_page_contract {
+
+ Edit the properties for a community
+
+ @author yon@openforce.net
+ @creation-date 2002-05-20
+ @version $Id: community-edit.tcl,v 1.1 2002/05/21 06:52:34 yon Exp $
+
+} -query {
+ {referer "community-edit"}
+}
+
+set user_id [ad_conn user_id]
+set community_id [dotlrn_community::get_community_id]
+
+dotlrn::require_user_admin_community -user_id $user_id $community_id
+
+db_1row select_community_info {
+ select pretty_name,
+ description
+ from dotlrn_communities
+ where community_id = :community_id
+}
+
+form create edit_community_info
+
+element create edit_community_info pretty_name \
+ -label Name \
+ -datatype text \
+ -widget text \
+ -html {size 60} \
+ -value $pretty_name
+
+element create edit_community_info description \
+ -label Description \
+ -datatype text \
+ -widget textarea \
+ -html {rows 5 cols 60 wrap soft} \
+ -value $description \
+ -optional
+
+if {[form is_valid edit_community_info]} {
+ form get_values edit_community_info pretty_name description
+
+ db_dml update_community_info {
+ update dotlrn_communities_all
+ set pretty_name = :pretty_name,
+ description = :description
+ where community_id = :community_id
+ }
+
+ ad_returnredirect $referer
+ ad_script_abort
+}
+
+set roles [dotlrn_community::get_roles -community_id $community_id]
+
+form create edit_community_role_names
+
+foreach {rel_type role pretty_name pretty_plural} [eval concat $roles] {
+ element create edit_community_role_names "${role}_pretty_name" \
+ -label "$role Pretty Name" \
+ -datatype text \
+ -widget text \
+ -html {size 60} \
+ -value $pretty_name
+
+ element create edit_community_role_names "${role}_pretty_plural" \
+ -label "$role Pretty Plural" \
+ -datatype text \
+ -widget text \
+ -html {size 60} \
+ -value $pretty_plural
+}
+
+if {[form is_valid edit_community_role_names]} {
+ set new_roles [list]
+
+ foreach {rel_type role pretty_name pretty_plural} [eval concat $roles] {
+ lappend new_roles [list \
+ $rel_type \
+ $role \
+ [element get_value edit_community_role_names "${role}_pretty_name"] \
+ [element get_value edit_community_role_names "${role}_pretty_plural"] \
+ ]
+ }
+
+ dotlrn_community::set_roles_pretty_data -community_id $community_id -roles_data $new_roles
+
+ ad_returnredirect $referer
+ ad_script_abort
+}
+
+set title {Edit Properties}
+set context_bar {{one-community-admin Administer} {Edit Properties}}
+
+ad_return_template
Index: openacs-4/packages/dotlrn/www/member-add-2.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/member-add-2.adp,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/dotlrn/www/member-add-2.adp 29 Mar 2002 19:14:46 -0000 1.9
+++ openacs-4/packages/dotlrn/www/member-add-2.adp 21 May 2002 06:52:34 -0000 1.10
@@ -29,7 +29,7 @@
Role:
Index: openacs-4/packages/dotlrn/www/member-add-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/member-add-2.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/dotlrn/www/member-add-2.tcl 29 Mar 2002 19:14:46 -0000 1.6
+++ openacs-4/packages/dotlrn/www/member-add-2.tcl 21 May 2002 06:52:34 -0000 1.7
@@ -42,12 +42,12 @@
}
# Depending on the community_type, we have allowable rel_types
-set rel_types [dotlrn_community::get_allowed_rel_types -community_id $community_id]
+set rel_types [dotlrn_community::get_roles -community_id $community_id]
template::multirow create roles rel_type pretty_name
-foreach rel_type $rel_types {
- template::multirow append roles $rel_type [dotlrn_community::get_role_pretty_name_from_rel_type -rel_type $rel_type]
+foreach role $rel_types {
+ template::multirow append roles [lindex $role 0] [lindex $role 2]
}
ad_return_template
Index: openacs-4/packages/dotlrn/www/one-community-admin.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/one-community-admin.tcl,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/dotlrn/www/one-community-admin.tcl 6 May 2002 23:55:02 -0000 1.18
+++ openacs-4/packages/dotlrn/www/one-community-admin.tcl 21 May 2002 06:52:34 -0000 1.19
@@ -37,7 +37,7 @@
set user_id [ad_get_user_id]
# Permissions
-dotlrn::require_user_admin_community $community_id
+dotlrn::require_user_admin_community -user_id $user_id $community_id
db_1row select_community_info {}
Index: openacs-4/packages/dotlrn-portlet/www/dotlrn-admin-portlet.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-portlet/www/dotlrn-admin-portlet.adp,v
diff -u -r1.16 -r1.17
--- openacs-4/packages/dotlrn-portlet/www/dotlrn-admin-portlet.adp 19 May 2002 16:19:46 -0000 1.16
+++ openacs-4/packages/dotlrn-portlet/www/dotlrn-admin-portlet.adp 21 May 2002 06:53:03 -0000 1.17
@@ -18,26 +18,28 @@
%>
-