Merge pull request #105 from tobiasd/master
added pre configured StatusNet support
This commit is contained in:
commit
452cb52232
1 changed files with 104 additions and 64 deletions
|
@ -97,6 +97,28 @@ function statusnet_settings_post ($a,$post) {
|
||||||
del_pconfig( local_user(), 'statusnet', 'oauthtoken' );
|
del_pconfig( local_user(), 'statusnet', 'oauthtoken' );
|
||||||
del_pconfig( local_user(), 'statusnet', 'oauthsecret' );
|
del_pconfig( local_user(), 'statusnet', 'oauthsecret' );
|
||||||
del_pconfig( local_user(), 'statusnet', 'baseapi' );
|
del_pconfig( local_user(), 'statusnet', 'baseapi' );
|
||||||
|
} else {
|
||||||
|
if (isset($_POST['statusnet-preconf-apiurl'])) {
|
||||||
|
/***
|
||||||
|
* If the user used one of the preconfigured StatusNet server credentials
|
||||||
|
* use them. All the data are available in the global config.
|
||||||
|
* Check the API Url never the less and blame the admin if it's not working ^^
|
||||||
|
*/
|
||||||
|
$globalsn = get_config('statusnet', 'sites');
|
||||||
|
foreach ( $globalsn as $asn) {
|
||||||
|
if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl'] ) {
|
||||||
|
$apibase = $asn['apiurl'];
|
||||||
|
$c = fetch_url( $apibase . 'statusnet/version.xml' );
|
||||||
|
if (strlen($c) > 0) {
|
||||||
|
set_pconfig(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey'] );
|
||||||
|
set_pconfig(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret'] );
|
||||||
|
set_pconfig(local_user(), 'statusnet', 'baseapi', $asn['apiurl'] );
|
||||||
|
} else {
|
||||||
|
notice( t('Please contact your site administrator.<br />The provided API URL is not valid.').EOL.$asn['apiurl'].EOL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
goaway($a->get_baseurl().'/settings/addon');
|
||||||
} else {
|
} else {
|
||||||
if (isset($_POST['statusnet-consumersecret'])) {
|
if (isset($_POST['statusnet-consumersecret'])) {
|
||||||
// check if we can reach the API of the StatusNet server
|
// check if we can reach the API of the StatusNet server
|
||||||
|
@ -148,7 +170,7 @@ function statusnet_settings_post ($a,$post) {
|
||||||
set_pconfig(local_user(),'statusnet','post',intval($_POST['statusnet-enable']));
|
set_pconfig(local_user(),'statusnet','post',intval($_POST['statusnet-enable']));
|
||||||
set_pconfig(local_user(),'statusnet','post_by_default',intval($_POST['statusnet-default']));
|
set_pconfig(local_user(),'statusnet','post_by_default',intval($_POST['statusnet-default']));
|
||||||
notice( t('StatusNet settings updated.') . EOL);
|
notice( t('StatusNet settings updated.') . EOL);
|
||||||
}}}
|
}}}}
|
||||||
}
|
}
|
||||||
function statusnet_settings(&$a,&$s) {
|
function statusnet_settings(&$a,&$s) {
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
|
@ -176,17 +198,35 @@ function statusnet_settings(&$a,&$s) {
|
||||||
/***
|
/***
|
||||||
* no consumer keys
|
* no consumer keys
|
||||||
*/
|
*/
|
||||||
|
$globalsn = get_config('statusnet', 'sites');
|
||||||
|
/***
|
||||||
|
* lets check if we have one or more globally configured StatusNet
|
||||||
|
* server OAuth credentials in the configuration. If so offer them
|
||||||
|
* with a little explanation to the user as choice - otherwise
|
||||||
|
* ignore this option entirely.
|
||||||
|
*/
|
||||||
|
if (! $globalsn == null) {
|
||||||
|
$s .= '<h4>' . t('Globally Available StatusNet OAuthKeys') . '</h4>';
|
||||||
|
$s .= '<p>'. t('There are preconfigured OAuth key pairs for some StatusNet servers available. If you are useing one of them, please use these credentials. If not feel free to connect to any other StatusNet instance (see below).') .'</p>';
|
||||||
|
$s .= '<div id="statusnet-preconf-wrapper">';
|
||||||
|
foreach ($globalsn as $asn) {
|
||||||
|
$s .= '<input type="radio" name="statusnet-preconf-apiurl" value="'. $asn['apiurl'] .'">'. $asn['sitename'] .'<br />';
|
||||||
|
}
|
||||||
|
$s .= '<p></p><div class="clear"></div></div>';
|
||||||
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||||
|
}
|
||||||
|
$s .= '<h4>' . t('Provide your own OAuth Credentials') . '</h4>';
|
||||||
$s .= '<p>'. t('No consumer key pair for StatusNet found. Register your Friendika Account as an desktop client on your StatusNet account, copy the consumer key pair here and enter the API base root.<br />Before you register your own OAuth key pair ask the administrator if there is already a key pair for this Friendika installation at your favorited StatusNet installation.') .'</p>';
|
$s .= '<p>'. t('No consumer key pair for StatusNet found. Register your Friendika Account as an desktop client on your StatusNet account, copy the consumer key pair here and enter the API base root.<br />Before you register your own OAuth key pair ask the administrator if there is already a key pair for this Friendika installation at your favorited StatusNet installation.') .'</p>';
|
||||||
$s .= '<div id="statusnet-consumer-wrapper">';
|
$s .= '<div id="statusnet-consumer-wrapper">';
|
||||||
$s .= '<label id="statusnet-consumerkey-label" for="statusnet-consumerkey">'. t('OAuth Consumer Key') .'</label>';
|
$s .= '<label id="statusnet-consumerkey-label" for="statusnet-consumerkey">'. t('OAuth Consumer Key') .'</label>';
|
||||||
$s .= '<input id="statusnet-consumerkey" type="text" name="statusnet-consumerkey" size="35" />';
|
$s .= '<input id="statusnet-consumerkey" type="text" name="statusnet-consumerkey" size="35" /><br />';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
$s .= '<label id="statusnet-consumersecret-label" for="statusnet-consumersecret">'. t('OAuth Consumer Secret') .'</label>';
|
$s .= '<label id="statusnet-consumersecret-label" for="statusnet-consumersecret">'. t('OAuth Consumer Secret') .'</label>';
|
||||||
$s .= '<input id="statusnet-consumersecret" type="text" name="statusnet-consumersecret" size="35" />';
|
$s .= '<input id="statusnet-consumersecret" type="text" name="statusnet-consumersecret" size="35" /><br />';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
$s .= '<label id="statusnet-baseapi-label" for="statusnet-baseapi">'. t("Base API Path \x28remember the trailing /\x29") .'</label>';
|
$s .= '<label id="statusnet-baseapi-label" for="statusnet-baseapi">'. t("Base API Path \x28remember the trailing /\x29") .'</label>';
|
||||||
$s .= '<input id="statusnet-baseapi" type="text" name="statusnet-baseapi" size="35" />';
|
$s .= '<input id="statusnet-baseapi" type="text" name="statusnet-baseapi" size="35" /><br />';
|
||||||
$s .= '<div class="clear"></div></div>';
|
$s .= '<p></p><div class="clear"></div></div>';
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
|
||||||
} else {
|
} else {
|
||||||
/***
|
/***
|
||||||
|
|
Loading…
Reference in a new issue