<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
  $OrganizerName = '';
  $OrganizerURL = '';
  $OrganizerIDToEdit = '';
  $OldOrganizerName = '';
  // POST-Variablen definieren
    if ( isset($_POST['senden']) )
    {
      foreach ($_POST as $key => $value) { $$key = $value; };
      // Formular überprüfen
        if ( $senden
             && $OrganizerName
             && (!isOrganizerInDatabase($OrganizerName)
                  OR $OrganizerName == $OldOrganizerName
                  OR ($job=='edit') AND !isOrganizerInDatabase($OrganizerName))
             && ( !$OrganizerURL OR checkURL( $OrganizerURL ) )
           )
        {
          $FormularKorrektAusgefuellt = true;
        }
        else 
        { 
          $FormularKorrektAusgefuellt = false; 
          $OrganizerIDToEdit = '';
        }
    }
    else
    {  
      if ( isset($_REQUEST['id'])  ) { $OrganizerID = $_REQUEST['id']; }
        else $OrganizerID ="";
      if ($_REQUEST['job']=='edit')
      { 
        $SQL = "SELECT * FROM ".DB_PREFIX."organizers Where OrganizerID = '$OrganizerID'";
        $resultat = mysql_query($SQL);
        while ($row = mysql_fetch_array($resultat)) { extract($row); }
        $OldOrganizerName = $OrganizerName;
      }
      $FormularKorrektAusgefuellt = false;
      $senden = ''; 
    }
  if ( !IsUserAdmin() ) echo $L_015;
  else
  {
    if ($FormularKorrektAusgefuellt == true)
    { 
      $Organizer = array( $OrganizerID, $OrganizerName, $OrganizerURL);
      // Organizer hinzufügen
      if ($_REQUEST['job']=='add')
      {
        if (addOrganizer($Organizer, "add")) echo $L_Organizer_successfully_saved.'<br />';
          else echo $L_ERROR_Organizer_NOT_saved.'<br />';
      }
      // Organizer bearbeiten
      if ($_REQUEST['job']=='edit')
      {
        if (addOrganizer($Organizer, "edit")) echo $L_Organizer_successfully_edited.'<br />';
          else echo $L_ERROR_Organizer_NOT_edited.'<br />';
      }
    echo '<br />
          <form method="post" action="index.php?submenu=calendar&amp;page=backend_showAllOrganizers" accept-charset="UTF-8">
            <fieldset>
              <input type="submit" value="'.$L_Button26.'" class="button" />
            </fieldset>
          </form>';
    }
    else
    {
      // Post-Variablen in Variablen speichern
        foreach ($_POST as $key => $value) $$key = stripslashes($value);
      echo '<form method="post" action="index.php?submenu=calendar&amp;page=backend_addOrganizer&amp;job='.$_REQUEST['job'].'" accept-charset="UTF-8">
        <table summary="AddOrganizer" style="float:left;">';
          include ('calendar/includes/addOrganizer/OrganizerName.php');
          include ('calendar/includes/addOrganizer/OrganizerURL.php');
          // Formular-Buttons
          echo '<tr>
            <td></td>
            <td>
              <input type="submit" name="senden" value="'.$L_Button01.'" class="button" />
              <input type="button" value="'.$L_Button03.'" onclick="self.location.href=\'index.php?submenu=calendar&amp;page=backend_showAllOrganizers\'" class="button"/>
              <input type="hidden" name="OrganizerID" value="'.$OrganizerID.'" />
              <input type="hidden" name="OldOrganizerName" value="'.$OldOrganizerName.'" />
            </td>
          </tr>
        </table>
        </form>          
      ';
    }
  }
?>