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.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 19 Jul 2003 01:48:45 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 21 Jul 2003 05:23:56 -0000 1.4
@@ -50,6 +50,8 @@
@param form_id The ID of the form that contains the name/value pairs
@param item_id_element The name of the form element that should be used as the item id
+ @see classified-ads::edit_ca_item
+
} {
return [classified-ads::edit_ca_item -item_id_element $item_id_element \
-form_id $form_id \
@@ -91,6 +93,7 @@
# Get extra widgets that we need to display
#
set package_id [ad_conn package_id]
+ set content_type "ca_ad"
set widget_list [db_list_of_ns_sets select_widgets {}]
if {[empty_string_p $revision_id]} {
@@ -104,11 +107,11 @@
db_1row select_data {} -column_array row
- set row(pretty_publish_date) [util_AnsiDatetoPrettyDate $publish_date]
+ set row(pretty_publish_date) [util_AnsiDatetoPrettyDate $row(publish_date)]
set row(data) [classified-ads::get_content -revision_id $revision_id]
return 0
- }
+}
ad_proc -public get_assigned_ads_by_category {
@@ -164,4 +167,44 @@
return [db_list_of_ns_sets select_ads {}]
}
+ad_proc -public get_category_id {
+ {-ad_id:required}
+} {
+ Return the keyword_id of the category the passed ad belongs to.
+
+ @author Roberto Mello
+} {
+ return [db_0or1row get_category_id {}]
}
+
+ad_proc -public generate_trail {
+ {-ad_id:required}
+ {-append_element}
+} {
+ Generates a cookie trail for a particular ad.
+
+ @param ad_id The id of the ad.
+ @author Roberto Mello
+} {
+ set keyword_id [classified-ads::ads::get_category_id -ad_id $ad_id]
+
+ if { [exists_and_not_null append_element] } {
+ set to_append $append_element
+ } else {
+ set to_append "Ad $ad_id"
+ }
+
+ #
+ # We call categories::generate_trail with "-append_element foo" so we
+ # can cache its results effectively.
+ #
+
+ set trail_list [util_memoize "classified-ads::categories::generate_trail -keyword_id $keyword_id -append_element foo"]
+
+ set last_element_index [expr [llength $trail_list] - 1]
+ set trail_list [lreplace $trail_list $last_element_index $last_element_index $to_append]
+
+ return $trail_list
+}
+
+}
Index: openacs-4/contrib/packages/classified-ads/tcl/ads-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/ads-procs.xql,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/classified-ads/tcl/ads-procs.xql 19 Jul 2003 01:48:45 -0000 1.3
+++ openacs-4/contrib/packages/classified-ads/tcl/ads-procs.xql 21 Jul 2003 05:23:56 -0000 1.4
@@ -74,4 +74,14 @@
+
+
+
+ select keyword_id
+ from cr_item_keyword_map
+ where item_id = :ad_id
+
+
+
+
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.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/tcl/categories-procs.tcl 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/tcl/categories-procs.tcl 21 Jul 2003 05:23:56 -0000 1.2
@@ -197,15 +197,15 @@
{-append_element}
} {
- generates a cookie trail for a particular category
+ Generates a cookie trail 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 [package_category_exists_p]
-
set trail_list [list]
+
db_foreach get_trail {} {
if {[string match $keyword_id $package_keyword_id]} {
set heading "Categories"
@@ -215,6 +215,7 @@
}
lappend trail_list [list $url $heading]
}
+
if {[exists_and_not_null append_element]} {
lappend trail_list $append_element
} else {
Index: openacs-4/contrib/packages/classified-ads/www/admin/ad-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/ad-delete.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/www/admin/ad-delete.tcl 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/www/admin/ad-delete.tcl 21 Jul 2003 05:23:56 -0000 1.2
@@ -1,19 +1,33 @@
ad_page_contract {
- Delete an Ad
+ Delete an Ad (1 of 2)
- @author Deds Castillo (deds@infiniteinfo.com)
- @creation-date 2002-10-08
+ @author Roberto Mello
+ @creation-date 2003-07-20
@cvs-id $Id$
} {
ad_id:integer,notnull
- {return_url "ads"}
+ title:notnull
+ {return_url "categories"}
}
-if {[catch {classified-ads::ads::delete -ad_id $ad_id} errmsg]} {
- ad_return_complaint 1 "
the following error occured during deletion: $errmsg"
- ad_script_abort
-}
+ad_form -name ad_delete -export ad_id \
+ -mode display \
+ -cancel_label "No" \
+ -cancel_url "ad-one?ad_id=$ad_id" \
+ -form {
-ad_returnredirect $return_url
+ {title:text(text) {label "Title"}
+ {value $title} }
+ {you_sure:text(inform) {label "Are you sure you want to delete this ad?"} }
+
+} -edit_data {
+ if {[catch {classified-ads::ads::delete -ad_id $ad_id} errmsg]} {
+ ad_return_complaint 1 " The following error occured during deletion: $errmsg"
+ ad_script_abort
+ }
+
+ ad_returnredirect $return_url
+ ad_script_abort
+}
Index: openacs-4/contrib/packages/classified-ads/www/admin/ad-one.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/ad-one.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/classified-ads/www/admin/ad-one.adp 21 Jul 2003 05:23:56 -0000 1.1
@@ -0,0 +1,6 @@
+
+@title@
+@context@
+ad.title
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl 21 Jul 2003 05:23:56 -0000 1.1
@@ -0,0 +1,83 @@
+ad_page_contract {
+ Display/Edit a Classified Ad
+
+ @author Roberto Mello (rmello@fslc.usu.edu)
+ @creation-date 2003-07-19
+ @cvs-id $Id: ad-one.tcl,v 1.1 2003/07/21 05:23:56 rmello Exp $
+
+} {
+ {ad_id:integer}
+ {revision_id ""}
+ {mode "display"}
+ {return_url "categories"}
+}
+
+#
+# Only needed in non-admin version
+#
+# set user_id [ad_conn user_id]
+
+#####
+# Actions
+#####
+
+set actions [list [list " Edit " edit] [list " Delete " delete]]
+set title "Ad $ad_id"
+set context [classified-ads::ads::generate_trail -ad_id $ad_id]
+
+ad_form -name ad -cancel_url $return_url -mode display -actions $actions -form {
+ ad_id:key
+ {return_url:text(hidden) {label "return url"}
+ {value $return_url} }
+ {title:text(text) {label "Title"}
+ {html {size 60} {maxlength 1000}} }
+ {description:text(textarea) {label "Short Description"}
+ {optional}
+ {html {cols 60 rows 3 wrap soft}} }
+ {data:text(textarea) {label "Content"}
+ {optional}
+ {html {cols 60 rows 10 wrap soft}} }
+
+} -on_request {
+ # Get extra custom widgets, if any
+
+ classified-ads::widgets::get_widget_params -content_type "ca_ad" -form_id ad
+
+ set form_values [classified-ads::get_attribute_values -item_id $ad_id -item_id_element ad_id]
+
+ classified-ads::widgets::set_widget_values -form_id ad -form_values $form_values
+ classified-ads::ads::get -ad_id $ad_id -revision_id $revision_id -array adinfo
+
+ element set_properties ad ad_id -value $ad_id
+ element set_properties ad title -value $adinfo(title)
+ element set_properties ad description -value $adinfo(description)
+ element set_properties ad data -value $adinfo(data)
+
+} -edit_data {
+ set ad_id [classified-ads::ads::edit \
+ -item_id_element ad_id \
+ -form_id ad]
+
+ template::form get_values ad return_url
+
+ ad_returnredirect $return_url
+ ad_script_abort
+
+} -edit_request {
+ # RBM: Hack because of ad_form's limitation
+}
+
+
+set action [form get_action ad]
+
+if { [string equal $action "delete"] } {
+ #
+ # If the delete button was pressed
+ #
+ #rp_form_put title $adinfo(title)
+ #rp_form_put return_url $return_url
+ rp_internal_redirect ad-delete
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/contrib/packages/classified-ads/www/admin/categories.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/categories.adp,v
diff -u -r1.4 -r1.5
--- openacs-4/contrib/packages/classified-ads/www/admin/categories.adp 19 Jul 2003 01:48:45 -0000 1.4
+++ openacs-4/contrib/packages/classified-ads/www/admin/categories.adp 21 Jul 2003 05:23:56 -0000 1.5
@@ -73,7 +73,7 @@
- @assigned_ads.title@
+ @assigned_ads.title@
|
@assigned_ads.pretty_publish_date@
@@ -113,7 +113,7 @@
|
- @unassigned_ads.title@
+ @unassigned_ads.title@
|
@unassigned_ads.pretty_publish_date@
|