Index: openacs-4/packages/lars-blogger/tcl/entry-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/tcl/entry-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/lars-blogger/tcl/entry-procs.tcl 27 Jan 2003 16:19:15 -0000 1.2 +++ openacs-4/packages/lars-blogger/tcl/entry-procs.tcl 28 Aug 2003 09:41:55 -0000 1.3 @@ -2,7 +2,6 @@ Entry procs for blogger. } - namespace eval lars_blogger::entry {} ad_proc -public lars_blogger::entry::get { @@ -12,13 +11,93 @@ # Select the info into the upvar'ed Tcl Array upvar $array row - db_1row select_entry { *SQL* } -column_array row + db_1row select_entry {} -column_array row } +ad_proc -public lars_blogger::entry::require_write_permission { + {-entry_id:required} +} { + permission::require_permission -object_id $entry_id -privilege write + + set admin_p [permission::permission_p -privilege "admin" -object_id $entry_id] + + if { !$admin_p && [ad_conn user_id] != [db_string creation_user {}] } { + ad_return_forbidden "Security Violation" "
+ You don't have permission to modify this entry. +
+ This incident has been logged. +
" + ad_script_abort + } +} -ad_proc -public do_notifications { +ad_proc -public lars_blogger::entry::publish { {-entry_id:required} + {-package_id ""} + {-no_update:boolean} + {-redirect_url ""} } { + if { !$no_update_p } { + # Set draft_p = 'f' + db_dml update_entry { *SQL* } + # Flush cache + lars_blog_flush_cache + } + + if { ![empty_string_p $redirect_url] } { + ad_returnredirect $redirect_url + ns_conn close + } + + # Setup instance feed if needed + lars_blog_setup_feed -package_id $package_id + + # Setup user feed if needed + lars_blog_setup_feed -user -package_id $package_id + + # Notifications + lars_blogger::entry::do_notifications -entry_id $entry_id + + # Ping weblogs.com + lars_blog_weblogs_com_update_ping +} + + +ad_proc -public lars_blogger::entry::htmlify { + -array:required +} { + Make the entry displayable in an HTML page +} { + upvar $array row + + set row(title) [ad_quotehtml $row(title)] + + # LARS: + # Not sure we should do the ns_adp_parse thing here, but heck, why not + # It should be safe, given the standard HTML filter security checks, which + # wouldn't let unsafe tags slip through, anyway + + set row(content) [ad_html_text_convert -from $row(content_format) -to "text/html" -- $row(content)] + + # We wrap this in a catch so if it bombs, at least we won't break any pages + catch { + set row(content) [ns_adp_parse -string $row(content)] + } + + # look for the base site name in the url + if {[regexp {^https?://([^ /]+)} $row(title_url) initial base_url] } { + set row(title_url_base) $base_url + } else { + set row(title_url_base) {} + } +} + + + + +ad_proc -public lars_blogger::entry::do_notifications { + {-entry_id:required} +} { # Select all the important information get -entry_id $entry_id -array blog @@ -28,7 +107,11 @@ set new_content "" append new_content "$blog(poster_first_names) $blog(poster_last_name) posted to $blog_name at $blog(posted_time_pretty) on $blog(entry_date_pretty):\n\n" - append new_content "$blog(title)\n\n" + append new_content "$blog(title)\n[string repeat "-" [string length $blog(title)]]\n" + if { ![empty_string_p $blog(title_url)] } { + append new_content "$blog(title_url)\n" + } + append new_content "\n" append new_content "[ad_convert_to_text -- [ns_adp_parse -string $blog(content)]]\n\n" append new_content "This entry: $entry_url\n\n" append new_content "$blog_name: $blog_url\n"