From adec979fd5453cf213b776d7dceaaaac4eb05713 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 12 Aug 2012 15:07:03 +0200 Subject: more subscription refactoring BROKEN now the actual sending of bulk messages (digest, list) is reimplemented and partially tested. Still not complete --- lib/exe/indexer.php | 86 +++++------------------------------------------------ 1 file changed, 7 insertions(+), 79 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index e149770c0..270341fe6 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -166,92 +166,20 @@ function runSitemapper(){ * @author Adrian Lang */ function sendDigest() { - echo 'sendDigest(): started'.NL; - global $ID; global $conf; + global $ID; + + echo 'sendDigest(): started'.NL; if (!$conf['subscribers']) { echo 'sendDigest(): disabled'.NL; return false; } - $subscriptions = subscription_find($ID, array('style' => '(digest|list)', - 'escaped' => true)); - global $auth; - global $lang; - global $conf; - global $USERINFO; - - // remember current user info - $olduinfo = $USERINFO; - $olduser = $_SERVER['REMOTE_USER']; - - foreach($subscriptions as $id => $users) { - if (!subscription_lock($id)) { - continue; - } - foreach($users as $data) { - list($user, $style, $lastupdate) = $data; - $lastupdate = (int) $lastupdate; - if ($lastupdate + $conf['subscribe_time'] > time()) { - // Less than the configured time period passed since last - // update. - continue; - } - - // Work as the user to make sure ACLs apply correctly - $USERINFO = $auth->getUserData($user); - $_SERVER['REMOTE_USER'] = $user; - if ($USERINFO === false) { - continue; - } - - if (substr($id, -1, 1) === ':') { - // The subscription target is a namespace - $changes = getRecentsSince($lastupdate, null, getNS($id)); - } else { - if(auth_quickaclcheck($id) < AUTH_READ) continue; - - $meta = p_get_metadata($id); - $changes = array($meta['last_change']); - } - - // Filter out pages only changed in small and own edits - $change_ids = array(); - foreach($changes as $rev) { - $n = 0; - while (!is_null($rev) && $rev['date'] >= $lastupdate && - ($_SERVER['REMOTE_USER'] === $rev['user'] || - $rev['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT)) { - $rev = getRevisions($rev['id'], $n++, 1); - $rev = (count($rev) > 0) ? $rev[0] : null; - } - - if (!is_null($rev) && $rev['date'] >= $lastupdate) { - // Some change was not a minor one and not by myself - $change_ids[] = $rev['id']; - } - } - - if ($style === 'digest') { - foreach($change_ids as $change_id) { - subscription_send_digest($USERINFO['mail'], $change_id, - $lastupdate); - } - } elseif ($style === 'list') { - subscription_send_list($USERINFO['mail'], $change_ids, $id); - } - // TODO: Handle duplicate subscriptions. - - // Update notification time. - subscription_set($user, $id, $style, time(), true); - } - subscription_unlock($id); - } + $sub = new Subscription(); + $sent = $sub->send_bulk($ID); - // restore current user info - $USERINFO = $olduinfo; - $_SERVER['REMOTE_USER'] = $olduser; + echo "sendDigest(): sent $sent mails".NL; echo 'sendDigest(): finished'.NL; - return true; + return (bool) $sent; } /** -- cgit v1.2.3 From 84c1127cc070777c8cbcf488f5422bc4b71470a8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 12 Aug 2012 17:30:01 +0200 Subject: correctly check if subscriptions are enabled --- lib/exe/indexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 270341fe6..bbfd51b39 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -170,7 +170,7 @@ function sendDigest() { global $ID; echo 'sendDigest(): started'.NL; - if (!$conf['subscribers']) { + if(!actionOK('subscribe')) { echo 'sendDigest(): disabled'.NL; return false; } -- cgit v1.2.3 From 46a853c3756aa4abe582ccb0de6f4e1f4b2035c4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 27 Nov 2012 17:39:04 +0100 Subject: correct return in sendDigest() the function always returned true, even if no action was taken. This resulted in no further indexer tasks being run. --- lib/exe/indexer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 1ccede923..c336514cd 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -181,6 +181,8 @@ function sendDigest() { global $conf; global $USERINFO; + $sent = false; + // remember current user info $olduinfo = $USERINFO; $olduser = $_SERVER['REMOTE_USER']; @@ -236,9 +238,11 @@ function sendDigest() { foreach($change_ids as $change_id) { subscription_send_digest($USERINFO['mail'], $change_id, $lastupdate); + $sent = true; } } elseif ($style === 'list') { subscription_send_list($USERINFO['mail'], $change_ids, $id); + $sent = true; } // TODO: Handle duplicate subscriptions. @@ -252,7 +256,7 @@ function sendDigest() { $USERINFO = $olduinfo; $_SERVER['REMOTE_USER'] = $olduser; echo 'sendDigest(): finished'.NL; - return true; + return $sent; } /** -- cgit v1.2.3 From 4f4c6fd5079db8beb50ea9b9aa08351a49a57d21 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 3 Dec 2012 00:07:36 +0100 Subject: lib/exe/indexer.php: Fix sending of the GIF when it is deferred FS#2646 Before this change the GIF wasn't sent at all when the PHP settings indicate that sending of the GIF needs to be deferred and it was sent when the debug output was on. --- lib/exe/indexer.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index c336514cd..28ee5331f 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -37,9 +37,12 @@ if ($evt->advise_before()) { runTrimRecentChanges(true) or $evt->advise_after(); } -if($defer) sendGIF(); -if(!$output) ob_end_clean(); +if(!$output) { + ob_end_clean(); + if($defer) sendGIF(); +} + exit; // -------------------------------------------------------------------- -- cgit v1.2.3 From 9fd5ca2ec2955ee29404be1a39ddd9affcd0c78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gro=CC=88nke?= Date: Sat, 19 Jan 2013 16:30:42 +0100 Subject: jQuery latest * jQuery 1.9.0 * jQuery-UI v1.9.2 * jQuery.fn.live > jQuery.fn.on * jQuery.fn.browser replacement (jquery.mb.browser.js) --- lib/exe/js.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 42979eeed..7c1c27138 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -43,6 +43,7 @@ function js_out(){ DOKU_INC."lib/scripts/jquery/jquery$min.js", DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", + DOKU_INC."lib/scripts/jquery/jquery.mb.browser.js", DOKU_INC."lib/scripts/fileuploader.js", DOKU_INC."lib/scripts/fileuploaderextended.js", DOKU_INC.'lib/scripts/helpers.js', -- cgit v1.2.3 From c499bfe13cc054e1a85ba63045d722c713ca8da4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 26 Jan 2013 12:26:15 +0100 Subject: added jquery-migrate as a copatibility layer this will be removed soon again. plugins using jQuery should make sure they are compatible to jQuery 1.9 --- lib/exe/js.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 7c1c27138..969a811cf 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -44,6 +44,7 @@ function js_out(){ DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", DOKU_INC."lib/scripts/jquery/jquery.mb.browser.js", + DOKU_INC."lib/scripts/jquery/jquery-migrate.js", DOKU_INC."lib/scripts/fileuploader.js", DOKU_INC."lib/scripts/fileuploaderextended.js", DOKU_INC.'lib/scripts/helpers.js', -- cgit v1.2.3 From a6c670e5041ca2038caf0175ab47fced4a3258cb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 26 Jan 2013 12:35:15 +0100 Subject: added minified version of jquery-migrate --- lib/exe/js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index 969a811cf..bec6d3d12 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -44,7 +44,7 @@ function js_out(){ DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", DOKU_INC."lib/scripts/jquery/jquery.mb.browser.js", - DOKU_INC."lib/scripts/jquery/jquery-migrate.js", + DOKU_INC."lib/scripts/jquery/jquery-migrate$min.js", DOKU_INC."lib/scripts/fileuploader.js", DOKU_INC."lib/scripts/fileuploaderextended.js", DOKU_INC.'lib/scripts/helpers.js', -- cgit v1.2.3 From d91a4ef556635b5298c47df2856851f0694b2885 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Tue, 29 Jan 2013 01:44:45 +0100 Subject: Add a break to ajax_qsearch() When the search input is still only a few characters, the number of matching pages is big. Browsers have heavy work to progress this whole return, better cut off so only the part that is directly displayed will be sent. --- lib/exe/ajax.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 9989269cf..fdc28d4f1 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -57,6 +57,7 @@ function ajax_qsearch(){ print ''.$lang['quickhits'].''; print '
    '; + $counter = 0; foreach($data as $id => $title){ if (useHeading('navigation')) { $name = $title; @@ -69,6 +70,12 @@ function ajax_qsearch(){ } } echo '
  • ' . html_wikilink(':'.$id,$name) . '
  • '; + + $counter ++; + if($counter > 50) { + echo '
  • ...
  • '; + break; + } } print '
'; } -- cgit v1.2.3 From 48606867454b93c7d11708b8193fbc2a4368aaf9 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Sun, 3 Feb 2013 19:53:11 +0100 Subject: use var and remove suggestions when needed Use variable for maximum number of suggestions for quicksearch. And hide suggestions when search field is emptied, or when no suggestion are found. --- lib/exe/ajax.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index fdc28d4f1..9769503a7 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -45,6 +45,8 @@ function ajax_qsearch(){ global $lang; global $INPUT; + $maxnumbersuggestions = 50; + $query = $INPUT->post->str('q'); if(empty($query)) $query = $INPUT->get->str('q'); if(empty($query)) return; @@ -72,7 +74,7 @@ function ajax_qsearch(){ echo '
  • ' . html_wikilink(':'.$id,$name) . '
  • '; $counter ++; - if($counter > 50) { + if($counter > $maxnumbersuggestions) { echo '
  • ...
  • '; break; } -- cgit v1.2.3 From f144452ffbdd0ff09501838b3520147b6e409601 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 3 Feb 2013 21:50:46 +0100 Subject: removed obsolete browser plugin (migrate does it) --- lib/exe/js.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index bec6d3d12..41d3e735c 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -43,7 +43,6 @@ function js_out(){ DOKU_INC."lib/scripts/jquery/jquery$min.js", DOKU_INC.'lib/scripts/jquery/jquery.cookie.js', DOKU_INC."lib/scripts/jquery/jquery-ui$min.js", - DOKU_INC."lib/scripts/jquery/jquery.mb.browser.js", DOKU_INC."lib/scripts/jquery/jquery-migrate$min.js", DOKU_INC."lib/scripts/fileuploader.js", DOKU_INC."lib/scripts/fileuploaderextended.js", -- cgit v1.2.3