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