]> git.mxchange.org Git - friendica-addons.git/commitdiff
tumblr: Added admin page for API key
authorMichael Vogel <icarus@dabo.de>
Sun, 15 Jun 2014 13:05:04 +0000 (15:05 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 15 Jun 2014 13:05:04 +0000 (15:05 +0200)
tumblr/README
tumblr/templates/admin.tpl [new file with mode: 0644]
tumblr/tumblr.php

index 62d7fd0456a8e2d9f8fbca63a60463893362e1f1..9b77bdcde99abe0a945e9d5bbb319f2775547d6c 100644 (file)
@@ -1,9 +1,7 @@
-Define in your .htconfig.php:
-$a->config['tumblr']['consumer_key'] = "your-consumer-key";
-$a->config['tumblr']['consumer_secret'] = "your-consumer-secret";
-
-You can get it here:
+Register an application at this address:
 http://www.tumblr.com/oauth/apps
 
+use (your server name)addon/tumblr/callback.php as callback URL
+
 Tumblr-OAuth-Library:
 https://groups.google.com/d/msg/tumblr-api/g6SeIBWvsnE/gnWqT9jFSlEJ
diff --git a/tumblr/templates/admin.tpl b/tumblr/templates/admin.tpl
new file mode 100644 (file)
index 0000000..b361f18
--- /dev/null
@@ -0,0 +1,3 @@
+{{include file="field_input.tpl" field=$consumer_key}}
+{{include file="field_input.tpl" field=$consumer_secret}}
+<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
index cd9713cf89f133e3406b72e1a034f268ac45c5a8..619ff16e807f43611f6b7af7c963adca9372da99 100644 (file)
@@ -54,6 +54,25 @@ function tumblr_content(&$a) {
        return $o;
 }
 
+function tumblr_plugin_admin(&$a, &$o){
+        $t = get_markup_template( "admin.tpl", "addon/tumblr/" );
+
+        $o = replace_macros($t, array(
+                '$submit' => t('Save Settings'),
+                                                                // name, label, value, help, [extra values]
+                '$consumer_key' => array('consumer_key', t('Consumer Key'),  get_config('tumblr', 'consumer_key' ), ''),
+                '$consumer_secret' => array('consumer_secret', t('Consumer Secret'),  get_config('tumblr', 'consumer_secret' ), ''),
+        ));
+}
+
+function tumblr_plugin_admin_post(&$a){
+        $consumer_key     =       ((x($_POST,'consumer_key'))              ? notags(trim($_POST['consumer_key']))   : '');
+        $consumer_secret =       ((x($_POST,'consumer_secret'))   ? notags(trim($_POST['consumer_secret'])): '');
+        set_config('tumblr','consumer_key',$consumer_key);
+        set_config('tumblr','consumer_secret',$consumer_secret);
+        info( t('Settings updated.'). EOL );
+}
+
 function tumblr_connect($a) {
        // Start a session.  This is necessary to hold on to  a few keys the callback script will also need
        session_start();