3 namespace Friendica\Module\Admin\Item;
5 use Friendica\Core\L10n;
6 use Friendica\Core\Renderer;
7 use Friendica\Model\Item;
8 use Friendica\Module\BaseAdminModule;
9 use Friendica\Util\Strings;
11 class Delete extends BaseAdminModule
13 public static function post()
17 if (empty($_POST['page_deleteitem_submit'])) {
21 parent::checkFormSecurityTokenRedirectOnError('/admin/item/delete', 'admin_deleteitem');
23 if (!empty($_POST['page_deleteitem_submit'])) {
24 $guid = trim(Strings::escapeTags($_POST['deleteitemguid']));
25 // The GUID should not include a "/", so if there is one, we got an URL
26 // and the last part of it is most likely the GUID.
27 if (strpos($guid, '/')) {
28 $guid = substr($guid, strrpos($guid, '/') + 1);
30 // Now that we have the GUID, drop those items, which will also delete the
31 // associated threads.
32 Item::delete(['guid' => $guid]);
35 info(L10n::t('Item marked for deletion.') . EOL);
36 self::getApp()->internalRedirect('admin/item/delete');
39 public static function content()
43 $t = Renderer::getMarkupTemplate('admin/item/delete.tpl');
45 return Renderer::replaceMacros($t, [
46 '$title' => L10n::t('Administration'),
47 '$page' => L10n::t('Delete Item'),
48 '$submit' => L10n::t('Delete this Item'),
49 '$intro1' => L10n::t('On this page you can delete an item from your node. If the item is a top level posting, the entire thread will be deleted.'),
50 '$intro2' => L10n::t('You need to know the GUID of the item. You can find it e.g. by looking at the display URL. The last part of http://example.com/display/123456 is the GUID, here 123456.'),
51 '$deleteitemguid' => ['deleteitemguid', L10n::t("GUID"), '', L10n::t("The GUID of the item you want to delete."), 'required', 'autofocus'],
52 '$form_security_token' => parent::getFormSecurityToken("admin_deleteitem")