]> git.mxchange.org Git - friendica.git/blob - src/Module/Admin/Item/Delete.php
Added parameters
[friendica.git] / src / Module / Admin / Item / Delete.php
1 <?php
2
3 namespace Friendica\Module\Admin\Item;
4
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;
10
11 class Delete extends BaseAdminModule
12 {
13         public static function post($parameters)
14         {
15                 parent::post($parameters);
16
17                 if (empty($_POST['page_deleteitem_submit'])) {
18                         return;
19                 }
20
21                 parent::checkFormSecurityTokenRedirectOnError('/admin/item/delete', 'admin_deleteitem');
22
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);
29                         }
30                         // Now that we have the GUID, drop those items, which will also delete the
31                         // associated threads.
32                         Item::delete(['guid' => $guid]);
33                 }
34
35                 info(L10n::t('Item marked for deletion.') . EOL);
36                 self::getApp()->internalRedirect('admin/item/delete');
37         }
38
39         public static function content($parameters)
40         {
41                 parent::content($parameters);
42
43                 $t = Renderer::getMarkupTemplate('admin/item/delete.tpl');
44
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")
53                 ]);
54         }
55 }