]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Admin/Item/Delete.php
post/thread views are renamed, search bugs fixed
[friendica.git] / src / Module / Admin / Item / Delete.php
index f5f4687cec51a33cf79d2a06585f0c6538ca7adc..1ee91f4250216662f31d7b197fd66b01b9c508b0 100644 (file)
@@ -1,24 +1,43 @@
 <?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Module\Admin\Item;
 
-use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\DI;
 use Friendica\Model\Item;
-use Friendica\Module\BaseAdminModule;
+use Friendica\Module\BaseAdmin;
 use Friendica\Util\Strings;
 
-class Delete extends BaseAdminModule
+class Delete extends BaseAdmin
 {
        public static function post(array $parameters = [])
        {
-               parent::post($parameters);
+               self::checkAdminAccess();
 
                if (empty($_POST['page_deleteitem_submit'])) {
                        return;
                }
 
-               parent::checkFormSecurityTokenRedirectOnError('/admin/item/delete', 'admin_deleteitem');
+               self::checkFormSecurityTokenRedirectOnError('/admin/item/delete', 'admin_deleteitem');
 
                if (!empty($_POST['page_deleteitem_submit'])) {
                        $guid = trim(Strings::escapeTags($_POST['deleteitemguid']));
@@ -29,11 +48,11 @@ class Delete extends BaseAdminModule
                        }
                        // Now that we have the GUID, drop those items, which will also delete the
                        // associated threads.
-                       Item::delete(['guid' => $guid]);
+                       Item::markForDeletion(['guid' => $guid]);
                }
 
-               info(L10n::t('Item marked for deletion.') . EOL);
-               self::getApp()->internalRedirect('admin/item/delete');
+               info(DI::l10n()->t('Item marked for deletion.'));
+               DI::baseUrl()->redirect('admin/item/delete');
        }
 
        public static function content(array $parameters = [])
@@ -43,13 +62,13 @@ class Delete extends BaseAdminModule
                $t = Renderer::getMarkupTemplate('admin/item/delete.tpl');
 
                return Renderer::replaceMacros($t, [
-                       '$title' => L10n::t('Administration'),
-                       '$page' => L10n::t('Delete Item'),
-                       '$submit' => L10n::t('Delete this Item'),
-                       '$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.'),
-                       '$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.'),
-                       '$deleteitemguid' => ['deleteitemguid', L10n::t("GUID"), '', L10n::t("The GUID of the item you want to delete."), 'required', 'autofocus'],
-                       '$form_security_token' => parent::getFormSecurityToken("admin_deleteitem")
+                       '$title' => DI::l10n()->t('Administration'),
+                       '$page' => DI::l10n()->t('Delete Item'),
+                       '$submit' => DI::l10n()->t('Delete this Item'),
+                       '$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.'),
+                       '$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.'),
+                       '$deleteitemguid' => ['deleteitemguid', DI::l10n()->t("GUID"), '', DI::l10n()->t("The GUID of the item you want to delete."), DI::l10n()->t('Required'), 'autofocus'],
+                       '$form_security_token' => self::getFormSecurityToken("admin_deleteitem")
                ]);
        }
 }