summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-07-04 01:04:25 -0400
committerEvan Prodromou <evan@prodromou.name>2008-07-04 01:04:25 -0400
commit73a0271960a5e7e2bc6e040595d3071d7b689a99 (patch)
tree569be28a814427c5b0005e4b96ef536ba14ddc60 /lib
parent784299c25778fccb3292b4f339446f37c11d2bf9 (diff)
enqueue notices for offline broadcast
darcs-hash:20080704050425-84dde-d0106845c7b16b80be8e0d5ee9ac93a457334df7.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/common.php2
-rw-r--r--lib/util.php21
2 files changed, 22 insertions, 1 deletions
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) {