diff options
author | Jehan-Guillaume (ioguix) de Rorthais | 2012-08-17 08:57:35 +0000 |
---|---|---|
committer | Jehan-Guillaume (ioguix) de Rorthais | 2012-08-22 10:39:42 +0000 |
commit | 4c1be973cee44fe295a57c35d83a088e1e8023f3 (patch) | |
tree | f6b85238ffe97bf753c2d6b05bbfe282d5f3a317 | |
parent | 516f4f7844ffe0eecbdb91f44cd95be232431c53 (diff) |
Add plugin GuiControl.
This plugins allows to activate/deactivate links/buttons/actions in PPA
gui. It does NOT deactivate the feature itself, just remove the
LINKS, ie. anyone will be able to access a feature if he can forge its
URL.
-rw-r--r-- | plugins/GuiControl/conf/config.inc.php | 485 | ||||
-rw-r--r-- | plugins/GuiControl/plugin.php | 145 |
2 files changed, 630 insertions, 0 deletions
diff --git a/plugins/GuiControl/conf/config.inc.php b/plugins/GuiControl/conf/config.inc.php new file mode 100644 index 00000000..b0d1b979 --- /dev/null +++ b/plugins/GuiControl/conf/config.inc.php @@ -0,0 +1,485 @@ +<?php + +$plugin_conf = array( + + /** + * Top Links + **/ + 'top_links' => array ( + // 'sql' => true, + // 'history' => true, + // 'find' => true, + // 'logout' => true, + ), + + /** + * Tabs Links + **/ + 'tab_links' => array ( + 'root' => array ( + // 'intro' => true, + // 'servers' => true, + ), + // case 'report' ??? + 'server' => array ( + // 'databases' => true, + // 'roles' => true, /* postgresql 8.1+ */ + // 'users' => true, /* postgresql <8.1 */ + // 'groups' => true, + // 'account' => true, + // 'tablespaces' => true, + // 'export' => true, + // 'reports' => true, + ), + 'database' => array ( + // 'schemas' => true, + // 'sql' => true, + // 'find' => true, + 'variables' => false, + // 'processes' => true, + // 'locks' => true, + 'admin' => false, + 'privileges' => false, + 'languages' => false, + 'casts' => false, + // 'export' => true, + ), + 'schema' => array( + // 'tables' => true, + // 'views' => true, + // 'sequences' => true, + // 'functions' => true, + // 'fulltext' => true, + 'domains' => false, + 'aggregates' => false, + 'types' => false, + 'operators' => false, + 'opclasses' => false, + 'conversions' => false, + // 'privileges' => true, + // 'export' => true, + ), + 'table' => array( + // 'columns' => true, + // 'indexes' => true, + // 'constraints' => true, + // 'triggers' => true, + // 'rules' => true, + 'admin' => false, + 'info' => false, + // 'privileges' => true, + // 'import' => true, + // 'export' => true, + ), + 'view' => array ( + // 'columns' => true, + // 'definition' => true, + // 'rules' => true, + // 'privileges' => true, + // 'export' => true, + ), + 'function' => array( + // 'definition' => true, + // 'privileges' => true, + ), + 'aggregate' => array( + // 'definition' => true, + ), + 'role' => array( + // 'definition' => true, + ), + 'popup' => array( + // 'sql' => true, + // 'find' => true, + ), + 'column' => array( + // 'properties' => true, + // 'privileges' => true, + ), + 'fulltext' => array( + // 'ftsconfigs' => true, + // 'ftsdicts' => true, + // 'ftsparsers' => true, + ), + ), + + /** + * Trail Links + **/ + 'trail_links' => true, /* enable/disable the whole trail */ + + /** + * Navigation Links + **/ + 'navlinks' => array( + 'aggregates-properties' => array( + // 'showall' => true, + 'alter' => false, + 'drop' => false, + ), + 'aggregates-aggregates' => array( + 'create' => false, + ), + 'all_db-databases' => array( + 'create' => false, + ), + 'colproperties-colproperties' => array( + // 'browse' => true, + 'alter' => false, + 'drop' => false, + ), + 'constraints-constraints' => array( + 'addcheck' => false, + 'adduniq' => false, + 'addpk' => false, + 'addfk' => false, + ), + 'display-browse' => array( + // 'back' => true, + // 'edit' => true, + // 'collapse' => true, + 'createreport' => false, + 'createview' => false, + // 'download' => true, + // 'insert' => true, + // 'refresh' => true, + ), + 'domains-properties' => array( + 'drop' => false, + 'addcheck' => false, + // 'alter' => true, + ), + 'domains-domains' => array( + 'create' => false, + ), + 'fulltext-fulltext' => array( + 'createconf' => false, + ), + 'fulltext-viewdicts' => array( + 'createdict' => false, + ), + 'fulltext-viewconfig' => array( + 'addmapping' => false, + ), + 'functions-properties' => array( + // 'showall' => true, + 'alter' => false, + 'drop' => false, + ), + 'functions-functions' => array( + 'createpl' => false, + 'createinternal' => false, + 'createc' => false, + ), + 'groups-groups' => array( + 'create' => false, + ), + 'groups-properties' => array( + // 'showall' => true, + ), + 'history-history' => array( + // 'refresh' => true, + // 'download' => true, + // 'clear' => true, + ), + 'indexes-indexes' => array( + 'create' => false, + ), + 'operators-properties' => array( + // 'showall' => true, + ), + 'privileges-privileges' => array( + 'grant' => false, + 'revoke' => false, + // 'showalltables' => true, + // 'showallcolumns' => true, + // 'showallviews' => true, + // 'showalldatabases' => true, + // 'showallschemas' => true, + // 'showallfunctions' => true, + // 'showallsequences' => true, + // 'showalltablespaces' => true, + ), + 'reports-properties' => array( + // 'showall' => true, + 'alter' => false, + // 'exec' => true, + ), + 'reports-reports' => array( + 'create' => false, + ), + 'roles-account' => array( + 'changepassword' => true, + ), + 'roles-properties' => array( + // 'showall' => true, + 'alter' => false, + 'drop' => false, + ), + 'roles-roles' => array( + 'create' => false, + ), + 'rules-rules' => array( + 'create' => false, + ), + 'schemas-schemas' => array( + 'create' => false, + ), + 'sequences-properties' => array( + 'alter' => false, + 'nextval' => false, + 'restart' => false, + 'reset' => false, + ), + 'sequences-sequences' => array( + 'create' => false, + ), + 'servers-servers' => array( + // 'showall' => true, + /*we cannot filter the group names in navlinks presently*/ + ), + 'sql-form' => array( + // 'back' => true, + // 'alter' => true, + 'createreport' => false, + 'createview' => false, + // 'download' => true, + ), + 'tables-tables' => array( + 'create' => false, + 'createlike' => false, + ), + 'tablespaces-tablespaces' => array( + 'create' => false, + ), + 'tblproperties-tblproperties' => array( + // 'browse' => true, + // 'select' => true, + // 'insert' => true, + 'empty' => false, + 'drop' => false, + 'addcolumn' => false, + 'alter' => false, + ), + 'triggers-triggers' => array( + 'create' => false, + ), + 'types-properties' => array( + // 'showall' => true, + ), + 'types-types' => array( + 'create' => false, + 'createcomp' => false, + 'createenum' => false, + ), + 'users-account' => array( + // 'changepassword' => true, + ), + 'users-users' => array( + 'create' => false, + ), + 'viewproperties-definition' => array( + 'alter' => false, + ), + 'viewproperties-viewproperties' => array( + // 'browse' => true, + // 'select' => true, + 'drop' => false, + 'alter' => false, + ), + 'views-views' => array( + 'create' => false, + 'createwiz' => false, + ), + ), + + /** + * action links + **/ + + 'actionbuttons' => array( + 'admin-admin' => array( + 'edit' => false, + 'delete' => false, + ), + 'aggregates-aggregates' => array( + 'alter' => false, + 'drop' => false, + ), + 'all_db-databases' => array( + 'drop' => false, + // 'privileges' => true, + 'alter' => false, + ), + 'casts-casts' => array( + // none + ), + 'colproperties-colproperties' => array( + // none + ), + 'constraints-constraints' => array( + 'drop' => false, + ), + 'conversions-conversions' => array( + // none + ), + 'database-variables' => array( + // none + ), + 'database-processes-preparedxacts' => array( + // none + ), + 'database-processes' => array( + 'cancel' => false, + 'kill' => false, + ), + 'database-locks' => array( + // none + ), + 'display-browse' => array( + // TODO + // 'edit' => true, + // 'delete' => true, + ), + 'domains-properties' => array( + 'drop' => false, + ), + 'domains-domains' => array( + 'alter' => false, + 'drop' => false, + ), + 'fulltext-fulltext' => array( + 'drop' => false, + 'alter' => false, + ), + 'fulltext-viewparsers' => array( + // none + ), + 'fulltext-viewdicts' => array( + 'drop' => false, + 'alter' => false, + ), + 'fulltext-viewconfig' => array( + 'multiactions' => false, + 'drop' => false, + 'alter' => false, + ), + 'functions-functions' => array( + 'multiactions' => false, + 'alter' => false, + 'drop' => false, + // 'privileges' => true, + ), + 'groups-members' => array( + 'drop' => false, + ), + 'groups-properties' => array( + 'drop' => false, + ), + 'history-history' => array( + // 'run' => true, + // 'remove' => true, + ), + 'indexes-indexes' => array( + 'cluster' => false, + 'reindex' => false, + 'drop' => false, + ), + 'info-referrers' => array( + // 'properties' => true, + ), + 'info-parents' => array( + // 'properties' => true, + ), + 'info-children' => array( + // 'properties' => true, + ), + 'languages-languages' => array( + // none + ), + 'opclasses-opclasses' => array( + // none + ), + 'operators-operators' => array( + 'drop' => false, + ), + 'reports-reports' => array( + // 'run' => true, + 'edit' => false, + 'drop' => false, + ), + 'roles-roles' => array( + 'alter' => false, + 'drop' => false, + ), + 'rules-rules' => array( + 'drop' => false, + ), + 'schemas-schemas' => array( + 'multiactions' => false, + 'drop' => false, + // 'privileges' => true, + 'alter' => false, + ), + 'sequences-sequences' => array( + 'multiactions' => false, + 'drop' => false, + // 'privileges' => true, + 'alter' => false, + ), + 'servers-servers' => array( + // 'logout' => true, + ), + 'tables-tables' => array( + 'multiactions' => false, + // 'browse' => true, + // 'select' => true, + // 'insert' => true, + 'empty' => false, + 'alter' => false, + 'drop' => false, + 'vacuum' => false, + 'analyze' => false, + 'reindex' => false, + ), + 'tablespaces-tablespaces' => array( + 'drop' => false, + // 'privileges' => true, + 'alter' => false, + ), + 'tblproperties-tblproperties' => array( + // 'browse' => true, + 'alter' => false, + // 'privileges' => true, + 'drop' => false, + ), + 'triggers-triggers' => array( + 'alter' => false, + 'drop' => false, + 'enable' => false, + 'disable' => false, + ), + 'types-properties' => array( + // none + ), + 'types-types' => array( + 'drop' => false, + ), + 'users-users' => array( + 'alter' => false, + 'drop' => false, + ), + 'viewproperties-viewproperties' => array( + 'alter' => false, + ), + 'views-views' => array( + 'multiactions' => false, + // 'browse' => true, + // 'select' => true, + 'alter' => false, + 'drop' => false, + ), + ), +); + +?> diff --git a/plugins/GuiControl/plugin.php b/plugins/GuiControl/plugin.php new file mode 100644 index 00000000..44669362 --- /dev/null +++ b/plugins/GuiControl/plugin.php @@ -0,0 +1,145 @@ +<?php +require_once('classes/Plugin.php'); + +class GuiControl extends Plugin { + + /** + * Attributes + */ + protected $name = 'GuiControl'; + protected $lang; + protected $conf; + + /** + * Constructor + * Call parent constructor, passing the language that will be used. + * @param $language Current phpPgAdmin language. If it was not found in the plugin, English will be used. + */ + function __construct($language) { + parent::__construct($language); + } + + /** + * This method returns the functions that will hook in the phpPgAdmin core. + * To do include a function just put in the $hooks array the follwing code: + * 'hook' => array('function1', 'function2'). + * + * Example: + * $hooks = array( + * 'toplinks' => array('add_plugin_toplinks'), + * 'tabs' => array('add_tab_entry'), + * 'action_buttons' => array('add_more_an_entry') + * ); + * + * @return $hooks + */ + function get_hooks() { + $hooks = array( + 'toplinks' => array('filer_toplinks'), + 'tabs' => array('filter_tabs'), + 'trail' => array('filter_trail'), + 'navlinks' => array('filter_navlinks'), + 'actionbuttons' => array('filter_actionbuttons'), + 'tree' => array('filter_tree') + ); + return $hooks; + } + + /** + * This method returns the functions that will be used as actions. + * To do include a function that will be used as action, just put in the $actions array the follwing code: + * + * $actions = array( + * 'show_page', + * 'show_error', + * ); + * + * @return $actions + */ + function get_actions() { + $actions = array( + 'filer_toplinks', + 'filter_tabs', + 'filter_trail', + 'filter_navlinks', + 'filter_actionbuttons', + 'filter_tree', + ); + return $actions; + } + + function filer_toplinks(&$f_params) { + if (!isset($this->conf['top_links'])) + return; + + $top_links = &$f_params['toplinks']; + + foreach ($this->conf['top_links'] as $link => $enabled) + if (isset ($top_links[$link]) + && ($enabled === false) + ) + unset($top_links[$link]); + + return; + } + + function filter_tabs(&$f_params) { + $section = $f_params['section']; + $tabs = &$f_params['tabs']; + + if (!isset($this->conf['tab_links'][$section])) + return; + + foreach ($this->conf['tab_links'][$section] as $link => $enabled) + if (isset ($tabs[$link]) + && ($enabled === false) + ) + unset($tabs[$link]); + return; + } + + function filter_trail(&$f_params) { + if (!isset($this->conf['trail_links'])) + return; + + if ($this->conf['trail_links'] === false) + $f_params['trail'] = array(); + + return; + } + + function filter_navlinks(&$f_params) { + $place = $f_params['place']; + $navlinks = &$f_params['navlinks']; + + if (! isset($this->conf['navlinks'][$place])) + return; + + foreach ($this->conf['navlinks'][$place] as $link => $enabled) + if (isset ($navlinks[$link]) + && ($enabled === false) + ) + unset($navlinks[$link]); + return; + } + + function filter_actionbuttons(&$f_params) { + $place = $f_params['place']; + $actions = &$f_params['actionbuttons']; + + if (! isset($this->conf['actionbuttons'][$place])) + return; + + foreach ($this->conf['actionbuttons'][$place] as $link => $enabled) + if (isset ($actions[$link]) + && ($enabled === false) + ) + unset($actions[$link]); + return; + } + + function filter_tree() { + return; + } +} +?>
\ No newline at end of file |