Merge branch 'master' into develop
- Updated new develop version label - Incremented database build number
This commit is contained in:
commit
93daf7883e
474 changed files with 75160 additions and 91301 deletions
|
@ -1663,7 +1663,7 @@ function api_search($type)
|
|||
|
||||
$r = dba::p(
|
||||
"SELECT ".item_fieldlists()."
|
||||
FROM `item` ".item_joins()."
|
||||
FROM `item` ".item_joins(api_user())."
|
||||
WHERE ".item_condition()." AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))
|
||||
AND `item`.`body` LIKE CONCAT('%',?,'%')
|
||||
$sql_extra
|
||||
|
@ -1827,7 +1827,7 @@ function api_statuses_public_timeline($type)
|
|||
"SELECT " . item_fieldlists() . "
|
||||
FROM `thread`
|
||||
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
" . item_joins() . "
|
||||
" . item_joins(api_user()) . "
|
||||
STRAIGHT_JOIN `user` ON `user`.`uid` = `thread`.`uid`
|
||||
AND NOT `user`.`hidewall`
|
||||
AND `verb` = ?
|
||||
|
@ -1856,7 +1856,7 @@ function api_statuses_public_timeline($type)
|
|||
$r = dba::p(
|
||||
"SELECT " . item_fieldlists() . "
|
||||
FROM `item`
|
||||
" . item_joins() . "
|
||||
" . item_joins(api_user()) . "
|
||||
STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
AND NOT `user`.`hidewall`
|
||||
AND `verb` = ?
|
||||
|
@ -1930,7 +1930,7 @@ function api_statuses_networkpublic_timeline($type)
|
|||
"SELECT " . item_fieldlists() . "
|
||||
FROM `thread`
|
||||
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
" . item_joins() . "
|
||||
" . item_joins(api_user()) . "
|
||||
WHERE `thread`.`uid` = 0
|
||||
AND `verb` = ?
|
||||
AND NOT `thread`.`private`
|
||||
|
@ -2002,6 +2002,19 @@ function api_statuses_show($type)
|
|||
$sql_extra .= " AND `item`.`id` = %d";
|
||||
}
|
||||
|
||||
// try to fetch the item for the local user - or the public item, if there is no local one
|
||||
$uri_item = dba::selectFirst('item', ['uri'], ['id' => $id]);
|
||||
if (!DBM::is_result($uri_item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
||||
$item = dba::selectFirst('item', ['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
if (!DBM::is_result($item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
||||
$id = $item['id'];
|
||||
|
||||
$r = q(
|
||||
"SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
|
||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
||||
|
@ -2011,7 +2024,7 @@ function api_statuses_show($type)
|
|||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
|
||||
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'
|
||||
AND `item`.`uid` IN (0, %d) AND `item`.`verb` = '%s'
|
||||
$sql_extra",
|
||||
intval(api_user()),
|
||||
dbesc(ACTIVITY_POST),
|
||||
|
@ -2075,22 +2088,25 @@ function api_conversation_show($type)
|
|||
|
||||
logger('API: api_conversation_show: '.$id);
|
||||
|
||||
$r = q("SELECT `parent` FROM `item` WHERE `id` = %d", intval($id));
|
||||
if (DBM::is_result($r)) {
|
||||
$id = $r[0]["parent"];
|
||||
// try to fetch the item for the local user - or the public item, if there is no local one
|
||||
$item = dba::selectFirst('item', ['parent-uri'], ['id' => $id]);
|
||||
if (!DBM::is_result($item)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
||||
$parent = dba::selectFirst('item', ['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
throw new BadRequestException("There is no status with this id.");
|
||||
}
|
||||
|
||||
$id = $parent['id'];
|
||||
|
||||
$sql_extra = '';
|
||||
|
||||
if ($max_id > 0) {
|
||||
$sql_extra = ' AND `item`.`id` <= ' . intval($max_id);
|
||||
}
|
||||
|
||||
// Not sure why this query was so complicated. We should keep it here for a while,
|
||||
// just to make sure that we really don't need it.
|
||||
// FROM `item` INNER JOIN (SELECT `uri`,`parent` FROM `item` WHERE `id` = %d) AS `temp1`
|
||||
// ON (`item`.`thr-parent` = `temp1`.`uri` AND `item`.`parent` = `temp1`.`parent`)
|
||||
|
||||
$r = q(
|
||||
"SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
|
||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
||||
|
@ -2101,7 +2117,7 @@ function api_conversation_show($type)
|
|||
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'
|
||||
AND `item`.`uid` IN (0, %d) AND `item`.`verb` = '%s'
|
||||
AND `item`.`id`>%d $sql_extra
|
||||
ORDER BY `item`.`id` DESC LIMIT %d ,%d",
|
||||
intval($id),
|
||||
|
@ -2240,7 +2256,7 @@ function api_statuses_destroy($type)
|
|||
|
||||
$ret = api_statuses_show($type);
|
||||
|
||||
Item::deleteById($id);
|
||||
Item::deleteForUser(['id' => $id], api_user());
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -4132,7 +4148,7 @@ function api_fr_photoalbum_delete($type)
|
|||
if (!DBM::is_result($photo_item)) {
|
||||
throw new InternalServerErrorException("problem with deleting items occured");
|
||||
}
|
||||
Item::deleteById($photo_item[0]['id']);
|
||||
Item::deleteForUser(['id' => $photo_item[0]['id']], api_user());
|
||||
}
|
||||
|
||||
// now let's delete all photos from the album
|
||||
|
@ -4424,7 +4440,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::deleteById($photo_item[0]['id']);
|
||||
Item::deleteForUser(['id' => $photo_item[0]['id']], api_user());
|
||||
|
||||
$answer = ['result' => 'deleted', 'message' => 'photo with id `' . $photo_id . '` has been deleted from server.'];
|
||||
return api_format_data("photo_delete", $type, ['$result' => $answer]);
|
||||
|
|
|
@ -401,10 +401,12 @@ function visible_activity($item) {
|
|||
|
||||
/**
|
||||
* @brief SQL query for items
|
||||
*
|
||||
* @param int $uid user id
|
||||
*/
|
||||
function item_query() {
|
||||
function item_query($uid = 0) {
|
||||
return "SELECT " . item_fieldlists() . " FROM `item` " .
|
||||
item_joins() . " WHERE " . item_condition();
|
||||
item_joins($uid) . " WHERE " . item_condition();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -429,7 +431,6 @@ These Fields are not added below (yet). They are here to for bug search.
|
|||
`item`.`bookmark`,
|
||||
`item`.`unseen`,
|
||||
`item`.`deleted`,
|
||||
`item`.`origin`,
|
||||
`item`.`forum_mode`,
|
||||
`item`.`mention`,
|
||||
`item`.`global`,
|
||||
|
@ -442,7 +443,7 @@ These Fields are not added below (yet). They are here to for bug search.
|
|||
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`content-warning`,
|
||||
`item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
|
||||
`item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`,
|
||||
`item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`,
|
||||
`item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`, `item`.`origin`,
|
||||
`item`.`title`, `item`.`body`, `item`.`file`, `item`.`event-id`,
|
||||
`item`.`location`, `item`.`coord`, `item`.`app`, `item`.`attach`,
|
||||
`item`.`rendered-hash`, `item`.`rendered-html`, `item`.`object`,
|
||||
|
@ -464,16 +465,19 @@ These Fields are not added below (yet). They are here to for bug search.
|
|||
|
||||
/**
|
||||
* @brief SQL join for contacts that are needed for displaying items
|
||||
*
|
||||
* @param int $uid user id
|
||||
*/
|
||||
function item_joins() {
|
||||
function item_joins($uid = 0) {
|
||||
return sprintf("STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
AND NOT `contact`.`blocked`
|
||||
AND ((NOT `contact`.`readonly` AND NOT `contact`.`pending` AND (`contact`.`rel` IN (%s, %s)))
|
||||
OR `contact`.`self` OR (`item`.`id` != `item`.`parent`))
|
||||
OR `contact`.`self` OR (`item`.`id` != `item`.`parent`) OR `contact`.`uid` = 0)
|
||||
INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` AND NOT `author`.`blocked`
|
||||
INNER JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id` AND NOT `owner`.`blocked`
|
||||
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = %d
|
||||
LEFT JOIN `event` ON `event-id` = `event`.`id`",
|
||||
CONTACT_IS_SHARING, CONTACT_IS_FRIEND
|
||||
CONTACT_IS_SHARING, CONTACT_IS_FRIEND, intval($uid)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -481,7 +485,7 @@ function item_joins() {
|
|||
* @brief SQL condition for items that are needed for displaying items
|
||||
*/
|
||||
function item_condition() {
|
||||
return "`item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`";
|
||||
return "`item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`) ";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -494,7 +498,7 @@ function item_condition() {
|
|||
* that are based on unique features of the calling module.
|
||||
*
|
||||
*/
|
||||
function conversation(App $a, $items, $mode, $update, $preview = false, $order = 'commented') {
|
||||
function conversation(App $a, $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0) {
|
||||
require_once 'mod/proxy.php';
|
||||
|
||||
$ssl_state = ((local_user()) ? true : false);
|
||||
|
@ -518,7 +522,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
|
|||
$previewing = (($preview) ? ' preview ' : '');
|
||||
|
||||
if ($mode === 'network') {
|
||||
$items = conversation_add_children($items, false, $order);
|
||||
$items = conversation_add_children($items, false, $order, $uid);
|
||||
$profile_owner = local_user();
|
||||
if (!$update) {
|
||||
/*
|
||||
|
@ -579,7 +583,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
|
|||
. " var profile_page = 1; </script>";
|
||||
}
|
||||
} elseif ($mode === 'community') {
|
||||
$items = conversation_add_children($items, true, $order);
|
||||
$items = conversation_add_children($items, true, $order, $uid);
|
||||
$profile_owner = 0;
|
||||
if (!$update) {
|
||||
$live_update_div = '<div id="live-community"></div>' . "\r\n"
|
||||
|
@ -882,7 +886,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
|
|||
*
|
||||
* @return array items with parents and comments
|
||||
*/
|
||||
function conversation_add_children($parents, $block_authors, $order) {
|
||||
function conversation_add_children($parents, $block_authors, $order, $uid) {
|
||||
$max_comments = Config::get('system', 'max_comments', 100);
|
||||
|
||||
if ($max_comments > 0) {
|
||||
|
@ -896,38 +900,13 @@ function conversation_add_children($parents, $block_authors, $order) {
|
|||
$block_sql = $block_authors ? "AND NOT `author`.`hidden` AND NOT `author`.`blocked`" : "";
|
||||
|
||||
foreach ($parents AS $parent) {
|
||||
$thread_items = dba::p(item_query()." AND `item`.`uid` = ?
|
||||
AND `item`.`parent-uri` = ? $block_sql
|
||||
ORDER BY `item`.`commented` DESC" . $limit,
|
||||
local_user(),
|
||||
$parent['uri']
|
||||
);
|
||||
$thread_items = dba::p(item_query(local_user())."AND `item`.`parent-uri` = ?
|
||||
AND `item`.`uid` IN (0, ?) $block_sql
|
||||
ORDER BY `item`.`uid` ASC, `item`.`commented` DESC" . $limit,
|
||||
$parent['uri'], local_user());
|
||||
|
||||
$comments = dba::inArray($thread_items);
|
||||
|
||||
// Check if the original item is in the result.
|
||||
// When commenting from the community page there can be incomplete threads
|
||||
if (count($comments) > 0) {
|
||||
$parent_found = false;
|
||||
foreach ($comments as $comment) {
|
||||
if ($comment['uri'] == $comment['parent-uri']) {
|
||||
$parent_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$parent_found) {
|
||||
$comments = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($comments) == 0) {
|
||||
$thread_items = dba::p(item_query()." AND `item`.`uid` = 0
|
||||
AND `item`.`parent-uri` = ?
|
||||
ORDER BY `item`.`commented` DESC LIMIT ".intval($max_comments + 1),
|
||||
$parent['uri']
|
||||
);
|
||||
$comments = dba::inArray($thread_items);
|
||||
}
|
||||
|
||||
if (count($comments) != 0) {
|
||||
$items = array_merge($items, $comments);
|
||||
}
|
||||
|
|
|
@ -52,16 +52,6 @@ class dba {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($a->mode == App::MODE_INSTALL) {
|
||||
// server has to be a non-empty string that is not 'localhost' and not an IP
|
||||
if (strlen($server) && ($server !== 'localhost') && filter_var($server, FILTER_VALIDATE_IP) === false) {
|
||||
if (! dns_get_record($server, DNS_A + DNS_CNAME)) {
|
||||
self::$error = L10n::t('Cannot locate DNS info for database server \'%s\'', $server);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
|
||||
self::$driver = 'pdo';
|
||||
$connect = "mysql:host=".$server.";dbname=".$db;
|
||||
|
|
|
@ -29,7 +29,7 @@ function add_page_info_data($data, $no_photos = false) {
|
|||
// It maybe is a rich content, but if it does have everything that a link has,
|
||||
// then treat it that way
|
||||
if (($data["type"] == "rich") && is_string($data["title"]) &&
|
||||
is_string($data["text"]) && (sizeof($data["images"]) > 0)) {
|
||||
is_string($data["text"]) && !empty($data["images"])) {
|
||||
$data["type"] = "link";
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ function add_page_info_data($data, $no_photos = false) {
|
|||
$text .= " title='".$data["title"]."'";
|
||||
}
|
||||
|
||||
if (sizeof($data["images"]) > 0) {
|
||||
if (!empty($data["images"])) {
|
||||
$preview = str_replace(["[", "]"], ["[", "]"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false));
|
||||
// if the preview picture is larger than 500 pixels then show it in a larger mode
|
||||
// But only, if the picture isn't higher than large (To prevent huge posts)
|
||||
|
@ -322,7 +322,7 @@ function drop_items($items) {
|
|||
|
||||
if (count($items)) {
|
||||
foreach ($items as $item) {
|
||||
$owner = Item::deleteById($item);
|
||||
$owner = Item::deleteForUser(['id' => $item], local_user());
|
||||
if ($owner && !$uid)
|
||||
$uid = $owner;
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ function drop_item($id) {
|
|||
}
|
||||
|
||||
// delete the item
|
||||
Item::deleteById($item['id']);
|
||||
Item::deleteForUser(['id' => $item['id']], local_user());
|
||||
|
||||
goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
|
||||
//NOTREACHED
|
||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Event;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile;
|
||||
|
@ -1966,6 +1967,10 @@ function undo_post_tagging($s) {
|
|||
$cnt = preg_match_all('/([!#@])\[url=(.*?)\](.*?)\[\/url\]/ism', $s, $matches, PREG_SET_ORDER);
|
||||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
if (in_array($mtch[1], ['!', '@'])) {
|
||||
$contact = Contact::getDetailsByURL($mtch[2]);
|
||||
$mtch[3] = empty($contact['addr']) ? $mtch[2] : $contact['addr'];
|
||||
}
|
||||
$s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue