DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:listeabo

listeabo Plugin

Compatible with DokuWiki

2008-05-05

plugin Displays the subscription list (fr: Affiche la liste des abonnements)

Last updated on
2009-01-05
Provides
Admin, Action

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

Tagged with listing, subscription, users

Description

  • action: displays your subscription list
  • admin: displays all the subscriptions
  • French, German and English. It's easy to add your own language.

Template customization

  • This will add a button/link after the “Subscribe Page Changes” / “Subscribe Namespace Changes” buttons/links, at the bottom of your pages
    • Add a line into the ./inc/lang/xx/lang.php file (xx is your language code):
      $lang['btn_listeabo'] = 'Subscriptions';
    • Modify ./inc/template.php to add the new button/link:
      [...]
       case 'subscription':
            if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){
              if($_SERVER['REMOTE_USER']){
                if($INFO['subscribed']){
                  print html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',));
                } 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',));
                }
       
                //listeabo
                print html_btn('listeabo', $ID, '', array('do' => 'listeabo',));
                ///listeabo
       
                return true;
              }
            }
            return false;
       
      [...]
       
          case 'subscribens':
            if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){
              if($_SERVER['REMOTE_USER']){
                if($INFO['subscribedns']) {
                  tpl_link(wl($ID,'do=unsubscribens'),
                           $pre.(($inner)?$inner:$lang['btn_unsubscribens']).$suf,
                           'class="action unsubscribens" rel="nofollow"');
                } else {
                  tpl_link(wl($ID,'do=subscribens'),
                           $pre.(($inner)?$inner:$lang['btn_subscribens']).$suf,
                           'class="action subscribens" rel="nofollow"');
                }
       
                //listeabo
                tpl_link(wl($ID,'do=listeabo'),
                            $pre.(($inner)?$inner:$lang['btn_listeabo']).$suf,
                            'class="action subscribens" rel="nofollow"');
                ///listeabo
       
                return true;
              }
            }
            return false;

Version history

  • 2008-09-12: first one!
  • 2008-09-29: corrects PHP warnings.
  • 2008-10-06: Better superuser detection.
  • 2008-11-26: German language added (thanks to Otto R.)
  • 2009-01-05: Bugs corrected: BOM in the German lang.php file and error message when there are no subscriptions yet (thanks to Benjamin).

Discussion

  • Tell me…

2008-09-29

  • Nice one. And it almost works. But there are a few minor things to change.
  • First we need to add a button to our navi bar. Open lib/tpl/your_template/main.php and add
    <?php tpl_button('listeabo')?>

    to it (in default template you might wanna use line 61 for that).

  • Now, we can marvel at some PHP errors to fix. To do that, just open up the action.php of your plugin.
    Go to line 87 where you can read
    if (!in_array($page2, $mespages)) $mespages[]=$page2;

    and replace it with

    if (!is_array($mespages) || !in_array($page2, $mespages)) $mespages[]=$page2;

    because we don't know, if $mespages really is an array.

    • → Correction done in version 2008-09-29. Thanks!
  • After that, we're almost done.
    Finally search for
    $titrePage = $pagelist->_getMeta('title');

    on line 111 and change it to

    $titrePage = $pagelist->_getMeta($page['id'], 'title');

    What the author forgot is that helper_plugin_pagelist::_getMeta() needs the current page $id as its first parameter.

    • → It doesn't work for me. When I add the id parameter, the _getMeta function doesn't send me the good page title…
  • Hope this helps,
    best regards from Germany,
    P. Tietz <tietz_patrick [at] web [dot] de>

2008-12-17

  • Would love to use this plugin, while using the arctic template I had to do some more modifications.
  • I have one remaining bug which i can't figure out, the following message is shown:
    Warning: Cannot modify header information - headers already sent by (output started at E:\$Apache_Dokuwiki\dokuwiki\lib\plugins\listeabo\lang\de\lang.php:1) in E:\$Apache_Dokuwiki\dokuwiki\inc\actions.php on line 141
The German language file has a BOM that causes this effect. Open it for instance with SciTE and remove it, then this plugin works fine.
Hope that helps, Benjamin <b-j [at] gmx.de>
Corrected with version 2009-01-05
Thanks
  • I hope someone has an idea,
    best regards from Germany,
    Franklin <franklin_ankum [at] hotmail [dot] com>

2009-01-02

If there are no subscriptions yet, the plugin causes a warning:

Warning: Invalid argument supplied for foreach() in /path_to_wiki/lib/plugins/listeabo/action.php on line 84

