DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:groupusers

groupusers Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" unknown
  • 2022-07-31 "Igor" unknown
  • 2020-07-29 "Hogfather" yes

plugin List members of the given group(s) in a table

Last updated on
2023-09-28
Provides
Syntax
Repository
Source

A CosmoCode Plugin

Download and Installation

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

Changes

Syntax

The Syntax looks like this:

{{groupusers>group1[,group2,...]}}

Just give any number of comma-separated groups to list members of.

Add |nomail for disabling the mail address column:

{{groupusers|nomail>group1[,group2,...]}}

Additional

  • First Column User Link
  • Email to all

See remarks in syntax.php

syntax.php
<?php
/**
 * Syntax Plugin:
 * This plugin lists all users from the given groups in a tabel.
 * Syntax:
 * {{groupusers:<group1>[,group2[,group3...]]}}
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Dominik Eckelmann <eckelmann@cosmocode.de>
 */
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
class syntax_plugin_groupusers extends DokuWiki_Syntax_Plugin {
 
    function groupusers() { }
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Dominik Eckelmann',
            'email'  => 'dokuwiki@cosmocode.de',
            'date'   => '2009-07-09',
            'name'   => 'Groupusers Syntax plugin',
            'desc'   => 'Displays the users from one or more groups.',
            'url'    => 'http://www.dokuwiki.org/plugin:groupusers'
        );
    }
 
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }
 
    /**
     * What about paragraphs?
     */
    function getPType(){
        return 'normal';
    }
 
    /**
     * Where to sort in?
     */
    function getSort(){
        return 160;
    }
 
    function connectTo($mode) {
         $this->Lexer->addSpecialPattern('\{\{groupusers\>[^}]*?\}\}',$mode,'plugin_groupusers');
         $this->Lexer->addSpecialPattern('\{\{groupusers\|nomail\>[^}]*?\}\}',$mode,'plugin_groupusers');
    }
 
    function handle($match, $state, $pos, &$handler){
        $match = substr($match,13,-2);
        $data = array(null, $state, $pos);
		if (substr($match, 0, 7) == 'nomail>') 
        {
            $match = substr($match, 7);
            $data[] = 'nomail';
		}
 
        $match = explode(',',$match);
 
        $data[0] = $match;
		return $data;
    }
 
    function render($mode, &$renderer, $data) {
        global $auth;
        global $lang;
		global $PetMail; //thorsten@th-petersen.de ergänzt
                global $conf; //elaubmeyer@gmx.de ergänzt
 
        if (!method_exists($auth,"retrieveUsers")) return false;
        if($mode == 'xhtml'){
            $users = array();
            foreach ($data[0] as $grp) {
                if ($conf['authtype'] == "authplain"){ //elaubmeyer@gmx.de ergänzt
					$first = 0;
					$limit = -1;
					$filter = array('grps'=>'^'.preg_quote($grp,'/').'$');
 
				} else {// Wenn in SQL-Statements kein Regexp angegeben ist, wird das Statement nicht verarbeitet. Auch mit $limit = -1 ist ebbe!
					$first = 0;
					$limit = 0;
					$filter = array('grps' => $grp);
				}
 
                $getuser = $auth->retrieveUsers($first, $limit, $filter);
 
 
                //$getuser = $auth->retrieveUsers(0,-1,array('grps'=>'^'.preg_quote($grp,'/').'$'));
                $users = array_merge($users,$getuser);
            }
            $renderer->doc .= $match.'<table class="inline">';
            $renderer->doc .= '<tr>';
            $renderer->doc .= '<th>'.$lang['user'].'</th>';
            $renderer->doc .= '<th>'.$lang['fullname'].'</th>';
 
            if (!in_array('nomail', $data))
			{
				$renderer->doc .= '<th>'.$lang['email'].'</th>';
			}
 
            $renderer->doc .= '</tr>';
            foreach ($users as $user => $info) {
                $renderer->doc .= '<tr>';
				$renderer->doc .= '<td>'; //thorsten@th-petersen.de ergänzt
                $renderer->internallink($user); ////thorsten@th-petersen.de Original: $renderer->doc .= '<td>'.htmlspecialchars($user).'</td>';
				$renderer->doc .= '</td>'; //thorsten@th-petersen.de ergänzt
                $renderer->doc .= '<td>'.hsc($info['name']).'</td>';
 
                if (!in_array('nomail', $data))
				{
                    $renderer->doc .= '<td>';
					$renderer->emaillink($info['mail']);
                    $renderer->doc .= '</td>';
					$PetMail.=$info['mail'].';'; //thorsten@th-petersen.de ergänzt
				}
 
                $renderer->doc .= '</tr>';
            }
            $renderer->doc .= '</table>';
            $renderer->doc .= "Email an alle:<br>"; //thorsten@th-petersen.de ergänzt#
            $renderer->emaillink($PetMail); //thorsten@th-petersen.de ergänzt
            $PetMail = ''; //important for multiple use (moz@e.mail.de)
            return true;
        }
        return false;
    }
}
 
//Setup VIM: ex: et ts=4 enc=utf-8 :
plugin/groupusers.txt · Last modified: 2024-01-07 14:03 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