2019-05-02 06:01:43 +02:00
< ? php
2020-02-09 15:45:36 +01:00
/**
* @ 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 />.
*
*/
2019-05-02 06:01:43 +02:00
namespace Friendica\Module\Admin\Item ;
use Friendica\Core\Renderer ;
2019-12-15 22:34:11 +01:00
use Friendica\DI ;
2019-05-02 06:01:43 +02:00
use Friendica\Model\Item ;
2020-01-23 05:14:14 +01:00
use Friendica\Module\BaseAdmin ;
2019-05-02 06:01:43 +02:00
use Friendica\Util\Strings ;
2020-01-23 05:14:14 +01:00
class Delete extends BaseAdmin
2019-05-02 06:01:43 +02:00
{
2019-11-05 22:48:54 +01:00
public static function post ( array $parameters = [])
2019-05-02 06:01:43 +02:00
{
2019-11-05 21:22:54 +01:00
parent :: post ( $parameters );
2019-05-02 06:01:43 +02:00
if ( empty ( $_POST [ 'page_deleteitem_submit' ])) {
return ;
}
parent :: checkFormSecurityTokenRedirectOnError ( '/admin/item/delete' , 'admin_deleteitem' );
if ( ! empty ( $_POST [ 'page_deleteitem_submit' ])) {
$guid = trim ( Strings :: escapeTags ( $_POST [ 'deleteitemguid' ]));
// The GUID should not include a "/", so if there is one, we got an URL
// and the last part of it is most likely the GUID.
if ( strpos ( $guid , '/' )) {
$guid = substr ( $guid , strrpos ( $guid , '/' ) + 1 );
}
// Now that we have the GUID, drop those items, which will also delete the
// associated threads.
2020-03-03 07:47:28 +01:00
Item :: markForDeletion ([ 'guid' => $guid ]);
2019-05-02 06:01:43 +02:00
}
2020-01-18 20:52:34 +01:00
info ( DI :: l10n () -> t ( 'Item marked for deletion.' ) . EOL );
2019-12-16 00:28:31 +01:00
DI :: baseUrl () -> redirect ( 'admin/item/delete' );
2019-05-02 06:01:43 +02:00
}
2019-11-05 22:48:54 +01:00
public static function content ( array $parameters = [])
2019-05-02 06:01:43 +02:00
{
2019-11-05 21:22:54 +01:00
parent :: content ( $parameters );
2019-05-02 06:01:43 +02:00
$t = Renderer :: getMarkupTemplate ( 'admin/item/delete.tpl' );
return Renderer :: replaceMacros ( $t , [
2020-01-18 20:52:34 +01:00
'$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. " ), 'required' , 'autofocus' ],
2019-05-02 06:01:43 +02:00
'$form_security_token' => parent :: getFormSecurityToken ( " admin_deleteitem " )
]);
}
}