1<?php 2/** 3 * DokuWiki Plugin feedback (Admin Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Andreas Gohr <gohr@cosmocode.de> 7 */ 8 9// must be run within Dokuwiki 10if(!defined('DOKU_INC')) die(); 11 12class admin_plugin_feedback extends DokuWiki_Admin_Plugin { 13 14 /** 15 * @return int sort number in admin menu 16 */ 17 public function getMenuSort() { 18 return 3000; 19 } 20 21 /** 22 * @return bool true if only access for superuser, false is for superusers and moderators 23 */ 24 public function forAdminOnly() { 25 return false; 26 } 27 28 /** 29 * Should carry out any processing required by the plugin. 30 */ 31 public function handle() { 32 global $INPUT; 33 if(!$INPUT->has('data')) return; 34 35 $data = $INPUT->arr('data'); 36 37 $conf = ''; 38 foreach($data as $row){ 39 $ns = trim($row['ns']); 40 if($ns != '*') $ns = cleanID($ns); 41 $mail = trim($row['mail']); 42 if(!$ns) continue; 43 $conf .= "$ns\t$mail\n"; 44 } 45 46 if(io_saveFile(DOKU_CONF . 'plugin_feedback.conf', $conf)) { 47 msg($this->getLang('saved'), 1); 48 } 49 } 50 51 /** 52 * Render HTML output, e.g. helpful text and a form 53 */ 54 public function html() { 55 global $ID; 56 57 echo $this->locale_xhtml('intro'); 58 59 $conf = confToHash(DOKU_CONF . 'plugin_feedback.conf'); 60 ksort($conf); 61 62 $action = wl($ID, array('do' => 'admin', 'page' => 'feedback')); 63 echo '<form action="'.$action.'" method="post">'; 64 65 echo '<table class="inline">'; 66 echo '<tr>'; 67 echo '<th>'.$this->getLang('namespace').'</th>'; 68 echo '<th>'.$this->getLang('email').'</th>'; 69 echo '</tr>'; 70 $cnt = 0; 71 foreach($conf as $key => $val) { 72 echo '<tr>'; 73 echo '<td><input type="text" name="data['.$cnt.'][ns]" value="'.hsc($key).'" class="edit" /></td>'; 74 echo '<td><input type="text" name="data['.$cnt.'][mail]" value="'.hsc($val).'" class="edit" /></td>'; 75 echo '</tr>'; 76 $cnt++; 77 } 78 echo '<tr>'; 79 echo '<td><input type="text" name="data['.$cnt.'][ns]" value=""/></td>'; 80 echo '<td><input type="text" name="data['.$cnt.'][mail]" value=""/></td>'; 81 echo '</tr>'; 82 echo '</table>'; 83 84 echo '<input type="submit" value="'.$this->getLang('save').'" class="btn">'; 85 86 echo '</form>'; 87 88 } 89} 90 91// vim:ts=4:sw=4:et: