]> git.mxchange.org Git - friendica.git/blob - src/Module/Moderation/Item/Delete.php
New area "moderation"
[friendica.git] / src / Module / Moderation / Item / Delete.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Module\Moderation\Item;
23
24 use Friendica\Core\Renderer;
25 use Friendica\Model\Item;
26 use Friendica\Module\BaseModeration;
27
28 class Delete extends BaseModeration
29 {
30         protected function post(array $request = [])
31         {
32                 $this->checkModerationAccess();
33
34                 if (empty($request['page_deleteitem_submit'])) {
35                         return;
36                 }
37
38                 self::checkFormSecurityTokenRedirectOnError('/moderation/item/delete', 'moderation_deleteitem');
39
40                 $guid = trim($request['deleteitemguid']);
41                 // The GUID should not include a "/", so if there is one, we got an URL
42                 // and the last part of it is most likely the GUID.
43                 if (strpos($guid, '/')) {
44                         $guid = substr($guid, strrpos($guid, '/') + 1);
45                 }
46                 // Now that we have the GUID, drop those items, which will also delete the
47                 // associated threads.
48                 Item::markForDeletion(['guid' => $guid]);
49
50                 $this->systemMessages->addInfo($this->t('Item marked for deletion.'));
51                 $this->baseUrl->redirect('moderation/item/delete');
52         }
53
54         protected function content(array $request = []): string
55         {
56                 parent::content();
57
58                 $t = Renderer::getMarkupTemplate('moderation/item/delete.tpl');
59
60                 return Renderer::replaceMacros($t, [
61                         '$title'  => $this->t('Moderation'),
62                         '$page'   => $this->t('Delete Item'),
63                         '$submit' => $this->t('Delete this Item'),
64                         '$intro1' => $this->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.'),
65                         '$intro2' => $this->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.'),
66
67                         '$deleteitemguid'      => ['deleteitemguid', $this->t("GUID"), '', $this->t("The GUID of the item you want to delete."), $this->t('Required'), 'autofocus'],
68                         '$form_security_token' => self::getFormSecurityToken("moderation_deleteitem")
69                 ]);
70         }
71 }