<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\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();

    
    if (\DBWorkBASysSettings::isMVHS()) {
      $currentDozent = \SessionOperations::getCurrentWebToolsDozent();
      $datDoc->nr = $currentDozent->id;
      $datDoc->typ = 'TNL_D';

      return $datDoc;
    }

    $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;
}