use drop_item and some magic
This commit is contained in:
parent
9304bb6422
commit
dc41ac0f61
|
@ -11,6 +11,7 @@ use Friendica\Core\Config;
|
||||||
|
|
||||||
require_once("include/enotify.php");
|
require_once("include/enotify.php");
|
||||||
require_once("include/text.php");
|
require_once("include/text.php");
|
||||||
|
require_once('include/items.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Process send data from the admin panels subpages
|
* @brief Process send data from the admin panels subpages
|
||||||
|
@ -393,6 +394,7 @@ function admin_page_deleteitem_post(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_form_security_token_redirectOnErr('/admin/deleteitem/', 'admin_deleteitem');
|
check_form_security_token_redirectOnErr('/admin/deleteitem/', 'admin_deleteitem');
|
||||||
|
|
||||||
if (x($_POST['page_deleteitem_submit'])) {
|
if (x($_POST['page_deleteitem_submit'])) {
|
||||||
$guid = trim(notags($_POST['deleteitemguid']));
|
$guid = trim(notags($_POST['deleteitemguid']));
|
||||||
// The GUID should not include a "/", so if there is one, we got an URL
|
// The GUID should not include a "/", so if there is one, we got an URL
|
||||||
|
@ -400,17 +402,14 @@ function admin_page_deleteitem_post(App $a) {
|
||||||
if (strpos($guid, '/')) {
|
if (strpos($guid, '/')) {
|
||||||
$guid = substr($guid, strrpos($guid, '/')+1);
|
$guid = substr($guid, strrpos($guid, '/')+1);
|
||||||
}
|
}
|
||||||
// Now that we have the GUID, get the ID and the PARENT ID of the posting
|
// Now that we have the GUID get all IDs of the associated entries in the
|
||||||
// to determine if it is a top level posting or a comment. If it is a top
|
// item table of the DB and drop those items, which will also delete the
|
||||||
// level posting, we also need to delete the corresponding thread.
|
// associated threads.
|
||||||
dba::update('item', array('deleted' => true), array('guid' => (int)$guid));
|
$r = dba::select('item', array('id'), array('guid'=>$guid));
|
||||||
$r = qu("SELECT id, parent FROM item WHERE guid='%s'",$guid);
|
while ($row = dba::fetch($r)) {
|
||||||
if (dbm::is_result($r)) {
|
drop_item($row['id'], false);
|
||||||
$rr = $r[0];
|
|
||||||
if ($rr['id'] == $rr['parent']) {
|
|
||||||
dba::update('thread', array('deleted' => true), array('iid' => (int)$rr['id']));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
dba::close($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
info(t('Item marked for deletion.').EOL);
|
info(t('Item marked for deletion.').EOL);
|
||||||
|
|
Loading…
Reference in a new issue