From b158d625b53833ef391800a991ad93d965d9425e Mon Sep 17 00:00:00 2001 From: Steven Danz Date: Mon, 27 Jun 2005 04:17:48 +0200 Subject: track_changes.patch Second go at including changes to allow users to sign up on mailing lists so they may receive emails each time the page they are interested in is updated. darcs-hash:20050627021748-3ed6d-5f6993f51ab649e3928a513b0fbe7c421d880325.gz --- inc/common.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index ad4de9ffd..676787e73 100644 --- a/inc/common.php +++ b/inc/common.php @@ -621,6 +621,10 @@ function saveWikiText($id,$text,$summary){ if (empty($text)){ // remove empty files @unlink($file); + $mfile=wikiMN($id); + if (file_exists($mfile)) { + @unlink($mfile); + } $del = true; //autoset summary on deletion if(empty($summary)) $summary = $lang['deleted']; @@ -673,7 +677,15 @@ function notify($id,$rev="",$summary=""){ global $lang; global $conf; $hdrs =''; - if(empty($conf['notify'])) return; //notify enabled? + + $mlist = array(); + + $file=wikiMN($id); + if (file_exists($file)) { + $mlist = file($file); + } + + if(empty($conf['notify']) && count($mlist) == 0) return; //notify enabled? $text = rawLocale('mailtext'); $text = str_replace('@DATE@',date($conf['dformat']),$text); @@ -701,7 +713,25 @@ function notify($id,$rev="",$summary=""){ $text = str_replace('@DIFF@',$diff,$text); $subject = '['.$conf['title'].'] '.$subject; - mail_send($conf['notify'],$subject,$text,$conf['mailfrom']); + $bcc = ''; + if(count($mlist) > 0) { + foreach ($mlist as $who) { + $who = rtrim($who); + $info = auth_getUserData($who); + $level = auth_aclcheck($id,$who,$info['grps']); + if ($level >= AUTH_READ) { + if (strcasecmp($info['mail'],$conf['notify']) != 0) { + if (empty($bcc)) { + $bcc = $info['mail']; + } else { + $bcc = "$bcc,".$info['mail']; + } + } + } + } + } + + mail_send($conf['notify'],$subject,$text,$conf['mailfrom'],'',$bcc); } /** @@ -891,5 +921,23 @@ function check(){ } } +/** + * Let us know if a user is tracking a page + * + * @author Steven Danz + */ +function tracking($id,$uid){ + $file=wikiMN($id); + if (file_exists($file)) { + $mlist = file($file); + foreach ($mlist as $who) { + $who = rtrim($who); + if ($who==$uid) { + return true; + } + } + } + return false; +} //Setup VIM: ex: et ts=2 enc=utf-8 : -- cgit v1.2.3