*/ // 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.'action.php'); class action_plugin_listeabo extends DokuWiki_Action_Plugin { /** * return some info */ function getInfo() { return array( 'author' => 'Etienne M.', 'email' => 'emauvaisfr@yahoo.fr', 'date' => @file_get_contents(DOKU_PLUGIN.'listeabo/VERSION'), 'name' => 'listeabo Plugin', 'desc' => 'Affiche la liste des abonnements d\'un utilisateur / Displays the subscription list of a user', 'url' => 'http://www.dokuwiki.org/fr:plugin:listeabo', ); } /** * Constructor */ function action_plugin_listeabo() { $this->setupLocale(); } /** * register the eventhandlers */ function register(&$contr) { //$contr->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'ping', array()); $contr->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, '_handle_act', array()); $contr->register_hook('TPL_ACT_UNKNOWN', 'BEFORE', $this, '_handle_tpl_act', array()); } /** * catch listeabo action * * @author Etienne Mauvais */ function _handle_act(&$event, $param) { if($event->data != 'listeabo') return; $event->preventDefault(); } function _handle_tpl_act(&$event, $param) { global $lang; global $INFO; global $conf; global $auth; $nbAbo=0; $nbPages=0; $nbCat=0; if($event->data != 'listeabo') return; $event->preventDefault(); //Recherche des fichiers mlist dans le dossier meta $pages = $this->list_mlist($conf['savedir'].'/meta',true, $pages); //Si on est en mode admin //if (in_array('admin',$INFO['userinfo']['grps'])) $admin = trim($_REQUEST['admin']); //if (in_array('admin',$INFO['userinfo']['grps'])) $user = trim($_REQUEST['user']); if (auth_ismanager($INFO['client'])) { $admin = trim($_REQUEST['admin']); $user = trim($_REQUEST['user']); } if (!$user) $user=$INFO['client']; $userName=$auth->getUserData($user); $userName=$userName['name']; if (!$userName) $userName=$user; //Recherche dans chaque fichier mlist trouve foreach((is_array($pages)?$pages:array()) as $page) { preg_match("/meta\/(.*).mlist$/",$page,$page2); $page2=preg_replace("/\//",":",$page2[1]); foreach(file($page) as $nom) { $nom=chop($nom); if ($nom==$user || $admin) { //if (!in_array($page2, $mespages)) $mespages[]=$page2; if (!is_array($mespages) || !in_array($page2, $mespages)) $mespages[]=$page2; if ($admin) $abonnes[$page2][]=$nom; else break; } } } if ($admin) print '

'.$this->getLang('abo_aboactifs').'

' . DOKU_LF; else print '

'.$this->getLang('abo_abode').' '.$userName.'

' . DOKU_LF; if(!empty($mespages)) { $pagelist = plugin_load('helper', 'pagelist'); print ""; foreach($mespages as $page) { if (!$pagelist) { $titrePage=explode(":",$page); $titrePage=$titrePage[sizeof($titrePage)-1]; $titrePage=str_replace('_',' ',$titrePage); } else { $pagelist->page['id']=$page; $pagelist->page['exists'] = 1; $pagelist->_meta=NULL; $titrePage = $pagelist->_getMeta('title'); if (!$titrePage) $titrePage = str_replace('_', ' ', noNS($page)); $titrePage = hsc($titrePage); } $lien = "$titrePage"; print ""; if ($admin) { sort($abonnes[$page]); $abonnesMEF=""; foreach ($abonnes[$page] as $abonne) { $tmp=$auth->getUserData($abonne); if ($tmp) $abonnesMEF[]=''.$tmp['name'].''; else $abonnesMEF[]=$abonne; $nbAbo++; } print ""; } print "
  • "; if ($titrePage) { print "$lien"; $nbPages++; } else { print $this->getLang('abo_cat')." \"".preg_replace("/:$/","",$page)."\""; $nbCat++; } print "
".join(", ", $abonnesMEF); } else { print "
"; if ($titrePage) { if ($user==$INFO['client']) tpl_link(wl($page,'do=unsubscribe'), $pre.(($inner)?$inner:$lang['btn_unsubscribe']).$suf, 'class="action unsubscribe" rel="nofollow"'); } else { if ($user==$INFO['client']) tpl_link(wl($page,'do=unsubscribens'), $pre.(($inner)?$inner:$lang['btn_unsubscribens']).$suf, 'class="action unsubscribens" rel="nofollow"'); } $nbAbo++; } print "
"; print "$nbAbo ".$this->getLang('abo_cptabo')." ".$this->getLang('abo_cptdans')." $nbPages ".$this->getLang('abo_cptpages')." ".$this->getLang('abo_cptet')." $nbCat ".$this->getLang('abo_cptcat').".

"; } else { print '

'.$this->getLang('abo_noabo').'.

'; print '

'.$this->getLang('abo_whoto').'

'; } //if (in_array('admin',$INFO['userinfo']['grps'])) { if (auth_ismanager($INFO['client'])) { if (!$admin) print $this->getLang('abo_estadmin').''.$this->getLang('abo_voirtousabo').'.
'; if ($admin || $user != $INFO['client']) print ''.$this->getLang('abo_voirvosabo').'.'; } } function list_mlist($dir, $recursive=false, $files=0) { static $files; if(is_dir($dir)) { if($dh = opendir($dir)) { while(($file = readdir($dh)) !== false) { if($file != "." && $file != "..") { if (is_dir($dir."/".$file)) $this->list_mlist($dir."/".$file, $recursive, $files); else if (preg_match("/\.mlist$/",$file)) $files[]=$dir."/".$file; } } closedir($dh); } } return $files; } } // vim:ts=4:sw=4:et:enc=utf-8: