<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */


namespace Kufer\Web\KuferTools\Basis\KursUebersicht\Detailsreiter\Honorar\AddDozent;




abstract class AddDozentDialogUseCase extends \Kufer\KuferTools\Basis\UseCase\ToolUseCase
{
  public function __construct($request)
  {
    parent::__construct($request, new AddDozentDialogResponse());
  }

  abstract protected function getReiterDozentenId(): int;

  public function hasAccess($pToolSectionId = null)
  {
    if (!parent::hasAccess()) {
      return false;
    }
    if (!$this->isRechtAllowed(static::getToolSectionId() . '.0.2') && !$this->isRechtAllowed($this->getReiterDozentenId() . '.0.2')) {
      return false;
    }

    return true;
  }

  private function getKurs($knr)
  {
    $dbwKurse = new \DBWorkKurseWT(1, true);

    return $dbwKurse->getKurs($knr);
  }

  public function action()
  {
    $kurs = $this->getKurs($this->request->knr);

    return $this->getResponse($kurs);
  }

  protected function getResponse($pKurs)
  {
    $this->handleResponseStrategies();
    $this->response->kurs = $pKurs;
    
    
    $this->response->dozentAddXsrf = $this->getXsrfKey('addDozent', $this->request->knr);

    return $this->response;
  }

  protected function getResponseStrategies()
  { 
    return array();
  }
} 

class AddDozentDialogRequest
{
  public $knr;
}

class AddDozentDialogResponse extends \Kufer\KuferTools\Basis\UseCase\ToolResponse
{
  public $kurs;
}