Avoid some notices in the statusnet addon
[friendica-addons.git/.git] / statusnet / statusnet.php
index 274a6ab..bc4ef36 100644 (file)
@@ -164,7 +164,7 @@ function statusnet_settings_post(App $a, $post)
                                        }
                                }
                        }
-                       System::redirect('settings/connectors');
+                       $a->internalRedirect('settings/connectors');
                } else {
                        if (isset($_POST['statusnet-consumersecret'])) {
                                //  check if we can reach the API of the GNU Social server
@@ -192,7 +192,7 @@ function statusnet_settings_post(App $a, $post)
                                                notice(L10n::t('We could not contact the GNU Social API with the Path you entered.') . EOL);
                                        }
                                }
-                               System::redirect('settings/connectors');
+                               $a->internalRedirect('settings/connectors');
                        } else {
                                if (isset($_POST['statusnet-pin'])) {
                                        //  if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen
@@ -210,7 +210,7 @@ function statusnet_settings_post(App $a, $post)
                                        PConfig::set(local_user(), 'statusnet', 'post', 1);
                                        PConfig::set(local_user(), 'statusnet', 'post_taglinks', 1);
                                        //  reload the Addon Settings page, if we don't do it see Bug #42
-                                       System::redirect('settings/connectors');
+                                       $a->internalRedirect('settings/connectors');
                                } else {
                                        //  if no PIN is supplied in the POST variables, the user has changed the setting
                                        //  to post a dent for every new __public__ posting to the wall
@@ -938,7 +938,7 @@ function statusnet_address($contact)
 
 function statusnet_fetch_contact($uid, $contact, $create_user)
 {
-       if ($contact->statusnet_profile_url == "") {
+       if (empty($contact->statusnet_profile_url)) {
                return -1;
        }
 
@@ -1255,6 +1255,10 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
 
        $own_contact = statusnet_fetch_own_contact($a, $uid);
 
+       if (empty($own_contact)) {
+               return;
+       }
+
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                intval($own_contact),
                intval($uid));
@@ -1560,6 +1564,10 @@ function statusnet_fetch_own_contact(App $a, $uid)
                // Fetching user data
                $user = $connection->get('account/verify_credentials');
 
+               if (empty($user)) {
+                       return false;
+               }
+
                PConfig::set($uid, 'statusnet', 'own_url', Strings::normaliseLink($user->statusnet_profile_url));
 
                $contact_id = statusnet_fetch_contact($uid, $user, true);