53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace com\fwdekker\deathnotifier\tracking;
|
|
|
|
use com\fwdekker\deathnotifier\Action;
|
|
use com\fwdekker\deathnotifier\ActionException;
|
|
use com\fwdekker\deathnotifier\ActionMethod;
|
|
use com\fwdekker\deathnotifier\validator\IsNotBlankRule;
|
|
|
|
|
|
/**
|
|
* Removes a tracking of the current user.
|
|
*/
|
|
class RemoveTrackingAction extends Action
|
|
{
|
|
/**
|
|
* @var TrackingManager the manager to remove the tracking with
|
|
*/
|
|
private readonly TrackingManager $tracking_manager;
|
|
|
|
|
|
/**
|
|
* Constructs a new `RemoveTrackingAction`.
|
|
*
|
|
* @param TrackingManager $tracking_manager the manager to remove the tracking with
|
|
*/
|
|
public function __construct(TrackingManager $tracking_manager)
|
|
{
|
|
parent::__construct(
|
|
ActionMethod::POST,
|
|
"remove-tracking",
|
|
require_logged_in: true,
|
|
require_valid_csrf_token: true,
|
|
rule_lists: ["person_name" => [new IsNotBlankRule()]],
|
|
);
|
|
|
|
$this->tracking_manager = $tracking_manager;
|
|
}
|
|
|
|
|
|
/**
|
|
* Removes the current user's tracking of `$_POST["person_name"]`.
|
|
*
|
|
* @return mixed `null`
|
|
*/
|
|
function handle(): mixed
|
|
{
|
|
$this->tracking_manager->remove_tracking($_SESSION["uuid"], $_POST["person_name"]);
|
|
|
|
return null;
|
|
}
|
|
}
|