Index: openacs-4/packages/glossar/lib/glossar-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/lib/glossar-list.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/glossar/lib/glossar-list.tcl 2 Nov 2005 15:12:40 -0000 1.5 +++ openacs-4/packages/glossar/lib/glossar-list.tcl 13 Nov 2005 13:39:56 -0000 1.6 @@ -91,7 +91,7 @@ lappend actions "[_ glossar.New_Translation]" [export_vars -base "${base_url}/glossar-add" {owner_id gl_translation_p customer_id}] "[_ glossar.Add_New_Translation]" -set row_list [list title description source_category target_category glossar_edit glossar_files] +set row_list [list checkbox title description source_category target_category glossar_edit glossar_files] set no_perm_p 0 @@ -114,90 +114,92 @@ if { $no_perm_p == 0} { -template::list::create \ - -name gl_glossar \ - -key glossar_id \ - -no_data "[_ glossar.None]" \ - -selected_format $format \ - -pass_properties {customer_id owner_id edit_link} \ - -elements { - title { - label {[_ glossar.glossar_title]} - display_template "@gl_glossar.title@" - } - description { - label {[_ glossar.glossar_description]} - } - source_category { - label {[_ glossar.glossar_source_category_header]} - } - target_category { - label {[_ glossar.glossar_target_category]} - } - glossar_edit { - display_template "[_ acs-kernel.common_Edit]" - } - glossar_files { - display_template "[_ glossar.Files] (@gl_glossar.files_count@)" - } + template::list::create \ + -name gl_glossar \ + -key glossar_id \ + -no_data "[_ glossar.None]" \ + -selected_format $format \ + -pass_properties {customer_id owner_id edit_link} \ + -elements { + title { + label {[_ glossar.glossar_title]} + display_template "@gl_glossar.title@" + } + description { + label {[_ glossar.glossar_description]} + } + source_category { + label {[_ glossar.glossar_source_category_header]} + } + target_category { + label {[_ glossar.glossar_target_category]} + } + glossar_edit { + display_template "[_ acs-kernel.common_Edit]" + } + glossar_files { + display_template "[_ glossar.Files] (@gl_glossar.files_count@)" + } - } -actions $actions -sub_class narrow \ - -bulk_actions {"Move Glossars" "glossar-move" "Moves glossars to another customer"} \ - -orderby { - default_value title - glossar_id { - label {[_ glossar.glossar_id]} - orderby_desc {sort_key asc , gl.glossar_id desc} - orderby_asc {sort_key asc , gl.glossar_id asc} - default_direction desc - } - title { - label {[_ glossar.glossar_title]} - orderby_desc {sort_key asc , crr.title desc} - orderby_asc {sort_key asc , crr.title asc} - default_direction asc - } - } -orderby_name orderby \ - -filters { - customer_id {} - edit_link {} - } \ - -page_size_variable_p 1 \ - -page_size $page_size \ - -page_flush_p 0 \ - -page_query_name gl_glossar \ - -formats { - normal { - label "[_ acs-templating.Table]" - layout table - elements $row_list - } - csv { - label "[_ acs-templating.CSV]" - output csv - page_size 0 - row - } - } + } -actions $actions -sub_class narrow \ + -bulk_actions {"Move Glossars" $gl_glossar.move_url "Moves glossars to another customer"} \ + -orderby { + default_value title + glossar_id { + label {[_ glossar.glossar_id]} + orderby_desc {sort_key asc , gl.glossar_id desc} + orderby_asc {sort_key asc , gl.glossar_id asc} + default_direction desc + } + title { + label {[_ glossar.glossar_title]} + orderby_desc {sort_key asc , crr.title desc} + orderby_asc {sort_key asc , crr.title asc} + default_direction asc + } + } -orderby_name orderby \ + -filters { + customer_id {} + edit_link {} + } \ + -page_size_variable_p 1 \ + -page_size $page_size \ + -page_flush_p 0 \ + -page_query_name gl_glossar \ + -formats { + normal { + label "[_ acs-templating.Table]" + layout table + elements $row_list + } + csv { + label "[_ acs-templating.CSV]" + output csv + page_size 0 + row + } + } -db_multirow -extend {source_category target_category gl_translation_p glossar_edit glossar_files files_url edit_url title_url files_count} gl_glossar gl_glossar {} { - if {![empty_string_p $target_category_id]} { - set gl_translation_p 1 - } else { - set gl_translation_p 0 + db_multirow -extend {source_category target_category gl_translation_p glossar_edit glossar_files files_url edit_url title_url files_count} gl_glossar gl_glossar {} { + if {![empty_string_p $target_category_id]} { + set gl_translation_p 1 + } else { + set gl_translation_p 0 + } + set files_count [db_string get_files_count { } -default 0] + set glossar_edit "[_ glossar.glossar_Edit]" + 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 edit_url "[export_vars -base "${base_url}/glossar-edit" {glossar_id}]" + set files_url "[export_vars -base "${base_url}/glossar-file-upload" {glossar_id}]" + set return_url [ad_conn url] + set move_url "[export_vars -base "${base_url}/glossar-move" {$return_url}]" + } if_no_rows { + + } - set files_count [db_string get_files_count { } -default 0] - set glossar_edit "[_ glossar.glossar_Edit]" - 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 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_no_rows { - - -} } \ No newline at end of file Index: openacs-4/packages/glossar/tcl/glossar-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/tcl/glossar-install-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/glossar/tcl/glossar-install-procs.tcl 2 Nov 2005 15:12:40 -0000 1.3 +++ openacs-4/packages/glossar/tcl/glossar-install-procs.tcl 13 Nov 2005 13:39:56 -0000 1.4 @@ -65,17 +65,22 @@ -from_version_name $from_version_name \ -to_version_name $to_version_name \ -spec { - 0.3d1 0.3d2 { - # Create the default objects to map the category trees using the admin UI - set package_id [ad_conn package_id] - - package_instantiate_object -package_name acs_object -var_list [list [list new__context_id $package_id] [list new__package_id $package_id] [list new__title "#glossar.from_default_object_id#"]] acs_object - - package_instantiate_object -package_name acs_object -var_list [list [list new__context_id $package_id] [list new__package_id $package_id] [list new__title "#glossar.to_default_object_id#"]] acs_object - - } 0.3d2 0.3d3 { content::type::attribute::new -content_type {gl_glossar} -attribute_name {etat_id} -datatype {number} -pretty_name {[_ glossar.glossar_etat]} -column_spec {integer} } + 0.3d3 0.3d4 { + # Create the default objects to map the category trees using the admin UI + set package_ids [db_list glossar_package_ids { + SELECT package_id + FROM apm_packages + WHERE package_key = 'glossar' + }] + foreach package_id $package_ids { + package_instantiate_object -package_name acs_object -var_list [list [list new__context_id $package_id] [list new__package_id $package_id] [list new__title "#glossar.from_default_object_id#"]] acs_object + + package_instantiate_object -package_name acs_object -var_list [list [list new__context_id $package_id] [list new__package_id $package_id] [list new__title "#glossar.to_default_object_id#"]] acs_object + } + } + } } \ No newline at end of file Index: openacs-4/packages/glossar/www/glossar-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/www/glossar-add.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/glossar/www/glossar-add.tcl 2 Nov 2005 15:12:40 -0000 1.3 +++ openacs-4/packages/glossar/www/glossar-add.tcl 13 Nov 2005 13:39:56 -0000 1.4 @@ -54,30 +54,42 @@ if {$gl_translation_p == 1} { - ad_form -extend -name glossar-add -form { - {source_category_id:integer(category) {label "[_ glossar.glossar_source_category]"} {category_tree_id $source_tree_id} {assign_single_p t} {require_category_p t} {html {size 4}} } + {source_category_id:integer(category) {label "[_ glossar.glossar_source_category]"} {category_tree_id $source_tree_id} {category_assign_single_p t} {category_require_category_p t}} - {target_category_id:integer(category) {label "[_ glossar.glossar_target_category]"} {category_tree_id $target_tree_id} {assign_single_p t} {require_category_p f}} + {target_category_id:integer(category) {label "[_ glossar.glossar_target_category]"} {category_tree_id $target_tree_id} {category_assign_single_p t} {category_require_category_p f}} } } else { - ad_form -extend -name glossar-add -form { - {source_category_id:integer(category) {label "[_ glossar.glossar_single_category]"} {category_tree_id $source_tree_id} {assign_single_p t} {require_category_p t} {html {size 4}} } + {source_category_id:integer(category) {label "[_ glossar.glossar_single_category]"} {category_tree_id $source_tree_id} {category_assign_single_p t} {category_require_category_p t}} {target_category_id:text(hidden) {value "[db_null]"}} } } -ad_form -extend -name glossar-add -form { - {etat_id:number(select),optional {label "[_ glossar.glossar_etat]"} - {options [db_list_of_lists get_etats "select name, organization_id from organizations where organization_id in (select case when object_id_one = :owner_id then object_id_two else object_id_one end as organization_id from acs_rels ar, acs_rel_types art where ar.rel_type = art.rel_type and (object_id_one = :owner_id or object_id_two = :owner_id) and ar.rel_type = 'contact_rels_etat'"]}} + +set group_id [group::get_id -group_name "Etat"] +set is_etat_p [db_string check_if_is_etat {} -default 0] + +if {!$is_etat_p} { + set options [db_list_of_lists get_etats {}] + set options [concat [list [list "" ""]] $options] + + ad_form -extend -name glossar-add -form { + {etat_id:integer(select),optional {label "[_ glossar.glossar_etat]"} + {options $options} + } + } +} else { + ad_form -extend -name glossar-add -form { + {etat_id:text(hidden) {value [db_null]}} + } } Index: openacs-4/packages/glossar/www/glossar-add.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/www/glossar-add.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/glossar/www/glossar-add.xql 2 Nov 2005 15:12:40 -0000 1.2 +++ openacs-4/packages/glossar/www/glossar-add.xql 13 Nov 2005 13:39:56 -0000 1.3 @@ -8,7 +8,7 @@ crr.description, gl.source_category_id, gl.target_category_id, - gl.owner_id + gl.owner_id, gl.etat_id from gl_glossars gl, @@ -43,4 +43,27 @@ + + + select count(*) + from group_member_map + where group_id = :group_id + and member_id = :owner_id + + + + + + SELECT name, organization_id as etat_id + FROM organizations + WHERE organization_id in (SELECT CASE WHEN object_id_one = :owner_id + THEN object_id_two + ELSE object_id_one END as organization_id + FROM acs_rels ar, acs_rel_types art + WHERE ar.rel_type = art.rel_type + AND (object_id_one = :owner_id or object_id_two = :owner_id) + AND ar.rel_type = 'contact_rels_etat') + + + Index: openacs-4/packages/glossar/www/glossar-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/www/glossar-edit.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/glossar/www/glossar-edit.tcl 2 Nov 2005 15:12:40 -0000 1.2 +++ openacs-4/packages/glossar/www/glossar-edit.tcl 13 Nov 2005 13:39:56 -0000 1.3 @@ -18,30 +18,64 @@ } -db_1row get_glossar "SELECT title as old_title, comment as old_comment , source_category_id , target_category_id , etat_id , owner_id FROM gl_glossars WHERE glossar_id = :glossar_id" +db_1row get_glossar {} +set from_object_id [db_string get_from_default_object { }] +set to_object_id [db_string get_to_default_object { }] +# We get the mapped category tree's to show in the form +set source_tree_id [lindex [lindex [category_tree::get_mapped_trees $from_object_id] 0] 0] +set target_tree_id [lindex [lindex [category_tree::get_mapped_trees $to_object_id] 0] 0] +ad_form -name glossar-edit -form { + {title:text(text) {lable "[_ glossar.glossar_title]"} } + {comment:text(textarea),optional {lable "[_ glossar.glossar_comment]"} {html{rows 4 cols 30} }} + {glossar_id:integer(hidden)} +} -ad_form -name glossar-edit -form { +if {![empty_string_p $target_category_id]} { + ad_form -extend -name glossar-edit -form { + + {source_category_id:integer(category) {label "[_ glossar.glossar_source_category]"} {category_tree_id $source_tree_id} {category_assign_single_p t} {category_require_category_p t}} - {title:text(text) {lable "[_ glossar.glossar_title]"} {value "$old_title"} } - {comment:text(textarea),optional {lable "[_ glossar.glossar_comment]"} {value "$old_comment"} {html{rows 4 cols 30} }} - {glossar_id:integer(hidden) {value $glossar_id}} + {target_category_id:integer(category) {label "[_ glossar.glossar_target_category]"} {category_tree_id $target_tree_id} {category_assign_single_p t} {category_require_category_p f}} + + } + + +} else { + ad_form -extend -name glossar-edit -form { - {source_category_id:text(hidden) {value "$source_category_id"}} - {target_category_id:text(hidden) {value "$target_category_id"}} - {etat_id:number(select),optional {label "[_ glossar.glossar_etat]"} {options [db_list_of_lists get_etats "select name, organization_id from organizations where organization_id in (select case when object_id_one = :owner_id then object_id_two else object_id_one end as organization_id from acs_rels ar, acs_rel_types art where ar.rel_type = art.rel_type and (object_id_one = :owner_id or object_id_two = :owner_id) and ar.rel_type = 'contact_rels_etat'"]}} - {owner_id:key} + {source_category_id:integer(category) {label "[_ glossar.glossar_single_category]"} {category_tree_id $source_tree_id} {category_assign_single_p t} {category_require_category_p t}} -} -edit_data { + {target_category_id:text(hidden) {value "[db_null]"}} - gl_glossar::edit -glossar_id $glossar_id -title "$title" -comment "$comment" -source_category_id $source_category_id -target_category_id $target_category_id -owner_id $owner_id -etat_id $etat_id -} -edit_request {} + } +} + +set group_id [group::get_id -group_name "Etat"] +set is_etat_p [db_string check_if_is_etat {} -default 0] +if {!$is_etat_p} { + set options [db_list_of_lists get_etats {}] + set options [concat [list [list "" ""]] $options] + ad_form -extend -name glossar-edit -form { + {etat_id:integer(select),optional {label "[_ glossar.glossar_etat]"} {options $options}} + } +} else { + ad_form -extend -name glossar-edit -form { + {etat_id:text(hidden) {value [db_null]}} + } +} +ad_form -extend -name glossar-edit -form { + {owner_id:key} +} -edit_data { + gl_glossar::edit -glossar_item_id $glossar_id -title $title -description $comment -source_category_id $source_category_id -target_category_id $target_category_id -owner_id $owner_id -etat_id $etat_id +} -edit_request { +} Index: openacs-4/packages/glossar/www/glossar-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/www/glossar-edit.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossar/www/glossar-edit.xql 13 Nov 2005 13:39:56 -0000 1.1 @@ -0,0 +1,66 @@ + + + + + + SELECT r.title, + r.description as comment, + g.source_category_id, + g.target_category_id, + g.etat_id, + g.owner_id + FROM gl_glossars g, + cr_revisions r, + cr_items i + WHERE i.item_id = :glossar_id + AND r.revision_id = i.latest_revision + AND g.glossar_id = r.revision_id + + + + + + SELECT name, organization_id as etat_id + FROM organizations + WHERE organization_id in (SELECT CASE WHEN object_id_one = :owner_id + THEN object_id_two + ELSE object_id_one END as organization_id + FROM acs_rels ar, acs_rel_types art + WHERE ar.rel_type = art.rel_type + AND (object_id_one = :owner_id or object_id_two = :owner_id) + AND ar.rel_type = 'contact_rels_etat') + + + + + + select + object_id + from + acs_objects + where + title = '#glossar.from_default_object_id#' + + + + + + select + object_id + from + acs_objects + where + title = '#glossar.to_default_object_id#' + + + + + + select count(*) + from group_member_map + where group_id = :group_id + and member_id = :owner_id + + + + Index: openacs-4/packages/glossar/www/glossar-move.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/www/glossar-move.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossar/www/glossar-move.adp 13 Nov 2005 13:39:56 -0000 1.1 @@ -0,0 +1,14 @@ + +Move glossar +@context@ + +

Move glossar

+ +

Search for Customers who's name contains:

+

+ +

+ + + + \ No newline at end of file Index: openacs-4/packages/glossar/www/glossar-move.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/www/glossar-move.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossar/www/glossar-move.tcl 13 Nov 2005 13:39:56 -0000 1.1 @@ -0,0 +1,39 @@ +ad_page_contract { + glossar-move + + A page to allow the moving of a glossar to other customers. + + @author Al-Faisal El-Dajani (faisal.dajani@gmail.com) + @creation-date 2005-10-24 + +} { + {return_url "/"} + {query ""} + {glossar_id:notnull,multiple} +} + +set context "search" +set search_id "" +set glossar_id [string trim $glossar_id "{}"] + + +ad_form -name search -export {glossar_id} -form { + {query:text(text) {label ""} {html {size 24}}} + {Search:text(submit) {value "Search"}} +} + +template::list::create \ + -name customers \ + -multirow customers \ + -key customer_id \ + -elements { + name { + label {} + display_template { + @customers.name@ \[select\] + } + } + } +db_multirow -extend {move_url} customers get_customers_from_prefix {} { + set move_url [export_vars -base "move-glossar" {{customer_id $organization_id} glossar_id:multiple return_url}] +} \ No newline at end of file Index: openacs-4/packages/glossar/www/glossar-move.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/www/glossar-move.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossar/www/glossar-move.xql 13 Nov 2005 13:39:56 -0000 1.1 @@ -0,0 +1,17 @@ + + + + + + + SELECT o.name , o.organization_id + FROM organizations o, parties p + WHERE o.organization_id = p.party_id + AND o.organization_id in ([template::util::tcl_to_sql_list [group::get_members -group_id [group::get_id -group_name "Customers"]]]) + [contact::search_clause -and -search_id $search_id -query $query -party_id "o.party_id" -revision_id "revision_id"] + + + + + + Index: openacs-4/packages/glossar/www/move-glossar.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/glossar/www/move-glossar.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/glossar/www/move-glossar.tcl 13 Nov 2005 13:39:56 -0000 1.1 @@ -0,0 +1,27 @@ +ad_page_contract { + Moves a glossar to a customer +} { + customer_id:integer,notnull + glossar_id:integer,notnull,multiple + {return_url} +} + +foreach id $glossar_id { + set glossar_revision_id [content::item::get_best_revision -item_id $id] + db_1row get_glossar_info { + SELECT g.source_category_id, g.target_category_id, g.etat_id, r.title, r.description + FROM gl_glossars g, cr_revisions r + WHERE g.glossar_id = :glossar_revision_id + AND g.glossar_id = r.revision_id + } + + gl_glossar::edit -glossar_item_id $id \ + -owner_id $customer_id \ + -source_category_id $source_category_id\ + -target_category_id $target_category_id\ + -etat_id $etat_id \ + -title $title \ + -description $description +} + +ad_returnredirect $return_url \ No newline at end of file