summaryrefslogtreecommitdiff
path: root/inc/actions.php
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 /inc/actions.php
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
Diffstat (limited to 'inc/actions.php')
-rw-r--r--inc/actions.php48
1 files changed, 45 insertions, 3 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 :