Index: openacs-4/packages/glossar/lib/glossar-portlet-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/lib/glossar-portlet-list.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/glossar/lib/glossar-portlet-list.tcl 21 Oct 2005 14:28:33 -0000 1.2 +++ openacs-4/packages/glossar/lib/glossar-portlet-list.tcl 2 Jan 2006 13:22:06 -0000 1.3 @@ -7,12 +7,12 @@ # @arch-tag: 4324b14c-cb5d-4512-b56d-0e0ab10ff025 # @cvs-id $Id$ -foreach required_param {owner_ids} { +foreach required_param {owner_id} { if {![info exists $required_param]} { return -code error "$required_param is a required parameter." } } -foreach optional_param {gl_format gl_customer_id gl_orderby} { +foreach optional_param {gl_format gl_orderby} { if {![info exists $optional_param]} { set $optional_param {} } @@ -23,30 +23,33 @@ [dotlrn_community::get_community_id_from_url] \ ] -set glossar_id "0" - -set gl_translation_p 0 set page_size 100 set base_url "glossar" +set user_id [ad_conn user_id] -if [empty_string_p "[ad_conn user_id]"] { +if {[empty_string_p $user_id]} { ad_redirect_for_registration } -set customer_id [lindex $owner_ids 0] -set where_etat_ids [join [lrange $owner_ids 1 [llength $owner_ids]] "','" ] -set actions "" -ns_log notice "WHERE $where_etat_ids , owner $customer_id " +if {[goup::member_p -user_id $user_id -group_name Customer]} { + # owner is customer + set customer_id $owner_id + set query_name gl_glossar_portlet_customer +} else { + # owner is etat + set etat_id $owner_id + set query_name gl_glossar_portlet_etat +} -# We check if the owner_id is an relation, if it is, the real_owner_id +# We check if the owner_id is a relation, if it is, the real_owner_id # becomes the eta_id stored in gl_glossars, else it becomes the # owner_id which can be a customer_id or a etat_id. # We still pass on the owner_id to check permission. # Only if the owner_id is an relation we have two id's an etat_id # (glossar owner) and an extra custommer_id which is stored in # gl_glossar_terms to indicate which terms of a glossar , owned by a # etat, belong to a specific customer. -# This results into thre possible displays. +# This results into three possible displays. # 1. owner_id is a customer_id (all glossars , owned by customer_id, # with all terms will be displayed) # @@ -59,8 +62,8 @@ # 3. owner_id is a relation_id (all glossars, owned by the etat_id # which is stored in the relations object_id_one column, with all # terms having a customer_id, equal to the relations object_id_two. -# Question: Should it be possible to to display all glossars -# owned by the relations object_id_two (custommer_id) including all +# Question: Should it be possible to display all glossars +# owned by the relations object_id_two (customer_id) including all # terms as well? @@ -69,28 +72,26 @@ # No actions just a list of glossars -#set actions [list "[_ glossar.New_Lecture]" [export_vars -base "${base_url}/glossar-add" {owner_id gl_translation_p }] "[_ glossar.New_Lecture]"] +set actions [list "[_ glossar.New_Lecture]" [export_vars -base "${base_url}/glossar-add" {owner_id gl_translation_p }] "[_ glossar.New_Lecture]"] -set gl_translation_p 1 +lappend actions "[_ glossar.New_Translation]" [export_vars -base "${base_url}/glossar-add" {owner_id gl_translation_p }] "[_ glossar.Add_New_Translation]" -#lappend actions "[_ glossar.New_Translation]" [export_vars -base "${base_url}/glossar-add" {owner_id gl_translation_p }] "[_ glossar.Add_New_Translation]" +set row_list [list name {} title {} description {} source_category {} target_category {} glossar_edit {} glossar_files {}] -set row_list [list name title description source_category target_category glossar_edit glossar_files] - # Just check permission on the first owner_id (the current customer) set no_perm_p 0 -if [permission::permission_p -object_id $customer_id -privilege admin] { +if [permission::permission_p -object_id $owner_id -privilege admin] { -} elseif {[permission::permission_p -object_id $customer_id -privilege create]} { +} elseif {[permission::permission_p -object_id $owner_id -privilege create]} { set user_perm create -} elseif {[permission::permission_p -object_id $customer_id -privilege read]} { +} elseif {[permission::permission_p -object_id $owner_id -privilege read]} { set actions "" - set row_list [list name title description source_category target_category] + set row_list [list name {} title {} description {} source_category {} target_category {}] } else { @@ -100,15 +101,14 @@ } -set owner_id 0 if {$no_perm_p == 0} { template::list::create \ -name gl_glossar_portlet \ -key glossar_id \ -no_data "[_ glossar.None]" \ -selected_format $gl_format \ - -pass_properties {customer_id owner_ids edit_link } \ + -pass_properties {owner_id edit_link } \ -elements { name { label {[_ glossar.Organization_Name]} @@ -128,7 +128,7 @@ label {[_ glossar.glossar_target_category]} } glossar_edit { - display_template "[_ acs-kernel.common_Edit]" + display_template {#acs-kernel.common_Edit#} } glossar_files { display_template "[_ glossar.Files]" @@ -145,13 +145,13 @@ } title { label {[_ glossar.glossar_title]} - orderby_desc {sort_key asc , title desc} - orderby_asc {sort_key asc , title asc} + orderby_desc {sort_key asc, lower(title) desc} + orderby_asc {sort_key asc, lower(title) asc} default_direction asc } } -orderby_name orderby \ -filters { - customer_id {} + owner_id {} edit_link {} } \ -formats { @@ -169,9 +169,7 @@ } -set static_customer_id $customer_id - -db_multirow -extend {source_category target_category gl_translation_p glossar_edit glossar_files files_url edit_url title_url new_glossar} gl_glossar_portlet gl_glossar_portlet {} { +db_multirow -extend {source_category target_category gl_translation_p glossar_edit glossar_files files_url edit_url title_url new_glossar} gl_glossar_portlet $query_name {} { if {![empty_string_p $target_category_id]} { set gl_translation_p 1 } else { @@ -181,17 +179,17 @@ set glossar_files "[_ glossar.files]" set source_category "[category::get_name $source_category_id]" set target_category "[category::get_name $target_category_id]" - set title_url "[export_vars -base "${base_url}/glossar-term-list" {glossar_id gl_translation_p customer_id owner_id}]" + set title_url "[export_vars -base "${base_url}/glossar-term-list" {glossar_id gl_translation_p owner_id}]" set edit_url "[export_vars -base "${base_url}/glossar-add" {owner_id glossar_id gl_translation_p }]" set files_url "[export_vars -base "${base_url}/glossar-file-upload" {glossar_id}]" - if {$customer_id == $owner_id} { + if {$gl_owner_id == $owner_id} { set new_glossar "[export_vars -base "${base_url}/index" {owner_id}]" } else { - set new_glossar "[export_vars -base "${base_url}/index" {owner_id customer_id}]" + set new_glossar "[export_vars -base "${base_url}/index" {owner_id {customer_id $gl_owner_id}}]" } } if_no_rows { } -} \ No newline at end of file +}