gc_user_contributions

one of the documented procedures in this installation of the ACS
Usage:
gc_user_contributions   db   user_id   purpose
What it does:
Returns list items, one for each classified posting
Defined in: /web/philip/tcl/gc-defs.tcl

Source code:


    # we query out both the current and audit rows at once (so that we get a complete
    # chronology).  For an ad that is current but has an audit row as well, we'll 
    # get the current one first

    set selection [ns_db select $db "select classified_ad_id, posted, expired_p(expires) as expired_p, one_line, 'f' as audit_row_p
from classified_ads 
where user_id = $user_id
union
select classified_ad_id, posted, 'f' as expired_p, one_line, 't' as audit_row_p
from classified_ads_audit
where user_id = $user_id
order by classified_ad_id, audit_row_p"]

    set classified_items ""
    set last_id ""
    while {[ns_db getrow $db $selection]} {
	set_variables_after_query
	if { $classified_ad_id == $last_id } {
	    # this is an audit row for a current ad; skip printing it
	    continue
	}
	set suffix ""
	if {$expired_p == "t"} {
	    set suffix "<font color=red>expired</font>\n"
	}
	if {$audit_row_p == "t" } {
	    set suffix "<font color=red>deleted</font>\n"
	    set target_url "view-ad-history.tcl"
	} else {
	    # regular ad
	    set target_url "view-one.tcl"
	    if { $purpose == "site_admin" && $expired_p != "t" } {
		append suffix "\[<a target=another_window href=\"/admin/gc/edit-ad?classified_ad_id=$classified_ad_id\">Edit</a> |
<a target=another_window href=\"/admin/gc/delete-ad?classified_ad_id=$classified_ad_id\">Delete</a> \]\n"
	    }
	}
	append classified_items "<li>[util_AnsiDatetoPrettyDate $posted]: <A HREF=\"/gc/$target_url?classified_ad_id=$classified_ad_id\">$one_line</a> $suffix\n"
	set last_id $classified_ad_id
    }

    if [empty_string_p $classified_items] {
	return [list]
    } else {
	return [list 0 "Classified Ads" "<ul>\n\n$classified_items\n\n</ul>\n"]
    }


philg@mit.edu