X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fapi.php;h=a7d8ab3ca3a3af8fec7c6b19190f3b41c21473f4;hb=535ae04613d8b8dc673131ddb2788d9a0c478a1c;hp=e50bc92a8ee1ba356fc586d73bc4bb106ce52fa6;hpb=dad58e0f6fdff5e1ff8a002bb31119a38f08268b;p=friendica.git
diff --git a/include/api.php b/include/api.php
index e50bc92a8e..a7d8ab3ca3 100644
--- a/include/api.php
+++ b/include/api.php
@@ -40,7 +40,6 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\XML;
-require_once 'include/bbcode.php';
require_once 'include/conversation.php';
require_once 'include/html2plain.php';
require_once 'mod/share.php';
@@ -1610,6 +1609,7 @@ api_register_func('api/users/lookup', 'api_users_lookup', true);
function api_search($type)
{
$data = [];
+ $sql_extra = '';
if (!x($_REQUEST, 'q')) {
throw new BadRequestException("q parameter is required.");
@@ -1791,6 +1791,7 @@ function api_statuses_public_timeline($type)
$conversation_id = (x($_REQUEST, 'conversation_id') ? $_REQUEST['conversation_id'] : 0);
$start = $page * $count;
+ $sql_extra = '';
if ($exclude_replies && !$conversation_id) {
if ($max_id > 0) {
@@ -2147,7 +2148,6 @@ function api_statuses_repeat($type)
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` = ''
- $sql_extra
AND `item`.`id`=%d",
intval($id)
);
@@ -2218,7 +2218,7 @@ function api_statuses_destroy($type)
$ret = api_statuses_show($type);
- Item::delete($id);
+ Item::deleteById($id);
return $ret;
}
@@ -2267,8 +2267,10 @@ function api_statuses_mentions($type)
$myurl = substr($myurl, strpos($myurl, '://') + 3);
$myurl = str_replace('www.', '', $myurl);
+ $sql_extra = '';
+
if ($max_id > 0) {
- $sql_extra = ' AND `item`.`id` <= ' . intval($max_id);
+ $sql_extra .= ' AND `item`.`id` <= ' . intval($max_id);
}
$r = q(
@@ -2459,9 +2461,7 @@ function api_favorites_create_destroy($type)
throw new BadRequestException("Invalid action ".$action);
}
- $r = q("UPDATE item SET starred=%d WHERE id=%d AND uid=%d", $item[0]['starred'], $itemid, api_user());
-
- q("UPDATE thread SET starred=%d WHERE iid=%d AND uid=%d", $item[0]['starred'], $itemid, api_user());
+ $r = Item::update(['starred' => $item[0]['starred']], ['id' => $itemid]);
if ($r === false) {
throw new InternalServerErrorException("DB error");
@@ -2603,13 +2603,12 @@ function api_format_messages($item, $recipient, $sender)
if (x($_GET, 'getText')) {
$ret['title'] = $item['title'];
if ($_GET['getText'] == 'html') {
- $ret['text'] = bbcode($item['body'], false, false);
+ $ret['text'] = BBCode::convert($item['body'], false);
} elseif ($_GET['getText'] == 'plain') {
- //$ret['text'] = html2plain(bbcode($item['body'], false, false, true), 0);
- $ret['text'] = trim(html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 2, true), 0));
+ $ret['text'] = trim(html2plain(BBCode::convert(api_clean_plain_items($item['body']), false, 2, true), 0));
}
} else {
- $ret['text'] = $item['title'] . "\n" . html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 2, true), 0);
+ $ret['text'] = $item['title'] . "\n" . html2plain(BBCode::convert(api_clean_plain_items($item['body']), false, 2, true), 0);
}
if (x($_GET, 'getUserObjects') && $_GET['getUserObjects'] == 'false') {
unset($ret['sender']);
@@ -2631,7 +2630,7 @@ function api_convert_item($item)
$attachments = api_get_attachments($body);
// Workaround for ostatus messages where the title is identically to the body
- $html = bbcode(api_clean_plain_items($body), false, false, 2, true);
+ $html = BBCode::convert(api_clean_plain_items($body), false, 2, true);
$statusbody = trim(html2plain($html, 0));
// handle data: images
@@ -2649,7 +2648,7 @@ function api_convert_item($item)
$statustext = substr($statustext, 0, 1000)."... \n".$item["plink"];
}
- $statushtml = trim(bbcode($body, false, false));
+ $statushtml = BBCode::convert(api_clean_attachments($body), false);
// Workaround for clients with limited HTML parser functionality
$search = ["
", "
", "
",
@@ -2663,7 +2662,7 @@ function api_convert_item($item)
$statushtml = str_replace($search, $replace, $statushtml);
if ($item['title'] != "") {
- $statushtml = "
" . bbcode($item['title']) . "
" . $statushtml;
+ $statushtml = "
" . BBCode::convert($item['title']) . "
" . $statushtml;
}
do {
@@ -2681,7 +2680,7 @@ function api_convert_item($item)
// feeds without body should contain the link
if (($item['network'] == NETWORK_FEED) && (strlen($item['body']) == 0)) {
- $statushtml .= bbcode($item['plink']);
+ $statushtml .= BBCode::convert($item['plink']);
}
$entities = api_get_entitities($statustext, $body);
@@ -2753,7 +2752,7 @@ function api_get_entitities(&$text, $bbcode)
return [];
}
- $bbcode = bb_CleanPictureLinks($bbcode);
+ $bbcode = BBCode::cleanPictureLinks($bbcode);
// Change pure links in text to bbcode uris
$bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
@@ -2936,7 +2935,7 @@ function api_contactlink_to_array($txt)
];
} else {
$res = [
- 'name' => $text,
+ 'name' => $txt,
'url' => ""
];
}
@@ -3052,18 +3051,18 @@ function api_format_items_profiles($profile_row)
'religion' => $profile_row['religion'],
'public_keywords' => $profile_row['pub_keywords'],
'private_keywords' => $profile_row['prv_keywords'],
- 'likes' => bbcode(api_clean_plain_items($profile_row['likes']) , false, false, 2, false),
- 'dislikes' => bbcode(api_clean_plain_items($profile_row['dislikes']) , false, false, 2, false),
- 'about' => bbcode(api_clean_plain_items($profile_row['about']) , false, false, 2, false),
- 'music' => bbcode(api_clean_plain_items($profile_row['music']) , false, false, 2, false),
- 'book' => bbcode(api_clean_plain_items($profile_row['book']) , false, false, 2, false),
- 'tv' => bbcode(api_clean_plain_items($profile_row['tv']) , false, false, 2, false),
- 'film' => bbcode(api_clean_plain_items($profile_row['film']) , false, false, 2, false),
- 'interest' => bbcode(api_clean_plain_items($profile_row['interest']) , false, false, 2, false),
- 'romance' => bbcode(api_clean_plain_items($profile_row['romance']) , false, false, 2, false),
- 'work' => bbcode(api_clean_plain_items($profile_row['work']) , false, false, 2, false),
- 'education' => bbcode(api_clean_plain_items($profile_row['education']), false, false, 2, false),
- 'social_networks' => bbcode(api_clean_plain_items($profile_row['contact']) , false, false, 2, false),
+ 'likes' => BBCode::convert(api_clean_plain_items($profile_row['likes']) , false, 2),
+ 'dislikes' => BBCode::convert(api_clean_plain_items($profile_row['dislikes']) , false, 2),
+ 'about' => BBCode::convert(api_clean_plain_items($profile_row['about']) , false, 2),
+ 'music' => BBCode::convert(api_clean_plain_items($profile_row['music']) , false, 2),
+ 'book' => BBCode::convert(api_clean_plain_items($profile_row['book']) , false, 2),
+ 'tv' => BBCode::convert(api_clean_plain_items($profile_row['tv']) , false, 2),
+ 'film' => BBCode::convert(api_clean_plain_items($profile_row['film']) , false, 2),
+ 'interest' => BBCode::convert(api_clean_plain_items($profile_row['interest']) , false, 2),
+ 'romance' => BBCode::convert(api_clean_plain_items($profile_row['romance']) , false, 2),
+ 'work' => BBCode::convert(api_clean_plain_items($profile_row['work']) , false, 2),
+ 'education' => BBCode::convert(api_clean_plain_items($profile_row['education']), false, 2),
+ 'social_networks' => BBCode::convert(api_clean_plain_items($profile_row['contact']) , false, 2),
'homepage' => $profile_row['homepage'],
'users' => null
];
@@ -3536,6 +3535,8 @@ function api_ff_ids($type)
throw new ForbiddenException();
}
+ $a = get_app();
+
api_get_user($a);
$stringify_ids = defaults($_REQUEST, 'stringify_ids', false);
@@ -3662,7 +3663,7 @@ function api_direct_messages_new($type)
switch ($type) {
case "atom":
case "rss":
- $data = api_rss_extra($a, $data, $user_info);
+ $data = api_rss_extra($a, $data, $sender);
}
return api_format_data("direct-messages", $type, $data);
@@ -3794,6 +3795,8 @@ function api_direct_messages_box($type, $box, $verbose)
// pagination
$start = $page * $count;
+ $sql_extra = "";
+
// filters
if ($box=="sentbox") {
$sql_extra = "`mail`.`from-url`='" . dbesc($profile_url) . "'";
@@ -3991,7 +3994,7 @@ function api_fr_photoalbum_delete($type)
if (!DBM::is_result($photo_item)) {
throw new InternalServerErrorException("problem with deleting items occured");
}
- Item::delete($photo_item[0]['id']);
+ Item::deleteById($photo_item[0]['id']);
}
// now let's delete all photos from the album
@@ -4294,7 +4297,7 @@ function api_fr_photo_delete($type)
}
// function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
// to the user and the contacts of the users (drop_items() do all the necessary magic to avoid orphans in database and federate deletion)
- Item::delete($photo_item[0]['id']);
+ Item::deleteById($photo_item[0]['id']);
$answer = ['result' => 'deleted', 'message' => 'photo with id `' . $photo_id . '` has been deleted from server.'];
return api_format_data("photo_delete", $type, ['$result' => $answer]);
@@ -4611,7 +4614,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
$height = $Image->getHeight();
// create a new resource-id if not already provided
- $hash = ($photo_id == null) ? photo_new_resource() : $photo_id;
+ $hash = ($photo_id == null) ? Photo::newResource() : $photo_id;
if ($mediatype == "photo") {
// upload normal image (scales 0, 1, 2)
@@ -4909,7 +4912,7 @@ function api_friendica_remoteauth()
goaway(
$contact['poll'] . '?dfrn_id=' . $dfrn_id
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
- . '&type=profile&sec=' . $sec . $dest . $quiet
+ . '&type=profile&sec=' . $sec . $dest
);
}
api_register_func('api/friendica/remoteauth', 'api_friendica_remoteauth', true);
@@ -5173,7 +5176,7 @@ function api_clean_plain_items($Text)
{
$include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false");
- $Text = bb_CleanPictureLinks($Text);
+ $Text = BBCode::cleanPictureLinks($Text);
$URLSearchString = "^\[\]";
$Text = preg_replace("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
@@ -5228,7 +5231,7 @@ function api_best_nickname(&$contacts)
{
$best_contact = [];
- if (count($contact) == 0) {
+ if (count($contacts) == 0) {
return;
}
@@ -5757,11 +5760,12 @@ api_register_func('api/friendica/direct_messages_setseen', 'api_friendica_direct
* @brief search for direct_messages containing a searchstring through api
*
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
+ * @param string $box
* @return string (success: success=true if found and search_result contains found messages,
* success=false if nothing was found, search_result='nothing found',
* error: result=error with error message)
*/
-function api_friendica_direct_messages_search($type)
+function api_friendica_direct_messages_search($type, $box = "")
{
$a = get_app();
@@ -5909,10 +5913,12 @@ function api_saved_searches_list($type)
$result = [];
while ($term = $terms->fetch()) {
$result[] = [
- 'name' => $term['term'],
- 'query' => $term['term'],
+ 'created_at' => api_date(time()),
+ 'id' => intval($term['id']),
'id_str' => $term['id'],
- 'id' => intval($term['id'])
+ 'name' => $term['term'],
+ 'position' => null,
+ 'query' => $term['term']
];
}