]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Merge branch 'develop' into improvement/move-app-to-src-2
[friendica.git] / include / api.php
index 1705374bbb55371dc7ff673523fbbf663f434460..fc38f1bc80198329a28e2a1044eae3062b58c1cc 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';
@@ -525,6 +526,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]);
@@ -770,7 +780,11 @@ $called_api = null;
                                                ($item["deny_gid"] != "") OR
                                                $item["private"]);
 
-               $owner_user = api_get_user($a, $item["owner-link"]);
+               if ($item['thr-parent'] == $item['uri']) {
+                       $owner_user = api_get_user($a, $item["owner-link"]);
+               } else {
+                       $owner_user = $status_user;
+               }
 
                return (array($status_user, $owner_user));
        }
@@ -1396,6 +1410,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) {
 
@@ -3279,7 +3294,7 @@ $called_api = null;
 
                $r = q("SELECT `resource-id`, MAX(`scale`) AS `scale`, `album`, `filename`, `type`
                                FROM `photo`
-                               WHERE `uid` = %d AND `album` != 'Contact Photos' GROUP BY `resource-id`",
+                               WHERE `uid` = %d AND `album` != 'Contact Photos' GROUP BY `resource-id`, `album`, `filename`, `type`",
                        intval(local_user())
                );
                $typetoext = array(
@@ -3316,12 +3331,15 @@ $called_api = null;
                }
 
                $scale = (x($_REQUEST, 'scale') ? intval($_REQUEST['scale']) : false);
-               $scale_sql = ($scale === false ? "" : sprintf("and scale=%d", intval($scale)));
-               $data_sql = ($scale === false ? "" : "data, ");
-
-               $r = q("SELECT %s `resource-id`, `created`, `edited`, `title`, `desc`, `album`, `filename`,
-                                               `type`, `height`, `width`, `datasize`, `profile`, MIN(`scale`) AS `minscale`, MAX(`scale`) AS `maxscale`
-                               FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' %s GROUP BY `resource-id`",
+               $scale_sql = ($scale === false ? "" : sprintf("AND `scale`=%d",intval($scale)));
+               $data_sql = ($scale === false ? "" : "ANY_VALUE(`data`) AS data`,");
+
+               $r = q("SELECT %s ANY_VALUE(`resource-id`) AS `resource-id`, ANY_VALUE(`created`) AS `created`,
+                               ANY_VALUE(`edited`) AS `edited`, ANY_VALUE(`title`) AS `title`, ANY_VALUE(`desc`) AS `desc`,
+                               ANY_VALUE(`album`) AS `album`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`,
+                               ANY_VALUE(`height`) AS `height`, ANY_VALUE(`width`) AS `width`, ANY_VALUE(`datasize`) AS `datasize`,
+                               ANY_VALUE(`profile`) AS `profile`, min(`scale`) as minscale, max(`scale`) as maxscale
+                               FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' %s",
                        $data_sql,
                        intval(local_user()),
                        dbesc($_REQUEST['photo_id']),