aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-05-16 22:43:19 -0700
committerFriendika <info@friendika.com>2011-05-16 22:43:19 -0700
commit01a871c991e00ee1d61ea9f1a1c35fa3eb667b1a (patch)
tree3039619e8eec113fa877367c95ebb4114042c77e
parentf9444c8be50f91282a81eebc84825813d118bfe4 (diff)
parent85dc0826b6917d9809f9a7adeb3e0d015832ee91 (diff)
downloadvolse-hubzilla-01a871c991e00ee1d61ea9f1a1c35fa3eb667b1a.tar.gz
volse-hubzilla-01a871c991e00ee1d61ea9f1a1c35fa3eb667b1a.tar.bz2
volse-hubzilla-01a871c991e00ee1d61ea9f1a1c35fa3eb667b1a.zip
Merge pull request #102 from tobiasd/master
StatusNet connector fix
-rw-r--r--addon/statusnet/statusnet.php39
1 files changed, 36 insertions, 3 deletions
diff --git a/addon/statusnet/statusnet.php b/addon/statusnet/statusnet.php
index f763cd0c3..5ed92d13a 100644
--- a/addon/statusnet/statusnet.php
+++ b/addon/statusnet/statusnet.php
@@ -98,9 +98,34 @@ function statusnet_settings_post ($a,$post) {
del_pconfig( local_user(), 'statusnet', 'baseapi' );
} else {
if (isset($_POST['statusnet-consumersecret'])) {
- set_pconfig(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
- set_pconfig(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
- set_pconfig(local_user(), 'statusnet', 'baseapi', $_POST['statusnet-baseapi']);
+ // check if we can reach the API of the StatusNet server
+ // we'll check the API Version for that, if we don't get one we'll try to fix the path but will
+ // resign quickly after this one try to fix the path ;-)
+ $apibase = $_POST['statusnet-baseapi'];
+ $f = fopen( $apibase . 'statusnet/version.xml', 'r');
+ $c = stream_get_contents($f);
+ fclose($f);
+ if (strlen($c) > 0) {
+ // ok the API path is correct, let's save the settings
+ set_pconfig(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
+ set_pconfig(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
+ set_pconfig(local_user(), 'statusnet', 'baseapi', $apibase );
+ } else {
+ // the API path is not correct, maybe missing trailing / ?
+ $apibase = $apibase . '/';
+ $f = fopen( $apibase . 'statusnet/version.xml', 'r');
+ $c = stream_get_contents($f);
+ fclose($f);
+ if (strlen($c) > 0) {
+ // ok the API path is now correct, let's save the settings
+ set_pconfig(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
+ set_pconfig(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
+ set_pconfig(local_user(), 'statusnet', 'baseapi', $apibase );
+ } else {
+ // still not the correct API base, let's do noting
+ notice( t('We could not contact the StatusNet API with the Path you entered.').EOL );
+ }
+ }
header('Location: '.$a->get_baseurl().'/settings/addon');
} else {
if (isset($_POST['statusnet-pin'])) {
@@ -133,6 +158,7 @@ function statusnet_settings(&$a,&$s) {
/***
* 1) Check that we have a base api url and a consumer key & secret
* 2) If no OAuthtoken & stuff is present, generate button to get some
+ * allow the user to cancel the connection process at this step
* 3) Checkbox for "Send public notices (respect size limitation)
*/
$api = get_pconfig(local_user(), 'statusnet', 'baseapi');
@@ -187,6 +213,13 @@ function statusnet_settings(&$a,&$s) {
$s .= '<input id="statusnet-token2" type="hidden" name="statusnet-token2" value="'.$request_token['oauth_token_secret'].'" />';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
+ $s .= '<h4>'.t('Cancel Connection Process').'</h4>';
+ $s .= '<div id="statusnet-cancel-wrapper">';
+ $s .= '<p>'.t('Current StatusNet API is').': '.$api.'</p>';
+ $s .= '<label id="statusnet-cancel-label" for="statusnet-cancel">'. t('Cancel StatusNet Connection') . '</label>';
+ $s .= '<input id="statusnet-cancel" type="checkbox" name="statusnet-disconnect" value="1" />';
+ $s .= '</div><div class="clear"></div>';
+ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
} else {
/***
* we have an OAuth key / secret pair for the user