<?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.
*/
  $ArtistName = '';
  $ArtistURL = '';
  $ArtistIDToEdit = '';
  $OldArtistName = '';
  // POST-Variablen definieren
    if ( isset($_POST['senden']) )
    {
      foreach ($_POST as $key => $value) { $$key = $value; };
      // Formular überprüfen
        if ( $senden
             && $ArtistName
             && (!isArtistInDatabase($ArtistName)
                  OR $ArtistName == $OldArtistName
                  OR ($job=='edit') AND !isArtistInDatabase($ArtistName))
             && ( !$ArtistURL OR checkURL( $ArtistURL ) )
           )
        {
          $FormularKorrektAusgefuellt = true;
        }
        else 
        { 
          $FormularKorrektAusgefuellt = false; 
          $ArtistIDToEdit = '';
        }
    }
    else
    {  
      if ( isset($_REQUEST['id'])  ) { $ArtistID = $_REQUEST['id']; }
        else $ArtistID ="";
      if ($_REQUEST['job']=='edit')
      { 
        $SQL = "SELECT * FROM ".DB_PREFIX."artists Where ArtistID = '$ArtistID'";
        $resultat = mysql_query($SQL);
        while ($row = mysql_fetch_array($resultat)) { extract($row); }
        $OldArtistName = $ArtistName;
      }
      $FormularKorrektAusgefuellt = false;
      $senden = ''; 
    }
  if ( !IsUserAdmin() ) echo $L_015;
  else
  {
    if ($FormularKorrektAusgefuellt == true)
    { 
      $Artist = array( $ArtistID, $ArtistName, $ArtistURL);
      // Artist hinzufügen
      if ($_REQUEST['job']=='add')
      {
        if (addArtist($Artist, "add")) echo $L_Artist_successfully_saved.'<br />';
          else echo $L_ERROR_Artist_NOT_saved.'<br />';
      }
      // Artist bearbeiten
      if ($_REQUEST['job']=='edit')
      {
        if (addArtist($Artist, "edit")) echo $L_Artist_successfully_edited.'<br />';
          else echo $L_ERROR_Artist_NOT_edited.'<br />';
      }
    echo '<br />
          <form method="post" action="index.php?submenu=calendar&amp;page=backend_showAllArtists" 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_addArtist&amp;job='.$_REQUEST['job'].'" accept-charset="UTF-8">
        <table summary="AddArtist" style="float:left;">';
          include ('calendar/includes/addArtist/ArtistName.php');
          include ('calendar/includes/addArtist/ArtistURL.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_showAllArtists\'" class="button"/>
              <input type="hidden" name="ArtistID" value="'.$ArtistID.'" />
              <input type="hidden" name="OldArtistName" value="'.$OldArtistName.'" />
            </td>
          </tr>
        </table>
        </form>          
      ';
    }
  }
?>