allows connected user to see which pages / namespaces he have subscribed to and to subscribe or unsubscribe in a quick way
The Syntax Plugin allows to display the subscription list of the current user. It can display list for a specific namespace, the current namespace or all namespaces. In addition, it provides a quick way to subscribe or unsubscribe.
2009-01-27 : Added ACL check for quick subscribe dropdown filling
2009-01-26 : inherited subscription display option added, recursive parent subscription check fixed
2009-09-15 : added template for easy styling, fixed some bugs (img paths …) and added regexp based item exclusion (for _template, sidebar …)
2010-09-24 : merged some patches (thx to “MR”) and fixed caching issue
En, De, Pt, Es and Fr lang files included, translations are welcome …
Many thanks to Thomas and Mark for the De lang file, to RC for Pt lang file and to Federico for Es lang file
<usersubscriptions [ns] [r[=[N]]] [deletelink] [quicksubscribe] [displayinheritedsubscriptions] />
Download and install the plugin using the Plugin Manager using the following URL. Refer to Plugins on how to install plugins manually.
Fixed in new release
* If the “action” parameter of the quicksubscribe <form> element contains a value for id (I'm not sure when it wouldn't), it is ignored when the form is submitted. I added this line between where the <form> and <select> elements are written and it worked correctly:
$renderer->doc .= '<input type="hidden" name="id" value="' . $ID . '" />';
The ID parameter is just useful to stay on the same page, but not needed in request vars, it should work (and does for me) without your fix
* For some unknown reason I get an exception in syntax.php @ line 211 complaining that the <…>data/pages/cache directory doesn't exist. One way to fix this is to wrap the 5 lines starting with 211 in a try-catch block. I noticed that I do have a <…>data/pages/_cache directory. Possibly wikiFN() is stripping off valid characters from directory names?
I was unable to reproduce that, but it seems strange (to me at least) that you have a _cache directory in data/pages
I fixed this bug in last release, used relative path
Added a regexp based namespace exclusion capability, have a look in the _getUserSubscriptions method in syntax.php
In the same method there was also a read privilege check from the beginning— Thomas Templin, 10. Jun. 2009 11:14 CEST
Site is back online, I finally got my internet connection back …
Here the patch as unified diff
--- usersubscriptions.tpl.php.old 2009-10-20 11:02:14.000000000 +0200 +++ usersubscriptions.tpl.php 2009-10-20 11:29:52.000000000 +0200 @@ -45,7 +45,7 @@ </p> </td> <td class="usersubscriptions_delete"> - <?php if($info['deleteoption']) { ?><a href="<?php echo wl($ID); ?>?pluginusersubscriptions_unsubscribe=<?php echo ($info['isnamespace'] ? 'ns' : 'pg').'-'.$id.($info['isnamespace'] ? ':' : ''); ?>#usersubscriptions_anchor"> + <?php if($info['deleteoption']) { ?><a href="<?php echo wl($ID); ?>&pluginusersubscriptions_unsubscribe=<?php echo ($info['isnamespace'] ? 'ns' : 'pg').'-'.$id.($info['isnamespace'] ? ':' : ''); ?>#usersubscriptions_anchor"> <img src="<?php echo DOKU_BASE; ?>lib/plugins/usersubscriptions/images/delete.png" alt="<?php echo $this->getLang('delete'); ?>" title="<?php echo $this->getLang('delete'); ?>" /> </a><?php } ?> </td> @@ -65,6 +65,7 @@ <tr> <td colspan="<?php echo $deletelink ? '2' : '1'; ?>" class="usersubscriptions_nothing"> <?php echo $this->getLang('quick_subscription'); ?> : <form method="get" action="<?php echo wl($ID); ?>#usersubscriptions_anchor"> + <input type="hidden" name="id" value="<?php echo $ID; ?>"> <select name="pluginusersubscriptions_subscribe" onchange="this.form.submit();"> <option value=""><?php echo $this->getLang('quick_subscription_select'); ?></option> <?php
MR
I fixed all bugs I knew in plugin and so make the patch available :
This patch is a unified diff and shall be applied in you Dokuwiki plugin folder typically lib/plugins/
diff -ruwbB /tmp/usersubscriptions/syntax.php usersubscriptions/syntax.php --- /tmp/usersubscriptions/syntax.php 2009-09-15 12:13:14.000000000 +0200 +++ usersubscriptions/syntax.php 2009-10-22 12:08:02.000000000 +0200 @@ -152,9 +152,16 @@ $usersubscriptions[$id] = $info; } + ob_start(); + if(file_exists(DOKU_TPLINC.'usersubscriptions.tpl.php')) include DOKU_TPLINC.'usersubscriptions.tpl.php'; else include DOKU_PLUGIN.'usersubscriptions/usersubscriptions.tpl.php'; + $content = ob_get_contents(); + ob_end_clean(); + + $renderer->doc .= $content; + return true; } return false; diff -ruwbB /tmp/usersubscriptions/usersubscriptions.tpl.php usersubscriptions/usersubscriptions.tpl.php --- /tmp/usersubscriptions/usersubscriptions.tpl.php 2009-09-15 12:15:49.000000000 +0200 +++ usersubscriptions/usersubscriptions.tpl.php 2009-10-22 12:13:11.000000000 +0200 @@ -38,14 +38,14 @@ <img src="<?php echo DOKU_BASE; ?>lib/plugins/usersubscriptions/images/<?php echo $info['isnamespace'] ? 'namespace' : 'page'; ?>.png" alt="<?php echo $this->getLang($info['isnamespace'] ? 'it_is_a_namespace' : 'it_is_a_page'); ?>" title="<?php echo $this->getLang($info['isnamespace'] ? 'it_is_a_namespace' : 'it_is_a_page'); ?>" /> </a> <span class="usersubscriptions_id"> - <a href="<?php echo wl($id); ?>"><?php echo ($id != '') ? $id : $this->getLang('quick_subscription_root'); ?></a> + <a href="<?php echo wl($id).($info['isnamespace'] ? ':' : ''); ?>"><?php echo ($id != '') ? $id : $this->getLang('quick_subscription_root'); ?></a> </span> <br /> <?php echo $info['inheritedsubscription'] ? $this->getLang('because_parent_ns_subscribed') : ' '; ?> </p> </td> <td class="usersubscriptions_delete"> - <?php if($info['deleteoption']) { ?><a href="<?php echo wl($ID); ?>?pluginusersubscriptions_unsubscribe=<?php echo ($info['isnamespace'] ? 'ns' : 'pg').'-'.$id.($info['isnamespace'] ? ':' : ''); ?>#usersubscriptions_anchor"> + <?php if($info['deleteoption']) { ?><a href="<?php echo wl($ID); ?>&pluginusersubscriptions_unsubscribe=<?php echo ($info['isnamespace'] ? 'ns' : 'pg').'-'.$id.($info['isnamespace'] ? ':' : ''); ?>#usersubscriptions_anchor"> <img src="<?php echo DOKU_BASE; ?>lib/plugins/usersubscriptions/images/delete.png" alt="<?php echo $this->getLang('delete'); ?>" title="<?php echo $this->getLang('delete'); ?>" /> </a><?php } ?> </td> @@ -65,6 +65,7 @@ <tr> <td colspan="<?php echo $deletelink ? '2' : '1'; ?>" class="usersubscriptions_nothing"> <?php echo $this->getLang('quick_subscription'); ?> : <form method="get" action="<?php echo wl($ID); ?>#usersubscriptions_anchor"> + <input type="hidden" name="id" value="<?php echo $ID; ?>"> <select name="pluginusersubscriptions_subscribe" onchange="this.form.submit();"> <option value=""><?php echo $this->getLang('quick_subscription_select'); ?></option> <?php
This patch will correct following issues :
- Bad URL formatting resulting in inability to use subscribe/unsubscribe functions
- Bad links in subscription list concerning namespaces
- Inability to place the plugin render elsewhere that on top of page
When I log out my user while viewing the page with my subscriberlist on, the list won't show up anymore when I try to log in later again.
I have to delete cache or edit the page with the pluginsyntax manually, to make the list appear again. Any Ideas how to fix that?
Plugin Version: 2009-09-15 (incl. the patch from above)
Wiki Version: 2009-02-14
— Verci, 30. Nov. 2009 11:12 CEST
Did you add NOCACHE to the page?
no, I didn't - it works properly after including a~~NOCACHE~~to the page - thx!
Included all patches, block now shows where it is expected to … Also moved cache disabling line a bit upper, because when user disconnected, cache was not disabled so a version of the page without the form was cached and then served again even if the user reconnected … my bad …
After an Dokuwiki-upgrade to the newest version (Anteater) i get an error, when i want to open the subscription-page. “Fatal error: Call to undefined function is_subscribed() in /…/lib/plugins/usersubscriptions/syntax.php on line 174” Is there a new Plugin-Version on the horizon or can you help me?
Indeed the is_subscribed() function has disappeared from Dokuwiki (it was used through an include inside the plugin).
A quick “dirty” fix is to copy the function in the syntax.php file of the plugin. A good place is between the includes and the class (the function shall absolutely be out of the class definition).
Below a copy of the code coming from the former release of Dokuwikifunction 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); return is_int($pos); } return false; }It should probably be more proper to work on a patch that will use the new Dokuwiki functions, but I don't have enough time at now.
Hope this help, waiting for a better solution
MR (2010-12-08)
Thank you very much, it works fine now! *thumbup*