X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fapi.php;h=64a896b55498e2579e475225c08e5d385bfcd8f2;hb=0c310db23d253e489c27b80f99aeaaa06275fea6;hp=2ae1aeaa026e25e9f8c7fbca5b7d0bb61ec4aa79;hpb=cc16369b6f45eff2c0faa91bda96ae619f9f80e4;p=friendica.git diff --git a/include/api.php b/include/api.php index 2ae1aeaa02..64a896b554 100644 --- a/include/api.php +++ b/include/api.php @@ -133,7 +133,7 @@ * @hook 'logged_in' * array $user logged user record */ - function api_login(&$a){ + function api_login(App $a){ // login with oauth try{ $oauth = new FKOAuth1(); @@ -251,8 +251,8 @@ * @param App $a * @return string API call result */ - function api_call(&$a){ - GLOBAL $API, $called_api; + function api_call(App $a){ + global $API, $called_api; $type="json"; if (strpos($a->query_string, ".xml")>0) $type="xml"; @@ -404,7 +404,7 @@ * @param array $user_info * @return array */ - function api_rss_extra(&$a, $arr, $user_info){ + function api_rss_extra(App $a, $arr, $user_info){ if (is_null($user_info)) $user_info = api_get_user($a); $arr['$user'] = $user_info; $arr['$rss'] = array( @@ -444,7 +444,7 @@ * @param int|string $contact_id Contact ID or URL * @param string $type Return type (for errors) */ - function api_get_user(&$a, $contact_id = Null, $type = "json"){ + function api_get_user(App $a, $contact_id = Null, $type = "json"){ global $called_api; $user = null; $extra_query = ""; @@ -712,7 +712,7 @@ * @param array $item : item from db * @return array(array:author, array:owner) */ - function api_item_get_user(&$a, $item) { + function api_item_get_user(App $a, $item) { $status_user = api_get_user($a, $item["author-link"]); @@ -2344,6 +2344,9 @@ * dislikes => int count */ function api_format_items_activities(&$item, $type = "json") { + + $a = get_app(); + $activities = array( 'like' => array(), 'dislike' => array(), @@ -2451,7 +2454,7 @@ 'homepage' => $profile['homepage'], 'users' => null); return $profile; - } + } } /** @@ -2521,9 +2524,9 @@ // Retweets are only valid for top postings // It doesn't work reliable with the link if its a feed - #$IsRetweet = ($item['owner-link'] != $item['author-link']); - #if ($IsRetweet) - # $IsRetweet = (($item['owner-name'] != $item['author-name']) OR ($item['owner-avatar'] != $item['author-avatar'])); + //$IsRetweet = ($item['owner-link'] != $item['author-link']); + //if ($IsRetweet) + // $IsRetweet = (($item['owner-name'] != $item['author-name']) OR ($item['owner-avatar'] != $item['author-avatar'])); if ($item["id"] == $item["parent"]) { @@ -2874,14 +2877,14 @@ // BadRequestException if no id specified (for clients using Twitter API) if ($id == 0) throw new BadRequestException('Message id not specified'); - // add parent-uri to sql command if specified by calling app + // add parent-uri to sql command if specified by calling app $sql_extra = ($parenturi != "" ? " AND `parent-uri` = '" . dbesc($parenturi) . "'" : ""); // get data of the specified message id $r = q("SELECT `id` FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra, - intval($uid), + intval($uid), intval($id)); - + // error message if specified id is not in database if (!dbm::is_result($r)) { if ($verbose == "true") { @@ -2893,8 +2896,8 @@ } // delete message - $result = q("DELETE FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra, - intval($uid), + $result = q("DELETE FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra, + intval($uid), intval($id)); if ($verbose == "true") { @@ -3068,8 +3071,8 @@ 'image/gif' => 'gif' ); $data = array('photo'=>array()); - if($r) { - foreach($r as $rr) { + if ($r) { + foreach ($r as $rr) { $photo = array(); $photo['id'] = $rr['resource-id']; $photo['album'] = $rr['album']; @@ -3218,7 +3221,7 @@ function api_share_as_retweet(&$item) { $body = trim($item["body"]); - if (diaspora::is_reshare($body, false)===false) { + if (Diaspora::is_reshare($body, false)===false) { return false; } @@ -3590,7 +3593,7 @@ intval($gid), dbesc($name)); // error message if specified gid is not in database - if (count($rname) == 0) + if (!dbm::is_result($rname)) throw new BadRequestException('wrong group name'); // delete group @@ -3629,7 +3632,7 @@ intval($uid), dbesc($name)); // error message if specified group name already exists - if (count($rname) != 0) + if (dbm::is_result($rname)) throw new BadRequestException('group name already exists'); // check if specified group name is a deleted group @@ -3637,7 +3640,7 @@ intval($uid), dbesc($name)); // error message if specified group name already exists - if (count($rname) != 0) + if (dbm::is_result($rname)) $reactivate_group = true; // create group @@ -3860,7 +3863,7 @@ // get data of the specified message id $r = q("SELECT `id` FROM `mail` WHERE `id` = %d AND `uid` = %d", - intval($id), + intval($id), intval($uid)); // error message if specified id is not in database if (!dbm::is_result($r)) { @@ -3869,8 +3872,8 @@ } // update seen indicator - $result = q("UPDATE `mail` SET `seen` = 1 WHERE `id` = %d AND `uid` = %d", - intval($id), + $result = q("UPDATE `mail` SET `seen` = 1 WHERE `id` = %d AND `uid` = %d", + intval($id), intval($uid)); if ($result) { @@ -3921,7 +3924,7 @@ // message if nothing was found if (!dbm::is_result($r)) $success = array('success' => false, 'search_results' => 'problem with query'); - else if (count($r) == 0) + else if (count($r) == 0) $success = array('success' => false, 'search_results' => 'nothing found'); else { $ret = Array();