Index: openacs-4/contrib/packages/classified-ads/www/admin/field-addedit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/field-addedit.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/contrib/packages/classified-ads/www/admin/field-addedit.tcl 29 Jul 2003 09:10:42 -0000 1.3 +++ openacs-4/contrib/packages/classified-ads/www/admin/field-addedit.tcl 30 Jul 2003 04:56:41 -0000 1.4 @@ -2,6 +2,7 @@ Add/Edit fields (attributes) @author Paul Doerwald (paul@liquidmedia.ca) + @author Roberto Mello @creation-date 2002-10-24 } { attribute_id:integer,notnull,optional @@ -32,8 +33,19 @@ set package_id [ad_conn package_id] set indent_pattern "-" set indent_factor 2 -set main_category_id [classified-ads::main_keyword_exists_p] +# +# RBM: If the user is a site-wide admin, then we show up to the root +# category, to allow the adding of site-wide fields. But otherwise +# we only go up to this package's top category. +# + +if {[acs_user::site_wide_admin_p]} { + set main_category_id [classified-ads::get_main_keyword_id] +} else { + set main_category_id [classified-ads::get_package_keyword_id] +} + template::form create new_field if {[template::form is_request new_field] && [info exists attribute_id]} { @@ -78,18 +90,12 @@ -html "size 30" \ -value $pretty_plural -# -# RBM: FIXME: We should allow adding of site-wide fields here. In order to -# realize that we need to give the main root category as argument to the user. -# Figure out how. -# - template::element create new_field keyword_id \ -widget select \ -datatype integer \ -label "Category" \ -help_text "The category to which this new field will belong to. A category of name \"classified-ads-package-xxx\" means the main category for this package instance, and the field will be available to all its subcategories." \ - -options [db_list_of_lists categories { }] \ + -options [classified-ads::categories::get_all_tree -keyword_id $main_category_id] \ -value $keyword_id template::element create new_field datatype \