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


class DataMenuTeamsDozenten extends DataMenuMainTopLeftCached
{
  private $dbw;
  private $teamIds = '';

  public function __construct($urlParam)
  {
    parent::__construct($urlParam);

    $this->dbw = DBWorkTeams::getDefaultInstance();

    $teamIds = RequestOperations::getVarValue('team');
    if (is_numeric($teamIds)) {
      $this->teamIds = array($teamIds);
    } elseif (is_array($teamIds)) {
      $this->teamIds = $teamIds;
    }

    if (is_array($this->teamIds)) {
      $this->dbw->newSearch();
      $this->dbw->fromobject->id = $this->teamIds;
    }

    $this->exportadapter = new ExpTeams();
  }

  public function _getClickPath($pName = 'Dozenten-Teams')
  {
    
    parent::_getClickPath();
    $tmp = $pName;
    if ($this->toolsettings->clickDozUebersichtText != '') {
      $tmp = $this->toolsettings->clickDozUebersichtText;
    }

    $this->clickpfad .= "<span class='clickadrbold'> " . CleanOperations::cleanStringForHtml($tmp) . "</span>\n";
    
    return $this->clickpfad;
  }

  public function getsight($sightid = 666)
  {
    parent::getsight($sightid);
  }

  public function getdataarraybody()
  {
    if ($this->toolsettings->dozentenTeamAuchLeere) {
      $this->dataarraybody = $this->dbw->getAll();
    } else {
      $this->dataarraybody = $this->dbw->getTeamsWithDozenten($this->toolsettings->semlist);
    }
  }

  
  protected function getCacheKey()
  {
    if (!$this->toolsettings->cacheTeamsDozenten) {
      return false;
    }
    $key = 'DMTeamsDozenten';
    if (is_array($this->teamIds)) {
      $key .= '-' . implode('#', $this->teamIds);
    }
    if ($this->toolsettings->dozentenTeamAuchLeere) {
      $key .= '-auchLeere';
    }

    return sha1($key);
  }

  protected function getTtl()
  {
    return 86400;
  }
}