* @hook 'logged_in'
* array $user logged user record
*/
- function api_login(&$a){
+ function api_login(App &$a){
// login with oauth
try{
$oauth = new FKOAuth1();
dbesc(trim($user)),
dbesc($encrypted)
);
- if(count($r))
+ if (dbm::is_result($r))
$record = $r[0];
}
* @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";
logger("API call duration: ".round($duration, 2)."\t".$a->query_string, LOGGER_DEBUG);
if (get_config("system", "profiler")) {
- logger(sprintf("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
+ $duration = microtime(true)-$a->performance["start"];
+
+ logger(parse_url($a->query_string, PHP_URL_PATH).": ".sprintf("Database: %s/%s, Network: %s, I/O: %s, Other: %s, Total: %s",
round($a->performance["database"] - $a->performance["database_write"], 3),
round($a->performance["database_write"], 3),
round($a->performance["network"], 2),
- round($a->performance["rendering"], 2),
- round($a->performance["parser"], 2),
round($a->performance["file"], 2),
- round($duration - $a->performance["database"]
- - $a->performance["network"] - $a->performance["rendering"]
- - $a->performance["parser"] - $a->performance["file"], 2),
+ round($duration - ($a->performance["database"] + $a->performance["network"]
+ + $a->performance["file"]), 2),
round($duration, 2)),
LOGGER_DEBUG);
if (is_null($user_info)) $user_info = api_get_user($a);
$arr['$user'] = $user_info;
$arr['$rss'] = array(
- 'alternate' => $user_info['url'],
- 'self' => App::get_baseurl(). "/". $a->query_string,
- 'base' => App::get_baseurl(),
- 'updated' => api_date(null),
+ 'alternate' => $user_info['url'],
+ 'self' => App::get_baseurl(). "/". $a->query_string,
+ 'base' => App::get_baseurl(),
+ 'updated' => api_date(null),
'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME),
- 'language' => $user_info['language'],
- 'logo' => App::get_baseurl()."/images/friendica-32.png",
+ 'language' => $user_info['language'],
+ 'logo' => App::get_baseurl()."/images/friendica-32.png",
);
return $arr;
'screen_name' => (($r[0]['nick']) ? $r[0]['nick'] : $r[0]['name']),
'location' => ($r[0]["location"] != "") ? $r[0]["location"] : $network_name,
'description' => $r[0]["about"],
- 'profile_image_url' => $r[0]["photo"],
- 'profile_image_url_https' => $r[0]["photo"],
+ 'profile_image_url' => $r[0]["micro"],
+ 'profile_image_url_https' => $r[0]["micro"],
'url' => $r[0]["url"],
'protected' => false,
'followers_count' => 0,
// count friends
$r = q("SELECT count(*) as `count` FROM `contact`
WHERE `uid` = %d AND `rel` IN ( %d, %d )
- AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0",
+ AND `self`=0 AND NOT `blocked` AND `hidden`=0",
intval($uinfo[0]['uid']),
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND)
$r = q("SELECT count(*) as `count` FROM `contact`
WHERE `uid` = %d AND `rel` IN ( %d, %d )
- AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0",
+ AND `self`=0 AND NOT `blocked` AND `hidden`=0",
intval($uinfo[0]['uid']),
intval(CONTACT_IS_FOLLOWER),
intval(CONTACT_IS_FRIEND)
if (isset($_GET["q"])) {
$r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));
- if (!count($r))
+ if (!dbm::is_result($r))
$r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"]));
- if (count($r)) {
+ if (dbm::is_result($r)) {
$k = 0;
foreach ($r AS $user) {
$user_info = api_get_user($a, $user["id"], "json");
`contact`.`id` AS `cid`
FROM `item`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
+ AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `item`.`uid` = %d AND `verb` = '%s'
AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted`
$sql_extra
`user`.`nickname`, `user`.`hidewall`
FROM `item`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
+ AND (NOT `contact`.`blocked` OR `contact`.`pending`)
STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid`
AND NOT `user`.`hidewall`
WHERE `verb` = '%s' AND `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
`contact`.`id` AS `cid`
FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
+ AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted`
AND `item`.`uid` = %d AND `item`.`verb` = '%s'
$sql_extra",
`contact`.`id` AS `cid`
FROM `item`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
+ AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `item`.`parent` = %d AND `item`.`visible`
AND NOT `item`.`moderated` AND NOT `item`.`deleted`
AND `item`.`uid` = %d AND `item`.`verb` = '%s'
`contact`.`id` AS `cid`
FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
+ AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted`
AND NOT `item`.`private` AND `item`.`allow_cid` = '' AND `item`.`allow`.`gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
`contact`.`id` AS `cid`
FROM `item` FORCE INDEX (`uid_id`)
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
+ AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `item`.`uid` = %d AND `verb` = '%s'
AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s'))
AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted`
`contact`.`id` AS `cid`
FROM `item` FORCE INDEX (`uid_contactid_id`)
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
- AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
+ AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `item`.`uid` = %d AND `verb` = '%s'
AND `item`.`contact-id` = %d
AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted`
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
AND `item`.`starred` = 1
AND `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND (NOT `contact`.`blocked` OR `contact`.`pending`)
$sql_extra
AND `item`.`id`>%d
ORDER BY `item`.`id` DESC LIMIT %d ,%d ",
'religion' => $profile['religion'],
'public_keywords' => $profile['pub_keywords'],
'private_keywords' => $profile['prv_keywords'],
- 'likes' => bbcode(api_clean_plain_items($profile['likes']), false, false, 2, true),
- 'dislikes' => bbcode(api_clean_plain_items($profile['dislikes']), false, false, 2, true),
- 'about' => bbcode(api_clean_plain_items($profile['about']), false, false, 2, true),
- 'music' => bbcode(api_clean_plain_items($profile['music']), false, false, 2, true),
- 'book' => bbcode(api_clean_plain_items($profile['book']), false, false, 2, true),
- 'tv' => bbcode(api_clean_plain_items($profile['tv']), false, false, 2, true),
- 'film' => bbcode(api_clean_plain_items($profile['film']), false, false, 2, true),
- 'interest' => bbcode(api_clean_plain_items($profile['interest']), false, false, 2, true),
- 'romance' => bbcode(api_clean_plain_items($profile['romance']), false, false, 2, true),
- 'work' => bbcode(api_clean_plain_items($profile['work']), false, false, 2, true),
- 'education' => bbcode(api_clean_plain_items($profile['education']), false, false, 2, true),
- 'social_networks' => bbcode(api_clean_plain_items($profile['contact']), false, false, 2, true),
+ 'likes' => bbcode(api_clean_plain_items($profile['likes']), false, false, 2, false),
+ 'dislikes' => bbcode(api_clean_plain_items($profile['dislikes']), false, false, 2, false),
+ 'about' => bbcode(api_clean_plain_items($profile['about']), false, false, 2, false),
+ 'music' => bbcode(api_clean_plain_items($profile['music']), false, false, 2, false),
+ 'book' => bbcode(api_clean_plain_items($profile['book']), false, false, 2, false),
+ 'tv' => bbcode(api_clean_plain_items($profile['tv']), false, false, 2, false),
+ 'film' => bbcode(api_clean_plain_items($profile['film']), false, false, 2, false),
+ 'interest' => bbcode(api_clean_plain_items($profile['interest']), false, false, 2, false),
+ 'romance' => bbcode(api_clean_plain_items($profile['romance']), false, false, 2, false),
+ 'work' => bbcode(api_clean_plain_items($profile['work']), false, false, 2, false),
+ 'education' => bbcode(api_clean_plain_items($profile['education']), false, false, 2, false),
+ 'social_networks' => bbcode(api_clean_plain_items($profile['contact']), false, false, 2, false),
'homepage' => $profile['homepage'],
'users' => null);
return $profile;
if ($user_info['self'] == 0)
$sql_extra = " AND false ";
- $r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra",
+ $r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND NOT `self` AND (NOT `blocked` OR `pending`) $sql_extra",
intval(api_user())
);
intval(api_user())
);
- if(!dbm::is_result($r))
+ if (!dbm::is_result($r))
return;
$ids = array();
intval(api_user())
);
- if ((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
+ if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
throw new BadRequestException("Unknown contact");
$cid = $r[0]['id'];
intval($uid),
intval($gid));
// error message if specified gid is not in database
- if (count($r) == 0)
+ if (!dbm::is_result($r))
throw new BadRequestException("gid not available");
}
else
intval($uid),
intval($gid));
// error message if specified gid is not in database
- if (count($r) == 0)
+ if (!dbm::is_result($r))
throw new BadRequestException('gid not available');
// get data of the specified group id and group name
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
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
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
$profile_url = $user_info["url"];
// message if nothing was found
- if (count($r) == 0)
+ if (!dbm::is_result($r))
+ $success = array('success' => false, 'search_results' => 'problem with query');
+ else if (count($r) == 0)
$success = array('success' => false, 'search_results' => 'nothing found');
else {
$ret = Array();
}
api_register_func('api/friendica/direct_messages_search', 'api_friendica_direct_messages_search', true);
-
/**
* @brief return data of all the profiles a user has to the client
*
intval(api_user()),
intval($profileid));
// error message if specified gid is not in database
- if (count($r) == 0)
+ if (!dbm::is_result($r))
throw new BadRequestException("profile_id not available");
}
else