Index: openacs-4/packages/acs-object-management/catalog/acs-object-management.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/catalog/acs-object-management.en_US.ISO-8859-1.xml,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/catalog/acs-object-management.en_US.ISO-8859-1.xml 28 Jul 2009 23:35:08 -0000 1.1 +++ openacs-4/packages/acs-object-management/catalog/acs-object-management.en_US.ISO-8859-1.xml 13 Aug 2009 00:15:05 -0000 1.2 @@ -1,8 +1,10 @@ ACS Object Types Management - Add + Action + add Add an attribute + Add checked attributes Add a Form element Add a Form Add a Type @@ -17,6 +19,7 @@ Name of attribute displayed in forms. Plural form of pretty name. Attributes + Available Attributes Export code to recreate dynamic types and forms Tcl code to recreate selected dynamic types and forms Content @@ -26,6 +29,7 @@ Delete Datatype + Delete checked attributes Dynamic Types Edit Form Name Chose the attrbiute for this widget. @@ -60,6 +64,7 @@ Supertype unable to retrieve widget parameter %name% for attribute %attribute_id% - returning "" as parameter value View + View Attributes Views Widget -- Default Widget -- Index: openacs-4/packages/acs-object-management/tcl/attribute-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/attribute-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/attribute-procs.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/attribute-procs.tcl 13 Aug 2009 00:15:05 -0000 1.2 @@ -1,6 +1,6 @@ ad_library { - Procs to help with attributes for object types, supplemantary for now to + Procs to help with attributes for object types, supplementary for now to mbryzek's original arsdigita code found in acs-subsite. @author Don Baccus (dhogaza@pacifierlcom) @@ -33,6 +33,36 @@ {-check_expr ""} {-column_spec ""} } { + + Add an attribute to an object type, optionally create the column in the SQL table, + and recreate the type's root view. + + @param object_type The type the new attribute belongs to. + @param attribute_name The name of the new attribute. + @param datatype The acs datatype of the new attribute. + @param pretty_name The human-readable name for the new attribute. + @param pretty_plural Optional human-readable plural name for the new attribute. + @param table_name SQL table to use for storage (defaults to the type's table). + @param column_name Column name for the attribute (default attribute name). + @param default_value Default value (default null). + @param min_n_values Minimum number of values for the attribute (default 1). + @param max_n_values Maximum number of values for the attribute (default 1). + @param sort_order Sort order (defaults to the current maximum+1 for the type). + @param storage_type Storage type, either "generic" or "type_specific" (default "type_specific"). + @param static_p If true, only one value exists for the entire object type. + @param create_column_p If true, automatically create the column in the SQL table. + @param database_type The SQL datatype for this attribute (defaults to the type defined + for the abstract acs_datatype). + @param size Optional size parameter (for types like number or varchar). + @param null_p If true, this attribute can have the value null. + @param references Optional table name to reference via a foreign key (table must have a + primary key). + @param check_expr Optional check expression to apply to the SQL column. + @param column_spec Optional column_spec for the column. Overrides database_type, + size, null_p, references, check_expr. If column_spec is not null, it must be + a complete SQL column specification. + + @return The attribute_id of the new attribute. } { set var_list [list \ [list object_type $object_type] \ @@ -55,44 +85,69 @@ [list references $references] \ [list check_expr $check_expr] \ [list column_spec $column_spec]] - package_exec_plsql -var_list $var_list acs_attribute create_attribute + set attribute_id [package_exec_plsql -var_list $var_list acs_attribute create_attribute] + package_exec_plsql -var_list [list [list object_type $object_type]] acs_object_type refresh_view - db_flush_cache -cache_pool acs_metadata -cache_key_pattern ${object_type}::* + object_type::flush_cache -object_type $object_type + return $attribute_id } ad_proc object_type::attribute::delete { -object_type:required -attribute_name:required {-drop_column_p f} } { + + Delete the given attribute for the given object type. + + @param object_type The object type this attribute belongs to. + @param attribute_name The name (not id) of the attribute to delete. + @param drop_column_p If true, delete the column from the SQL table. + } { set var_list [list \ [list object_type $object_type] \ [list attribute_name $attribute_name] \ [list drop_column_p $drop_column_p]] package_exec_plsql -var_list $var_list acs_attribute drop_attribute package_exec_plsql -var_list [list [list object_type $object_type]] acs_object_type refresh_view - db_flush_cache -cache_pool acs_metadata -cache_key_pattern ${object_type}::* + object_type::flush_cache -object_type $object_type } ad_proc object_type::attribute::get { -object_type:required -attribute_name:required -array:required } { + + Get the metadata for the given attribute and place it in the named array at the + caller's level. + + @param object_type The object type this attribute belongs to. + @param attribute_name The name of the attribute. + @param array The name of the array to store the metadata in. } { upvar $array local - db_1row -cache_pool acs_metadata -cache_key ${object_type}::attribute::get \ + db_1row -cache_pool acs_metadata -cache_key t::${object_type}::attribute::get \ get {} -column_array local } ad_proc object_type::attribute::get_attribute_id { -object_type:required -attribute_name:required - -array:required } { + + Get the attribute id for the given attribute name associated with the given object type. + If the attribute doesn't exist, an error will be thrown. + + @param object_type The object type this attribute belongs to. + @param attribute_name The name of the attribute. + + @return The attribute_id of the given attribute. } { upvar $array local - db_1row -cache_pool acs_metadata -cache_key ${object_type}::attribute::get_attribute_id \ - get_attribute_id {} -column_array local + return [db_string \ + -cache_pool acs_metadata \ + -cache_key t::${object_type}::attribute::get_attribute_id \ + get_attribute_id] } Index: openacs-4/packages/acs-object-management/tcl/cache-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/cache-init.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/cache-init.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/cache-init.tcl 13 Aug 2009 00:15:05 -0000 1.2 @@ -1,6 +1,8 @@ ad_library { - Initialization cache for object metadata operations + Initialization cache for object metadata operations. Modify the size by + changing the value of the package parameter DBCacheSize and restarting + your server. @creation-date 30 June 2009 @author Don Baccus (dhogaza@pacifier.com) Index: openacs-4/packages/acs-object-management/tcl/object-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/object-procs.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/object-procs.tcl 13 Aug 2009 00:15:05 -0000 1.2 @@ -1,6 +1,7 @@ ad_library { - Supporting procs for ACS Objects. + Supporting procs for ACS Objects. Unlike the object type and view metadata procs, + these don't cache at the moment. @author Don Baccus (dhogaza@pacifier.com) @creation-date July 1, 2009 @@ -16,6 +17,22 @@ -type_attributes_array:required -supertype_attributes_array:required } { + + Walk through the attribute names stored in the attribute_array parameter, and + generate two arrays. The "type_attributes_array" will contain the values for + the attributes that belong to the given object type, while the + supertype_attributes_array will contain the values for the attributes that + belong to the set of given object_type's supertypes. + + This is used privately to generate insert/update dml statements for each of the + tables associated with a given type's inheritance hierarchy. + + @param object_type The object type we're processing. + @param attributes_array The attributes for the object type and all of its supertypes. + @param type_attributes_array Output array for the attribute values for the object type. + @param supertype_attributes_array Output array for the attribute values for all of + the type's supertypes. + } { upvar $attributes_array local_attributes_array upvar $type_attributes_array local_type_attributes_array @@ -34,14 +51,27 @@ } } -# Change this to allow an array name or attributes, with the appropriate error. - ad_proc -private object::new_inner { -object_type:required -object_id:required -attributes:required } { + + Private function called by object::new to create a new object of a given type. It + recursively walks the type hierarchy, inserting table values for the type's + supertypes as it goes. object::new wraps the outer call in a transaction to + guarantee that object creation is atomic. + + @param object_type The type we're creating. + @param object_id The id of the object we're creating. If empty, a new object_id + will be created. + @param attributes The attribute values for the new object in array get format. + + @return The object_id of the new object. +} { + array set attributes_array $attributes + object_type::get -object_type $object_type -array object_type_info set id_column $object_type_info(id_column) @@ -64,8 +94,10 @@ if { $object_id eq "" } { set object_id [db_nextval acs_object_id_seq] } - if { [llength [array name subtype_attributes]] > 0 } { - # error ... + if { [llength [array names supertype_attributes]] > 0 } { + # Internal error check - if we're creating an acs_object, it has no supertype + # therefore should have no supertype_attributes. + return -code "Internal error - supertype_attributes should be empty" } } @@ -82,6 +114,7 @@ } else { # error for now as we don't handle generics etc + return -code error "Generic attributes are not supported." } return $object_id @@ -90,11 +123,45 @@ ad_proc object::new { {-object_type acs_object} {-object_id ""} - {-attributes ""} + -attributes + -array } { + + Create a new object. This does not fully support the OpenACS object model. + + 1. We don't call the object type's "new" function, if one exists. This package + doesn't create them, and in general I'd like to move away from them as it's + one of the things that makes supporting both oracle and postgresql burdensome. + + 2. This means that this function will fail if an object type has a "new" function + that does tricky things beyond simply creating the supertype object, then + adding the given type's table entry. + + 3. This function doesn't handle generic storage. This is definitely a feature, + not a bug. + + @param object_type The type we're creating. Defaults to acs_object. + @param object_id The id of the object we're creating. If empty, a new object_id + will be created. + @param attributes The attribute values for the new object in array get format. If + given, the 'array' parameter must not be specified. + @param array The name of the array in the caller's namespace that contains the + attribute values. If given, the 'attribute' parameter value must not specified. + + @return The object_id of the new object. + } { - array set attributes_array $attributes + if { [info exists attributes] && [info exists array] } { + return -code error "Only one of the 'attributes' and 'array' parameters can be given" + } + + if { [info exists attributes] } { + array set attributes_array $attributes + } else { + upvar $array attributes_array + } + set attributes_array(object_type) $object_type if { [ad_conn isconnected] } { @@ -118,13 +185,24 @@ ad_proc object::delete { -object_id:required } { + + Delete an object. + + @param object_id The id of the object to delete. } { package_exec_plsql -var_list [list [list object_id $object_id]] acs_object delete } ad_proc object::get_object_type { -object_id:required } { + + Return the type of an object. + + @param object_id The object's id. + + @return The object's type. + } { return [db_string get_object_type {}] } @@ -134,6 +212,22 @@ {-view ""} -array:required } { + + Return the attributes of an object type, using the given view (the root view, i.e. + all attributes, by default). View attributes rather than type attributes are used + because they contain information on how to transform the database values to a + canonical form (i.e. calling to_char(date, 'YYYY-MMM-DD'). + + To do: localize values if asked to (create a localization proc that can be + called explicitly by code that doesn't use our "get" function). + + @param object_id The id of the object. + @param view The object view to use. Defaults to the root view, i.e. all attributes. If + the specified view has been created for a type different than the object's type, + the results will be interesting. Actually, carefully done, this can be used to + cast from a supertype to a subtype but you'd better know what you're doing. + @param array The name of an output array in the caller's namespace. + } { upvar $array local_array if { $view eq "" } { @@ -148,6 +242,14 @@ -object_type:required -attributes:required } { + Private function called by object::update to update an object of a given type. It + recursively walks the type hierarchy, updating table values for the type's + supertypes as it goes. object::update wraps the outer call in a transaction to + guarantee that object creation is atomic. + + @param object_type The type we're updating. + @param object_id The id of the object we're updating. + @param attributes The new attribute values for the object in array get format. } { array set attributes_array $attributes object_type::get -object_type $object_type -array object_type_info @@ -194,6 +296,17 @@ -object_id:required -attributes:required } { + Update an object's value. One of the interesting things about the original + Ars Digita object type specification is that it called for new and delete procs + for object types, but not for update procs. Some object types created for + packages include update procs, most do not. + + Since most types don't include update procs, unlike the object create case, we're not + losing any functionality for them by doing explicit updates at the Tcl level. + + @param object_type The type we're updating. + @param object_id The id of the object we're updating. + @param attributes The new attribute values for the object in array get format. } { array set attributes_array $attributes Index: openacs-4/packages/acs-object-management/tcl/object-type-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-type-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/object-type-procs.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/object-type-procs.tcl 13 Aug 2009 00:15:05 -0000 1.2 @@ -72,7 +72,8 @@ [list drop_table_p $drop_table_p] \ [list drop_children_p $drop_children_p]] package_exec_plsql -var_list $var_list acs_object_type drop_type - db_flush_cache -cache_pool acs_metadata -cache_key_pattern ${object_type}::* + object_type::flush_cache -object_type $object_type + object_view::flush_cache -object_view * } ad_proc -public object_type::get { @@ -96,7 +97,7 @@ } { upvar 1 $array row - db_1row -cache_pool acs_metadata -cache_key ${object_type}::get \ + db_1row -cache_pool acs_metadata -cache_key t::${object_type}::get \ select_object_type_info {} -column_array row } @@ -113,7 +114,7 @@ -object_type:required } { } { - return [db_string -cache_pool acs_metadata -cache_key ${object_type}::get_root_view \ + return [db_string -cache_pool acs_metadata -cache_key t::${object_type}::get_root_view \ select_root_view {}] } @@ -154,14 +155,21 @@ @author Lee Denison (lee@thaum.net) } { - return [db_list -cache_pool acs_metadata -cache_key ${subtype}::supertypes supertypes {}] + return [db_list -cache_pool acs_metadata -cache_key t::${subtype}::supertypes supertypes {}] } ad_proc object_type::get_attribute_names { -object_type:required } { Return a list of attribute names declared for the given object type. } { - return [db_list -cache_pool acs_metadata -cache_key ${object_type}::attribute_names \ + return [db_list -cache_pool acs_metadata -cache_key t::${object_type}::attribute_names \ select_attribute_names {}] } + +ad_proc -public object_type::flush_cache { + -object_type:required +} { +} { + db_flush_cache -cache_pool acs_metadata -cache_key_pattern t::${object_type}::* +} Index: openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl 13 Aug 2009 00:15:05 -0000 1.2 @@ -8,13 +8,52 @@ } +namespace eval object_type {} namespace eval object_type::view {} +namespace eval object_type::view::attribute {} -ad_proc -public object_type::view::new { +ad_proc object_type::view::new { -object_type:required -object_view:required -pretty_name:required } { } { db_dml insert_object_view {} + object_type::flush_cache -object_type $object_type } + +ad_proc object_type::view::delete { + -object_view:required +} { +} { + object_type::view::flush_cache -object_view $object_view + db_dml delete_object_view {} +} + +ad_proc object_type::view::get { + -object_view:required + -array:required +} { +} { + upvar $array local + db_1row -cache_pool acs_metadata -cache_key v::${object_view}::get \ + get_object_view {} -column_array local +} + +ad_proc object_type::view::get_element { + -object_view:required + -element:required +} { +} { + object_type::view::get -object_view $object_view -array view + return $view($element) +} + +ad_proc object_type::view::flush_cache { + -object_view:required +} { + object_type::flush_cache -object_type [object_type::view::get_element \ + -object_view $object_view \ + -element object_type] + db_flush_cache -cache_pool acs_metadata -cache_key_pattern v::${object_view}::* +} Index: openacs-4/packages/acs-object-management/tcl/object-view-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-view-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/object-view-procs.xql 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/object-view-procs.xql 13 Aug 2009 00:15:05 -0000 1.2 @@ -10,4 +10,19 @@ + + + delete from acs_object_views + where object_view = :object_view + + + + + + select * + from acs_object_views + where object_view = :object_view + + + Index: openacs-4/packages/acs-object-management/tcl/view-attribute-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/view-attribute-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/tcl/view-attribute-procs.tcl 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,38 @@ +ad_library { + + Procs to help with attributes for object views. + + @author Don Baccus (dhogaza@pacifierlcom) + @cvs-id $Id: view-attribute-procs.tcl,v 1.1 2009/08/13 00:15:05 donb Exp $ +} + +namespace eval object_type {} +namespace eval object_type::view {} +namespace eval object_type::view::attribute {} + +ad_proc object_type::view::attribute::copy { + -to_object_view:required + -from_object_view + -attribute_id:required +} { +} { + + set object_type \ + [object_type::view::get_element -object_view $to_object_view -element object_type] + + if { ![info exists from_object_view] } { + set from_object_view [object_type::get_root_view -object_type $object_type] + } + + db_dml copy {} + object_type::view::flush_cache -object_view $to_object_view +} + +ad_proc object_type::view::attribute::delete { + -object_view:required + -attribute_id:required +} { +} { + db_dml delete {} + object_type::view::flush_cache -object_view $object_view +} Index: openacs-4/packages/acs-object-management/tcl/view-attribute-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/view-attribute-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/tcl/view-attribute-procs.xql 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,26 @@ + + + + + + insert into acs_object_view_attributes + (attribute_id, col_name, object_view, pretty_name, col_expr, sort_order) + select attribute_id, col_name, :to_object_view, pretty_name, col_expr, + (select coalesce(max(sort_order), 1) + from acs_object_view_attributes + where object_view = :to_object_view) + from acs_object_view_attributes + where object_view = :from_object_view + and attribute_id = :attribute_id + + + + + + delete from acs_object_view_attributes + where object_view = :object_view + and attribute_id = :attribute_id + + + + Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-object-management/www/admin/attribute-delete-confirm.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-object-management/www/admin/attribute-delete-confirm.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/acs-object-management/www/admin/attribute-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/attribute-delete.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/attribute-delete.adp 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/attribute-delete.adp 13 Aug 2009 00:15:05 -0000 1.2 @@ -2,6 +2,6 @@

