summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Brand <gb@isis.u-strasbg.fr>2008-02-27 16:50:24 +0100
committerGuy Brand <gb@isis.u-strasbg.fr>2008-02-27 16:50:24 +0100
commit52b0dd6759c3a1c726ae81acf5ab430b1ee6f308 (patch)
tree45af9dde8f41aee2df3fd6afd60f074ac8c73874
parentf342ae92e0880da9d8a88123be054e597b2a7beb (diff)
downloadrpg-52b0dd6759c3a1c726ae81acf5ab430b1ee6f308.tar.gz
rpg-52b0dd6759c3a1c726ae81acf5ab430b1ee6f308.tar.bz2
Add namespace changes mail notifications
This patch lets DokuWiki send mail notifications when any page inside a namespace gets modified. Two actions are introduced: subscribens and unsubscribens and two new buttons also appear in the bundled template. darcs-hash:20080227155024-19e2d-8ce5bd66f4e870db31d6b438516599f294365ce1.gz
-rw-r--r--inc/actions.php48
-rw-r--r--inc/common.php51
-rw-r--r--inc/lang/en/lang.php6
-rw-r--r--inc/lang/en/subscribermail.txt4
-rw-r--r--inc/template.php5
5 files changed, 100 insertions, 14 deletions
diff --git a/inc/actions.php b/inc/actions.php
index 83500475b..2ae366ce0 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -47,6 +47,10 @@ function act_dispatch(){
if($ACT == 'subscribe' || $ACT == 'unsubscribe')
$ACT = act_subscription($ACT);
+ //check if user is asking to (un)subscribe a namespace
+ if($ACT == 'subscribens' || $ACT == 'unsubscribens')
+ $ACT = act_subscriptionns($ACT);
+
//check permissions
$ACT = act_permcheck($ACT);
@@ -169,7 +173,7 @@ function act_clean($act){
//disable all acl related commands if ACL is disabled
if(!$conf['useacl'] && in_array($act,array('login','logout','register','admin',
'subscribe','unsubscribe','profile',
- 'resendpwd',))){
+ 'resendpwd','subscribens','unsubscribens',))){
msg('Command unavailable: '.htmlspecialchars($act),-1);
return 'show';
}
@@ -178,7 +182,7 @@ function act_clean($act){
'preview','search','show','check','index','revisions',
'diff','recent','backlink','admin','subscribe',
'unsubscribe','profile','resendpwd','recover','wordblock',
- 'draftdel',)) && substr($act,0,7) != 'export_' ) {
+ 'draftdel','subscribens','unsubscribens',)) && substr($act,0,7) != 'export_' ) {
msg('Command unknown: '.htmlspecialchars($act),-1);
return 'show';
}
@@ -417,7 +421,7 @@ function act_export($act){
}
/**
- * Handle 'subscribe', 'unsubscribe'
+ * Handle page 'subscribe', 'unsubscribe'
*
* @author Steven Danz <steven-danz@kc.rr.com>
* @todo localize
@@ -451,4 +455,42 @@ function act_subscription($act){
return 'show';
}
+/**
+ * Handle namespace 'subscribe', 'unsubscribe'
+ *
+ */
+function act_subscriptionns($act){
+ global $ID;
+ global $INFO;
+ global $lang;
+
+ if(!getNS($ID)) {
+ $file = metaFN(getNS($ID),'.mlist');
+ } else {
+ $file = metaFN(getNS($ID),'/.mlist');
+ }
+
+ if ($act=='subscribens' && !$INFO['subscribedns']){
+ if ($INFO['userinfo']['mail']){
+ if (io_saveFile($file,$_SERVER['REMOTE_USER']."\n",true)) {
+ $INFO['subscribedns'] = true;
+ msg(sprintf($lang[$act.'_success'], $INFO['userinfo']['name'], $ID),1);
+ } else {
+ msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1);
+ }
+ } else {
+ msg($lang['subscribe_noaddress']);
+ }
+ } elseif ($act=='unsubscribens' && $INFO['subscribedns']){
+ if (io_deleteFromFile($file,$_SERVER['REMOTE_USER']."\n")) {
+ $INFO['subscribedns'] = false;
+ msg(sprintf($lang[$act.'_success'], $INFO['userinfo']['name'], $ID),1);
+ } else {
+ msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1);
+ }
+ }
+
+ return 'show';
+}
+
//Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/inc/common.php b/inc/common.php
index ce32e42cb..7f550dbde 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -108,10 +108,11 @@ function pageinfo(){
$info['rev'] = $REV;
if($_SERVER['REMOTE_USER']){
- $info['userinfo'] = $USERINFO;
- $info['perm'] = auth_quickaclcheck($ID);
- $info['subscribed'] = is_subscribed($ID,$_SERVER['REMOTE_USER']);
- $info['client'] = $_SERVER['REMOTE_USER'];
+ $info['userinfo'] = $USERINFO;
+ $info['perm'] = auth_quickaclcheck($ID);
+ $info['subscribed'] = is_subscribed($ID,$_SERVER['REMOTE_USER'],false);
+ $info['subscribedns'] = is_subscribed($ID,$_SERVER['REMOTE_USER'],true);
+ $info['client'] = $_SERVER['REMOTE_USER'];
// set info about manager/admin status
$info['isadmin'] = false;
@@ -1071,12 +1072,20 @@ function obfuscate($email) {
}
/**
- * Let us know if a user is tracking a page
+ * Let us know if a user is tracking a page or a namespace
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function is_subscribed($id,$uid){
- $file=metaFN($id,'.mlist');
+function is_subscribed($id,$uid,$ns=false){
+ if(!$ns) {
+ $file=metaFN($id,'.mlist');
+ } else {
+ if(!getNS($id)) {
+ $file = metaFN(getNS($id),'.mlist');
+ } else {
+ $file = metaFN(getNS($id),'/.mlist');
+ }
+ }
if (@file_exists($file)) {
$mlist = file($file);
$pos = array_search($uid."\n",$mlist);
@@ -1100,6 +1109,7 @@ function subscriber_addresslist($id){
if (!$conf['subscribers']) return;
+ // load the page mlist file content
$mlist = array();
$file=metaFN($id,'.mlist');
if (@file_exists($file)) {
@@ -1123,6 +1133,33 @@ function subscriber_addresslist($id){
}
}
+ // load also the namespace mlist file content
+ if(!getNS($id)) {
+ $nsfile = metaFN(getNS($id),'.mlist');
+ } else {
+ $nsfile = metaFN(getNS($id),'/.mlist');
+ }
+ if (@file_exists($nsfile)) {
+ $mlist = file($nsfile);
+ }
+ if(count($mlist) > 0) {
+ foreach ($mlist as $who) {
+ $who = rtrim($who);
+ $info = $auth->getUserData($who);
+ if($info === false) continue;
+ $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;
}
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index c2fdaf5db..d7ece398b 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -39,8 +39,10 @@ $lang['btn_delete'] = 'Delete';
$lang['btn_back'] = 'Back';
$lang['btn_backlink'] = "Backlinks";
$lang['btn_backtomedia'] = 'Back to Mediafile Selection';
-$lang['btn_subscribe'] = 'Subscribe Changes';
-$lang['btn_unsubscribe'] = 'Unsubscribe Changes';
+$lang['btn_subscribe'] = 'Subscribe Page Changes';
+$lang['btn_unsubscribe'] = 'Unsubscribe Page Changes';
+$lang['btn_subscribens'] = 'Subscribe Namespace Changes';
+$lang['btn_unsubscribens'] = 'Unsubscribe Namespace Changes';
$lang['btn_profile'] = 'Update Profile';
$lang['btn_reset'] = 'Reset';
$lang['btn_resendpwd'] = 'Send new password';
diff --git a/inc/lang/en/subscribermail.txt b/inc/lang/en/subscribermail.txt
index bdb2f6c7d..d7c7671c6 100644
--- a/inc/lang/en/subscribermail.txt
+++ b/inc/lang/en/subscribermail.txt
@@ -7,10 +7,10 @@ Here are the changes:
@DIFF@
--------------------------------------------------------
-To unsubscribe from this page log into the wiki at
+To cancel the page notifications, log into the wiki at
@DOKUWIKIURL@ then visit
@NEWPAGE@
-and choose 'Unsubscribe Changes'.
+and unsubscribe page and/or namespace changes.
--
This mail was generated by DokuWiki at
diff --git a/inc/template.php b/inc/template.php
index b0cb56c5b..4f4ba9813 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -518,6 +518,11 @@ function tpl_button($type){
} else {
print html_btn('subscribe',$ID,'',array('do' => 'subscribe',));
}
+ if($INFO['subscribedns']){
+ print html_btn('unsubscribens',$ID,'',array('do' => 'unsubscribens',));
+ } else {
+ print html_btn('subscribens',$ID,'',array('do' => 'subscribens',));
+ }
return true;
}
}