Index: openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-create.sql 27 Jul 2003 00:46:16 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-create.sql 30 Jul 2003 04:56:41 -0000 1.4
@@ -14,19 +14,21 @@
not null
constraint cr_ca_attributes_pk
primary key,
- package_id integer
- constraint ca_attributes_package_id_fk
- references acs_objects,
- sitewide_p char(1)
- default 'f'
- constraint ca_attributes_sitewide_p_nn
- not null
- constraint ca_attributes_sitewide_p_ck
- check (sitewide_p in ('t','f')),
- constraint ca_attributes_un
- unique(attribute_id,package_id)
+ --
+ -- RBM: We have keyword_id here so we can have per-category
+ -- custom fields. Selling books requires ISBN, but motorcycles
+ -- requires something else.
+ --
+ keyword_id integer
+ constraint ca_attributes_keyword_id_nn
+ not null
+ constraint ca_attributes_keyword_id_fk
+ references cr_keywords(keyword_id),
+ constraint ca_attributes_un unique(attribute_id, keyword_id)
);
+CREATE INDEX ca_attributes_keyword_id_idx
+ON ca_attributes( keyword_id );
create table ca_attribute_values (
object_id integer
Index: openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-drop.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-drop.sql 16 Jul 2003 04:52:31 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-drop.sql 30 Jul 2003 04:56:41 -0000 1.2
@@ -6,6 +6,7 @@
--
drop table ca_attribute_values;
+drop index ca_attributes_keyword_id_idx;
drop table ca_attributes;
drop table ca_attribute_widget_values;
drop table ca_attribute_widgets;
Index: openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-package-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-package-create.sql 27 Jul 2003 00:46:16 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/sql/postgresql/attributes-package-create.sql 30 Jul 2003 04:56:41 -0000 1.4
@@ -5,7 +5,7 @@
-- @cvs-id $Id$
--
-select define_function_args('ca_attributes__create_attribute','content_type,attribute_name,datatype,pretty_name,pretty_plural,sort_order,default_value,storage,table_name,column_spec,package_id');
+select define_function_args('ca_attributes__create_attribute','content_type,attribute_name,datatype,pretty_name,pretty_plural,sort_order,default_value,storage,table_name,column_spec,keyword_id');
create or replace function ca_attributes__create_attribute (varchar,varchar,varchar,varchar,varchar,integer,varchar,varchar,varchar,varchar,integer)
returns integer as '
@@ -20,7 +20,7 @@
p_storage alias for $8;
p_table_name alias for $9;
p_column_spec alias for $10;
- p_package_id alias for $11;
+ p_keyword_id alias for $11;
v_attribute_id acs_attributes.attribute_id%TYPE;
v_sort_order acs_attributes.sort_order%TYPE;
v_sitewide_p ca_attributes.sitewide_p%TYPE;
@@ -119,18 +119,12 @@
end if; end if;
-- insert the attribute_id into our own table for purposes
--- of tracking the package_id
+-- of tracking the keyword_id
- if p_package_id is null then
- v_sitewide_p := ''t'';
- else
- v_sitewide_p := ''f'';
- end if;
-
insert into ca_attributes
- (attribute_id, package_id, sitewide_p)
+ (attribute_id, keyword_id)
values
- (v_attribute_id, p_package_id, v_sitewide_p);
+ (v_attribute_id, p_keyword_id);
return v_attribute_id;
end;
@@ -184,31 +178,30 @@
' language 'plpgsql';
-select define_function_args('ca_attributes__register_widget','attribute_id,widget,label,keyword_id,html_options,extra_options,select_options,validate,optional_p,enabled_p');
+select define_function_args('ca_attributes__register_widget','attribute_id,widget,label,html_options,extra_options,select_options,validate,optional_p,enabled_p');
-create or replace function ca_attributes__register_widget (integer,varchar,varchar,integer,varchar,text,varchar,varchar,char,char)
+create or replace function ca_attributes__register_widget (integer,varchar,varchar,varchar,text,varchar,varchar,char,char)
returns integer as '
declare
p_attribute_id alias for $1;
p_widget alias for $2;
p_label alias for $3;
- p_keyword_id alias for $4;
- p_html_options alias for $5;
- p_extra_options alias for $6;
- p_select_options alias for $7;
- p_validate alias for $8;
- p_optional_p alias for $9;
- p_enabled_p alias for $10;
+ p_html_options alias for $4;
+ p_extra_options alias for $5;
+ p_select_options alias for $6;
+ p_validate alias for $7;
+ p_optional_p alias for $8;
+ p_enabled_p alias for $9;
begin
-- DEDS: FIXME - check for options when inserting something that does not support it
-- RBM: 07/2003 - What does the above mean?
insert into ca_attribute_widget_values
- ( attribute_id, widget, label, keyword_id, html_options, extra_options,
+ ( attribute_id, widget, label, html_options, extra_options,
select_options, validate, optional_p, enabled_p )
values
- ( p_attribute_id, p_widget, p_label, p_keyword_id, p_html_options, p_extra_options,
+ ( p_attribute_id, p_widget, p_label, p_html_options, p_extra_options,
p_select_options, p_validate, p_optional_p, p_enabled_p );
return null;
Index: openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl,v
diff -u -r1.10 -r1.11
--- openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 29 Jul 2003 09:10:42 -0000 1.10
+++ openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 30 Jul 2003 04:56:41 -0000 1.11
@@ -137,7 +137,7 @@
#
if {[empty_string_p $category_id]} {
- set category_id [classified-ads::categories::package_category_exists_p]
+ set category_id [classified-ads::categories::get_package_keyword_id]
}
#
@@ -149,7 +149,7 @@
if {[llength $custom_fields_list] > 0} {
foreach field $custom_fields_list {
- append custom_fields ", ads.$field"
+ append custom_fields ", ads.[lindex $field 0]"
}
}
Index: openacs-4/contrib/packages/classified-ads/tcl/categories-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/categories-procs-postgresql.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/classified-ads/tcl/categories-procs-postgresql.xql 29 Jul 2003 09:10:42 -0000 1.2
+++ openacs-4/contrib/packages/classified-ads/tcl/categories-procs-postgresql.xql 30 Jul 2003 04:56:41 -0000 1.3
@@ -101,10 +101,10 @@
SELECT
- attribute_name
+ attribute_name, pretty_name
FROM
acs_attributes att,
- ca_attribute_widget_values cawv,
+ ca_attributes ca,
(
select
subtree.keyword_id
@@ -113,11 +113,27 @@
and parent.tree_sortkey between subtree.tree_sortkey and tree_right(subtree.tree_sortkey)
) keywords
WHERE
- att.attribute_id = cawv.attribute_id
+ att.attribute_id = ca.attribute_id
AND
- cawv.keyword_id = keywords.keyword_id
+ ca.keyword_id = keywords.keyword_id
+
+
+
+ select
+ repeat(:indent_pattern, (tree_level(subtree.tree_sortkey) - 2) * :indent_factor::integer) || subtree.heading AS heading,
+ subtree.keyword_id
+ from
+ cr_keywords parent, cr_keywords subtree
+ where
+ parent.keyword_id = :keyword_id
+ and
+ parent.tree_sortkey between subtree.tree_sortkey and tree_right(subtree.tree_sortkey)
+
+
+
+
Index: openacs-4/contrib/packages/classified-ads/tcl/categories-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/categories-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/tcl/categories-procs.tcl 29 Jul 2003 09:10:42 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/tcl/categories-procs.tcl 30 Jul 2003 04:56:41 -0000 1.4
@@ -8,266 +8,277 @@
}
-namespace eval classified-ads::categories {
+namespace eval classified-ads::categories {}
- ad_proc -public new {
- {-keyword_id ""}
- {-heading:required}
- {-description ""}
- {-parent_id ""}
- } {
+ad_proc -public classified-ads::categories::new {
+ {-keyword_id ""}
+ {-heading:required}
+ {-description ""}
+ {-parent_id ""}
+} {
- creates a new keyword that's used for categorization
+ Creates a new keyword that's used for categorization
- @param keyword_id The keyword id for this new keyword. A new id will be provided if null.
- @param heading The heading of the new keyword
- @param description The description of the new keyword
- @param parent_id The parent of this new keyword if it is a subcategory
+ @param keyword_id The keyword id for this new keyword. A new id will be provided if null.
+ @param heading The heading of the new keyword
+ @param description The description of the new keyword
+ @param parent_id The parent of this new keyword if it is a subcategory
- } {
- set creation_user [ad_conn user_id]
- set creation_ip [ad_conn peeraddr]
- return [db_exec_plsql create_keyword {}]
- }
+} {
+ set creation_user [ad_conn user_id]
+ set creation_ip [ad_conn peeraddr]
+ return [db_exec_plsql create_keyword {}]
+}
- ad_proc -public edit {
- {-keyword_id:required}
- {-heading:required}
- {-description ""}
- } {
+ad_proc -public classified-ads::categories::edit {
+ {-keyword_id:required}
+ {-heading:required}
+ {-description ""}
+} {
- edits properties of an existing category
+ Edits properties of an existing category
- @param keyword_id The keyword id of the category to edit
- @param heading The new heading to use
- @param description The new description to use
+ @param keyword_id The keyword id of the category to edit
+ @param heading The new heading to use
+ @param description The new description to use
- } {
- db_transaction {
- set_heading -keyword_id $keyword_id -heading $heading
- set_description -keyword_id $keyword_id -description $description
- } on_error {
- ad_return_complaint 1 "
the following error occured: $errmsg"
- ad_script_abort
- }
+} {
+ db_transaction {
+ set_heading -keyword_id $keyword_id -heading $heading
+ set_description -keyword_id $keyword_id -description $description
+ } on_error {
+ ad_return_complaint 1 "the following error occured: $errmsg"
+ ad_script_abort
+ }
- return $keyword_id
- }
+ return $keyword_id
+}
- ad_proc -public delete {
- {-keyword_id:required}
- } {
+ad_proc -public classified-ads::categories::delete {
+ {-keyword_id:required}
+} {
+ Deletes a category
- deletes a category
+ @param keyword_id The keyword id of the category to delete
+} {
+ return [db_exec_plsql delete_category {}]
+}
- @param keyword_id The keyword id of the category to delete
+ad_proc -public classified-ads::categories::get_package_keyword_id {
+ {-package_id ""}
+} {
+ Returns the keyword_id of the associated category for this package
- } {
- return [db_exec_plsql delete_category {}]
- }
+ @param package_id The package id to query, defaults to current package id if not specified
+} {
+ set main_keyword_id [classified-ads::get_main_keyword_id]
+ if {!$main_keyword_id} {
+ ad_return_error "Main Category Not Found" "The sytem can't find the main [classified-ads::package_key] category. Are you sure you have restarted the server?"
+ }
- ad_proc -public package_category_exists_p {
- {-package_id ""}
- } {
+ if {[empty_string_p $package_id]} {
+ set package_id [ad_conn package_id]
+ }
- returns the keyword_id of the associated category for this package
+ set heading "[classified-ads::package_key]-package-$package_id"
+ set package_keyword_id [db_string get_id {} -default 0]
- @param package_id The package id to query, defaults to current package id if not specified
+ if {!$package_keyword_id} {
+ set package_keyword_id [classified-ads::categories::new -heading $heading \
+ -description "Package Main Category" \
+ -parent_id $main_keyword_id \
+ ]
+ }
- } {
- set main_keyword_id [classified-ads::main_keyword_exists_p]
+ return $package_keyword_id
+}
- if {!$main_keyword_id} {
- ad_return_error "Main Category Not Found" "The sytem can't find the main [classified-ads::package_key] category. Are you sure you have restarted the server?"
- }
-
- if {[empty_string_p $package_id]} {
- set package_id [ad_conn package_id]
- }
+ad_proc -public classified-ads::categories::get {
+ {-keyword_id:required}
+ {-array:required}
+} {
+ Returns the data for a particular category
- set heading "[classified-ads::package_key]-package-$package_id"
- set package_keyword_id [db_string get_id {} -default 0]
+ @param keyword_id The keyword id of the category to get the data
+ @param array An array where the data will be stored
+} {
+ upvar $array row
- if {!$package_keyword_id} {
- set package_keyword_id [classified-ads::categories::new -heading $heading \
- -description "Package Main Category" \
- -parent_id $main_keyword_id \
- ]
- }
+ set row(heading) [get_heading -keyword_id $keyword_id]
+ set row(description) [get_description -keyword_id $keyword_id]
- return $package_keyword_id
- }
+ return 0
+}
+ad_proc -public classified-ads::categories::get_all_tree {
+ {-keyword_id ""}
+ {-include_description:boolean "0"}
+ {-indent_factor:integer 2}
+ {-indent_pattern " "}
+} {
+ Returns a list of lists with the tree of categories for the
+ passed keyword_id, indented indent_factor times by indent_pattern.
- ad_proc -public get {
- {-keyword_id:required}
- {-array:required}
- } {
+ @author Roberto Mello
- returns the data for a particular category
+ @param keyword_id The id of the keyword to get categories for.
+ Defaults to the main keyword_id of the current package instance.
- @param keyword_id The keyword id of the category to get the data
- @param array An array where the data will be stored
+ @param include_description If especified, the category descriptions will be added to the
+ returned list.
+ @param indent_factor Number of time to repeat the indentation pattern.
+ @param indent_pattern A character to repeat in the indentation.
- } {
- upvar $array row
-
- set row(heading) [get_heading -keyword_id $keyword_id]
- set row(description) [get_description -keyword_id $keyword_id]
+ @see classified-ads::categories::get
+ @see classified-ads::categories::get_package_keyword_id
+} {
+ if {[empty_string_p $keyword_id]} {
+ set keyword_id [classified-ads::categories::get_package_keyword_id]
+ }
- return 0
- }
+ set extra_fields ""
+
+ if {$include_description_p} {
+ set extra_fields ", subtree.description"
+ }
+ return [db_list_of_lists get {}]
+}
- ad_proc -public get_heading {
- {-keyword_id:required}
- } {
+ad_proc -public classified-ads::categories::get_heading {
+ {-keyword_id:required}
+} {
+ Returns the heading for a particular category
- returns the heading for a particular category
+ @param keyword_id The keyword id of the category to get the heading
+} {
+ return [db_exec_plsql get_heading {}]
+}
- @param keyword_id The keyword id of the category to get the heading
+ad_proc -public classified-ads::categories::set_heading {
+ {-keyword_id:required}
+ {-heading:required}
+} {
+ Sets the heading for a particular category
- } {
- return [db_exec_plsql get_heading {}]
- }
+ @param keyword_id The keyword id of the category to set the heading
+ @param heading The new heading
+} {
+ return [db_exec_plsql set_heading {}]
+}
- ad_proc -public set_heading {
- {-keyword_id:required}
- {-heading:required}
- } {
+ad_proc -public classified-ads::categories::get_description {
+ {-keyword_id:required}
+} {
+ Returns the description for a particular category
- sets the heading for a particular category
+ @param keyword_id The keyword id of the category to get the description
+} {
+ return [db_exec_plsql get_description {}]
+}
- @param keyword_id The keyword id of the category to set the heading
- @param heading The new heading
+ad_proc -public classified-ads::categories::set_description {
+ {-keyword_id:required}
+ {-description ""}
+} {
+ Sets the description for a particular category
- } {
- return [db_exec_plsql set_heading {}]
- }
+ @param keyword_id The keyword id of the category to set the description
+ @param description The new description
+} {
+ return [db_exec_plsql set_description {}]
+}
- ad_proc -public get_description {
- {-keyword_id:required}
- } {
+ad_proc -public classified-ads::categories::get_path {
+ {-keyword_id:required}
+} {
+ Returns the path of a particular category
- returns the description for a particular category
+ @param keyword_id The keyword id of the category to get the path
- @param keyword_id The keyword id of the category to get the description
+} {
+ return [db_exec_plsql get_path {}]
+}
- } {
- return [db_exec_plsql get_description {}]
- }
+ad_proc -public classified-ads::categories::get_custom_fields {
+ {-keyword_id:required}
+} {
+ Returns a list (of lists) of column names and their pretty names of custom
+ fields available for this category. Either the field was assigned
+ directly to this category or to one of its parents.
+ @author Roberto Mello
+ @creation-date 2003-07-29
+ @see classified-ads::ads::get_assigned_ads_by_category
+} {
+ return [db_list get_fields {}]
+}
- ad_proc -public set_description {
- {-keyword_id:required}
- {-description ""}
- } {
+ad_proc -public classified-ads::categories::generate_trail {
+ {-keyword_id:required}
+ {-append_element}
+} {
+ Generates a cookie trail for a particular category.
- sets the description for a particular category
+ @param keyword_id The keyword id that defines the end of the trail to be generated
+ @param append_element The last element to put in the trail. If none then the element defined by keyword_id is used
+} {
+ set package_keyword_id [classified-ads::categories::get_package_keyword_id]
+ set trail_list [list]
- @param keyword_id The keyword id of the category to set the description
- @param description The new description
+ db_foreach get_trail {} {
+ if {[string match $keyword_id $package_keyword_id]} {
+ set heading "Categories"
+ set url "categories"
+ } else {
+ set url "categories?keyword_id=$keyword_id"
+ }
- } {
- return [db_exec_plsql set_description {}]
- }
+ lappend trail_list [list $url $heading]
+ }
+ if {[exists_and_not_null append_element]} {
+ lappend trail_list $append_element
+ } else {
+ # no extra elements were passed, so our last element should have no link
+ set last_element_index [expr [llength $trail_list] - 1]
+ set trail_list [lreplace $trail_list $last_element_index $last_element_index $heading]
+ }
+ return $trail_list
+}
- ad_proc -public get_path {
- {-keyword_id:required}
- } {
- returns the path of a particular category
+ad_proc -public classified-ads::categories::item_assign {
+ {-keyword_id:required}
+ {-item_id:required}
+} {
- @param keyword_id The keyword id of the category to get the path
+ Maps a content item to a keyword
- } {
- return [db_exec_plsql get_path {}]
- }
+ @param keyword_id The keyword id of the category we map to
+ @param item_id The item id of the content item we map
- ad_proc -public get_custom_fields {
- {-keyword_id:required}
- } {
- Returns a list of column names of custom fields available for
- this category. Either the field was assigned directly to this
- category or to one of its parents.
+} {
+ return [db_exec_plsql add_map {}]
+}
- @author Roberto Mello
- @creation-date 2003-07-29
- @see classified-ads::ads::get_assigned_ads_by_category
- } {
- return [db_list get_fields {}]
- }
- ad_proc -public generate_trail {
- {-keyword_id:required}
- {-append_element}
- } {
+ad_proc -public classified-ads::categories::item_unassign {
+ {-keyword_id:required}
+ {-item_id:required}
+} {
- Generates a cookie trail for a particular category.
+ Unmaps a content item to a keyword
- @param keyword_id The keyword id that defines the end of the trail to be generated
- @param append_element The last element to put in the trail. If none then the element defined by keyword_id is used
+ @param keyword_id The keyword id of the category we unmap to
+ @param item_id The item id of the content item we unmap
- } {
- set package_keyword_id [package_category_exists_p]
- set trail_list [list]
-
- db_foreach get_trail {} {
- if {[string match $keyword_id $package_keyword_id]} {
- set heading "Categories"
- set url "categories"
- } else {
- set url "categories?keyword_id=$keyword_id"
- }
- lappend trail_list [list $url $heading]
- }
-
- if {[exists_and_not_null append_element]} {
- lappend trail_list $append_element
- } else {
- # no extra elements were passed, so our last element should have no link
- set last_element_index [expr [llength $trail_list] - 1]
- set trail_list [lreplace $trail_list $last_element_index $last_element_index $heading]
- }
- return $trail_list
- }
-
-
- ad_proc -public item_assign {
- {-keyword_id:required}
- {-item_id:required}
- } {
-
- maps a content item to a keyword
-
- @param keyword_id The keyword id of the category we map to
- @param item_id The item id of the content item we map
-
- } {
- return [db_exec_plsql add_map {}]
- }
-
-
- ad_proc -public item_unassign {
- {-keyword_id:required}
- {-item_id:required}
- } {
-
- unmaps a content item to a keyword
-
- @param keyword_id The keyword id of the category we unmap to
- @param item_id The item id of the content item we unmap
-
- } {
- return [db_exec_plsql delete_map {}]
- }
-
-
+} {
+ return [db_exec_plsql delete_map {}]
}
Index: openacs-4/contrib/packages/classified-ads/tcl/categories-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/categories-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/tcl/categories-procs.xql 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/tcl/categories-procs.xql 30 Jul 2003 04:56:41 -0000 1.2
@@ -2,7 +2,7 @@
-
+
select keyword_id
Index: openacs-4/contrib/packages/classified-ads/tcl/classified-ads-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/classified-ads-init.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-init.tcl 25 Jul 2003 02:39:38 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-init.tcl 30 Jul 2003 04:56:41 -0000 1.4
@@ -58,7 +58,7 @@
ns_log Debug "classified-ads-init: checking for root keyword..."
- if {![classified-ads::main_keyword_exists_p]} {
+ if {![classified-ads::get_main_keyword_id]} {
ns_log Error "Root Keyword for classified ads not found. Datamodel probably not loaded."
} else {
ns_log Debug "Root Keyword for classified ads found."
Index: openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs-postgresql.xql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs-postgresql.xql 27 Jul 2003 00:46:16 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs-postgresql.xql 30 Jul 2003 04:56:41 -0000 1.4
@@ -237,7 +237,7 @@
'type_specific', -- storage
'cr_ca_ads', -- table_name
:column_spec, -- column_spec
- null -- package_id
+ :main_keyword_id -- keyword_id
);
@@ -250,7 +250,6 @@
:attribute_id, -- attribute_name
:widget , -- widget
:pretty_name, -- label
- :main_keyword_id, -- keyword_id
:html_options, -- html_options
:extra_options, -- extra_options
:select_options, -- select_options
Index: openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 27 Jul 2003 00:46:16 -0000 1.9
+++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 30 Jul 2003 04:56:41 -0000 1.10
@@ -23,7 +23,7 @@
}
-ad_proc -public classified-ads::main_keyword_exists_p {} {
+ad_proc -public classified-ads::get_main_keyword_id {} {
Returns the keyword id of the main category for the package, 0 if not yet created
} {
# These are magic values
@@ -70,7 +70,7 @@
root classified-ads category (because we now support per-category
custom fields).
} {
- set main_keyword_id [classified-ads::main_keyword_exists_p]
+ set main_keyword_id [classified-ads::get_main_keyword_id]
set attributes [list type expires_on]
foreach attrib $attributes {
Index: openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.xql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.xql 27 Jul 2003 00:46:16 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.xql 30 Jul 2003 04:56:41 -0000 1.4
@@ -2,7 +2,7 @@
-
+
select keyword_id
Index: openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl 25 Jul 2003 23:53:19 -0000 1.6
+++ openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl 30 Jul 2003 04:56:41 -0000 1.7
@@ -37,7 +37,7 @@
# package instance.
#
- set keyword_id [classified-ads::categories::package_category_exists_p \
+ set keyword_id [classified-ads::categories::get_package_keyword_id \
-package_id $package_id]
}
Index: openacs-4/contrib/packages/classified-ads/www/ad-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/ad-new.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/www/ad-new.tcl 19 Jul 2003 01:48:45 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/www/ad-new.tcl 30 Jul 2003 04:56:41 -0000 1.4
@@ -13,11 +13,11 @@
}
if {![info exists keyword_id]} {
- set package_category_id [classified-ads::categories::package_category_exists_p]
+ set package_category_id [classified-ads::categories::get_package_keyword_id]
set keyword_id $package_category_id
set title "Place New Ad (no category)"
-} elseif {[string equal [classified-ads::main_keyword_exists_p] $keyword_id]} {
+} elseif {[string equal [classified-ads::get_main_keyword_id] $keyword_id]} {
ad_return_complaint 1 " No access to the root id"
ad_script_abort
Index: openacs-4/contrib/packages/classified-ads/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/index.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/contrib/packages/classified-ads/www/index.tcl 29 Jul 2003 09:10:42 -0000 1.4
+++ openacs-4/contrib/packages/classified-ads/www/index.tcl 30 Jul 2003 04:56:41 -0000 1.5
@@ -7,19 +7,20 @@
@cvs-id $Id$
} {
- {keyword_id ""}
+ {keyword_id 0}
{display ""}
+ {wtb "t"}
}
set root_folder_id [classified-ads::get_root_folder_id]
-set package_category_id [classified-ads::categories::package_category_exists_p]
+set package_category_id [classified-ads::categories::get_package_keyword_id]
set package_category_p 0
set title "Categories"
-if {[empty_string_p $keyword_id]} {
+if {$keyword_id == 0} {
set keyword_id $package_category_id
set package_category_p 1
-} elseif {[string equal [classified-ads::main_keyword_exists_p] $keyword_id]} {
+} elseif {[string equal [classified-ads::get_main_keyword_id] $keyword_id]} {
ad_return_complaint 1 " No access to the root id"
ad_script_abort
} else {
@@ -28,16 +29,42 @@
set title $category_info(heading)
}
+#
+# Get custom fields and set to be the list-builder spec
+#
+
+set custom_fields_list [util_memoize "classified-ads::categories::get_custom_fields -keyword_id $keyword_id"]
+set list_builder_spec ""
+
+foreach field $custom_fields_list {
+ append list_builder_spec "\t[lindex $field 0] {
+ label \"[lindex $field 1]\"
+ }"
+}
+
db_multirow categories select_categories {}
template::util::list_of_ns_sets_to_multirow \
- -rows [classified-ads::ads::get_unassigned_ads_by_category] \
- -var_name unassigned_ads
-
-template::util::list_of_ns_sets_to_multirow \
-rows [classified-ads::ads::get_assigned_ads_by_category -category_id $keyword_id] \
-var_name assigned_ads
+template::list::create \
+ -name assigned_ads \
+ -multirow assigned_ads \
+ -key ad_id \
+ -actions [list "Place Ad" [export_vars -base ad-one {keyword_id}] "Place an Ad"] \
+ -row_pretty_plural "Ads" \
+ -elements {
+ title {
+ label "Title"
+ }
+ item_id {
+ label "Item"
+ link_url_eval "ad-one?ad_id=$item_id"
+ link_html { title "View this ad" }
+ }
+ }
+
set return_url "[ad_conn url]?[ad_conn query]"
set context [classified-ads::categories::generate_trail -keyword_id $keyword_id]
Index: openacs-4/contrib/packages/classified-ads/www/admin/ad-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/ad-new.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/contrib/packages/classified-ads/www/admin/ad-new.tcl 24 Jul 2003 01:04:48 -0000 1.5
+++ openacs-4/contrib/packages/classified-ads/www/admin/ad-new.tcl 30 Jul 2003 04:56:41 -0000 1.6
@@ -13,11 +13,11 @@
}
if {![info exists keyword_id]} {
- set package_category_id [classified-ads::categories::package_category_exists_p]
+ set package_category_id [classified-ads::categories::get_package_keyword_id]
set keyword_id $package_category_id
set title "Place New Ad (no category)"
-} elseif {[string equal [classified-ads::main_keyword_exists_p] $keyword_id]} {
+} elseif {[string equal [classified-ads::get_main_keyword_id] $keyword_id]} {
ad_return_complaint 1 " No access to the root id"
ad_script_abort
Index: openacs-4/contrib/packages/classified-ads/www/admin/categories.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/categories.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/contrib/packages/classified-ads/www/admin/categories.tcl 29 Jul 2003 09:10:42 -0000 1.5
+++ openacs-4/contrib/packages/classified-ads/www/admin/categories.tcl 30 Jul 2003 04:56:41 -0000 1.6
@@ -13,14 +13,14 @@
}
set root_folder_id [classified-ads::get_root_folder_id]
-set package_category_id [classified-ads::categories::package_category_exists_p]
+set package_category_id [classified-ads::categories::get_package_keyword_id]
set package_category_p 0
set title "Categories"
if {[empty_string_p $keyword_id]} {
set keyword_id $package_category_id
set package_category_p 1
-} elseif {[string equal [classified-ads::main_keyword_exists_p] $keyword_id]} {
+} elseif {[string equal [classified-ads::get_main_keyword_id] $keyword_id]} {
ad_return_complaint 1 " No access to the root id"
ad_script_abort
} else {
Index: openacs-4/contrib/packages/classified-ads/www/admin/field-addedit-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/field-addedit-postgresql.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/classified-ads/www/admin/field-addedit-postgresql.xql 29 Jul 2003 09:10:42 -0000 1.2
+++ openacs-4/contrib/packages/classified-ads/www/admin/field-addedit-postgresql.xql 30 Jul 2003 04:56:41 -0000 1.3
@@ -15,7 +15,7 @@
'type_specific'::varchar,
'cr_ca_ads'::varchar,
:column_spec::varchar,
- :package_id::int4
+ :keyword_id::int4
) as attribute_id
@@ -28,7 +28,6 @@
:attribute_id,
:widget,
:label,
- :keyword_id,
:html_options,
:extra_options,
:select_options,
@@ -59,17 +58,4 @@
-
-
-
- select
- repeat(:indent_pattern, (tree_level(subtree.tree_sortkey) - 2) * :indent_factor::integer) || subtree.heading AS heading,
- subtree.keyword_id
- from cr_keywords parent, cr_keywords subtree
- where subtree.tree_sortkey between parent.tree_sortkey and tree_right(parent.tree_sortkey)
- and parent.parent_id = :main_category_id
-
-
-
-
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 -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 \
Index: openacs-4/contrib/packages/classified-ads/www/admin/fields.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/fields.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/www/admin/fields.adp 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/www/admin/fields.adp 30 Jul 2003 04:56:41 -0000 1.2
@@ -6,9 +6,9 @@
Add a new field
-
+
- ID | Name | Pretty Name | Pretty Plural | Order | Storage | Datatype | Default | Table | Column | Options |
+ ID | Name | Pretty Name | Category | Order | Storage | Datatype | Default | Table | Column | Options |
@@ -17,7 +17,7 @@
- @fields.attribute_id@ | @fields.attribute_name@ | @fields.pretty_name@ | @fields.pretty_plural@ | @fields.sort_order@ | @fields.storage@ | @fields.datatype@ | @fields.default_value@ | @fields.table_name@ | @fields.column_name@ | (delete) |
+ @fields.attribute_id@ | @fields.attribute_name@ | @fields.pretty_name@ | @fields.category_heading@ | @fields.sort_order@ | @fields.storage@ | @fields.datatype@ | @fields.default_value@ | @fields.table_name@ | @fields.column_name@ | (delete) |
Index: openacs-4/contrib/packages/classified-ads/www/admin/fields.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/fields.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/www/admin/fields.tcl 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/www/admin/fields.tcl 30 Jul 2003 04:56:41 -0000 1.2
@@ -13,7 +13,9 @@
set package_id [ad_conn package_id]
set content_type "ca_ad"
-db_multirow fields select_attributes {}
+db_multirow -extend { category_heading } fields select_attributes {} {
+ set category_heading [classified-ads::categories::get_heading -keyword_id $keyword_id]
+}
ad_return_template
Index: openacs-4/contrib/packages/classified-ads/www/admin/fields.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/Attic/fields.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/www/admin/fields.xql 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/www/admin/fields.xql 30 Jul 2003 04:56:41 -0000 1.2
@@ -2,14 +2,30 @@
- select aa.attribute_id, coalesce(aa.column_name, aa.attribute_name) as column_name, aa.default_value, coalesce(aa.table_name,at.table_name) as table_name, aa.storage, aa.datatype, aa.sort_order, aa.attribute_name, aa.pretty_name, aa.pretty_plural
- from acs_attributes aa,
- ca_attributes ca, acs_object_types at
- where aa.attribute_id = ca.attribute_id
- and (ca.package_id = :package_id or ca.sitewide_p = 't')
- and aa.object_type = :content_type
- and at.object_type = :content_type
- order by sort_order
+
+ select
+ aa.attribute_id,
+ coalesce(aa.column_name, aa.attribute_name) as column_name,
+ aa.default_value,
+ coalesce(aa.table_name, at.table_name) as table_name,
+ aa.storage, aa.datatype, aa.sort_order,
+ aa.attribute_name, aa.pretty_name, aa.pretty_plural
+ from
+ acs_attributes aa,
+ ca_attributes ca,
+ acs_object_types at,
+ ca_attribute_widget_values cawv,
+ cr_keywords ck
+ where
+ aa.attribute_id = ca.attribute_id
+ and
+ (ca.package_id = :package_id or ca.sitewide_p = 't')
+ and
+ aa.object_type = :content_type
+ and
+ at.object_type = :content_type
+ order by
+ sort_order