xref: /plugin/feedback/admin.php (revision 7858dc83204affa61f8d9fd1391fda66153243be)
134054578SAndreas Gohr<?php
234054578SAndreas Gohr/**
334054578SAndreas Gohr * DokuWiki Plugin feedback (Admin Component)
434054578SAndreas Gohr *
534054578SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
634054578SAndreas Gohr * @author  Andreas Gohr <gohr@cosmocode.de>
734054578SAndreas Gohr */
834054578SAndreas Gohr
934054578SAndreas Gohr// must be run within Dokuwiki
1034054578SAndreas Gohrif(!defined('DOKU_INC')) die();
1134054578SAndreas Gohr
1234054578SAndreas Gohrclass admin_plugin_feedback extends DokuWiki_Admin_Plugin {
1334054578SAndreas Gohr
1434054578SAndreas Gohr    /**
1534054578SAndreas Gohr     * @return int sort number in admin menu
1634054578SAndreas Gohr     */
1734054578SAndreas Gohr    public function getMenuSort() {
18*7858dc83SAndreas Gohr        return 3000;
1934054578SAndreas Gohr    }
2034054578SAndreas Gohr
2134054578SAndreas Gohr    /**
2234054578SAndreas Gohr     * @return bool true if only access for superuser, false is for superusers and moderators
2334054578SAndreas Gohr     */
2434054578SAndreas Gohr    public function forAdminOnly() {
2534054578SAndreas Gohr        return false;
2634054578SAndreas Gohr    }
2734054578SAndreas Gohr
2834054578SAndreas Gohr    /**
2934054578SAndreas Gohr     * Should carry out any processing required by the plugin.
3034054578SAndreas Gohr     */
3134054578SAndreas Gohr    public function handle() {
32*7858dc83SAndreas Gohr        global $INPUT;
33*7858dc83SAndreas Gohr        if(!$INPUT->has('data')) return;
34*7858dc83SAndreas Gohr
35*7858dc83SAndreas Gohr        $data = $INPUT->arr('data');
36*7858dc83SAndreas Gohr
37*7858dc83SAndreas Gohr        $conf = '';
38*7858dc83SAndreas Gohr        foreach($data as $row){
39*7858dc83SAndreas Gohr            $ns = trim($row['ns']);
40*7858dc83SAndreas Gohr            if($ns != '*') $ns = cleanID($ns);
41*7858dc83SAndreas Gohr            $mail = trim($row['mail']);
42*7858dc83SAndreas Gohr            if(!$ns) continue;
43*7858dc83SAndreas Gohr            $conf .= "$ns\t$mail\n";
44*7858dc83SAndreas Gohr        }
45*7858dc83SAndreas Gohr
46*7858dc83SAndreas Gohr        if(io_saveFile(DOKU_CONF . 'plugin_feedback.conf', $conf)) {
47*7858dc83SAndreas Gohr            msg($this->getLang('saved'), 1);
48*7858dc83SAndreas Gohr        }
4934054578SAndreas Gohr    }
5034054578SAndreas Gohr
5134054578SAndreas Gohr    /**
5234054578SAndreas Gohr     * Render HTML output, e.g. helpful text and a form
5334054578SAndreas Gohr     */
5434054578SAndreas Gohr    public function html() {
55*7858dc83SAndreas Gohr        global $ID;
56*7858dc83SAndreas Gohr
57*7858dc83SAndreas Gohr        echo $this->locale_xhtml('intro');
58*7858dc83SAndreas Gohr
59*7858dc83SAndreas Gohr        $conf = confToHash(DOKU_CONF . 'plugin_feedback.conf');
60*7858dc83SAndreas Gohr        ksort($conf);
61*7858dc83SAndreas Gohr
62*7858dc83SAndreas Gohr        $action = wl($ID, array('do' => 'admin', 'page' => 'feedback'));
63*7858dc83SAndreas Gohr        echo '<form action="'.$action.'" method="post">';
64*7858dc83SAndreas Gohr
65*7858dc83SAndreas Gohr        echo '<table class="inline">';
66*7858dc83SAndreas Gohr        echo '<tr>';
67*7858dc83SAndreas Gohr        echo '<th>'.$this->getLang('namespace').'</th>';
68*7858dc83SAndreas Gohr        echo '<th>'.$this->getLang('email').'</th>';
69*7858dc83SAndreas Gohr        echo '</tr>';
70*7858dc83SAndreas Gohr        $cnt = 0;
71*7858dc83SAndreas Gohr        foreach($conf as $key => $val) {
72*7858dc83SAndreas Gohr            echo '<tr>';
73*7858dc83SAndreas Gohr            echo '<td><input type="text" name="data['.$cnt.'][ns]" value="'.hsc($key).'" class="edit" /></td>';
74*7858dc83SAndreas Gohr            echo '<td><input type="text" name="data['.$cnt.'][mail]" value="'.hsc($val).'" class="edit" /></td>';
75*7858dc83SAndreas Gohr            echo '</tr>';
76*7858dc83SAndreas Gohr            $cnt++;
77*7858dc83SAndreas Gohr        }
78*7858dc83SAndreas Gohr        echo '<tr>';
79*7858dc83SAndreas Gohr        echo '<td><input type="text" name="data['.$cnt.'][ns]" value=""/></td>';
80*7858dc83SAndreas Gohr        echo '<td><input type="text" name="data['.$cnt.'][mail]" value=""/></td>';
81*7858dc83SAndreas Gohr        echo '</tr>';
82*7858dc83SAndreas Gohr        echo '</table>';
83*7858dc83SAndreas Gohr
84*7858dc83SAndreas Gohr        echo '<input type="submit" value="'.$this->getLang('save').'" class="btn">';
85*7858dc83SAndreas Gohr
86*7858dc83SAndreas Gohr        echo '</form>';
87*7858dc83SAndreas Gohr
8834054578SAndreas Gohr    }
8934054578SAndreas Gohr}
9034054578SAndreas Gohr
9134054578SAndreas Gohr// vim:ts=4:sw=4:et: