Index: openacs-4/contrib/packages/classified-ads/classified-ads.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/classified-ads.info,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/classified-ads/classified-ads.info 18 Jul 2003 03:16:49 -0000 1.2
+++ openacs-4/contrib/packages/classified-ads/classified-ads.info 25 Jul 2003 23:53:19 -0000 1.3
@@ -15,14 +15,16 @@
Infiniteinfo
This package implements a generic classified ads module using the content repository. It features categorization, adding of custom fields, etc.
-
+
+
-
-
+
+
+
Index: openacs-4/contrib/packages/classified-ads/sql/postgresql/ads-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/sql/postgresql/ads-create.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/classified-ads/sql/postgresql/ads-create.sql 24 Jul 2003 00:11:03 -0000 1.2
+++ openacs-4/contrib/packages/classified-ads/sql/postgresql/ads-create.sql 25 Jul 2003 23:53:19 -0000 1.3
@@ -21,37 +21,9 @@
''ad_id'', -- id_column
''ca_ads__name'' -- name_method
);
-
--- create the attributes
-
- v_attribute_id := ca_attributes__create_attribute (
- ''ca_ad'', -- content_type
- ''expires_on'', -- attribute_name
- ''date'', -- datatype
- ''Expiry Date'', -- pretty_name
- ''Expiry Dates'', -- pretty_plural
- null, -- sort_order
- null, -- default_value
- ''type_specific'', -- storage
- ''cr_ca_ads'', -- table_name
- ''timestamp'', -- column_spec
- null -- package_id
- );
-
- PERFORM ca_attributes__register_widget (
- v_attribute_id, -- attribute_name
- ''date'', -- widget
- ''Ad expires on'', -- label
- null, -- keyword_id (NULL because it is site-wide)
- null, -- html_options
- '' -format "MONTH DD YYYY" -help'' -- extra_options
- null, -- select_options
- null, -- validate
- ''t'', -- optional_p
- ''t'' -- enabled_p
- );
-
+
-- register mime_types
+
PERFORM content_type__register_mime_type (
''ca_ad'', -- content_type
''text/plain'' -- mime_type
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.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs-postgresql.xql 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs-postgresql.xql 25 Jul 2003 23:53:19 -0000 1.2
@@ -222,4 +222,90 @@
+
+
+
+ create function ca_inline_0 ()
+ returns integer as '
+ declare
+ v_attribute_id ca_attributes.attribute_id%TYPE;
+ begin
+
+ v_attribute_id := ca_attributes__create_attribute (
+ ''ca_ad'', -- content_type
+ ''type'', -- attribute_name
+ ''integer'', -- datatype
+ ''Type'', -- pretty_name
+ ''Types'', -- pretty_plural
+ null, -- sort_order
+ ''0'', -- default_value
+ ''type_specific'', -- storage
+ ''cr_ca_ads'', -- table_name
+ ''integer'', -- column_spec
+ null -- package_id
+ );
+
+ PERFORM ca_attributes__register_widget (
+ v_attribute_id, -- attribute_name
+ ''radio'', -- widget
+ ''Type'', -- label
+ :main_keyword_id, -- keyword_id
+ null, -- html_options
+ null, -- extra_options
+ ''{{"For Sale" 0} {"Wanted to Buy" 1}}'', -- select_options
+ ''{type {![string equal $value 0] && ![string equal $value 1]} {"Invalid option selected, please select For Sale or Wanted to Buy"}}'', -- validate
+ ''f'', -- optional_p
+ ''t'' -- enabled_p
+ );
+
+ v_attribute_id := ca_attributes__create_attribute (
+ ''ca_ad'', -- content_type
+ ''expires_on'', -- attribute_name
+ ''date'', -- datatype
+ ''Expiry Date'', -- pretty_name
+ ''Expiry Dates'', -- pretty_plural
+ null, -- sort_order
+ null, -- default_value
+ ''type_specific'', -- storage
+ ''cr_ca_ads'', -- table_name
+ ''timestamp'', -- column_spec
+ null -- package_id
+ );
+
+ PERFORM ca_attributes__register_widget (
+ v_attribute_id, -- attribute_name
+ ''date'', -- widget
+ ''Ad expires on'', -- label
+ :main_keyword_id, -- keyword_id
+ null, -- html_options
+ '' -format "MONTH DD YYYY" -help'' -- extra_options
+ null, -- select_options
+ null, -- validate
+ ''t'', -- optional_p
+ ''t'' -- enabled_p
+ );
+
+ return NULL;
+ end;
+ ' language 'plpgsql';
+
+
+
+
+
+
+
+ SELECT ca_inline_0();
+
+
+
+
+
+
+
+ DROP FUNCTION ca_inline_0();
+
+
+
+
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.7 -r1.8
--- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 25 Jul 2003 02:39:38 -0000 1.7
+++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 25 Jul 2003 23:53:19 -0000 1.8
@@ -60,7 +60,39 @@
return $folder_id
}
+ad_proc -private classified-ads::install_sitewide_attributes {
+ -package_id:required
+} {
+ Checks if the site-wide attributes (used by all classified-ads
+ instances) have been installed and installs them if necessary.
+ Called through an after-mount Tcl callback. We do this here instead
+ of in the SQL creation scripts because we need the keyword_id of the
+ root classified-ads category (because we now support per-category
+ custom fields).
+} {
+ set main_keyword_id [classified-ads::main_keyword_exists_p]
+ set attributes [list type expires_on]
+ set attributes_query [join attributes ","]
+ set count [db_1row count_attributes {}]
+
+ if { $count != [llength $attributes] } {
+ #
+ # Site-wide attributes have not been created. Create them.
+ #
+
+ db_transaction {
+ db_exec_plsql create_function {}
+ db_exec_plsql run_function {}
+ db_exec_plsql drop_function {}
+ }
+
+ return 1
+ }
+
+ return 0
+}
+
ad_proc -public classified-ads::get_folder_id {
{-package_id}
} {
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.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.xql 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.xql 25 Jul 2003 23:53:19 -0000 1.2
@@ -112,5 +112,15 @@
+
+
+ SELECT COUNT(*)
+ FROM acs_attributes
+ WHERE object_type = 'ca_ad'
+ AND attribute_name IN ( $attributes_query )
+
+
+
+
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.5 -r1.6
--- openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl 25 Jul 2003 02:39:38 -0000 1.5
+++ openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl 25 Jul 2003 23:53:19 -0000 1.6
@@ -55,12 +55,12 @@
}
# Is there a default value?
+
+ #set default_value [ns_set get $one_widget default_value]
- set default_value [ns_set get $one_widget default_value]
-
- if {![empty_string_p $default_value]} {
- append extra_ops " -value $default_value"
- }
+ #if {![empty_string_p $default_value]} {
+ # append extra_ops " -value $default_value"
+ #}
# Is there a validate clause?
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.2 -r1.3
--- openacs-4/contrib/packages/classified-ads/www/index.tcl 23 Jul 2003 21:08:19 -0000 1.2
+++ openacs-4/contrib/packages/classified-ads/www/index.tcl 25 Jul 2003 23:53:20 -0000 1.3
@@ -1,10 +1,44 @@
ad_page_contract {
- Classified Ads Main User Page
+ Classified Ads Main Page
- @author Roberto Mello
- @creation-date 2003-07-21
+ @author Roberto Mello
+ @creation-date 2003-07-20
@cvs-id $Id$
+} {
+ {keyword_id ""}
+ {display ""}
}
+set root_folder_id [classified-ads::get_root_folder_id]
+set package_category_id [classified-ads::categories::package_category_exists_p]
+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]} {
+ ad_return_complaint 1 "
No access to the root id"
+ ad_script_abort
+} else {
+ # Select info for this category
+ classified-ads::categories::get -keyword_id $keyword_id -array category_info
+ set title $category_info(heading)
+}
+
+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_list [list $keyword_id]] \
+ -var_name assigned_ads
+
+set return_url "[ad_conn url]?[ad_conn query]"
+set context [classified-ads::categories::generate_trail -keyword_id $keyword_id]
+
+ad_return_template
Index: openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl 25 Jul 2003 02:39:57 -0000 1.5
+++ openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl 25 Jul 2003 23:53:20 -0000 1.6
@@ -24,9 +24,27 @@
set actions [list [list " Edit " edit] [list " Delete " delete]]
set url_title "Ad $ad_id"
set context [classified-ads::ads::generate_trail -ad_id $ad_id]
-
set action [form get_action ad]
+#
+# Get information for this ad
+#
+
+classified-ads::ads::get -ad_id $ad_id -revision_id $revision_id -array adinfo
+
+#
+# If no return_url was passed, let's return to the category of this
+# particular ad.
+#
+
+if { [string equal $return_url "categories"] } {
+ set return_url "categories?keyword_id=$adinfo(keyword_id)"
+}
+
+#
+# Now we're ready to create the form
+#
+
ad_form -name ad -cancel_url $return_url -mode display -actions $actions -form {
ad_id:key
{return_url:text(hidden) {label "return url"}
@@ -42,9 +60,9 @@
}
-classified-ads::ads::get -ad_id $ad_id -revision_id $revision_id -array adinfo
-
+#
# Get extra custom widgets, if any
+#
classified-ads::widgets::get_widget_params \
-content_type "ca_ad" \
@@ -84,10 +102,13 @@
set title [template::element::get_value ad title]
set description [template::element::get_value ad description]
- ad_returnredirect "ad-delete?[export_vars -url {ad_id title description return_url context}]"
- #rp_form_put context $context
- #rp_internal_redirect ad-delete
+ #
+ # Tried to use rp_internal_redirect but had problems.
+ # This is less elegant but works.
+ #
+
+ ad_returnredirect "ad-delete?[export_vars -url {ad_id title description return_url context}]"
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.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/www/admin/categories.tcl 21 Jul 2003 16:08:07 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/www/admin/categories.tcl 25 Jul 2003 23:53:20 -0000 1.4
@@ -9,6 +9,7 @@
} {
{keyword_id ""}
+ {display ""}
}
set root_folder_id [classified-ads::get_root_folder_id]