calendar_user_contributions

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

Source code:


    if { $purpose == "site_admin" } {
	set restriction_clause ""
    } else {
	set restriction_clause "\nand c.approved_p = 't'"
    }
    set db_sub [ns_db gethandle subquery]

    set selection [ns_db select $db "
    select c.calendar_id, c.title, c.approved_p, c.start_date, cc.scope, cc.group_id, ug.group_name, ug.short_name,
           decode(cc.scope, 'public', 1, 'group', 2, 'user', 3, 4) as scope_ordering
    from calendar c, calendar_categories cc, user_groups ug
    where c.creation_user = $user_id $restriction_clause
    and c.category_id= cc.category_id
    and cc.group_id=ug.group_id(+)
    order by scope_ordering, cc.group_id, c.start_date"]

    set items ""
    set last_group_id ""
    set item_counter 0
    while { [ns_db getrow $db $selection] } {
	set_variables_after_query
	
	switch $scope {
	    public {
		if { $item_counter==0 } {
		    append items "<h4>Public Calendar Postings</h4>"		    
		    set root_url "/calendar"
		    set admin_root_url "/calendar/admin"
		}
	    }
	    group {
		if { $last_group_id!=$group_id } {
		    append items "<h4>$group_name Calendar Postings</h4>"
		    
		    set sub_selection [ns_db 0or1row $db_sub "
		    select section_key
		    from content_sections
		    where scope='group' and group_id=$group_id
		    and module_key='calendar'"]
		    
		    if { [empty_string_p $selection] } {
			set root_url "/calendar"
			set admin_root_url "/calendar/admin"
		    } else {
			set_variables_after_subquery
			set root_url "[ug_url]/[ad_urlencode $short_name]/[ad_urlencode $section_key]"
			set admin_root_url "[ug_admin_url]/[ad_urlencode $short_name]/[ad_urlencode $section_key]"
			
		    }
		} 
	    } 
	}
		
	if { $purpose == "site_admin" } {
	    append items "<li>[util_AnsiDatetoPrettyDate $start_date]: <a href=\"$admin_root_url/item?[export_url_vars calendar_id]\">$title</a>\n"
	    if { $approved_p == "f" } {
		append items "&nbsp; <font color=red>not approved</font>"
	    }
	} else {
	    append items "<li>[util_AnsiDatetoPrettyDate $start_date]: <a href=\"$root_url/item?[export_url_vars calendar_id]\">$title</a>\n"
	}
	
	set last_group_id $group_id
	incr item_counter
    }

    ns_db releasehandle $db_sub

    if [empty_string_p $items] {
	return [list]
    } else {
	return [list 0 "Calendar Postings" "<ul>\n\n$items\n\n</ul>"]
    }


philg@mit.edu