Index: openacs-4/packages/dotlrn-catalog/lib/course-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-catalog/lib/course-chunk.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/dotlrn-catalog/lib/course-chunk.tcl 10 May 2005 14:14:52 -0000 1.8
+++ openacs-4/packages/dotlrn-catalog/lib/course-chunk.tcl 2 Nov 2005 20:30:21 -0000 1.9
@@ -4,9 +4,15 @@
@author Viaro Networks www.viaro.net
@creation-date 08-01-2005
} {
-
+ {enroll_p "1"}
}
+db_0or1row get_course_dates { }
+set referer "[ad_conn url]?course_id=$course_id"
+if {[exists_and_not_null start_date] && [exists_and_not_null end_date]} {
+ set enroll_p [dotlrn_catalog::get_enroll_p -start_date $start_date -end_date $end_date]
+}
+
set dotlrn_url [dotlrn::get_url]
if { ![info exists index] } {
set index ""
@@ -31,12 +37,12 @@
}
set category_p [db_string get_category { } -default -1]
+
set info [ad_html_text_convert -from text/enhanced -to text/plain $info]
-set reg_asm_id [parameter::get -parameter AsmForRegisterId -package_id [ad_conn subsite_id]]
-set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+set reg_asm_id [parameter::get -parameter RegistrationId -package_id [subsite::main_site_id]]
+set cc_package_id [ad_conn package_id]
set tree_id [db_string get_tree_id { } -default "-1"]
-
# Get the category name
set category_name "[category::get_name [category::get_mapped_categories $course_id]]"
@@ -46,18 +52,19 @@
set item_id [dotlrn_catalog::get_item_id -revision_id $course_id]
if { [permission::permission_p -object_id $course_id -privilege "admin"] } {
set admin_p 1
- } else {
- set admin_p 0
}
}
+if { [acs_user::site_wide_admin_p] } {
+ set admin_p 1
+}
set obj_n 0
set dotlrn_class "("
set dotlrn_com "("
# For dotlrn associations
-db_multirow -extend { obj_n admin_p } relations relation { } {
+db_multirow -extend { obj_n } relations relation { } {
set obj_n 1
if { [string equal $type "dotlrn_catalog_class_rel" ]} {
append dotlrn_class "'$object_id'"
@@ -70,75 +77,127 @@
append dotlrn_class "0)"
append dotlrn_com "0)"
-db_multirow classes_list get_dotlrn_classes { }
+db_multirow -extend { join } classes_list get_dotlrn_classes { } {
+ if {![dotlrn_community::member_p $object_id [ad_conn user_id]]} {
+ if { $asmid == -1 } {
+ if {[dotlrn_community::member_pending_p -community_id $object_id -user_id [ad_conn user_id]]} {
+ set join "\[ \#dotlrn.Pending_Approval\# \]"
+ } elseif {![dotlrn_community::not_closed_p -community_id $object_id]} {
+ set join ""
+ } elseif {[dotlrn_community::needs_approval_p -community_id $object_id]} {
+ set label "Request Membership"
+ set join "\#dotlrn-catalog.request_membership_link\#"
+ } else {
+ set join "#dotlrn.join_link#"
+ }
+ }
+ } else {
+ set join "\[[_ dotlrn-catalog.member_p] \]"
+ }
+}
+set elements {
+ class {
+ label "[_ dotlrn-catalog.class_name]"
+ display_template {
+
+ @classes_list.pretty_name@
+
+
+ @classes_list.pretty_name@
+
+ }
+ }
+ dep_name {
+ label "[_ dotlrn-catalog.dep_name]"
+ display_template {
+ @classes_list.department_name@
+ }
+ }
+ term_name {
+ label "[_ dotlrn-catalog.term_name]"
+ display_template {
+ @classes_list.term_name@
+ }
+ }
+ subject {
+ label "[_ dotlrn-catalog.subject_name]"
+ display_template {
+ @classes_list.class_name@
+ }
+ }
+ join {
+ display_template {
+ @classes_list.join;noquote@
+ }
+ }
+}
+
+
+
template::list::create \
-name dotlrn_classes \
-multirow classes_list \
-key object_id \
-row_pretty_plural "[_ dotlrn-catalog.dotlrn_classes]" \
- -elements {
- class {
- label "[_ dotlrn-catalog.class_name]"
- display_template {
-
- @classes_list.pretty_name@
-
-
- @classes_list.pretty_name@
-
- }
- }
- dep_name {
- label "[_ dotlrn-catalog.dep_name]"
- display_template {
- @classes_list.department_name@
- }
- }
- term_name {
- label "[_ dotlrn-catalog.term_name]"
- display_template {
- @classes_list.term_name@
- }
- }
- subject {
- label "[_ dotlrn-catalog.subject_name]"
- display_template {
- @classes_list.class_name@
- }
- }
+ -elements $elements
+
+set elements {
+ community {
+ label "[_ dotlrn-catalog.com_name]"
+ display_template {
+
+ @com_list.pretty_name@
+
+
+ @com_list.pretty_name@
+
+ }
}
+ join {
+ display_template {
+ @com_list.join;noquote@
+ }
+ }
+}
-db_multirow com_list get_dotlrn_communities { }
+db_multirow -extend {join} com_list get_dotlrn_communities {} {
+ if {![dotlrn_community::member_p $object_id [ad_conn user_id]]} {
+ if { $asmid == -1 } {
+ if {[dotlrn_community::member_pending_p -community_id $object_id -user_id [ad_conn user_id]]} {
+ set join "\[ \#dotlrn.Pending_Approval\# \]"
+ } elseif {![dotlrn_community::not_closed_p -community_id $object_id]} {
+ set join ""
+ } elseif {[dotlrn_community::needs_approval_p -community_id $object_id]} {
+ set label "Request Membership"
+ set join "\#dotlrn-catalog.request_membership_link\#"
+ } else {
+ set join "#dotlrn.join_link#"
+ }
+ }
+ } else {
+ set join "\[[_ dotlrn-catalog.member_p] \]"
+ }
+}
+
template::list::create \
-name dotlrn_communities \
-multirow com_list \
-key object_id \
-row_pretty_plural "[_ dotlrn-catalog.dotlrn_com]" \
- -elements {
- community {
- label "[_ dotlrn-catalog.com_name]"
- display_template {
-
- @com_list.pretty_name@
-
-
- @com_list.pretty_name@
-
- }
- }
- }
+ -elements $elements
#Send the registration assessment_id
-set reg_chunck "assessment_id=$asmid"
+set ret_chunck "../assessment/assessment?assessment_id=$asmid"
if { ![string eq $reg_asm_id 0] } {
+
if { [ad_conn user_id] == 0} {
- set reg_chunck "assessment_id=$reg_asm_id&next_asm=$asmid"
+ set ret_chunck "../assessment/assessment?assessment_id=$reg_asm_id&next_asm=$asmid"
}
}