diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-01-26 11:21:39 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-01-26 11:21:39 +0100 |
commit | ba56222349781fd8e3938ab18127d46f3c1e0061 (patch) | |
tree | 1e39e4e2960462ea06ae55a993512bf18ce4aa25 /inc/common.php | |
parent | 1285aa3a44c9fdf49bfd8992f33bac068bae8226 (diff) | |
parent | c38b7fab9eeb9456aaf5fe8e4481c3b8569e5644 (diff) | |
download | rpg-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 'inc/common.php')
-rw-r--r-- | inc/common.php | 85 |
1 files changed, 13 insertions, 72 deletions
diff --git a/inc/common.php b/inc/common.php index 3c40a47dc..bc49e76b2 100644 --- a/inc/common.php +++ b/inc/common.php @@ -107,9 +107,11 @@ function pageinfo() { $info['isadmin'] = false; $info['ismanager'] = false; if(isset($_SERVER['REMOTE_USER'])) { + $sub = new Subscription(); + $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($ID); - $info['subscribed'] = get_info_subscribed(); + $info['subscribed'] = $sub->user_subscription(); $info['client'] = $_SERVER['REMOTE_USER']; if($info['perm'] == AUTH_ADMIN) { @@ -320,15 +322,13 @@ function idfilter($id, $ue = true) { if($conf['useslash'] && $conf['userewrite']) { $id = strtr($id, ':', '/'); } elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && - $conf['userewrite'] && - strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') === false + $conf['userewrite'] ) { $id = strtr($id, ':', ';'); } if($ue) { $id = rawurlencode($id); $id = str_replace('%3A', ':', $id); //keep as colon - $id = str_replace('%3B', ';', $id); //keep as semicolon $id = str_replace('%2F', '/', $id); //keep as slash } return $id; @@ -1105,90 +1105,31 @@ function saveOldRevision($id) { * @author Andreas Gohr <andi@splitbrain.org> */ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array()) { - global $lang; global $conf; - global $INFO; - global $DIFF_INLINESTYLES; // decide if there is something to do, eg. whom to mail if($who == 'admin') { if(empty($conf['notify'])) return false; //notify enabled? - $text = rawLocale('mailtext'); - $to = $conf['notify']; - $bcc = ''; + $tpl = 'mailtext'; + $to = $conf['notify']; } elseif($who == 'subscribers') { - if(!$conf['subscribers']) return false; //subscribers enabled? + if(!actionOK('subscribe')) return false; //subscribers enabled? if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) return false; //skip minors $data = array('id' => $id, 'addresslist' => '', 'self' => false); trigger_event( 'COMMON_NOTIFY_ADDRESSLIST', $data, - 'subscription_addresslist' + array(new Subscription(), 'notifyaddresses') ); - $bcc = $data['addresslist']; - if(empty($bcc)) return false; - $to = ''; - $text = rawLocale('subscr_single'); - } elseif($who == 'register') { - if(empty($conf['registernotify'])) return false; - $text = rawLocale('registermail'); - $to = $conf['registernotify']; - $bcc = ''; + $to = $data['addresslist']; + if(empty($to)) return false; + $tpl = 'subscr_single'; } else { return false; //just to be safe } - // prepare replacements (keys not set in hrep will be taken from trep) - $trep = array( - 'NEWPAGE' => wl($id, '', true, '&'), - 'PAGE' => $id, - 'SUMMARY' => $summary - ); - $trep = array_merge($trep, $replace); - $hrep = array(); - // prepare content - if($who == 'register') { - $subject = $lang['mail_new_user'].' '.$summary; - } elseif($rev) { - $subject = $lang['mail_changed'].' '.$id; - $trep['OLDPAGE'] = wl($id, "rev=$rev", true, '&'); - $old_content = rawWiki($id, $rev); - $new_content = rawWiki($id); - $df = new Diff(explode("\n", $old_content), - explode("\n", $new_content)); - $dformat = new UnifiedDiffFormatter(); - $tdiff = $dformat->format($df); - - $DIFF_INLINESTYLES = true; - $hdf = new Diff(explode("\n", hsc($old_content)), - explode("\n", hsc($new_content))); - $dformat = new InlineDiffFormatter(); - $hdiff = $dformat->format($hdf); - $hdiff = '<table>'.$hdiff.'</table>'; - $DIFF_INLINESTYLES = false; - } else { - $subject = $lang['mail_newpage'].' '.$id; - $trep['OLDPAGE'] = '---'; - $tdiff = rawWiki($id); - $hdiff = nl2br(hsc($tdiff)); - } - $trep['DIFF'] = $tdiff; - $hrep['DIFF'] = $hdiff; - - // send mail - $mail = new Mailer(); - $mail->to($to); - $mail->bcc($bcc); - $mail->subject($subject); - $mail->setBody($text, $trep, $hrep); - if($who == 'subscribers') { - $mail->setHeader( - 'List-Unsubscribe', - '<'.wl($id, array('do'=> 'subscribe'), true, '&').'>', - false - ); - } - return $mail->send(); + $subscription = new Subscription(); + return $subscription->send_diff($to, $tpl, $id, $rev, $summary); } /** |