3 namespace Friendica\Module\Admin\Item;
5 use Friendica\Core\Renderer;
7 use Friendica\Model\Item;
8 use Friendica\Module\BaseAdmin;
9 use Friendica\Util\Strings;
11 class Delete extends BaseAdmin
13 public static function post(array $parameters = [])
15 parent::post($parameters);
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(DI::l10n()->t('Item marked for deletion.') . EOL);
36 DI::baseUrl()->redirect('admin/item/delete');
39 public static function content(array $parameters = [])
41 parent::content($parameters);
43 $t = Renderer::getMarkupTemplate('admin/item/delete.tpl');
45 return Renderer::replaceMacros($t, [
46 '$title' => DI::l10n()->t('Administration'),
47 '$page' => DI::l10n()->t('Delete Item'),
48 '$submit' => DI::l10n()->t('Delete this Item'),
49 '$intro1' => DI::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' => DI::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', DI::l10n()->t("GUID"), '', DI::l10n()->t("The GUID of the item you want to delete."), 'required', 'autofocus'],
52 '$form_security_token' => parent::getFormSecurityToken("admin_deleteitem")