<commit_before><?php 
$acl = new ACL();

// Todo neue ACL-Abfrage nutzen
if(!is_admin and !$acl->hasPermission("groups")){
   noperms();
} else {
include_once "../lib/string_functions.php";

$modified = false;
$created = false;
$removed = false;

if(isset($_POST["add_group"])){
   $acl = new ACL();
   $all_permissions = $acl->getDefaultACL(false, true);
   
   foreach($_POST["user_permissons"] as $permission_name){
      $all_permissions[$permission_name] = true;
   }
   
   $name = trim($_POST["name"]);
   if(!empty($name)){
     $acl->createGroup($name, $all_permissions);
     $created = true;
     $name = real_htmlspecialchars($name);
}

} else if(isset($_GET["delete"])){
$id = intval($_GET["delete"]);
$acl = new ACL();
$acl->deleteGroup($id);
$removed = true;

}else if(isset($_POST["edit_group"])){
   $acl = new ACL();
   $all_permissions = $acl->getDefaultACL(false, true);
   $id = $_POST["id"];
   
   foreach($_POST["user_permissons"] as $permission_name){
      $all_permissions[$permission_name] = true;
   } 
   
   $name = trim($_POST["name"]);
   $all_permissions = json_encode($all_permissions);
   if(!empty($name)){
     $acl->updateGroup($id, $name, $all_permissions);
     $modified = true;
     $name = real_htmlspecialchars($name);
}
}
?>
<h1>Gruppen</h1>
<?php if($created){?>
<p style='color:green;'>Die Gruppe "<?php echo $name;?>" wurde erfolgreich angelegt.</p>
<?php }?>

<?php if($modified){?>
<p style='color:green;'>Die Gruppe "<?php echo $name;?>" wurde erfolgreich bearbeitet.</p>
<?php }?>

<?php if($removed){?>
<p style='color:green;'>Die Gruppe wurde erfolgreich gelöscht</p>
<?php }?>

<?php if(!isset($_GET["add"]) and !isset($_GET["edit"])){<commit_msg>Fehler wenn keine Rechte angekreuzt waren korrigiert<commit_after><?php 
$acl = new ACL();

// Todo neue ACL-Abfrage nutzen
if(!is_admin and !$acl->hasPermission("groups")){
   noperms();
} else {
include_once "../lib/string_functions.php";

$modified = false;
$created = false;
$removed = false;

if(isset($_POST["add_group"])){
   $acl = new ACL();
   $all_permissions = $acl->getDefaultACL(false, true);
   
   if(count($_POST["user_permissons"]) > 0){
      foreach($_POST["user_permissons"] as $permission_name){
        $all_permissions[$permission_name] = true;
   }
   
   }
   
   $name = trim($_POST["name"]);
   if(!empty($name)){
     $acl->createGroup($name, $all_permissions);
     $created = true;
     $name = real_htmlspecialchars($name);
}

} else if(isset($_GET["delete"])){
$id = intval($_GET["delete"]);
$acl = new ACL();
$acl->deleteGroup($id);
$removed = true;

}else if(isset($_POST["edit_group"])){
   $acl = new ACL();
   $all_permissions = $acl->getDefaultACL(false, true);
   $id = $_POST["id"];
   
   if(count($_POST["user_permissons"]) > 0){
      foreach($_POST["user_permissons"] as $permission_name){
         $all_permissions[$permission_name] = true;
   } 
   
   }
   
   $name = trim($_POST["name"]);
   $all_permissions = json_encode($all_permissions);
   if(!empty($name)){
     $acl->updateGroup($id, $name, $all_permissions);
     $modified = true;
     $name = real_htmlspecialchars($name);
}
}
?>
<h1>Gruppen</h1>
<?php if($created){?>
<p style='color:green;'>Die Gruppe "<?php echo $name;?>" wurde erfolgreich angelegt.</p>
<?php }?>

<?php if($modified){?>
<p style='color:green;'>Die Gruppe "<?php echo $name;?>" wurde erfolgreich bearbeitet.</p>
<?php }?>

<?php if($removed){?>
<p style='color:green;'>Die Gruppe wurde erfolgreich gelöscht</p>
<?php }?>

<?php if(!isset($_GET["add"]) and !isset($_GET["edit"])){
{'fraction_non_alphanumeric': 0.2132435465768799, 'fraction_numerical': 0.0016835016835016834, 'mean_word_length': 4.82516339869281, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2856639', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1308, 'n_words': 243}