diff options
author | steven-danz <steven-danz@kc.rr.com> | 2005-08-08 06:50:34 +0200 |
---|---|---|
committer | steven-danz <steven-danz@kc.rr.com> | 2005-08-08 06:50:34 +0200 |
commit | f9eb5648430624cb0f4e143aee3358ccc8146f4e (patch) | |
tree | 502d01b44db758049da4f21d55ef139d975f44b0 | |
parent | 6de3759a1b7a74492845c76e1f0bd1078e2220c7 (diff) | |
download | rpg-f9eb5648430624cb0f4e143aee3358ccc8146f4e.tar.gz rpg-f9eb5648430624cb0f4e143aee3358ccc8146f4e.tar.bz2 |
subscribe_changes.patch
Updates to the subscription patch to add a configuration option to enable/disable
the feature, move the messages to the language files, and general cleanup
darcs-hash:20050808045034-4c315-88a72dc8d2b22fdd9af8caa0505ef5c737965c86.gz
-rw-r--r-- | conf/dokuwiki.php | 1 | ||||
-rw-r--r-- | inc/actions.php | 13 | ||||
-rw-r--r-- | inc/common.php | 67 | ||||
-rw-r--r-- | inc/lang/en/lang.php | 5 | ||||
-rw-r--r-- | inc/template.php | 18 |
5 files changed, 59 insertions, 45 deletions
diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index 127b36d0a..990e61e19 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -69,6 +69,7 @@ $conf['notify'] = ''; //send change info to this email (leave $conf['mailfrom'] = ''; //use this email when sending mails $conf['gdlib'] = 2; //the GDlib version (0, 1 or 2) 2 tries to autodetect $conf['spellchecker']= 0; //enable Spellchecker (needs PHP >= 4.3.0 and aspell installed) +$conf['subscribers'] = 0; //enable change notice subscription support //Set target to use when creating links - leave empty for same window $conf['target']['wiki'] = ''; diff --git a/inc/actions.php b/inc/actions.php index 8a3a61cb9..3322a81aa 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -282,25 +282,26 @@ function act_export($act){ function act_subscription($act){ global $ID; global $INFO; - + global $lang; + $file=metaFN($ID,'.mlist'); if ($act=='subscribe' && !$INFO['subscribed']){ if ($INFO['userinfo']['mail']){ if (io_saveFile($file,$_SERVER['REMOTE_USER']."\n",true)) { $INFO['subscribed'] = true; - msg('Added '.$INFO['userinfo']['name'].' to subscription list for '.$ID,1); + msg(sprintf($lang[$act.'_success'], $INFO['userinfo']['name'], $ID),1); } else { - msg('Error adding '.$INFO['userinfo']['name'].' to subscription list for '.$ID,-1); + msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1); } } else { - msg('There is no address associated with your login, you cannot be added to the subscription list',-1); + msg($lang['subscribe_noaddress']); } } elseif ($act=='unsubscribe' && $INFO['subscribed']){ if (io_deleteFromFile($file,$_SERVER['REMOTE_USER']."\n")) { $INFO['subscribed'] = false; - msg('Removed '.$INFO['userinfo']['name'].' from subscription list for '.$ID,1); + msg(sprintf($lang[$act.'_success'], $INFO['userinfo']['name'], $ID),1); } else { - msg('Error removing '.$INFO['userinfo']['name'].' from subscription list for '.$ID,-1); + msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1); } } diff --git a/inc/common.php b/inc/common.php index 891601357..3d929a2be 100644 --- a/inc/common.php +++ b/inc/common.php @@ -746,8 +746,9 @@ function notify($id,$rev="",$summary=""){ global $conf; $hdrs =''; + $bcc = subscriber_addresslist($id); - if(empty($conf['notify']) && count($mlist) == 0) return; //notify enabled? + if(empty($conf['notify']) && empty($bcc)) return; //notify enabled? $text = rawLocale('mailtext'); $text = str_replace('@DATE@',date($conf['dformat']),$text); @@ -775,32 +776,6 @@ 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) { - $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); } @@ -1007,4 +982,42 @@ function is_subscribed($id,$uid){ return false; } +/** + * Return a string with the email addresses of all the + * users subscribed to a page + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function subscriber_addresslist($id){ + global $conf; + + $emails = ''; + + if ($conf['subscribers'] == 1) { + $mlist = array(); + $file=metaFN($id,'.mlist'); + if (file_exists($file)) { + $mlist = file($file); + } + 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($emails)) { + $emails = $info['mail']; + } else { + $emails = "$emails,".$info['mail']; + } + } + } + } + } + } + + return $emails; +} + //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 5b350b441..31e375cb5 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -161,5 +161,10 @@ $lang['img_format'] = 'Format'; $lang['img_camera'] = 'Camera'; $lang['img_keywords']= 'Keywords'; +$lang['subscribe_success'] = 'Added %s to subscription list for %s'; +$lang['subscribe_error'] = 'Error adding %s to subscription list for %s'; +$lang['subscribe_noaddress']= 'There is no address associated with your login, you cannot be added to the subscription list'; +$lang['unsubscribe_success']= 'Removed %s from subscription list for %s'; +$lang['unsubscribe_error'] = 'Error removing %s from subscription list for %s'; //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/template.php b/inc/template.php index 9f39b6b79..3937d99d2 100644 --- a/inc/template.php +++ b/inc/template.php @@ -118,12 +118,6 @@ function tpl_content(){ case 'admin': tpl_admin(); break; - case 'track': - html_track(); - break; - case 'ignore': - html_ignore(); - break; default: msg("Failed to handle command: ".hsc($ACT),-1); } @@ -342,7 +336,7 @@ function tpl_button($type){ print html_backtomedia_button(array('ns' => $NS),'b'); break; case 'subscription': - if($conf['useacl'] && $ACT == 'show'){ + if($conf['useacl'] && $ACT == 'show' && $conf['subscribers'] == 1){ if($_SERVER['REMOTE_USER']){ if($INFO['subscribed']){ print html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',)); @@ -438,13 +432,13 @@ function tpl_actionlink($type,$pre='',$suf=''){ if($INFO['perm'] == AUTH_ADMIN) tpl_link(wl($ID,'do=admin'),$pre.$lang['btn_admin'].$suf,'class="action"'); break; - case 'track': - if($conf['useacl'] && $ACT == 'show'){ + case 'subscribe': + if($conf['useacl'] && $ACT == 'show' && $conf['subscribers'] == 1){ if($_SERVER['REMOTE_USER']){ - if(tracking($ID,$_SERVER['REMOTE_USER'])){ - tpl_link(wl($ID,'do=ignore'),$pre.$lang['btn_ignore'].$suf,'class="action"'); + if($info['subscribed']) { + tpl_link(wl($ID,'do=unsubscribe'),$pre.$lang['btn_unsubscribe'].$suf,'class="action"'); } else { - tpl_link(wl($ID,'do=track'),$pre.$lang['btn_track'].$suf,'class="action"'); + tpl_link(wl($ID,'do=subscribe'),$pre.$lang['btn_subscribe'].$suf,'class="action"'); } } } |