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

namespace Kufer\Web\KuferTools\Dozent\KursUebersicht\Detailsreiter\Dokumente;

class DokumenteUseCase extends \Kufer\Web\KuferTools\Basis\Kursdetails\Detailsreiter\Dokumente\DokumenteUseCase
{
  public static function getToolId()
  {
    return \ToolsAPI::TOOL_KURSUEBERSICHT_DOZ;
  }

  public static function getToolSectionId()
  {
    return 593;
  }

  public function hasAccess($pToolSectionId = null)
  {
    if (!parent::hasAccess()) {
      return false;
    }
    if (!$this->isRechtAllowed('334.1.9')) {
      return false;
    }

    return true;
  }

  protected function getDatDocObj()
  {
    $datDoc = parent::getDatDocObj();

    $currentDozent = \SessionOperations::getCurrentWebToolsDozent();
    $datDoc->freigabe_doz_tools = true;
    $datDoc->nr_oder_jeder = $currentDozent->id; 
    $datDoc->typen = implode(',', \DatDocAPI::getDatDocDocumentTypes4KurseAndDozenten());

    return $datDoc;
  }

  protected function getKursId(): string
  {
    return $this->request->knr;
  }

  protected function isUploadAllowed(): bool
  {
    return true;
  }
}

class DokumenteRequest
{
  public $knr;
}