Skip to content

Commit

Permalink
fix(farmservice): make delete work again + mini refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mrflos committed Feb 13, 2024
1 parent bf26dd5 commit fee4c9a
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 233 deletions.
37 changes: 37 additions & 0 deletions handlers/__DeletePageHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL 3.0
* @link https://yeswiki.net
*/

namespace YesWiki\Ferme;

use YesWiki\Ferme\Service\FarmService;
use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Core\Service\PageManager;
use YesWiki\Core\Service\TripleStore;
use YesWiki\Core\YesWikiHandler;
use YesWiki\Core\Controller\CsrfTokenController;

class __DeletePageHandler extends YesWikiHandler
{
public function run()
{
$output = '';
$tag = $this->wiki->GetPageTag();
$userCanDelete = $this->wiki->UserIsAdmin() || $this->wiki->UserIsOwner();
$entryManager = $this->wiki->services->get(EntryManager::class);
if ($entryManager->isEntry($tag) && !empty($_GET['confirme']) && $_GET['confirme'] == 'oui' && $userCanDelete) {
try {
if ($this->wiki->services->get(CsrfTokenController::class)->checkToken('main', 'POST', 'csrf-token', false)) {
$farm = $this->wiki->services->get(FarmService::class);
$farm->deleteWikiFromEntry($tag);
}
} catch (Throwable $th) {
exit('No CSRF token'); // do nothing
}
}
return $output;
}
}
10 changes: 0 additions & 10 deletions handlers/page/__deletepage.php

This file was deleted.

Loading

0 comments on commit fee4c9a

Please sign in to comment.