3 namespace Friendica\Module\Admin\Item;
5 use Friendica\Core\L10n;
6 use Friendica\Core\Renderer;
8 use Friendica\Model\Item;
9 use Friendica\Module\BaseAdminModule;
10 use Friendica\Util\Strings;
12 class Delete extends BaseAdminModule
14 public static function post(array $parameters = [])
16 parent::post($parameters);
18 if (empty($_POST['page_deleteitem_submit'])) {
22 parent::checkFormSecurityTokenRedirectOnError('/admin/item/delete', 'admin_deleteitem');
24 if (!empty($_POST['page_deleteitem_submit'])) {
25 $guid = trim(Strings::escapeTags($_POST['deleteitemguid']));
26 // The GUID should not include a "/", so if there is one, we got an URL
27 // and the last part of it is most likely the GUID.
28 if (strpos($guid, '/')) {
29 $guid = substr($guid, strrpos($guid, '/') + 1);
31 // Now that we have the GUID, drop those items, which will also delete the
32 // associated threads.
33 Item::delete(['guid' => $guid]);
36 info(L10n::t('Item marked for deletion.') . EOL);
37 DI::baseUrl()->redirect('admin/item/delete');
40 public static function content(array $parameters = [])
42 parent::content($parameters);
44 $t = Renderer::getMarkupTemplate('admin/item/delete.tpl');
46 return Renderer::replaceMacros($t, [
47 '$title' => L10n::t('Administration'),
48 '$page' => L10n::t('Delete Item'),
49 '$submit' => L10n::t('Delete this Item'),
50 '$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.'),
51 '$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.'),
52 '$deleteitemguid' => ['deleteitemguid', L10n::t("GUID"), '', L10n::t("The GUID of the item you want to delete."), 'required', 'autofocus'],
53 '$form_security_token' => parent::getFormSecurityToken("admin_deleteitem")