[dokuwiki] Re: Namespace notifications (patch)
- From: Guy Brand <gb@xxxxxxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Wed, 27 Feb 2008 18:13:09 +0100
Guy Brand wrote:
> The attached patch is a first attempt to add namespace notifications
Replying to myself. I'm resending the patch after having run many
tests. When one subscribes both to a page changes notifications and to
the notifications of the namespace the page belongs to, only one mail
is sent. I slightly modified the notification message sent by email.
The (un)subscribe buttons still look a bit ugly.
--
bug
New patches:
[Add namespace changes mail notifications
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20080227155024
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.
] {
hunk ./inc/actions.php 50
+ //check if user is asking to (un)subscribe a namespace
+ if($ACT == 'subscribens' || $ACT == 'unsubscribens')
+ $ACT = act_subscriptionns($ACT);
+
hunk ./inc/actions.php 176
- 'resendpwd',))){
+
'resendpwd','subscribens','unsubscribens',))){
hunk ./inc/actions.php 185
- 'draftdel',)) && substr($act,0,7) != 'export_' ) {
+ 'draftdel','subscribens','unsubscribens',)) &&
substr($act,0,7) != 'export_' ) {
hunk ./inc/actions.php 424
- * Handle 'subscribe', 'unsubscribe'
+ * Handle page 'subscribe', 'unsubscribe'
hunk ./inc/actions.php 450
+ } else {
+ msg(sprintf($lang[$act.'_error'], $INFO['userinfo']['name'], $ID),1);
+ }
+ }
+
+ 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);
hunk ./inc/common.php 111
- $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'];
hunk ./inc/common.php 1075
- * Let us know if a user is tracking a page
+ * Let us know if a user is tracking a page or a namespace
hunk ./inc/common.php 1079
-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');
+ }
+ }
hunk ./inc/common.php 1112
+ // load the page mlist file content
hunk ./inc/common.php 1118
+ 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'];
+ }
+ }
+ }
+ }
+ }
+
+ // 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);
+ }
hunk ./inc/lang/en/lang.php 42
-$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';
hunk ./inc/lang/en/subscribermail.txt 10
-To unsubscribe from this page log into the wiki at
+To cancel the page notifications, log into the wiki at
hunk ./inc/lang/en/subscribermail.txt 13
-and choose 'Unsubscribe Changes'.
+and unsubscribe page and/or namespace changes.
hunk ./inc/template.php 520
+ }
+ if($INFO['subscribedns']){
+ print html_btn('unsubscribens',$ID,'',array('do' =>
'unsubscribens',));
+ } else {
+ print html_btn('subscribens',$ID,'',array('do' => 'subscribens',));
}
Context:
[Update php & html tests in preformatted test file to reflect changes in parser
Chris Smith <chris@xxxxxxxxxxxxx>**20080223063145
This test file examines the handler. The decisions on htmlok & phpok settings
have been
moved from the handler to the renderer changing the nature of the test that
can be
carried out on these syntax modes in this file.
Refer other patch adding xhtml renderer tests for 'phpok' & 'htmlok' and their
associated syntax modes in parser_preformatted.test.php
]
[Test cases for 'phpok' & 'htmlok' config settings
Chris Smith <chris@xxxxxxxxxxxxx>**20080223062428]
[Fix for FS#1334, see also FS#1090
Chris Smith <chris@xxxxxxxxxxxxx>**20080223025539
FS#1090 ensured DW would never rebuild instructions in the same run by forcing
subsequent
instruction requests to use the version cached on the first request. That
introduced problems
when the caching of the instructions failed (FS#1334). This patch allows
subsequent rebuilds
when cache storage failed.
]
[fix usage of is_admin in auth_aclcheck
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080226172257
There were a few problems with name encoding for groups and users
introduced in the recent aclcheck change
]
[Don't depend on plugin for Zip/TarLib
Tom N Harris <tnharris@xxxxxxxxxxxxx>**20080226005222]
[INDEXER_TASKS_RUN event for index-time hooks
Tom N Harris <tnharris@xxxxxxxxxxxxx>**20080226011940
The event INDEXER_TASKS_RUN is fired by lib/exe/indexer.php when a page is
viewed. Plugins should only hook BEFORE the event if it is important for the
task to be run as often as possible. Otherwise, hook AFTER the even to be run
only when other tasks have completed.
Plugin authors must call stopPropagation() and preventDefault() if any work is
done. If your plugin does nothing, then you must allow the event to continue.
Not following these rules may cause DokuWiki to exceed the PHP execution time
limit.
]
[use fulltext index to search for used media files FS#1336 FS#1275
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223205254
This changes how DokuWiki looks for reference toa media file which is
about to deleted. Instead of doing a full grep through all pages it now
uses the fulltext index first, then does an exact match on the found
pages.
This speeds up the search significantly on larger wikis. However the
fulltext search limits now apply: images with names shorter than 3 charcters
may not be found.
This needs extensive testing!
]
[Table Row And Col Classes
Pierre Spring <pierre.spring@xxxxxxx>**20080223175808
This patch adds classes to the table rows and cells (td and th). This can be
of usage when templating and within syntax plugins.
]
[cope with non-RFC-conform webservers in HTTPClient FS#1340
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223183639
This fixes problems in the HTTP client for web servers which separate their
response headers with Unix linfeeds only (instead of CRLFs as stated in RFC
2616).
]
[Check memory settings on ?do=check
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223180701
This should help with diagnosing memory related problems
]
[correct diff display when dealing with deleted or newly created pages
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223143711]
[wl(): don't include empty id parameter FS#1138
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223133200]
[mysql auth backend: check DB query result correctly FS#1039
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223130827]
[alway initialize an empty toolbar first FS#1337
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223125855]
[use strftime() instead of date() FS#1335 :!:
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223124045
This patch replaces the use of the date() function with the strftime()
function. The latter will respect a set locale and will use localized
strings for things like month names.
Because the format options for strftime differ from the ones used in date,
DokuWiki will rest the value of $conf['dformat'] if it contains an old
date format string (detected by missing % characters).
Plugins or templates using the $conf['dformat'] need to be updated.
]
[renamed justlink option to linkonly
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080223101426]
[media_justlink
Pierre Spring <pierre.spring@xxxxxxx>**20080221160833]
[popularity plugin: record PCRE infos
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080220213222]
[updated year in copyright notice
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080220201711]
[add gidnumber to LDAP auth userdata FS#1338
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080219165659]
[popularity plugin added
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080219165223
This new default plugin allows to send feedback to the DokuWiki developers. An
introduction is available at
http://www.splitbrain.org/blog/2008-02/17-gathering_dokuwiki_usage_data
]
[Finnish language update
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080217172914]
[fix for plugin manager breaking multibyte chars
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215214857]
[do case insensitive search word highlighting in page FS#1297
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215180239]
[fix highlighting of search engine referer keywords for recent highlight change
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215175816]
[better highlighting for phrase searches FS#1193
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215174653
This patch makes the highlighting of phrases in search snippets and on
the pages itself much better.
Now a regexp gets passed to the ?s= parameter. I ask everybody to test
this feature throughly especially for the handling of malicious inputs
and the use of non-latin characters.
]
[Use auth backend to verify password on profile update FS#1328
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215154316]
[fix for resetting timelimit in fetch.php FS#1243
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215152132]
[Make session reference file check overridable for auth backends
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215121716]
[invalidate all user session cache when userdatabase is changed FS#1085
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215114923
A reference file is now stored in data/cache/sessionpurge and is used to
check if user sessions are still valid.
To accomondate for slow auth backends DokuWiki caches user info for
a certain time in the user session.
]
[redirect to root namespace in mediamanager when namespace was deleted FS#1286
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215105251]
[correctly encode namespace in mediapopup URL FS#1319
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215094453]
[fix line endings for meta data editing in media manager FS#1324
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215091527]
[add title attribute on page title FS#1330
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215090454]
[LDAP backend: try to rebind with current user for getUserData() FS#1053
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080215085556]
[fix for earlier phpok & htmlok path
Chris Smith <chris@xxxxxxxxxxxxx>**20080214113350]
[French strings update
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20080213214113]
[make sure not supported profile fields are not accepted FS#1329
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080213214505]
[check modMail capability correctly FS#1329
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080213213322]
[Hungarian update
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080213204325]
[filter usernames case-insensitive in user manager
Gabriel Birke <Gabriel.Birke@xxxxxxxxx>**20080213194342]
[Importoldchangelog: Added metadata support
'Simon Coffey <spc03@xxxxxxxxxxxx>'**20080213145734
Added function savePerPageMetadata() to populate creator and contributor fields
of metadata array from old-style changes.log.
]
[Rationalise Parser PHP & HTML syntax mode handling to renderer only.
Chris Smith <chris@xxxxxxxxxxxxx>**20080213024941
This patch corrects the problems with the previously (reversed) patch
"remove htmlok and phpok tests from Doku_Handler".
The handler will now write php, phpblock, html & htmlblock instructions
and let the renderer decide how these instructions should be processed.
The xhtml renderer will follow the "phpok" and "htmlok" config settings.
If these settings are turned off the any instructions will be rendered as
code with php or html syntax highlighting (as appropriate).
]
[Have aclcheck use auth_isadmin
Guy Brand <gb@xxxxxxxxxxxxxxxxx>**20080212213222]
[Hungarian update
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080209092859]
[make sure $ID is set correct when rendering metadata
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080208212733]
[removed security token requirement for login
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080208200733
This was discussed a while ago on the mailing list. We want to work cross-site
logins keep working.
]
[TAG develsnap 2008-02-01
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20080201000001]
Patch bundle hash:
0136c01f9f26cc98449004f625325c2ef765b8cd
- References:
- [dokuwiki] Namespace notifications (patch)
- From: Guy Brand
Other related posts:
- » [dokuwiki] Namespace notifications (patch)
- » [dokuwiki] Re: Namespace notifications (patch)
- [dokuwiki] Namespace notifications (patch)
- From: Guy Brand