Location: PHPKode > projects > PhpChrystal - An Open Intranet System > 0.071Alpha1/phpTurnierAdmin.php
<?php
  session_start();

  // XML::COMMENT (Datei exportieren)
  if ($_GET['cmd'] == 'do_export')
  {
    (!isset($_SESSION['active_login'])) ? (exit) : ($dummy);

	header("Content-type: text/plain\r\n");
    include_once("./classes/CTourneyControl.php");
    $ctcontrol = new CTourneyControl;

	if ($_GET['type'] == 'ngl')
      die($ctcontrol->createNGLExport());
    else
      die($ctcontrol->createWWCLExport());
  }
  else
  {
    include_once("./classes/CCore.php");
  }


  // XML::MODUL   (phpTurnierAdmin)
  // XML::VERSION (0.071 Alpha1)
  // XML::AUTHOR  (::[CTH]Goldenhawk::)
  // XML::INFO    (Administrationsmodul für Turnierverwaltung)


  // XML::COMMENT (Vesrion, Name und Autor festlege)
  $PLUGIN_VERSION = "0.071 Alpha1";
  $PLUGIN_NAME    = "phpTurnierAdmin";
  $PLUGIN_AUTHOR  = "::[CTH]Goldenhawk::";

  // XML::FUNC::getInfo ($self->getInfo())
  // XML::DESC::getInfo (liefert Name, Autor und Version des Modules zurück)
  // XML::VERSION::getInfo  (1.0)
  // XML::RETURN::getInfo ($PLUGIN_NAME,$PLUGIN_AUTHOR,$PLUGIN_VERSION)
  function getInfo()
  {
    global $PLUGIN_VERSION,$PLUGIN_NAME,$PLUGIN_AUTHOR;

    return $PLUGIN_NAME;
    return $PLUGIN_AUTHOR;
    return $PLUGIN_VERSION;
  }

  // XML::COMMENT (Spiele festlegen)
  $arDE2Potences = $ctcontrol->getDE2Potences();

  // XML::COMMENT (Verhalten bei zuwenig Teams festlegen)
  $arHandleLowTeamNumber  = array(	'bFillWithFreeDummies' => $cxml->printString($lang['admin.lessteams.1']),
  					'bDoDelete' => $cxml->printString($lang['admin.lessteams.2']),
  					'bManuelFillWithFreeDummies' => $cxml->printString($lang['admin.lessteams.3']),
  					);
  global $arHandleLowTeamNumber;


  // XML::COMMENT (Template initalisieren)
  $cdesign->initalizeTemplate($arNoOpts);

  // XML::COMMENT (-----------------------------)
  // XML::COMMENT (------ Ausgaberoutinen ------)
  // XML::COMMENT (-----------------------------)
  if (!isset($_SESSION['active_userid']))
    $cfunc->faultExt($cxml->printString($lang_def["fault.not_loged_in"]));

  (!$csecure->verifyUserForAdminArea(array('iUserID' => $_SESSION['active_userid'], 'area' => $PLUGIN_NAME))) ? ($cfunc->faultExt($cxml->printString($lang_def['fault.not_authorized']))) : ($dummy);

  // XML::COMMENT (Turnier hinzufügen)
  if ($_GET['cmd'] == 'admin_overview')
  {
    if (!$iTourneyID)
    {
      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;what=status","");
	  $arOpts[noopt] = 1;

	  $desTop[0][text] = $cxml->printString($lang['admin.change.subject.delete']);
	  $desTop[1][text] = $cxml->printString($lang['admin.change.subject.status']);
	  $desTop[2][text] = $cxml->printString($lang['admin.change.subject.details']);
	  $cl->cellsTop($desTop);

	  $arTourneys = $ctcontrol->getTourneys($arNoOpts);

	  for($iCnt = 0;$iCnt<count($arTourneys);$iCnt++)
	  {
		// XML::COMMENT (Status laden)
		$arStatusOfTourney = $ctcontrol->getRoundStatus($arTourneys[$iCnt][iTourneyID]);
		$szStatusOfTourney = $arStatusOfTourney['defStatus'];

	    $desText[0][text] = $cl->createInput(array('type' => 'checkbox', 'name' => 'in_arToDelete[]', 'value' => $arTourneys[$iCnt][iTourneyID]));

	    if (($szStatusOfTourney == 'waiting') && ($arTourneys[$iCnt][enumHandleLowTeams] == 'bManuelFillWithFreeDummies'))
	      $arChoose = array('' => $cxml->printString($lang['ar.2.1'],$cevent->convertTSToDB($arTourneys[$iCnt][tsStartTime])), 'bStartNow' => $cxml->printString($lang['ar.2.5']));
		elseif ($szStatusOfTourney == 'closed')
		  $arChoose = array('' => $cxml->printString($lang['ar.2.2']));
		elseif (($szStatusOfTourney == 'waiting') && ($arTourneys[$iCnt][enumHandleLowTeams] == 'bManuelFillWithFreeDummies'))
		  $arChoose = array('' => $cxml->printString($lang['ar.2.1'],$cevent->convertTSToDB($arTourneys[$iCnt][tsStartTime])));
		elseif ($szStatusOfTourney == 'paused')
		  $arChoose = array('' => $cxml->printString($lang['ar.2.3']), 'bContinueTourney' => $cxml->printString($lang['ar.2.6']));
		elseif ($szStatusOfTourney == 'running')
		  $arChoose = array('' => $cxml->printString($lang['ar.2.6']), 'bStopTourney' => $cxml->printString($lang['ar.2.7']));
		elseif ($szStatusOfTourney == 'waiting')
		  $arChoose = array('' => $cxml->printString($lang['ar.2.1'],$cevent->convertTSToDB($arTourneys[$iCnt][tsStartTime])));

		$desText[1][text] = $cdesign->createSelectBox("in_enumStatus_".$arTourneys[$iCnt][iTourneyID],$arChoose,"",$arNoOpts);
	    $desText[2][text] = "<a href=\"$PHP_SELF?cmd=admin_overview&amp;iTourneyID=".$arTourneys[$iCnt][iTourneyID]."\">".$cgames->getNameOfGame($arTourneys[$iCnt][iGameID])." ".$arTourneys[$iCnt][iConstellation]."on".$arTourneys[$iCnt][iConstellation]."</a>";
	    $cl->TableText($desText);
	    $cl->FormHidden("in_arIDs[]",$arTourneys[$iCnt][iTourneyID]);
	  }

	  (!$iCnt) ? (($desText[0][colspan] = 4) && ($desText[0][text] = $cxml->printString($lang['message.no_entries'])) && ($cl->cellsTop($desText))) : ($cl->FormSubmit("4",$lang['admin.selected.delete']));
	}
	// XML::COMMENT (iTourneyID wurde angegeben, also Turniersettings laden)
	else
	{
      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;what=change&amp;iTourneyID=$iTourneyID","");

	  $arTourney = $ctcontrol->getTourneySettings($iTourneyID);

	  $m_ar = $cgames->getNameOfGamesAsArray();
	  $desTop[0][text] = $cxml->printString($lang['admin.change.subject.settings']);
	  $desTop[0][colspan] = 2;
	  $cl->cellsTop($desTop);

	  $szStatusOfTourney = $ctcontrol->getRoundStatus($iTourneyID);

	  if ($szStatusOfTourney != 'closed')
	  {
	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.game']),$cdesign->createSelectBox("in_iGameID",$m_ar,$arTourney[iGameID],$arNoOpts),"out");

	    // XML::COMMENT (Wieviel gegen wieviel => legt automatisch die Teamgröße fest)
	    for ($iCnt = 1;$iCnt<=16;$iCnt++)
	      $arConstellation[$iCnt] = $iCnt."on".$iCnt;

        $cl->cells2Noopt($cxml->printString($lang['admin.overview.constellation']),$cdesign->createSelectBox("in_iConstellation",$arConstellation,$arTourney['iConstellation'],$arNoOpts),"out");

	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.tourney_start']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_change_start'))." ".$cevent->createDateMenu($noopt).", ".$cevent->createTimeMenu($noopt),"out");

	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.tourney_end']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_change_end'))." ".$cevent->createDateMenu(array('fname' => '_end')).", ".$cevent->createTimeMenu(array('fname' => '_end')),"out");

	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.join_start']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_change_join'))." ".$cevent->createDateMenu(array('fname' => '_join')).", ".$cevent->createTimeMenu(array('fname' => '_join')),"out");

	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.max_teams']),$cdesign->createSelectBox("in_iMaxTeams",$ctcontrol->getDE2PotencesAsHash(),$arTourney['iOrgMaxTeams'],$arNoOpts),"out");

	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.tourney_type']),$cdesign->createSelectBox("in_enumMode",$ctcontrol->getTourneyTypes(),$arTourney[enumMode],$arNoOpts),"out");

	    // XML::COMMENT (Was soll geschehen, wenn ein Turnier wgn. zu wenig Teilnehmern nicht stattfindet?)
	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.handle_low_team_number']),$cdesign->createSelectBox("in_enumHandleLowTeams",$arHandleLowTeamNumber,$arTourney[enumHandleLowTeams],$arNoOpts),"out");

	    // XML::COMMENT (Nur Administrator darf Ergebnisse von Spielen eintragen)
	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.only_admin']),$cl->createInput(array('type' => 'checkbox', 'checked' => $arTourney[bAllowSubmitFightOnlyByAdmin], 'name' => 'in_bAllowSubmitFightOnlyByAdmin')),"out");

	    // XML::COMMENT (Nur Looserteam darf Ergebnisse von Spielen eintragen)
	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.only_looser']),$cl->createInput(array('type' => 'checkbox', 'checked' => $arTourney[bAllowSubmitFightOnlyByLoser], 'name' => 'in_bAllowSubmitFightOnlyByLoser')),"out");
	  }


	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.prizes']),$cl->createTextarea(array('name' => 'in_szPrices', 'value' => $ctext->br2nl($arTourney[szPrices]))),"out");

	  $cl->cellsDummy("2","");
	  $cl->cellsTop(array(array('text' => $cxml->printString($lang['admin.change.subject.wwcl']), 'colspan' => '2')));

	  if (!$m_ar = $cgames->getXMLWwclGameIniAsArray())
		$cfunc->faultExt($cxml->printString($lang['fault.could_not_parse_wwcl'],language));

	  $cl->cells2Noopt($cxml->printString($lang['admin.change.wwcl_game']),$cdesign->createSelectBox("in_iWWCLGameID",$m_ar,$arTourney['iWWCLGameID'],$arNoOpts),"out");
	  $cl->cellsDummy("2","");

	  $cl->cellsTop(array(array('text' => $cxml->printString($lang['admin.change.subject.ngl']), 'colspan' => '2')));

	  if (!$m_ar = $cgames->getXMLNglGameIniAsArray())
		$cfunc->faultExt($cxml->printString($lang['fault.could_not_parse_ngl'],language));

	  $cl->cells2Noopt($cxml->printString($lang['admin.change.ngl_game']),$cdesign->createSelectBox("in_iNGLGameID",$m_ar,$arTourney['iNGLGameID'],$arNoOpts),"out");
	  $cl->cellsDummy("2","");

	  $desTop[0][text] = $cxml->printString($lang['admin.change.subject.runtime']);
	  $desTop[0][colspan] = 2;
	  $cl->cellsTop($desTop);

	  if ($arTourney[mappool])
	    $cl->cells2Noopt($cxml->printString($lang['admin.change.mappool']),"<a href=\"phpGamesAdmin.php?cmd=admin_mappool&amp;id=".$arTourney[iGameID]."\">".$cxml->printString($lang['admin.change.link.mappool'])."</a>","out");

	  if (($szStatusOfTourney != 'closed') && (!$szStatusOfTourney != 'waiting'))
	    $cl->cells2Noopt($cxml->printString($lang['admin.change.pause_tourney']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bMatchPaused', 'checked' => $arTourneys['bMatchPaused'])),"out");

	  $cl->cells2Noopt($cxml->printString($lang['admin.change.teams']),"<a href=\"$PHP_SELF?cmd=admin_kick&amp;iTourneyID=$iTourneyID\">".$cxml->printString($lang['admin.change.link.teams'])."</a>","out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.change.matches']),"<a href=\"$PHP_SELF?cmd=admin_matches&amp;iTourneyID=$iTourneyID\">".$cxml->printString($lang['admin.change.link.matches'])."</a>","out");
	  //$cl->cells2Noopt($cxml->printString($lang['admin.change.results']),"<a href=\"$PHP_SELF?cmd=admin_fights&amp;iTourneyID=$iTourneyID\">".$cxml->printString($lang['admin.change.link.results'])."</a>","out");

      $cl->FormSubmit("2",$cxml->printString($lang['admin.change.form']));
	}
  }
  elseif ($_GET['cmd'] == 'admin_tourney_assistent')
  {
	if (!$_GET['page'])
	  $_GET['page'] = 'start';

	$cl->cellsTop(array(array('text' => $cxml->printString($lang['admin.tourney_assistent.subject.'.$_GET['page']]), 'colspan' => 2)));
	$cl->TableText(array(array('text' => $cxml->printString($lang['admin.tourney_assistent.hint.'.$_GET['page']]), 'colspan' => 2)));

    // XML::CODE (Eingegebene Daten als Session-Variable verfügbar machen)
    $cl->parsePostString(array('szSpacer' => 'tourney'));

	if ($_GET['page'] == 'start')
	{
	  $arGames = $cgames->getNameOfGamesAsArray();

	  $cl->FormNew("$PHP_SELF?cmd=admin_tourney_assistent&amp;page=settings","");

      if (!is_array($arGames))
        $cl->cells2Noopt($cxml->printString($lang['admin.overview.game']),$cxml->printString($lang['admin.overview.no_games'])." ".$cxml->printString($lang['admin.overview.add_game']),"out");
	  else
	    $cl->cells2Noopt($cxml->printString($lang['admin.overview.game']),$cdesign->createSelectBox("in_iGameID",$arGames,$_SESSION['temp_tourney_iGameID'],$arNoOpts)." ".$cxml->printString($lang['admin.overview.add_game']),"out");

	  // XML::COMMENT (Wieviel gegen wieviel => legt automatisch die Teamgröße fest)
	  for ($iCnt = 1;$iCnt<=16;$iCnt++)
	    $arConstellation[$iCnt] = $iCnt."on".$iCnt;

	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.constellation']),$cdesign->createSelectBox("in_iConstellation",$arConstellation,$_SESSION['temp_tourney_iConstellation'],$arNoOpts),"out");

	  // XML::COMMENT (Maximale Anzahl von Teams festlegen)
	  for ($iCnt = 0;$iCnt<count($arDE2Potences);$iCnt++)
	    $arMaxTeams[$arDE2Potences[$iCnt]] = $arDE2Potences[$iCnt];

	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.max_teams']),$cdesign->createSelectBox("in_iMaxTeams",$arMaxTeams,$_SESSION['temp_tourney_iMaxTeams'],$arNoOpts),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.tourney_type']),$cdesign->createSelectBox("in_enumMode",$ctcontrol->getTourneyTypes(),$_SESSION['temp_tourney_enumMode'],$arNoOpts),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.coins']),$cl->createInput(array('type' => 'text', 'name' => 'in_iCoins', 'value' => $_SESSION['temp_tourney_iCoins'],'size' => '2')),"out");
	}
	elseif ($_GET['page'] == 'settings')
	{
	  $cl->FormNew("$PHP_SELF?cmd=admin_tourney_assistent&amp;page=leagues","");

	  $cl->FormHidden("in_hidden_bAllowSubmitFightOnlyByAdmin","1");
	  $cl->FormHidden("in_hidden_bAllowSubmitFightOnlyByLoser","1");
	  $cl->FormHidden("in_hidden_bForceScreenshotUpload","1");
	  $cl->FormHidden("in_hidden_bSortTeamsStrict","1");

	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.prizes']),$cl->createTextarea(array('name' => 'in_szPrices', 'value' => $_SESSION['temp_tourney_szszPrices'])),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.only_admin']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bAllowSubmitFightOnlyByAdmin', 'checked' => $_SESSION['temp_tourney_bAllowSubmitFightOnlyByAdmin'])),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.only_looser']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bAllowSubmitFightOnlyByLoser', 'checked' => $_SESSION['temp_tourney_bAllowSubmitFightOnlyByLoser'])),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.force_ss_upload']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bForceScreenshotUpload', 'checked' => $_SESSION['temp_tourney_bForceScreenshotUpload'])),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.main_orga']),$cuser->createUsernameMenu(array('only_admin' => '1', 'user_selected' => $_SESSION['temp_tourney_iUserID'], 'name' => 'in_iUserID')),"out");
	}
	elseif ($_GET['page'] == 'leagues')
	{
	  $cl->FormNew("$PHP_SELF?cmd=admin_tourney_assistent&amp;page=automatic","");

	  $cl->FormHidden("in_hidden_bWWCLSupport","1");
	  $cl->FormHidden("in_hidden_bNGLSupport","1");
	

	  if (!$arWWCLGames = $cgames->getXMLWwclGameIniAsArray())
		$bWWCLIsDisabled = '1';

	  if (!$arNGLGames = $cgames->getXMLNglGameIniAsArray())
		$bNGLIsDisabled = '1';

	  if ($bWWCLIsDisabled)
	    $cl->TableText(array(array('text' => $cxml->printString($lang['fault.could_not_parse_wwcl'],language), 'colspan' => '2')));

	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.wwcl_support']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bWWCLSupport', 'checked' => $_SESSION['temp_tourney_bWWCLSupport'], 'disabled' => $bWWCLIsDisabled)),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.change.wwcl_game']),$cdesign->createSelectBox("in_iWWCLGameID",$arWWCLGames,$arTourney['iWWCLGameID'],array('bIsDisabled' => $bWWCLIsDisabled)),"out");

	  if ($bNGLIsDisabled)
	    $cl->TableText(array(array('text' => $cxml->printString($lang['fault.could_not_parse_ngl'],language), 'colspan' => '2')));

	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.ngl_support']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bNGLSupport', 'checked' => $_SESSION['temp_tourney_bNGLSupport'], 'disabled' => $bNGLIsDisabled)),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.change.ngl_game']),$cdesign->createSelectBox("in_szNGLGameID",$arNGLGames,$arTourney['szNGLGameID'],array('bIsDisabled' => $bNGLIsDisabled)),"out");
	}
	elseif ($_GET['page'] == 'automatic')
	{
	  $cl->FormNew("$PHP_SELF?cmd=admin_tourney_assistent&amp;page=timeline","");

	  // XML::COMMENT (Mappool verwenden)
	  $arMaps = array('' => $cxml->printString($lang['ar.3.no_map']),
					'bUseMappool'	=> $cxml->printString($lang['ar.3.mappool']),
					'bTeamCanAdd'		=> $cxml->printString($lang['ar.3.team_can_add']),
					);

	  $cl->FormHidden("in_hidden_bUseServerPool","1");
	  $cl->FormHidden("in_hidden_bPostNewsAfterTourneyEnds","1");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.activate_mappool']),$cdesign->createSelectBox("in_enumMapPool",$arMaps,$_SESSION['temp_tourney_enumMapPool'],$arNoOpts),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.activate_serverpool']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bUseServerPool', 'checked' => $_SESSION['temp_tourney_bUseServerPool'])),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.handle_low_team_number']),$cdesign->createSelectBox("in_enumHandleLowTeams",$arHandleLowTeamNumber,$_SESSION['temp_tourney_enumHandleLowTeams'],$arNoOpts),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.post_news']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bPostNewsAfterTourneyEnds', 'checked' => $_SESSION['temp_tourney_bPostNewsAfterTourneyEnds'])),"out");
	}
	elseif ($_GET['page'] == 'timeline')
	{
	  $cl->FormNew("$PHP_SELF?cmd=admin_tourney_assistent&amp;page=finish","");

	  $cl->FormHidden("in_hidden_bJoinStart","1");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.tourney_start']),$cevent->createDateMenu($noopt).", ".$cevent->createTimeMenu($noopt),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.tourney_end']),$cevent->createDateMenu(array('fname' => '_end')).", ".$cevent->createTimeMenu(array('fname' => '_end')),"out");
	  $cl->cells2Noopt($cxml->printString($lang['admin.overview.join_start']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bJoinStart'))." ".$cevent->createDateMenu(array('fname' => '_join')).", ".$cevent->createTimeMenu(array('fname' => '_join')),"out");
      ($ctcontrol->getTourneyGroupsAsHash($arNoOpts)) ? ($szSelectGroup = $cdesign->createSelectBox("in_iGroupID",$ctcontrol->getTourneyGroupsAsHash($arNoOpts),$_SESSION['temp_tourney_iGroupID'],$arNoOpts)) : ($szSelectGroup = $cxml->printString($lang['fault.no_groups']));
      $cl->cells2Noopt($cxml->printString($lang['admin.overview.assign_group']),$szSelectGroup,"out");
	}

	// XML::COMMENT (Falls der letzte Schritt aufgerufen wurde, brauchen wir kein Submit-Button mehr)
	if ($_GET['page'] != 'finish')
	  $cl->FormSubmit("2",$cxml->printString($lang['admin.tourney_assistent.form.'.$_GET['page']]));
	// XML::COMMENT (Wir müssen nun das Turnier erstellen)
	else
	  $ctcontrol->createTourney($_SESSION);
  }
  elseif ($_GET['cmd'] == 'admin_fights')
  {
  }
  elseif ($_GET['cmd'] == 'admin_timeline')
  {
    if (!$_GET['page'])
    {
      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;what=timeline_delete","");

      $desTop[0][text] = "";
      $desTop[1][text] = $cxml->printString($lang['admin.timeline.subject.groupname']);
      $desTop[2][text] = $cxml->printString($lang['admin.timeline.subject.begin']);
      $desTop[3][text] = $cxml->printString($lang['admin.timeline.subject.end']);
      $desTop[4][text] = $cxml->printString($lang['admin.timeline.subject.edit']);
	  $cl->cellsTop($desTop);

      $arGroups = $ctcontrol->getTourneyGroups($arNoOpts);

      for ($iCnt = 0;$iCnt<count($arGroups);$iCnt++)
      {
        (!$arGroups[$iCnt][szGroupName]) ? ($arGroups[$iCnt][szGroupName] = $lang_def['unknown']) : ($dummy);

        $desText[0][text] = $cl->createInput(array('type' => 'checkbox', 'name' => 'in_arToDelete[]', 'value' => $arGroups[$iCnt][iGroupID]));
        $desText[1][text] = "<a href = \"$PHP_SELF?cmd=admin_timeline&amp;page=handle&amp;iGroupID=".$arGroups[$iCnt][iGroupID]."\">".$arGroups[$iCnt][szGroupName]."</a>";
        $desText[2][text] = $cevent->convertTSToDB($arGroups[$iCnt][tsStartLine]);
        $desText[3][text] = $cevent->convertTSToDB($arGroups[$iCnt][tsEndLine]);
        $desText[4][text] = "<a href = \"phpTurnierAdmin.php?cmd=admin_timeline&amp;page=edit_timeline&amp;iGroupID=".$arGroups[$iCnt][iGroupID]."\">".$cxml->printString($lang['admin.timeline.link.edit_timeline'])."</a>";
        $cl->TableText($desText);
      }

      if (!$iCnt)
        $cl->TableText(array(array('text' => $cxml->printString($lang['message.no_entries.3']), 'colspan' => 5)));
      else
        $cl->FormSubmit("5",$cxml->printString($lang['admin.timeline.form']));

      $cl->cellsDummy("5","");
      $cl->TableText(array(array('text' => $cxml->printString($lang['admin.timeline.link.add_timeline']), 'colspan' => 5, 'p_class' => 'center')));
    }
    elseif ($_GET['page'] == 'handle')
    {
      if (!$_GET['iGroupID'])
        $szTop = $cxml->printString($lang['admin.timeline.subject.add_timeline']);
      else
      {
        $szTop = $cxml->printString($lang['admin.timeline.subject.edit_timeline']);
        $szForm = "&amp;iGroupID=".$_GET['iGroupID'];
        $arGroup = $ctcontrol->getTourneyGroups(array('iGroupID' => $_GET['iGroupID']));
      }

      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;what=handle".$szForm,"");
      $cl->cellsTop(array(array('text' => $szTop, 'colspan' => 2)));
      $cl->cells2Noopt($cxml->printString($lang['admin.timeline.handle.groupname']),$cl->createInput(array('type' => 'text', 'name' => 'in_szGroupName', 'value' => $arGroup[0][szGroupName])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.timeline.handle.desc']),$cl->createTextarea(array('name' => 'in_szDescription', 'value' => $arGroup[0][szDescription])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.timeline.handle.max_join']),$cl->createInput(array('name' => 'in_iMaxJoinForUser', 'value' => $arGroup[0][iMaxJoinForUser], 'maxlength' => 2)),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.timeline.handle.start_join']),$cevent->createDateMenu(array('fname' => '_start_join')).", ".$cevent->createTimeMenu(array('fname' => '_start_join')),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.timeline.handle.end_join']),$cevent->createDateMenu(array('fname' => '_end_join')).", ".$cevent->createTimeMenu(array('fname' => '_end_join')),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.timeline.handle.start_group']),$cevent->createDateMenu(array('fname' => '_start_group')).", ".$cevent->createTimeMenu(array('fname' => '_start_group')),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.timeline.handle.end_group']),$cevent->createDateMenu(array('fname' => '_end_group')).", ".$cevent->createTimeMenu(array('fname' => '_end_group')),"out");
      $cl->FormSubmit("2","");
    }
    elseif ($_GET['page'] == 'edit_timeline')
    {
      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;what=timeline_edit&amp;iGroupID=".$_GET['iGroupID'],"");

      $arTimeline = $ctcontrol->getTimeline(array('iGroupID' => $_GET['iGroupID']));
      $tsStart 	  = $ctcontrol->getTimelineBorder(array('iGroupID' => $_GET['iGroupID'], 'enumMode' => 'start'));
      $tsEnd 	  = $ctcontrol->getTimelineBorder(array('iGroupID' => $_GET['iGroupID'], 'enumMode' => 'end'));

	  $arDateStart = getdate($tsStart);
	  $arDateEnd  = getdate($tsEnd);

      $tsNowStart = mktime(0,0,0,$arDateStart['mon'],$arDateStart['mday'],$arDateStart['year']);
      $tsNowEnd = mktime($arDateEnd['hours'],0,0,$arDateEnd['mon'],$arDateEnd['mday'],$arDateEnd['year']);

      $arTimeline = $ctcontrol->getXMLTimeline();

      for ($iCnt = $tsNowStart;$iCnt<($tsNowEnd + 1);$iCnt+=3600)
      {
        $arTimelineEntry = $ctcontrol->getTimeline(array('tsStart' => $iCnt));
        $arNowDate = getdate($iCnt);

        if ($arNowDate['mday'] != $iLastMDay)
        {
          $cl->cellsTop(array(array('text' => $cevent->getDateOfTimestamp($iCnt),'colspan' => '3')));
          $iLastMDay = $arNowDate['mday'];
        }

        $cl->FormHidden("in_arIDs[]",$arTimelineEntry[0][id]);
        $desText[0][text] = $arNowDate['hours'];

		$desText[1][text] = '&nbsp;';
        $desText[1][p_class] = $arTimelineEntry[0][szSymbol];
        $desText[1][title] = $arTimeline[$arTimelineEntry[0][szSymbol]];
        $desText[2][text] = $cdesign->createSelectBox("in_szSymbol_".$arTimelineEntry[0][id],$arTimeline,$arTimelineEntry[0][szSymbol],$arNoOpts);

        $cl->TableText($desText);
      }

      $cl->FormSubmit("3",$cxml->printString($lang['admin.timeline.form.2']));
    }
  }
  elseif ($_GET['cmd'] == 'admin_matches')
  {
    $arTourneys = $ctcontrol->getTourneySettings($iTourneyID);

    if ($arTourneys[iRoundOf1])
      $iBracket = "1";

    $arPlan = $ctcontrol->getPlan(array('iTourneyID' => $iTourneyID, 'iBracket' => $iBracket));

    $cl->newForm(array('action' => "$PHP_SELF?cmd=cmd_update&amp;what=matches&amp;iTourneyID=$iTourneyID", 'jsEventOnSubmit' => "selectAll('in_left[]','in_right[]')"));

    for ($iCnt = 0;$iCnt<count($arPlan);$iCnt++)
    {
      $arSelectLeft[$arPlan[$iCnt][iTeam1ID]] = $ctcontrol->getNameOfTeam($arPlan[$iCnt][iTeam1ID]);
      $arSelectRight[$arPlan[$iCnt][iTeam2ID]] = $ctcontrol->getNameOfTeam($arPlan[$iCnt][iTeam2ID]);
      $cl->FormHidden("in_seedings[]",$arPlan[$iCnt][id].":".$arPlan[$iCnt][iTeam1ID].":".$arPlan[$iCnt][iTeam2ID]);
    }

    $iSize = count($arSelectLeft);

    $cl->cellsTop(array(array('colspan' => 3, 'text' => $cxml->printString($lang['admin.matches.subject']))));
    $cl->TableText(array(array('colspan' => 3, 'text' => $cxml->printString($lang['admin.matches.hint']))));
    $cl->cellsDummy("3","");

    $desText[0][text] = $cdesign->createSelectBox("in_left[]",$arSelectLeft,"",array('iSize' => $iSize, 'jsEventOnChange' => "checkSelect('in_left[]')", 'bIsMultiple' => 1));
    $desText[0][rowspan] = 3;
    $desText[1][text] = $cl->createInput(array('type' => 'button', 'disabled' => 1, 'value' => $cxml->printString($lang['admin.matches.button.swap']), 'name' => 'but_swap', 'jsEventOnClick' => 'buttonSwap()'));
    $desText[2][text] = $cdesign->createSelectBox("in_right[]",$arSelectRight,"",array('iSize' => $iSize, 'jsEventOnChange' => "checkSelect('in_right[]')", 'bIsMultiple' => 1));
    $desText[2][rowspan] = 3;
    $cl->TableTExt($desText);
	unset($desText);

	$cl->TableText(array(array('text' => $cl->createInput(array('type' => 'button', 'disabled' => 1, 'value' => $cxml->printString($lang['admin.matches.button.top']), 'name' => 'but_top', 'jsEventOnClick' => "buttonPosition('top')")))));
	$cl->TableText(array(array('text' => $cl->createInput(array('type' => 'button', 'disabled' => 1, 'value' => $cxml->printString($lang['admin.matches.button.bottom']), 'name' => 'but_bottom', 'jsEventOnClick' => "buttonPosition('bottom')")))));
    $cl->FormSubmit("3","");
  }
  elseif ($_GET['cmd'] == 'admin_kick')
  {
    $arTourneys = $ctcontrol->getTourneySettings($iTourneyID);

    if (!$id)
    {
      $arOpts[key]   = 'iTourneyID';
      $arOpts[value] = $iTourneyID;
      $arTeams = $ctcontrol->getTeams($arOpts);

      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;what=kick&amp;iTourneyID=$iTourneyID","");
	  $desTop[0][text] = "&nbsp;";
	  $desTop[1][text] = $cxml->printString($lang['admin.kick.subject.teams']);
	  $desTop[2][text] = $cxml->printString($lang['admin.kick.subject.count_teams']);
	  $cl->cellsTop($desTop);

      for ($iCnt = 0;$iCnt<count($arTeams);$iCnt++)
      {
        if ($arTeams[$iCnt][iStatus] > 0)
        {
          $arPlayers = $ctcontrol->getPlayers(array('iTeamID' => $arTeams[$iCnt][iTeamID]));

          for ($iCnt2 = 0;$iCnt2<count($arPlayers);$iCnt2++)
          {
            if ($arPlayers[$iCnt2][bIsTeamleader])
              $iTeamleaderID = $arPlayers[$iCnt2][iUserID];
          }

          $desText[0][p_class] = 'option';
          $desText[0][text]	= "<input type=checkbox name=in_tokick[] value=\"".$arTeams[$iCnt][iTeamID]."\">";
          $desText[1][p_class] = 'right';

          if (($iCnt2 > 1) && ($arTourneys[iConstellation] > 1))
            $desText[1][text] = "<a href = \"phpTurnierAdmin.php?cmd=admin_kick&amp;iTourneyID=$iTourneyID&amp;id=".$arTeams[$iCnt][iTeamID]."\">".$arTeams[$iCnt][szTeamname]."</a>";
          else
            $desText[1][text] = "<a href=\"phpTurnierIndex.php?cmd=show_details&amp;what=team&amp;iTourneyID=$iTourneyID&amp;id=".$arTeams[$iCnt][id]."\">".$arTeams[$iCnt][szTeamname]."</a>";

          $desText[2][text] = $cxml->printString($lang['admin.kick.team_info'],$iCnt2,$cdesign->createUserLink(array('user' => $iTeamleaderID)));

          $cl->TableText($desText);
	    }
	  }

	  unset($desText);
	  (!$iCnt) ? (($desText[0][text] = $cxml->printString($lang['message.no_entries.2'])) && ($cl->cellsTop($desText))) : ($cl->FormSubmit("3",$cxml->printString($lang['admin.kick.form.1'])));
    }
    else
    {
      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;what=kickplayer","");
      $cl->cellsTop(array(array('text' => "&nbsp;"),array('text' => $cxml->printString($lang['admin.kick.subject.player_name']))));
      $cl->FormHidden("in_teamid",$id);

      $arPlayers = $ctcontrol->getPlayersOfTeam($id);

      for ($iCnt = 0;$iCnt<count($arPlayers);$iCnt++)
      {
        if ($arPlayers[$iCnt][bIsTeamleader])
          $cl->FormHidden("in_teamleader",$arPlayers[$iCnt][id]);

        $cl->cells2Noopt($cl->createInput(array('type' => 'checkbox', 'name' => 'in_tokick[]', 'value' => $arPlayers[$iCnt][id])),$cdesign->createUserLink(array('user' => $arPlayers[$iCnt][iUserID])),"out");
      }

      $cl->FormSubmit("2",$cxml->printString($lang['admin.kick.form.2']));
    }
  }
  elseif ($_GET['cmd'] == 'cmd_update')
  {
	if ($_GET['what'] == 'change')
	{
	  (!$_GET['iTourneyID']) ? ($cfunc->faultExt($cxml->printString($lang['fault.no_iTourneyID']))) : ($dummy);

      if ($_POST['in_change_start'])
	    $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'tsStartTime', 'szValue' => mktime($in_hour,$in_min,0,$in_month,$in_day,$in_year)));

      if ($_POST['in_change_join'])
	    $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'tsJoinStart', 'szValue' => mktime($in_hour_join,$in_min_join,0,$in_month_join,$in_day_join,$in_year_join)));

      if ($_POST['in_change_end'])
	    $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'tsEndTime', 'szValue' => mktime($in_hour_end,$in_min_end,0,$in_month_end,$in_day_end,$in_year_end)));

	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'iGameID', 'szValue' => $_POST['in_iGameID']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'iConstellation', 'szValue' => $_POST['in_iConstellation']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'iMaxTeams', 'szValue' => $_POST['in_iMaxTeams']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'iWWCLGameID', 'szValue' => $_POST['in_iWWCLGameID']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'iNGLGameID', 'szValue' => $_POST['in_iNGLGameID']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'szPrices', 'szValue' => $_POST['in_szPrices']));

	  // XML::COMMENT (Spieltyp)
  	  if ($_POST['in_iMaxTeams'] < 4)
	    $_POST['in_enumMode'] = "mode_single";

	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'enumMode', 'szValue' => $_POST['in_enumMode']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'bAllowSubmitFightOnlyByAdmin', 'szValue' => $_POST['in_bAllowSubmitFightOnlyByAdmin']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'bAllowSubmitFightOnlyByLoser', 'szValue' => $_POST['in_bAllowSubmitFightOnlyByLoser']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'enumHandleLowTeams', 'szValue' => $_POST['in_enumHandleLowTeams']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'szPrice', 'szValue' => $_POST['in_szPrice']));
	  $ctcontrol->setTourneySettings(array('iTourneyID' => $_GET['iTourneyID'], 'szKey' => 'bMatchPaused', 'szValue' => $_POST['in_bMatchPaused']));
	}
	elseif ($_GET['what'] == 'status')
	{
	  for ($iCnt = 0;$iCnt<count($_POST['in_arIDs']);$iCnt++)
	  {
	    $szStatus = ${'in_enumStatus_'.$_POST['in_arIDs'][$iCnt]};

	    if ($szStatus == 'bStopTourney')
	      $ctcontrol->setTourneySettings(array('iTourneyID' => $_POST['in_arIDs'][$iCnt], 'szKey' => 'bMatchPaused', 'szValue' => '1'));
	    elseif ($szStatus == 'bContinueTourney')
	      $ctcontrol->setTourneySettings(array('iTourneyID' => $_POST['in_arIDs'][$iCnt], 'szKey' => 'bMatchPaused', 'szValue' => ''));
	    elseif ($szStatus == 'bStartNow')
	    {
	      $ctcontrol->setTourneySettings(array('iTourneyID' => $_POST['in_arIDs'][$iCnt], 'szKey' => 'enumHandleLowTeams', 'szValue' => 'bFillWithFreeDummies'));
	      $ctcontrol->setTourneySettings(array('iTourneyID' => $_POST['in_arIDs'][$iCnt], 'szKey' => 'bTourneyWasStartedManual', 'szValue' => '1'));
	      $ctcontrol->setTourneySettings(array('iTourneyID' => $_POST['in_arIDs'][$iCnt], 'szKey' => 'tsStartTime', 'szValue' => $cevent->getNowTimestamp()));
	    }
	  }

	  // XML::COMMENT (Nachträglich alle Turniere löschen)
	  $ctcontrol->deleteTourneys($in_arToDelete);
	}
	elseif ($_GET['what'] == 'kick')
	{
	  $arOpts[iTourneyID] = $_GET['iTourneyID'];

	  for ($iCnt = 0;$iCnt<count($in_tokick);$iCnt++)
	  {
	    $arOpts['iTeamID'] = $in_tokick[$iCnt];

	    if ($arOpts['iTeamID'] != '')
	      $cmatch->kickTeamFromRunningMatch($arOpts);
	  }
	}
	elseif ($_GET['what'] == 'kickplayer')
	{
	  for ($iCnt = 0;$iCnt<count($in_tokick);$iCnt++)
	  {
	    $ctcontrol->deletePlayer(array('iPlayerID' => $in_tokick[$iCnt]));

	    if ($in_tokick[$iCnt] == $in_teamleader)
	      $bSetNewTeamleader = 1;
	  }

	  if ($bSetNewTeamleader)
	    $ctcontrol->setNewTeamleader(array('iTeamID' => $in_teamid));
	}
	elseif ($_GET['what'] == 'fights')
	{
	  for ($iCnt = 0;$iCnt<count($in_teams);$iCnt++)
	  {
	    $m_teams = explode(":",$in_teams[$iCnt]);

	    $arOpts[iTourneyID] = $_GET['iTourneyID'];
	    $arOpts[iTeam1ID] = $m_teams[0];
	    $arOpts[iTeam2ID] = $m_teams[1];
	    $arOpts[iPointsTeam1]   = ${$m_teams[0]."result"};
	    $arOpts[iPointsTeam2]   = ${$m_teams[1]."result"};

	    if (($arOpts[iPointsTeam1] == $arOpts[iPointsTeam2]) && (($arOpts[iPointsTeam1] != '') && ($arOpts[iPointsTeam2] != '')))
	      $cfunc->faultExt($cxml->printString($lang['fault.no_winner']));
		if ((!$arOpts[iTeam1ID]) || (!$arOpts[iTeam2ID]) || ($arOpts[iTeam1ID] == $arOpts[iTeam2ID]))
		  $cfunc->faultExt($cxml->printString($lang['fault.parse_data']));

	    $cmatch->changeFight($arOpts);
	    unset($arOpts);
	  }
	}
	elseif ($_GET['what'] == 'add_freedummy')
	{
	  $ctcontrol->addDebugFreeDummy(array('iTourneyID' => $_GET['iTourneyID'], 'szMissingField' => $missing, 'iPlanID' => $id));
	}
	elseif ($_GET['what'] == 'add_freedummy_match')
	{
	  $ctcontrol->addDebugFreeDummyMatch(array('iTourneyID' => $_GET['iTourneyID']));
	}
	elseif ($_GET['what'] == 'matches')
	{
	  for ($iCnt = 0;$iCnt<count($in_seedings);$iCnt++)
	  {
	    $arSeeding = explode(":",$in_seedings[$iCnt]);

	    $arMatch[$arSeeding[1]] = $arSeeding[2];
	    $arID[$arSeeding[1]] = $arSeeding[0];
	    $arID[$arSeeding[2]] = $arSeeding[0];
	  }

	  for ($iCnt = 0;$iCnt<count($in_left);$iCnt++)
	  {
	    if (($arMatch[$in_left[$iCnt]] == $in_right[$iCnt]) || ($arMatch[$in_right[$iCnt]] == $in_left[$iCnt]))
	      continue;
	    else
	      $cmatch->changeMatch(array('iPlanID' => $arID[$in_left[$iCnt]], 'iTeam1ID' => $in_left[$iCnt], 'iTeam2ID' => $in_right[$iCnt], 'iTourneyID' => $_GET['iTourneyID']));
	  }
	}
	elseif ($_GET['what'] == 'handle')
	{
	  $arOpts = $cl->getPostOptions($arNoOpts);

	  $arOpts['tsStartLine'] = $cevent->createTimestampFromMenu(array('fname' => '_start_group'));
	  $arOpts['tsEndLine'] = $cevent->createTimestampFromMenu(array('fname' => '_end_group'));
	  $arOpts['tsJoinStartLine'] = $cevent->createTimestampFromMenu(array('fname' => '_start_join'));
	  $arOpts['tsJoinEndLine'] = $cevent->createTimestampFromMenu(array('fname' => '_end_join'));

	  if ($_GET['iGroupID'])
	  {
	    $arOpts['iGroupID'] = $_GET['iGroupID'];
	    $ctcontrol->setTourneyGroup($arOpts);
	  }
	  else
	  {
	    $ctcontrol->addTourneyGroup($arOpts);
	  }
	}
	elseif ($_GET['what'] == 'timeline_delete')
	{
	  for ($iCnt = 0;$iCnt<count($_POST['in_arToDelete']);$iCnt++)
	    $ctcontrol->deleteTourneyGroups($_POST['in_arToDelete'][$iCnt]);
	}
	elseif ($_GET['what'] == 'timeline_edit')
	{
	  for ($iCnt = 0; $iCnt<count($_POST['in_arIDs']);$iCnt++)
	    $ctcontrol->setTimeline(array('iTimelineID' => $_POST['in_arIDs'][$iCnt], 'szSymbol' => $_POST['in_szSymbol_'.$_POST['in_arIDs'][$iCnt]]));
	}
	printDanke();
  }

  // XML::COMMENT (Seite abschließen)
  $cdesign->createSiteFooter($arOpts);
?>
Return current item: PhpChrystal - An Open Intranet System