Fix for not being able to delete items
This commit is contained in:
parent
e9dbf55400
commit
bdbc51229a
12 changed files with 65 additions and 25 deletions
|
@ -405,10 +405,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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -467,16 +469,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`.`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)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -484,7 +489,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`) ";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -497,7 +502,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);
|
||||
|
@ -521,7 +526,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) {
|
||||
/*
|
||||
|
@ -885,7 +890,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 = 0) {
|
||||
$max_comments = Config::get('system', 'max_comments', 100);
|
||||
|
||||
if ($max_comments > 0) {
|
||||
|
@ -899,7 +904,7 @@ 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`.`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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue