<?php

function rore($user_admin_rore, $rore, $art_rore)
{

$rore =  strtoupper($rore);
  # Funktion zum überprüfen von Rollen / Rechten
  # Hat ein Benutzer die angegebene Rolle / das Recht wird true zurückgegeben
  
  $db = dbconnect();
  if($art_rore == 'RE'){

    
    $result2_rore = $db->query( "SELECT DISTINCT 1
                                  FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
                                 WHERE a.rid = d.rid
                                   AND b.VAID = d.VAID
                                   AND a.rid = e.rid
                                   AND c.admin_rolle = e.admin_rolle
                                   AND b.user = '$user_admin_rore'
                                   AND upper(e.admin_rolle) LIKE '$rore'" );
    $row2_rore = $result2_rore->fetch_array();
    if($row2_rore[0] == 1){
      return true;
    }else{
      return false;
    }
  }

  if($art_rore == 'RO'){

    $result2_rore = $db->query( "SELECT 1
                                   FROM prog_admin, prog_admin_rollen_user_zuord, prog_admin_rolle
                                  WHERE admin.vaid = admin_rollen_user_zuord.vaid
                                    AND admin_rolle.rid = admin_rollen_user_zuord.rid
                                    AND upper(admin_rolle.bezeichnung) LIKE '$rore'
                                    AND admin.user = '$user_admin_rore'" );
    $row2_rore = $result2_rore->fetch_array();


    if($row2_rore[0] == 1){
      return true;
    }else{
      return false;
    }
  }
}

#if(rore('schwaral','Administrator','RO')){ 
#  echo "berechtigt";
#}else{
#  echo "nicht berechtigt";
#}
?>