Merge pull request #6162 from JonnyTischbein/issue_delete_comment_from_guid
Delete comment from its guid and return to parent guid
This commit is contained in:
commit
e086f05aa4
1 changed files with 26 additions and 7 deletions
|
@ -352,7 +352,7 @@ function drop_item($id, $return = '')
|
||||||
|
|
||||||
// locate item to be deleted
|
// locate item to be deleted
|
||||||
|
|
||||||
$fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity'];
|
$fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', parent];
|
||||||
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]);
|
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]);
|
||||||
|
|
||||||
if (!DBA::isResult($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
|
@ -408,6 +408,11 @@ function drop_item($id, $return = '')
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false;
|
$is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false;
|
||||||
|
$parentitem = null;
|
||||||
|
if (!empty($item['parent'])){
|
||||||
|
$fields = ['guid'];
|
||||||
|
$parentitem = Item::selectFirstForUser(local_user(), $fields, ['id' => $item['parent']]);
|
||||||
|
}
|
||||||
|
|
||||||
// delete the item
|
// delete the item
|
||||||
Item::deleteForUser(['id' => $item['id']], local_user());
|
Item::deleteForUser(['id' => $item['id']], local_user());
|
||||||
|
@ -417,14 +422,28 @@ function drop_item($id, $return = '')
|
||||||
// removes update_* from return_url to ignore Ajax refresh
|
// removes update_* from return_url to ignore Ajax refresh
|
||||||
$return_url = str_replace("update_", "", $return_url);
|
$return_url = str_replace("update_", "", $return_url);
|
||||||
|
|
||||||
// if unknown location or top level post called from display
|
// Check if delete a comment
|
||||||
if (empty($return_url) || ((strpos($return_url, 'display') !== false) AND (!$is_comment))) {
|
if ($is_comment) {
|
||||||
$a->internalRedirect('network');
|
// Return to parent guid
|
||||||
//NOTREACHED
|
if (!empty($parentitem)) {
|
||||||
|
$a->internalRedirect('display/' . $parentitem['guid']);
|
||||||
|
//NOTREACHED
|
||||||
|
}
|
||||||
|
// In case something goes wrong
|
||||||
|
else {
|
||||||
|
$a->internalRedirect('network');
|
||||||
|
//NOTREACHED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$a->internalRedirect($return_url);
|
// if unknown location or deleting top level post called from display
|
||||||
//NOTREACHED
|
if (empty($return_url) || strpos($return_url, 'display') !== false) {
|
||||||
|
$a->internalRedirect('network');
|
||||||
|
//NOTREACHED
|
||||||
|
} else {
|
||||||
|
$a->internalRedirect($return_url);
|
||||||
|
//NOTREACHED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notice(L10n::t('Permission denied.') . EOL);
|
notice(L10n::t('Permission denied.') . EOL);
|
||||||
|
|
Loading…
Reference in a new issue