-Really delete attribute "@attribute.attribute_name@"? +Really delete attribute "@attribute.pretty_name@"? Index: openacs-4/packages/acs-object-management/www/admin/dtype.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/Attic/dtype.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/dtype.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/dtype.tcl 13 Aug 2009 00:15:05 -0000 1.2 @@ -31,8 +31,8 @@ datatype { label "[_ acs-object-management.datatype]" } - delete { - label "[_ acs-object-management.Delete]" + action { + label "[_ acs-object-management.Action]" display_template " [_ acs-object-management.delete] @@ -42,7 +42,7 @@ object_type {} } -db_multirow -cache_pool acs_metadata -cache_key ${object_type}::get_attributes \ +db_multirow -cache_pool acs_metadata -cache_key t::${object_type}::get_attributes \ -extend { attribute_url delete_url } attributes get_attributes {} { set attribute_url [export_vars -base attribute {attribute_id object_type}] set delete_url [export_vars -base attribute-delete {object_type attribute_name}] @@ -69,7 +69,7 @@ object_type {} } -db_multirow -cache_pool acs_metadata -cache_key ${object_type}::get_inherited_attributes \ +db_multirow -cache_pool acs_metadata -cache_key t::${object_type}::get_inherited_attributes \ inherited_attributes get_inherited_attributes {} list::create \ @@ -81,10 +81,10 @@ pretty_name { label "[_ acs-object-management.pretty_name]" display_template " - + @views.pretty_name@ - @views.pretty_name@ @@ -93,8 +93,8 @@ object_view { label "[_ acs-object-management.view]" } - delete { - label "[_ acs-object-management.Delete]" + actions { + label "[_ acs-object-management.Action]" display_template " @@ -106,11 +106,10 @@ object_type {} } -db_multirow -cache_pool acs_metadata -cache_key ${object_type}::get_views \ +db_multirow -cache_pool acs_metadata -cache_key t::${object_type}::get_views \ -extend { view_url delete_url } views get_views {} { - set delete_url [export_vars -base view-delete { object_view }] - set view_url [export_vars -base view { object_view }] -ns_log Notice "Huh? view_url: $view_url delete_url: $delete_url" + set delete_url [export_vars -base view-delete {object_type object_view}] + set view_url [export_vars -base view {object_view}] } set add_form_url [export_vars -base form-ae {object_type}] Index: openacs-4/packages/acs-object-management/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/www/admin/index.tcl 28 Jul 2009 23:35:09 -0000 1.1 +++ openacs-4/packages/acs-object-management/www/admin/index.tcl 13 Aug 2009 00:15:05 -0000 1.2 @@ -30,8 +30,8 @@ label "[_ acs-object-management.object_type]" orderby "object_type" } - delete { - label "Delete" + action { + label "[_ acs-object-management.Action]" display_template "delete" } Index: openacs-4/packages/acs-object-management/www/admin/view-attributes-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view-attributes-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/view-attributes-add.tcl 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2009-07-25 + +} { + object_view:sql_identifier,notnull + attribute_id:integer,multiple + return_url:notnull +} + +foreach one_attribute_id $attribute_id { + object_type::view::attribute::copy -to_object_view $object_view -attribute_id $one_attribute_id +} + +ad_returnredirect $return_url + Index: openacs-4/packages/acs-object-management/www/admin/view-attributes-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view-attributes-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/view-attributes-delete.tcl 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,19 @@ +ad_page_contract { + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2009-07-25 + +} { + object_view:sql_identifier,notnull + attribute_id:integer,multiple + return_url:notnull +} + +foreach one_attribute_id $attribute_id { + object_type::view::attribute::delete \ + -object_view $object_view \ + -attribute_id $one_attribute_id +} + +ad_returnredirect $return_url + Index: openacs-4/packages/acs-object-management/www/admin/view-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/view-delete.adp 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,7 @@ + + +

+ +Really delete view "@view.pretty_name@"? + + Index: openacs-4/packages/acs-object-management/www/admin/view-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/view-delete.tcl 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,17 @@ +ad_page_contract { + +} { + object_view:sql_identifier,notnull + object_type:sql_identifier,notnull +} + +object_type::view::get \ + -object_view $object_view \ + -array view + +ad_form -name delete -export {object_view object_type} -form { +} -on_submit { + object_type::view::delete -object_view $object_view + ad_returnredirect ./[export_vars -base dtype {object_type}] + ad_script_abort +} Index: openacs-4/packages/acs-object-management/www/admin/view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/view.adp 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,9 @@ + +@page_title@ +@context@ + +

#acs-object-management.view_attributes#

+

#acs-object-management.object_view#: @view_info.pretty_name@

+ +

#acs-object-management.available_attributes#

+ Index: openacs-4/packages/acs-object-management/www/admin/view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/view.tcl 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,93 @@ +ad_page_contract { + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2009-08-07 + @cvs-id $Id: view.tcl,v 1.1 2009/08/13 00:15:05 donb Exp $ + +} { + {object_view:notnull,sql_identifier} +} + +object_type::view::get -object_view $object_view -array view_info +set object_type $view_info(object_type) + +set page_title $view_info(pretty_name) +set context [list [list . "Dynamic Types"] \ + [list [export_vars -base dtype \ + {{object_type $view_info(object_type)}}] $view_info(object_type)] \ + $page_title] +set return_url [ad_conn url]?[ad_conn query] + +list::create \ + -name view_attributes \ + -multirow view_attributes \ + -key attribute_id \ + -pass_properties { + object_view + } \ + -bulk_actions [list [_ acs-object-management.delete_checked_attributes] view-attributes-delete [_ acs-object-management.delete_checked_attributes]] \ + -bulk_action_export_vars {return_url object_view} \ + -elements { + pretty_name { + label "[_ acs-object-management.pretty_name]" + link_url_eval $attribute_url + } + col_name { + label "[_ acs-object-management.attribute]" + } + object_type { + label "[_ acs-object-management.object_type]" + } + datatype { + label "[_ acs-object-management.datatype]" + } + action { + label "[_ acs-object-management.Action]" + display_template " + + [_ acs-object-management.delete] + " + } + } + +db_multirow -cache_pool acs_metadata -cache_key v::${object_view}::get_view_attributes \ + -extend {attribute_url delete_url} view_attributes get_view_attributes {} { + set delete_url [export_vars -base view-attributes-delete {object_view return_url attribute_id}] +} + +list::create \ + -name available_attributes \ + -multirow available_attributes \ + -key attribute_id \ + -bulk_actions [list [_ acs-object-management.add_checked_attributes] view-attributes-add [_ acs-object-management.add_checked_attributes]] \ + -bulk_action_export_vars {return_url object_view} \ + -elements { + pretty_name { + label "[_ acs-object-management.pretty_name]" + } + col_name { + label "[_ acs-object-management.attribute]" + } + object_type { + label "[_ acs-object-management.object_type]" + } + datatype { + label "[_ acs-object-management.datatype]" + } + action { + label "[_ acs-object-management.Action]" + display_template " + + [_ acs-object-management.add] + " + } + } + +db_multirow -cache_pool acs_metadata -cache_key v::${object_view}::get_available_attributes \ + -extend {add_url} available_attributes get_available_attributes {} { + set add_url [export_vars -base view-attributes-add {object_view attribute_id return_url}] +} + +set add_form_url [export_vars -base form-ae {object_type}] +set return_url [ad_return_url] +ad_return_template Index: openacs-4/packages/acs-object-management/www/admin/view.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/www/admin/view.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-object-management/www/admin/view.xql 13 Aug 2009 00:15:05 -0000 1.1 @@ -0,0 +1,33 @@ + + + + + + + select aova.attribute_id, aova.col_name, aova.pretty_name, aova.sort_order, + aova.col_expr, aa.datatype, aa.object_type + from acs_attributes aa, acs_object_view_attributes aova + where aova.object_view = :object_view + and aa.attribute_id = aova.attribute_id + + + + + + select aova.attribute_id, aova.col_name, aova.pretty_name, aova.sort_order, + aova.col_expr, aa.datatype, aa.object_type + from acs_object_views aov, acs_object_view_attributes aova, + acs_attributes aa + where aov.object_type = :object_type + and aov.root_view_p + and aov.object_view = aova.object_view + and aova.attribute_id = aa.attribute_id + and not exists (select 1 + from acs_object_view_attributes aova2 + where aova2.object_view = :object_view + and aova2.col_name = aova.col_name) + order by aova.sort_order + + + +