From 73a0271960a5e7e2bc6e040595d3071d7b689a99 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 4 Jul 2008 01:04:25 -0400 Subject: enqueue notices for offline broadcast darcs-hash:20080704050425-84dde-d0106845c7b16b80be8e0d5ee9ac93a457334df7.gz --- lib/common.php | 2 ++ lib/util.php | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/common.php b/lib/common.php index 691d33953..0b5b4ab5c 100644 --- a/lib/common.php +++ b/lib/common.php @@ -51,6 +51,8 @@ $config = array('authority' => 'INVALID TAG', 'date' => 'PUT A DATE HERE', 'prefix' => ''), + 'queue' => + array('enabled' => false), 'license' => array('url' => 'http://creativecommons.org/licenses/by/3.0/', 'title' => 'Creative Commons Attribution 3.0', diff --git a/lib/util.php b/lib/util.php index 4d1abe51a..03d549334 100644 --- a/lib/util.php +++ b/lib/util.php @@ -808,6 +808,25 @@ function common_redirect($url, $code=307) { } function common_broadcast_notice($notice, $remote=false) { + if (common_config('queue', 'enabled')) { + # Do it later! + common_enqueue_notice($notice); + } else { + common_real_broadcast($notice, $remote); + } +} + +# Stick the notice on the queue + +function common_enqueue_notice($notice) { + $qi = new Queue_item(); + $qi->notice_id = $notice->id; + $qi->created = DB_DataObject_Cast::dateTime(); + $result = $qi->insert(); + return $result; +} + +function common_real_broadcast($notice, $remote=false) { // XXX: optionally use a queue system like http://code.google.com/p/microapps/wiki/NQDQ if (!$remote) { # Make sure we have the OMB stuff @@ -939,7 +958,7 @@ function common_ensure_syslog() { function common_log($priority, $msg, $filename=NULL) { common_ensure_syslog(); -# syslog($priority, $msg); + syslog($priority, $msg); } function common_debug($msg, $filename=NULL) { -- cgit v1.2.3-54-g00ecf