From: Michael Vogel Date: Sat, 18 Jan 2014 21:06:41 +0000 (+0100) Subject: Diaspora: Check for credentials in the setup. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e28b559bfca1430b05b267d32d64c5b9865f8660;p=friendica-addons.git Diaspora: Check for credentials in the setup. --- diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index 09262d83..ef8ff51b 100755 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -107,66 +107,84 @@ function diaspora_queue_hook(&$a,&$b) { function diaspora_settings(&$a,&$s) { - if(! local_user()) - return; + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ - /* Add our stylesheet to the page so we can make our settings look nice */ + $a->page['htmlhead'] .= '' . "\r\n"; - $a->page['htmlhead'] .= '' . "\r\n"; + /* Get the current state of our config variables */ - /* Get the current state of our config variables */ + $enabled = get_pconfig(local_user(),'diaspora','post'); - $enabled = get_pconfig(local_user(),'diaspora','post'); + $checked = (($enabled) ? ' checked="checked" ' : ''); - $checked = (($enabled) ? ' checked="checked" ' : ''); + $def_enabled = get_pconfig(local_user(),'diaspora','post_by_default'); - $def_enabled = get_pconfig(local_user(),'diaspora','post_by_default'); + $def_checked = (($def_enabled) ? ' checked="checked" ' : ''); - $def_checked = (($def_enabled) ? ' checked="checked" ' : ''); + $diaspora_username = get_pconfig(local_user(), 'diaspora', 'diaspora_username'); + $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"); - $diaspora_username = get_pconfig(local_user(), 'diaspora', 'diaspora_username'); - $diaspora_password = get_pconfig(local_user(), 'diaspora', 'diaspora_password'); - $diaspora_url = get_pconfig(local_user(), 'diaspora', 'diaspora_url'); + $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 */ - /* Add some HTML to the existing form */ + $s .= ''; + $s .= '

' . t('Diaspora') . '

'; + $s .= '
'; + $s .= ''; }