aboutsummaryrefslogtreecommitdiff
path: root/mod/apiadmin/actions/generate.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/apiadmin/actions/generate.php')
-rw-r--r--mod/apiadmin/actions/generate.php34
1 files changed, 34 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