]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Central item expiration routine for external items
[friendica.git] / include / api.php
index d4bd5de9e85dd340e3b64ba286414d9887720508..64afa8c14833f7a68814babbc3f1f1b84d5ab3da 100644 (file)
@@ -6,7 +6,8 @@
  * @todo Automatically detect if incoming data is HTML or BBCode
  */
 
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
 
 require_once 'include/HTTPExceptions.php';
 require_once 'include/bbcode.php';
@@ -455,10 +456,13 @@ $called_api = null;
         *              Contact url or False if contact id is unknown
         */
        function api_unique_id_to_url($id) {
-               $r = q("SELECT `url` FROM `contact` WHERE `uid` = 0 AND `id` = %d LIMIT 1",
-                       intval($id));
+               $r = dba::select('contact', array('url'), array('uid' => 0, 'id' => $id), array('limit' => 1));
 
-               return (dbm::is_result($r) && $r[0]["url"]);
+               if (dbm::is_result($r)) {
+                       return $r["url"];
+               } else {
+                       return false;
+               }
        }
 
        /**
@@ -525,6 +529,15 @@ $called_api = null;
                        }
                }
 
+               if (is_null($user) && x($_GET, 'profileurl')) {
+                       $user = dbesc(normalise_link($_GET['profileurl']));
+                       $nick = $user;
+                       $extra_query = "AND `contact`.`nurl` = '%s' ";
+                       if (api_user() !== false) {
+                               $extra_query .= "AND `contact`.`uid`=".intval(api_user());
+                       }
+               }
+
                if (is_null($user) AND ($a->argc > (count($called_api) - 1)) AND (count($called_api) > 0)) {
                        $argid = count($called_api);
                        list($user, $null) = explode(".", $a->argv[$argid]);
@@ -1400,6 +1413,7 @@ $called_api = null;
 
        /// @TODO move to top of file or somewhere better
        api_register_func('api/users/show','api_users_show');
+       api_register_func('api/externalprofile/show','api_users_show');
 
        function api_users_search($type) {
 
@@ -3016,8 +3030,9 @@ $called_api = null;
                        api_best_nickname($r);
 
                        $recipient = api_get_user($a, $r[0]['nurl']);
-               } else
+               } else {
                        $recipient = api_get_user($a, $_POST['user_id']);
+               }
 
                $replyto = '';
                $sub     = '';