*/ // must be run within Dokuwiki use dokuwiki\Form\Form; use plugin\struct\meta\Assignments; use plugin\struct\meta\Schema; use plugin\struct\meta\SchemaEditor; if(!defined('DOKU_INC')) die(); class admin_plugin_struct_assignments extends DokuWiki_Admin_Plugin { /** * @return int sort number in admin menu */ public function getMenuSort() { return 501; } /** * Return the text that is displayed at the main admin menu * * @param string $language language code * @return string menu string */ public function getMenuText($language) { return $this->getLang('menu_assignments'); } /** * @return bool true if only access for superuser, false is for superusers and moderators */ public function forAdminOnly() { return true; } /** * Should carry out any processing required by the plugin. */ public function handle() { global $INPUT; global $ID; $assignments = new Assignments(); if($INPUT->str('action') && $INPUT->arr('assignment') && checkSecurityToken()) { $assignment = $INPUT->arr('assignment'); $ok = true; if(!blank($assignment['assign']) && !blank($assignment['tbl'])) { if($INPUT->str('action') === 'delete') { $ok = $assignments->remove($assignment['assign'], $assignment['tbl']); } else if($INPUT->str('action') === 'add') { $ok = $assignments->add($assignment['assign'], $assignment['tbl']); } } if(!$ok) { msg('something went wrong while saving', -1); } send_redirect(wl($ID, array('do' => 'admin', 'page' => 'struct_assignments'), true, '&')); } } /** * Render HTML output, e.g. helpful text and a form */ public function html() { global $ID; echo $this->locale_xhtml('assignments_intro'); //fixme listing schema tables should be moved to one of the meta classes /** @var helper_plugin_struct_db $helper */ $helper = plugin_load('helper', 'struct_db'); $sqlite = $helper->getDB(); $res = $sqlite->query('SELECT tbl FROM schemas GROUP BY tbl'); $schemas = $sqlite->res2arr($res); $sqlite->res_close($res); $ass = new Assignments(); $assignments = $ass->getAll(); echo '