*/ class admin_plugin_submgr extends DokuWiki_Admin_Plugin { /** @var helper_plugin_submgr */ protected $hlp; /** * admin_plugin_submgr constructor. */ public function __construct() { $this->hlp = plugin_load('helper', 'submgr'); } /** * @return bool true if only access for superuser, false is for superusers and moderators */ public function forAdminOnly() { return false; } /** * Should carry out any processing required by the plugin. */ public function handle() { global $INPUT; global $ID; $url = wl($ID, array('do' => 'admin', 'page' => 'submgr'), true, '&'); if ($INPUT->has('d')) { try { $new = $INPUT->arr('d'); $this->hlp->addRule($new['item'], $new['type'], $new['members']); send_redirect($url); } catch (Exception $e) { msg($e->getMessage(), -1); } } if ($INPUT->has('rm')) { try { $this->hlp->removeRule($INPUT->str('rm')); send_redirect($url); } catch (Exception $e) { msg($e->getMessage(), -1); } } } /** * Render HTML output, e.g. helpful text and a form */ public function html() { global $ID; $url = wl($ID, array('do' => 'admin', 'page' => 'submgr')); echo $this->locale_xhtml('intro'); if (!$this->checkSettings()) return; echo '

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

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($this->hlp->getRules() as $item => $data) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
' . $this->getLang('item') . '' . $this->getLang('members') . '' . $this->getLang('type') . '
' . hsc($item) . '' . hsc($data[1]) . '' . $this->getLang($data[0]) . ''; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '

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

'; echo '
'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
'; echo $this->locale_xhtml('help'); } /** * Check capabilities and print errors * * @return bool */ protected function checkSettings() { /** @var DokuWiki_Auth_Plugin $auth */ global $auth; $ok = true; if (!actionOK('subscribe')) { echo $this->locale_xhtml('nosubs'); $ok = false; } if (!$auth->canDo('getUsers')) { echo $this->locale_xhtml('nousers'); $ok = false; } return $ok; } }