Diaspora: Check for credentials in the setup.

This commit is contained in:
Michael Vogel 2014-01-18 22:06:41 +01:00
parent 21f3adb911
commit e28b559bfc

View file

@ -128,6 +128,18 @@ function diaspora_settings(&$a,&$s) {
$diaspora_password = get_pconfig(local_user(), 'diaspora', 'diaspora_password');
$diaspora_url = get_pconfig(local_user(), 'diaspora', 'diaspora_url');
$status = "";
if ($diaspora_username AND $diaspora_password AND $diaspora_url) {
try {
require_once("addon/diaspora/diasphp.php");
$conn = new Diasphp($diaspora_url);
$conn->login($diaspora_username, $diaspora_password);
} catch (Exception $e) {
$status = t("Can't login to your Diaspora account. Please check username and password and ensure you used the complete address (including http...)");
}
}
/* Add some HTML to the existing form */
@ -139,6 +151,12 @@ function diaspora_settings(&$a,&$s) {
$s .= '<h3>' . t('Diaspora') . '</h3>';
$s .= '</span>';
if ($status) {
$s .= '<div id="diaspora-status-wrapper"><strong>';
$s .= $status;
$s .= '</strong></div><div class="clear"></div>';
}
$s .= '<div id="diaspora-enable-wrapper">';
$s .= '<label id="diaspora-enable-label" for="diaspora-checkbox">' . t('Enable Diaspora Post Plugin') . '</label>';
$s .= '<input id="diaspora-checkbox" type="checkbox" name="diaspora" value="1" ' . $checked . '/>';