DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:groupusers

This is an old revision of the document!


groupusers plugin

Compatible with DokuWiki

2008-05-05

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

Last updated on
2009-07-09
Provides
Syntax
Repository
Source

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 groupmatrix, listusergroup, permissioninfo

Tagged with groups, listing, users

Download and Installation

A CosmoCode Plugin Download and install the plugin using the Plugin Manager using the following URL. 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

Sea 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
 
        if (!method_exists($auth,"retrieveUsers")) return false;
        if($mode == 'xhtml'){
            $users = array();
            foreach ($data[0] as $grp) {
                $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 on one site (moz@e.mail.de )
            return true;
        }
        return false;
    }
}
 
//Setup VIM: ex: et ts=4 enc=utf-8 :
plugin/groupusers.1391710617.txt.gz · Last modified: 2014-02-06 19:16 by 217.84.186.77

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