As the function $this→list_mlist(…) in line 69 returns NULL in this case the foreach-loop fails. As a workaround I would suggest to modify line 84 as following:

 foreach((is_array($pages) ? $pages : array()) as $page) {

Best regards from Germany,
Benjamin <b-j [at] gmx.de>

Thanks! Corrected in the new version (2009-01-05)
Happy new year!

2009-08-17 Installation error

Hello,

There is an error when I try to install the plugin with the Plugin Manager :

Impossible de télécharger le fichier du plugin:
http://membres.lycos.fr/emauvais/dokuwiki/listeabo.tar.gz

Warning: gzinflate() [function.gzinflate]: data error in /homez.195/giquello/www/cyrille/inc/HTTPClient.php on line 381

But it works when I do it by hand …

(PHP Version 5.2.10 and DokuWiki-2009-02-14b.tgz)

2009-09-04

Good plugin - Tank You!

Info: The plugin requires the pagelist plugin for displaying the subscriptions.

Error: The unsubscribe Button in the list view doesn't work for namespace subscriptions. It links to
doku.php/namespace1:namespace2:?do=unsubscribens

It jumps to the start page, but doesn't unsubscribe the namespace subscription.
I don't know how I can correct this behaviour.

(DokuWiki 2009-02-14b)

I fixed it. It links now on a namespace subscriptions to the first page which is found in the namespace.

on line 126 I replaced:

            else {
                    if($page=='')
                      $page = "root";
              print $this->getLang('abo_cat')." \"".preg_replace("/:$/","",$page)."\"";
              $nbCat++;
            }

with this

            else {
		if($page=='')
			$page = "root";
		else	
			$page = $this->next_file($page);
              print $this->getLang('abo_cat')." \"".preg_replace("/:.[^:]*$/","",$page)."\"";
              $nbCat++;
            }

and added this function:

    function next_file($wiki_dir){
    	global $conf;
    	$dir = $conf['savedir'].'/pages/'.$wiki_dir; 
    	$dir = str_replace(":","/",$dir);   	
	    if($dh = opendir($dir)) {
	    	while(($file = readdir($dh)) !== false) {
				if($file != "." && $file != "..") {
				if (is_file($dir.$file))
				{
	              		closedir($dh);
	              		$file = str_replace(".txt","",$file);
	              		return $wiki_dir.$file;	              	
				}
				}
			}
		}
	}

(DokuWiki 2009-12-25c “Lemming”)

apuschmann 2010/04/12 16:22

2010-03-29 Adding button in Lemming

(DokuWiki 2009-12-25c)

The file <dokuwiki>/inc/template.php has changed in this DokuWiki version. The Template custimization to add the button as described above isn't up to date. I'm not sure if it is right but following worked for me. I added only following three lines to template.php (between //listeabo):

...
 case 'subscribens':
      if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){
        if($_SERVER['REMOTE_USER']){
          if($INFO['subscribedns']) {
            if(actionOK('unsubscribens'))
              $out .= tpl_link(wl($ID,'do=unsubscribens'),
                     $pre.(($inner)?$inner:$lang['btn_unsubscribens']).$suf,
                     'class="action unsubscribens" rel="nofollow"',1);
          } else {
            if(actionOK('subscribens'))
              $out .= tpl_link(wl($ID,'do=subscribens'),
                     $pre.(($inner)?$inner:$lang['btn_subscribens']).$suf,
                     'class="action subscribens" rel="nofollow"',1);
          }
 
              //listeabo
              $out .= tpl_link(wl($ID,'do=listeabo'),
                     $pre.(($inner)?$inner:$lang['btn_listeabo']).$suf,
                     'class="action subscribens" rel="nofollow"',1);
              //listeabo
 
        }
      }
...

Display fix for Anteater (and newer) versions

Since Anteater DokuWiki stores additional data about digest mail subscriptions in the *.mlist files. This prevents the plugin from displaying the usernames in a proper way. To re-enable the “good look” you could add the following three lines to your action.php: action.php - Line 94-96M. S.Matthias Schulte
lupo49

2011/04/29 20:52

To make it work under Angua

I actually like this plugin but I was only interested in the Admin-part here so no guarantee for the rest of this.
In addition to the digest-patch above some HTML-Escape characters in the .mlist files needed to be replaced. There is probably some function that does this and catches some more escapes, but I do not know it. So the full patch is:

...
foreach(file($page) as $nom) {
$nom=chop($nom);
 
//added code at line 90
// Discard digest information of the line
$digest = strpos($nom, ' ');
if($digest) $nom = substr($nom, 0, $digest);
 
$search = array("%5f", "%2d");
$replace = array("_", "-");
$nom = str_replace($search, $replace,$nom);
//and added code
 ...

Also the table layout can be improved, but that's a matter of taste.
You should also have a look at the english lang.php.
Watch out for the hardcoded “doku.php” string in action.php when the URL for pages is constructed in case you renamed that file.

Required: Remove not existing users from Abo

It would be nice, if there would be a possibility in the admin area of this plugin, to clean the .mlist files from entries of users, that do not longer exist… Thanks in advance!

plugin/listeabo.txt · Last modified: 2016-01-22 10:44 by Aleksandr