summaryrefslogtreecommitdiff
path: root/lib/exe
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-01-26 11:21:39 +0100
committerAndreas Gohr <andi@splitbrain.org>2013-01-26 11:21:39 +0100
commitba56222349781fd8e3938ab18127d46f3c1e0061 (patch)
tree1e39e4e2960462ea06ae55a993512bf18ce4aa25 /lib/exe
parent1285aa3a44c9fdf49bfd8992f33bac068bae8226 (diff)
parentc38b7fab9eeb9456aaf5fe8e4481c3b8569e5644 (diff)
downloadrpg-ba56222349781fd8e3938ab18127d46f3c1e0061.tar.gz
rpg-ba56222349781fd8e3938ab18127d46f3c1e0061.tar.bz2
Merge branch 'subscription' Pull Request #125
* subscription: (25 commits) link directly to subscription management in mails only use mailfromnobody for bulk mails added missing context for list mails readded mailfromnobody to subscription sending correctly escape diffs in HTML mails fixed lists in HTML mails simplified subscription->add() code a bit comment adjusted removed unused vars removed data parameter in subscription_handle_post() fixed tests some reformatting added compatibility function moved registration notification to subscription class fixed merge error in inc/auth.php consolidate more notification code in subscription class minor cleanup initialize new subscriptions with current time fixed subscription management correctly check if subscriptions are enabled ...
Diffstat (limited to 'lib/exe')
-rw-r--r--lib/exe/indexer.php93
1 files changed, 8 insertions, 85 deletions
diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index 28ee5331f..27576f76d 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -169,97 +169,20 @@ function runSitemapper(){
* @author Adrian Lang <lang@cosmocode.de>
*/
function sendDigest() {
- echo 'sendDigest(): started'.NL;
- global $ID;
global $conf;
- if (!$conf['subscribers']) {
+ global $ID;
+
+ echo 'sendDigest(): started'.NL;
+ if(!actionOK('subscribe')) {
echo 'sendDigest(): disabled'.NL;
return false;
}
- $subscriptions = subscription_find($ID, array('style' => '(digest|list)',
- 'escaped' => true));
- /** @var auth_basic $auth */
- global $auth;
- global $lang;
- global $conf;
- global $USERINFO;
-
- $sent = false;
-
- // 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);
- $sent = true;
- }
- } elseif ($style === 'list') {
- subscription_send_list($USERINFO['mail'], $change_ids, $id);
- $sent = true;
- }
- // 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 $sent;
+ return (bool) $sent;
}
/**