Index: openacs-4/packages/ecommerce/www/admin/customer-service/spam-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/customer-service/spam-2.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/ecommerce/www/admin/customer-service/spam-2.tcl 26 Aug 2001 23:38:30 -0000 1.2
+++ openacs-4/packages/ecommerce/www/admin/customer-service/spam-2.tcl 29 Jan 2002 00:11:46 -0000 1.3
@@ -3,11 +3,11 @@
ad_page_contract {
@param mailing_list:optional
@param user_class_id:optional
- @param product_id:optional
+ @param product_sku:optional
@param user_id_list:optional
@param category_id:optional
- @param viewed_product_id:optional
+ @param viewed_product_sku:optional
@param show_users_p:optional
@@ -18,17 +18,15 @@
} {
mailing_list:optional
user_class_id:optional
- product_id:optional
+ product_sku:optional
user_id_list:optional
category_id:optional
- viewed_product_id:optional
+ viewed_product_sku:optional
show_users_p:optional
start_date:array,date,optional
end_date:array,date,optional
}
-ns_set print [ns_getform]
-
ad_require_permission [ad_conn package_id] admin
set return_url "[ad_conn url]?[export_entire_form_as_url_vars]"
@@ -40,11 +38,6 @@
return
}
-if { [info exists start_date] && [info exists end_date] } {
- set start_date $start_date(date)
- set end_date $end_date(date)
-}
-
append doc_body "[ad_admin_header "Spam Users, Cont."]
Spam Users, Cont.
@@ -53,89 +46,59 @@
"
-ns_log debug spam-2 0
-
if { [info exists show_users_p] && $show_users_p == "t" } {
-ns_log debug spam-2 1
if { [info exists user_id_list] } {
- ns_log debug spam-2 a
- set sql "
- select user_id, first_names, last_name
- from cc_users
- where user_id in ([join $user_id_list ", "])"
+ set sql [db_map mailing_list]
+ # select user_id, first_names, last_name from cc_users where user_id in ([join $user_id_list ", "])
} elseif { [info exists mailing_list] } {
- ns_log debug spam-2 b
if { [llength $mailing_list] == 0 } {
- set search_criteria "(category_id is null and subcategory_id is null and subsubcategory_id is null)"
+ set search_criteria [db_map null_categories]
+ # (category_id is null and subcategory_id is null and subsubcategory_id is null)
} elseif { [llength $mailing_list] == 1 } {
- set search_criteria "(category_id=$mailing_list and subcategory_id is null)"
+ set search_criteria [db_map null_subcategory]
+ # (category_id=$mailing_list and subcategory_id is null)
} elseif { [llength $mailing_list] == 2 } {
- set search_criteria "(subcategory_id=[lindex $mailing_list 1] and subsubcategory_id is null)"
+ set search_criteria [db_map null_subsubcategory]
+ # (subcategory_id=[lindex $mailing_list 1] and subsubcategory_id is null)
} else {
- set search_criteria "subsubcategory_id=[lindex $mailing_list 2]"
+ set search_criteria [db_map subsubcategory]
+ # subsubcategory_id=[lindex $mailing_list 2]
}
-
- set sql "
- select users.user_id, first_names, last_name
- from cc_users, ec_cat_mailing_lists
- where users.user_id=ec_cat_mailing_lists.user_id
- and $search_criteria"
+ set sql "[db_map null_categories] and $search_criteria"
+ # select users.user_id, first_names, last_name from cc_users, ec_cat_mailing_lists where users.user_id=ec_cat_mailing_lists.user_id
} elseif { [info exists user_class_id] } {
- ns_log debug spam-2 c
if { ![empty_string_p $user_class_id]} {
- set sql_query "
- select users.user_id, first_names, last_name
- from cc_users, ec_user_class_user_map m
- where m.user_class_id=:user_class_id
- and m.user_id=users.user_id"
+ set sql [db_map user_class]
+ # select users.user_id, first_names, last_name from cc_users, ec_user_class_user_map m where m.user_class_id=:user_class_id and m.user_id=users.user_id
} else {
- set sql_query "
- select user_id, first_names, last_name
- from cc_users"
+ set sql [db_map all_users]
+ # select user_id, first_names, last_name from cc_users
}
-
- set sql $sql_query
- } elseif { [info exists product_id] } {
- ns_log debug spam-2 d
- set sql "
- select unique cc_users.user_id, first_names, last_name
- from cc_users, ec_items, ec_orders
- where ec_items.order_id=ec_orders.order_id
- and ec_orders.user_id=ccusers.user_id
- and ec_items.product_id=:product_id"
- } elseif { [info exists viewed_product_id] } {
- ns_log debug spam-2 e
- set sql "
- select unique u.user_id, first_names, last_name
- from cc_users u, ec_user_session_info ui, ec_user_sessions us
- where us.user_session_id=ui.user_session_id
- and us.user_id=u.user_id
- and ui.product_id=:viewed_product_id"
+ } elseif { [info exists product_sku] } {
+ set sql [db_map bought_product]
+ # select unique cc_users.user_id, first_names, last_name from cc_users, ec_items, ec_orders where ec_items.order_id=ec_orders.order_id and ec_orders.user_id=ccusers.user_id and ec_items.sku=:product_sku
+ } elseif { [info exists viewed_product_sku] } {
+ set sql [db_map viewed_product]
+ # select unique u.user_id, first_names, last_name from cc_users u, ec_user_session_info ui, ec_user_sessions us where us.user_session_id=ui.user_session_id and us.user_id=u.user_id and ui.sku=:viewed_product_sku
} elseif { [info exists category_id] } {
- ns_log debug spam-2 f
- set sql "
- select unique u.user_id, first_names, last_name
- from cc_users u, ec_user_session_info ui, ec_user_sessions us
- where us.user_session_id=ui.user_session_id
- and us.user_id=u.user_id
- and ui.category_id=:category_id"
+ set sql [db_map viewed_category]
+ # select unique u.user_id, first_names, last_name from cc_users u, ec_user_session_info ui, ec_user_sessions us where us.user_session_id=ui.user_session_id and us.user_id=u.user_id and ui.category_id=:category_id
} elseif { [info exists start_date] } {
- ns_log debug spam-2 g
- set sql "
- select user_id, first_names, last_name
- from cc_users
- where last_visit >= to_date(:start_date,'YYYY-MM-DD HH24:MI:SS')
- and last_visit <= to_date(:end_date,'YYYY-MM-DD HH24:MI:SS')"
+ set start $start_date(date)
+ set end $end_date(date)
+ set sql [db_map last_visit]
+ # select user_id, first_names, last_name from cc_users where last_visit >= to_date(:start,'YYYY-MM-DD HH24:MI:SS') and last_visit <= to_date(:end,'YYYY-MM-DD HH24:MI:SS')
} else {
+ set start ""
+ set end ""
ad_return_complaint 1 "I could not determine who you wanted to spam. Please go back and make a selection."
return
}
append doc_body "The following users will be spammed:
"
- ns_log debug spam-2 h [info exists sql]
db_foreach get_users_for_spam $sql {
@@ -144,10 +107,7 @@
append doc_body "
"
}
-set spam_id [db_string get_spam_id_seq_nextval "
-select ec_spam_id_sequence.nextval
- from dual
-"]
+set spam_id [db_nextval ec_spam_id_sequence]
# will export start_date and end_date separately so that they don't have to be re-put-together
# in spam-3.tcl
@@ -156,7 +116,7 @@
[ec_hidden_input var_to_spellcheck "message"]
[ec_hidden_input target_url "[ec_url_concat [ec_url] /admin]/customer-service/spam-3.tcl"]
[export_entire_form]
-[export_form_vars spam_id start_date end_date]
+[export_form_vars spam_id start end]
From |
@@ -183,7 +143,4 @@
[ad_admin_footer]
"
-doc_return 200 text/html $doc_body
-
-
-
+doc_return 200 text/html $doc_body
\ No newline at end of file