-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(farmservice): make delete work again + mini refactor
- Loading branch information
Showing
3 changed files
with
269 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.