<?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.
*/
  //token();
  if ( !isset($UserName) ) $UserName = '';
  if ( !isset($UserStatus) ) $UserStatus = '';
  if ( !isset($UserCurrentPassword) ) $UserCurrentPassword = '';
  if ( !isset($UserNewPassword) ) $UserNewPassword = '';
  if ( !isset($UserNewPasswordRepeated) ) $UserNewPasswordRepeated = '';
  if ( !isset($UserEmailadress) ) $UserEmailadress = '';
  if ( !isset($UserLanguage) ) $UserLanguage = '';
  if ( !isset($UserBackendCalenderListCols) ) $UserBackendCalenderListCols = $StandardUserBackendCalenderListCols;
  if ( !isset($UserRightEmail) ) $UserRightEmail = '';
  if ( !isset($UserRightAddNews) ) $UserRightAddNews = '';
  if ( !isset($UserRightEditNews) ) $UserRightEditNews = '';
  if ( !isset($UserRightDeleteNews) ) $UserRightDeleteNews = '';
  if ( !isset($uid) ) $uid = '';
  if ( !isset($senden) ) $senden = '';

  // Formular überprüfen
    if ( $senden )
    {
      if ( $senden
            && $UserName
            && $UserStatus
            && $UserNewPassword
            && $UserNewPasswordRepeated
            && $UserNewPassword==$UserNewPasswordRepeated
            && $UserEmailadress
            && checkEmail ($UserEmailadress)
            //&& $UserLanguage
            && $UserBackendCalenderListCols
            && strlen($UserNewPassword)>=$MinUserPasswordChars
          )
        {
          $FormularKorrektAusgefuellt = true;
        }
        else 
        { 
          $FormularKorrektAusgefuellt = false;
          $uid=$UserName;
        }
    }
    else
    {
      if ( $job=='edit')
      {
        $SQLQuery = "SELECT * FROM ".$prefix."user Where UserName = '$uid'";
        $Result = mysqli_query($db, $SQLQuery);
        while ($row = mysqli_fetch_array($Result)) { extract($row); }
      }
      $FormularKorrektAusgefuellt = false;
      $senden = ''; 
    }
  // Überschrift ausgeben
    if ( $job=='add'){ echo '<p class="Headline">'.$L_Headline18.'</p>'; }
    if ( $job=='edit') { echo '<p class="Headline">'.$L_Headline19.'</p>'; }
  if ( !IsUserAdmin() ) { echo $L_015; }
  else
  {
    // Inhalt hier einfügen
      if ($FormularKorrektAusgefuellt == true)
      {
        if ( $job=='add')
        {
          if (addUser ($UserName, $UserStatus, $UserNewPassword, $UserEmailadress, $UserSession, $UserLanguage, 0, $UserBackendCalenderListCols, $UserRightEmail, $UserRightAddNews, $UserRightEditNews, $UserRightDeleteNews))
          {
            echo $L_191.'<br />';
          }
          else
          {
            echo $L_192.'<br />';
          }
        }
        if ( $job=='edit')
        {
          if (editUser($UserName, $UserStatus, $UserNewPassword, $UserEmailadress, $UserNameOld, $UserLanguage, $UserBackendCalenderListCols, $UserRightEmail, $UserRightAddNews, $UserRightEditNews, $UserRightDeleteNews))
          {
            echo $L_053.'<br />';
          }
          else
          {
            echo $L_054.'<br />';
          }
        }        
        echo '<br />
              <form method="post" action="index.php?submenue=admin&amp;content=showUsers" accept-charset="UTF-8">
                <fieldset>
                  <input type="submit" value="'.$L_Button26.'" class="button" />
                </fieldset>
              </form>';
      }
      else
      {
        echo '<form id="addUser" method="post" action="index.php?submenue=admin&amp;content=addUser&amp;job='.$job.'" accept-charset="UTF-8">
                <table summary="addUser">';
                  include ('admin/includes/addUser/UserName.php');
                  include ('admin/includes/addUser/UserStatus.php');
                  include ('admin/includes/addUser/UserNewPassword.php');
                  include ('admin/includes/addUser/UserNewPasswordRepeated.php');
                  include ('admin/includes/addUser/UserEmailadress.php');
                  include ('admin/includes/addUser/UserSession.php');            
                  include ('admin/includes/addUser/UserLanguage.php');          
                  include ('admin/includes/addUser/UserBackendCalenderListCols.php');
                  include ('admin/includes/addUser/UserRightEmail.php');
                  include ('admin/includes/addUser/UserRightAddNews.php');
                  include ('admin/includes/addUser/UserRightEditNews.php');
                  include ('admin/includes/addUser/UserRightDeleteNews.php');
        // Button
          echo '<tr>
                  <td></td>
                  <td>
                    <input type="submit" name="senden" value="'.$L_Button01.'" class="button" />
                    <input type="button" value="'.$L_Button03.'" onclick="history.go(-1)" class="button" />
                    <input type="reset" value="'.$L_Button38.'" class="button" />
                    <input type="hidden" name="DEAKTIVIERT-http-equiv" value="showUsers" />
                    <input type="hidden" name="UserNameOld" value="'.$uid.'" />
                  </td>
                </tr>
              </table>
            </form>';
      }
    // Inhalt zuende
  }
?>