diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-09-24 15:09:49 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-09-24 15:09:49 +0000 |
commit | 0bf17c03c2de8423045bf59b83d1e6d12ed7ca42 (patch) | |
tree | c0e2b9a30e617d92392974139c605f5cde931fc6 /mod/apiadmin/actions | |
parent | 745cdb1c22401bd62cf8e3d9754bcaceab2617f3 (diff) | |
download | elgg-0bf17c03c2de8423045bf59b83d1e6d12ed7ca42.tar.gz elgg-0bf17c03c2de8423045bf59b83d1e6d12ed7ca42.tar.bz2 |
Introducing API key administration panel
git-svn-id: https://code.elgg.org/elgg/trunk@2114 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/apiadmin/actions')
-rw-r--r-- | mod/apiadmin/actions/generate.php | 34 | ||||
-rw-r--r-- | mod/apiadmin/actions/revokekey.php | 22 |
2 files changed, 56 insertions, 0 deletions
diff --git a/mod/apiadmin/actions/generate.php b/mod/apiadmin/actions/generate.php new file mode 100644 index 000000000..ca47deb3d --- /dev/null +++ b/mod/apiadmin/actions/generate.php @@ -0,0 +1,34 @@ +<?php + global $CONFIG; + + admin_gatekeeper(); + + $ref = get_input('ref'); + + if ($ref) + { + $keypair = create_api_user($CONFIG->site_id); + + if ($keypair) + { + + $newkey = new ElggObject(); + $newkey->subtype = 'api_key'; + $newkey->access_id = 2; + $newkey->title = $ref; + $newkey->public = $keypair->api_key; + + if (!$newkey->save()) + register_error(elgg_echo('apiadmin:generationfail')); + else + system_message(elgg_echo('apiadmin:generated')); + } + else + register_error(elgg_echo('apiadmin:generationfail')); + } + else + register_error(elgg_echo('apiadmin:noreference')); + + + forward($_SERVER['HTTP_REFERER']); +?>
\ No newline at end of file diff --git a/mod/apiadmin/actions/revokekey.php b/mod/apiadmin/actions/revokekey.php new file mode 100644 index 000000000..eeb5dd791 --- /dev/null +++ b/mod/apiadmin/actions/revokekey.php @@ -0,0 +1,22 @@ +<?php + + global $CONFIG; + + admin_gatekeeper(); + + $key = (int)get_input('keyid'); + + $obj = get_entity($key); + + if (($obj) && ($obj instanceof ElggObject) && ($obj->subtype == get_subtype_id('object', 'api_key'))) + { + if ($obj->delete()) + system_message(elgg_echo('apiadmin:keyrevoked')); + else + register_error(elgg_echo('apiadmin:keynotrevoked')); + } + else + register_error(elgg_echo('apiadmin:keynotrevoked')); + + forward($_SERVER['HTTP_REFERER']); +?>
\ No newline at end of file |