DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:usersubscriptions

usersubscriptions Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Allows connected users to see which pages / namespaces they have subscribed to and to subscribe or unsubscribe in a quick way

Last updated on
2009-09-15
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to listeabo

Tagged with listing, subscription, syntax

Description

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.

  • 2010-09-24: merged some patches (thx to “MR”) and fixed caching issue
  • 2009-09-15: added template for easy styling, fixed some bugs (img paths…) and added regexp based item exclusion (for _template, sidebar…)
  • 2009-01-27: Added ACL check for quick subscribe dropdown filling
  • 2009-01-26: inherited subscription display option added, recursive parent subscription check fixed

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

Syntax

<usersubscriptions [ns] [r[=[N]]] [deletelink] [quicksubscribe] [displayinheritedsubscriptions] />
  • [ns] — base namespace, MUST BE PRESENT IF OTHER OPTIONS ARE USED.
    Can be either empty or
    . for targeting the current namespace,
    * for targeting all namespaces or a specific namespace (must be absolute)
  • [r[=[N]]] — recursive option, if only r or r= are mentioned the maximum depth is infinite, if a number is passed it indicates how much successive namespaces will be explored (ex.: r=0 means only the current namespace, r=3 means 3 levels in depth)
  • [deletelink] — if present a link to unsubscribe is displayed
  • [quicksubscribe] — if present a form is displayed to allow the user to quick-subscribe
  • [displayinheritedsubscriptions] — if present elements that are subscribed because the user subscribed to a parent namespace.

Download and Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Translations

Screenshot

Generated by putting <usersubscriptions * r deletelink quicksubscribe /> in the page.

Discussion

2009-05-01

  • “src” values for <img> elements are broken for any site that has a non-default directory structure. For example we have DokuWiki installed to /wiki instead of /.
  • A similar problem exists for the URL of a background element in the style.css file.
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

2009-06-04

  • I fixed the “src” values for <img> just by replacing the /lib/blablabla by ./lib/blablabla in the syntax.php file.
I fixed this bug in last release, used relative path

2009-06-10

  • For quicksubscribe it might be a good idea to exclude template ( e.g. __template.txt or _template.txt) and sidebar (e.g. sidebar.txt) pages from beeing listed.

    It also might be a good idea only to show namespaces and pages a user has the read privilege.
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

2009-08-28

  • Download site seems to be gone. I can't get to the files or install the plugin? - writeme -at- ourholm *dot* net
Site is back online, I finally got my internet connection back …

2009-10-20

  • I experienced difficulties both for subscribe and unsubscribe functions. Both don't work. After code investigation, below are suggestions :
    • For subscribe problem, same as solution explained in discussion 2009-05-01 but I fixed that inside the template
    • For unsubscribe problem, I have to replace a '?' character by a '&' (coded as &amp;)

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); ?>&amp;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
  • Still a remaining problem. The plugin code is inserted using a “include” function instead of integrate it into the renderer and it makes it appear at the top of the wiki page (whatever is its original place in the page text). I'll try to fix that when I'll have some time and then keep you posted. ;-)

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') : '&nbsp;'; ?>
 			</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); ?>&amp;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

2009-11-30

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!

2010-09-24

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 …

2010-12-05

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 Dokuwiki
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);
    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

2014-04-04

I have installed this plug in, yet now this appears

Fatal error: Call to undefined function is_subscribed() 
in lib\plugins\usersubscriptions\syntax.php on line 178

Can someone help me please?

plugin/usersubscriptions.txt · Last modified: 2023-12-17 21:29 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki