From 1380fc452d56dd6f48ddbfa3a6b0e69edd043b04 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 6 Aug 2005 23:20:00 +0200 Subject: changes to the page subscription feature darcs-hash:20050806212000-7ad00-c5ab54a33289f8be0ce99443f82f0b3cf1bdbf0d.gz --- inc/common.php | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 676787e73..b0d7c4c10 100644 --- a/inc/common.php +++ b/inc/common.php @@ -26,12 +26,14 @@ function pageinfo(){ global $conf; if($_SERVER['REMOTE_USER']){ - $info['user'] = $_SERVER['REMOTE_USER']; - $info['userinfo'] = $USERINFO; - $info['perm'] = auth_quickaclcheck($ID); + $info['user'] = $_SERVER['REMOTE_USER']; + $info['userinfo'] = $USERINFO; + $info['perm'] = auth_quickaclcheck($ID); + $info['subscribed'] = is_subscribed($ID,$_SERVER['REMOTE_USER']); }else{ - $info['user'] = ''; - $info['perm'] = auth_aclcheck($ID,'',null); + $info['user'] = ''; + $info['perm'] = auth_aclcheck($ID,'',null); + $info['subscribed'] = false; } $info['namespace'] = getNS($ID); @@ -678,12 +680,6 @@ function notify($id,$rev="",$summary=""){ global $conf; $hdrs =''; - $mlist = array(); - - $file=wikiMN($id); - if (file_exists($file)) { - $mlist = file($file); - } if(empty($conf['notify']) && count($mlist) == 0) return; //notify enabled? @@ -713,6 +709,14 @@ function notify($id,$rev="",$summary=""){ $text = str_replace('@DIFF@',$diff,$text); $subject = '['.$conf['title'].'] '.$subject; + + // FIXME move this to its own function + $mlist = array(); + $file=metaFN($id,'.mlist'); + if (file_exists($file)) { + $mlist = file($file); + } + $bcc = ''; if(count($mlist) > 0) { foreach ($mlist as $who) { @@ -924,19 +928,16 @@ function check(){ /** * Let us know if a user is tracking a page * - * @author Steven Danz + * @author Andreas Gohr */ -function tracking($id,$uid){ - $file=wikiMN($id); - if (file_exists($file)) { +function is_subscribed($id,$uid){ + $file=metaFN($id,'.mlist'); + if (@file_exists($file)) { $mlist = file($file); - foreach ($mlist as $who) { - $who = rtrim($who); - if ($who==$uid) { - return true; - } - } + $pos = array_search($uid."\n",$mlist); + return is_int($pos); } + return false; } -- cgit v1.2.3