xref: /plugin/discussion/admin.php (revision 5ef1705f41041912b7883d46c49e8adc3908c1e7)
1<?php
2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
4require_once(DOKU_PLUGIN.'admin.php');
5
6/**
7 * All DokuWiki plugins to extend the admin function
8 * need to inherit from this class
9 */
10class admin_plugin_discussion extends DokuWiki_Admin_Plugin {
11
12    /**
13     * return some info
14     */
15    function getInfo(){
16      return array(
17        'author' => 'iDo',
18        'email'  => 'iDo@woow-fr.com',
19        'date'   => '2006-12-30',
20        'name'   => 'See all discussion',
21        'desc'   => '',
22        'url'    => '',
23      );
24    }
25
26    /**
27     * return sort order for position in admin menu
28     */
29    function getMenuSort() {
30      return 200;
31    }
32
33    /**
34     * handle user request
35     */
36    function handle() {
37    }
38
39    /**
40     * output appropriate html
41     */
42    function html() {
43    	require_once(DOKU_PLUGIN.'action.php');
44		$actionDiscussion= new action_plugin_discussion();
45
46		global $conf;
47		global $INFO;
48		global $ID;
49		global $ADMDISCUSSION;
50
51		$oID=$ID;
52		$ADMDISCUSSION['page']="adm";
53		//Execute action for page
54		if (isset($_REQUEST['comment'])) {
55			if ($_REQUEST['comment']!='edit') {
56
57				if (($_REQUEST['comment']=='add') && (isset($_REQUEST['cid']))) {
58
59				} else {
60					$obj=new unusedclass();
61					$actionDiscussion->comments($obj, null);
62				}
63			}
64		}
65
66		$chem=DOKU_INC.$conf['savedir']."/meta/";
67		$arr=$this->globr($chem,"*.comments");
68		$com =array();
69		foreach ($arr as $v) {
70			$ap=unserialize(io_readFile($v, false));
71			if (isset($ap['comments'])){
72				$ID=substr(str_replace(array($chem,".comments",'/'),array("","",':'),$v),1);
73				$ADMDISCUSSION['page']=' : <a href="'.wl($ID,'').'">'.str_replace("/doku.php/","",wl($ID,'')).'</a>';
74
75				if ((isset($_REQUEST['comment'])) && ($_REQUEST['comment']=='edit'))
76					$actionDiscussion->_show(NULL, $_REQUEST['cid']);
77				else
78					$actionDiscussion->_show((($oID==$ID)?@$_REQUEST['cid']:null));
79
80			}
81		}
82		$ID = $oID;
83		$ADMDISCUSSION['breakaction']=true;
84    }
85
86	/**
87	 * Recursive version of glob
88	 *
89	 * @return array containing all pattern-matched files.
90	 *
91	 * @param string $sDir      Directory to start with.
92	 * @param string $sPattern  Pattern to glob for.
93	 * @param int $nFlags      Flags sent to glob.
94	 */
95	function globr($sDir, $sPattern, $nFlags = NULL) {
96	  $sDir = escapeshellcmd($sDir);
97	  // Get the list of all matching files currently in the
98	  // directory.
99	  $aFiles = glob("$sDir/$sPattern", $nFlags);
100	  // Then get a list of all directories in this directory, and
101	  // run ourselves on the resulting array.  This is the
102	  // recursion step, which will not execute if there are no
103	  // directories.
104	  foreach (glob("$sDir/*", GLOB_ONLYDIR) as $sSubDir)  {
105	   $aSubFiles = $this->globr($sSubDir, $sPattern, $nFlags);
106	   $aFiles = array_merge($aFiles, $aSubFiles);
107	  }
108	  // The array we return contains the files we found, and the
109	  // files all of our children found.
110	  return $aFiles;
111	}
112
113}
114class unusedclass {
115	function unusedclass(){	$this->data='admin';}
116}
117?>
118