From 0bf17c03c2de8423045bf59b83d1e6d12ed7ca42 Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 24 Sep 2008 15:09:49 +0000 Subject: Introducing API key administration panel git-svn-id: https://code.elgg.org/elgg/trunk@2114 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/apiadmin/start.php | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 mod/apiadmin/start.php (limited to 'mod/apiadmin/start.php') diff --git a/mod/apiadmin/start.php b/mod/apiadmin/start.php new file mode 100644 index 000000000..496d8e461 --- /dev/null +++ b/mod/apiadmin/start.php @@ -0,0 +1,79 @@ +pluginspath . "apiadmin/actions/revokekey.php", true); + register_action("apiadmin/generate",false, $CONFIG->pluginspath . "apiadmin/actions/generate.php", true); + } + + /** + * Page setup. Adds admin controls to the admin panel. + * + */ + function apiadmin_pagesetup() + { + if (get_context() == 'admin' && isadminloggedin()) { + global $CONFIG; + add_submenu_item(elgg_echo('apiadmin'), $CONFIG->wwwroot . 'pg/apiadmin/'); + } + } + + + function apiadmin_page_handler($page) + { + global $CONFIG; + + if ($page[0]) + { + switch ($page[0]) + { + default : include($CONFIG->pluginspath . "apiadmin/index.php"); + } + } + else + include($CONFIG->pluginspath . "apiadmin/index.php"); + } + + function apiadmin_delete_key($event, $object_type, $object = null) + { + global $CONFIG; + + if (($object) && ($object->subtype == get_subtype_id('object', 'api_key'))) + { + // Delete + return remove_api_user($CONFIG->site_id, $object->public); + } + + return true; + } + + + // Make sure test_init is called on initialisation + register_elgg_event_handler('init','system','apiadmin_init'); + register_elgg_event_handler('pagesetup','system','apiadmin_pagesetup'); + + // Hook into delete to revoke secret keys + register_elgg_event_handler('delete','object','apiadmin_delete_key'); +?> \ No newline at end of file -- cgit v1.2.3