From a709d259ce3918aa325a11b90668a8f3230b7d68 Mon Sep 17 00:00:00 2001 From: Joshua P Panter Date: Mon, 9 Mar 2020 21:02:52 -0400 Subject: [PATCH] fix #37 No notifications when saving Wallabag credentials --- wallabag_v2/init.php | 58 ++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/wallabag_v2/init.php b/wallabag_v2/init.php index ed779f7..de4c14f 100644 --- a/wallabag_v2/init.php +++ b/wallabag_v2/init.php @@ -3,7 +3,7 @@ class Wallabag_v2 extends Plugin { private $host; function about() { - return array("1.10.1", + return array("1.10.2", "Post articles to a Wallabag v 2.x instance", "joshu@unfettered.net"); } @@ -58,12 +58,14 @@ function save() { $status = curl_getinfo($cURL, CURLINFO_HTTP_CODE); curl_close($cURL); // prepare result data + $watt = time() + 3600; // 1 hour + $wrtt = time() + 1123200; // 13 days $result = json_decode($result,true); // store result data $this->host->set($this, "wallabag_access_token", $result['access_token']); - $this->host->set($this, "wallabag_access_token_timeout", $time() + 3600); // 1 hour + $this->host->set($this, "wallabag_access_token_timeout", $watt ); $this->host->set($this, "wallabag_refresh_token", $result['refresh_token']); - $this->host->set($this, "wallabag_refresh_token_timeout", $time() + 1123200); // 13 days + $this->host->set($this, "wallabag_refresh_token_timeout", $wrtt); } else { // get curl! $status = 501; @@ -114,25 +116,28 @@ function hook_prefs_tab($args) { $w_csec = $this->host->get($this, "wallabag_client_secret"); $w_access = $this->host->get($this, "wallabag_access_token"); - print "
share ".__("Wallabag v2")."\">"; - print "
"; - print "
"; - print ""; - print ""; - print ""; - print ""; + print "
"; + print ""; + + print ""; + + print_hidden("op", "pluginhandler"); + print_hidden("method", "save"); + print_hidden("plugin", "wallabag_v2"); print ""; print ""; print ""; @@ -253,13 +258,13 @@ function hook_house_keeping() { $OAresult = json_decode($OAresult,true); // success? if ($OAstatus == 200) { - $aTimeout = time() + 3600; // 1 hour - $rTimeout = time() + 1123200; // 13 days + $watt = time() + 3600; // 1 hour + $wrtt = time() + 1123200; // 13 days // store new tokens and values $this->host->set($this, "wallabag_access_token", $OAresult['access_token']); - $this->host->set($this, "wallabag_access_token_timeout", $time() + 3600 ); // 1 hour + $this->host->set($this, "wallabag_access_token_timeout", $watt); $this->host->set($this, "wallabag_refresh_token", $OAresult['refresh_token']); - $this->host->set($this, "wallabag_refresh_token_timeout", time() + 1123200 ); // 13 days + $this->host->set($this, "wallabag_refresh_token_timeout", $wrtt); } } else { @@ -288,9 +293,10 @@ function hook_house_keeping() { $OAresult = json_decode($OAresult,true); // success? if ($OAstatus == 200) { + $watt = time() + 3600; // 1 hour // store new tokens $this->host->set($this, "wallabag_access_token", $OAresult['access_token']); - $this->host->set($this, "wallabag_access_token_timeout", time() + 3600 ); // 1 hour + $this->host->set($this, "wallabag_access_token_timeout", $watt); $this->host->set($this, "wallabag_refresh_token", $OAresult['refresh_token']); } }
".__("Wallabag URL (No trailing slash!)")."