Index: openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.tcl 11 Feb 2003 23:23:23 -0000 1.3 +++ openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.tcl 10 Mar 2003 21:45:46 -0000 1.4 @@ -101,6 +101,60 @@ return "" } +ad_proc -public irc::logger::rotate_logs { + -package_id:required + {-all:boolean} +} { + + Rotate the ETP pages so that the ETP page with the new log is + listed first instead of last. Please be aware that changes to + the sort order through of these logs through ETP might have + undesired side effects to the order. This an artifact of ETP + and not of the IRC logger. + + @creation-date 2003-02-18 + @author Bart Teeuwisse (bart.teeuwisse@thecodemill.biz) + + @param package_id The package_id of the ETP instance that is + the parent of the ETP log pages. + + @param -all Switch indicating wether all ETP instances should + be rotated or only the ETP log pages. This flag is used when + the 'current' link has been created and needs to be rotated to + the top of the page. + + @return none + + @error none +} { + + # Get the ID of the parent folder of the ETP log pages. + + set parent_id [db_string get_parent_id {} -default {}] + + # Rotate all ETP pages or just the logs? + + if {$all_p} { + set i1_select_criteria "true" + set i2_select_criteria "true" + } else { + set i1_select_criteria [db_map i1_criteria] + set i2_select_criteria [db_map i2_criteria] + } + + # Rotate the logs by assigning the tree_sortkey of the next ETP + # page to the current page. Assign the tree_sortkey of the first + # page to the last (=new) page. + + db_foreach etp_logs {} { + + # Assign the tree_sortkey of the next ETP page to the current + # page or the tree_sortkey of the first ETP to the last page. + + db_dml shift {} + } +} + ad_proc -public irc::logger::update_log { -date:required -package_id:required @@ -175,11 +229,45 @@ # Create a new ETP page for the log. db_exec_plsql page_create {} - } + set log_live_revision_id [etp::get_live_revision_id $parent_package_id $date] + # Rotate the logs so that the new log is + # on top. + + irc::logger::rotate_logs -package_id $parent_package_id + + # Symlink 'current' to the latest log. + + set log_url "[site_node::get_url -node_id $parent_package_id]$date" + if {![db_0or1row get_extlink {}]} { + + # Create a 'current' symlink to the + # new log. As ETP symlinks don't + # support labels the link is created + # as an ETP extlink which do support + # labels and descriptions. + + set link_label "current" + set link_description "Current $irc_channel_name conversation log" + db_exec_plsql create_extlink {} + + # Rotate the symlink to the top of the list. + + irc::logger::rotate_logs -package_id $parent_package_id -all + + } else { + + # Point the 'current' symlink to the new log. + + db_dml update_extlink {} + + } + } else { + set log_live_revision_id [etp::get_live_revision_id $parent_package_id $date] + } + # The update the existing ETP page for the log. - set log_live_revision_id [etp::get_live_revision_id $parent_package_id $date] set log_description "Conversation log of $irc_channel_name of $date" db_dml update_revision {}