hanze/iwa-panda2

Model/Utils.php in datatowebsite
Repositories | Summary | Log | Files | README.md

Utils.php (1177B) download


 1<?php
 2Class Utils{
 3  static function post_to_array():array{
 4    $arr = [];
 5    foreach ($_POST as $key => $value) {
 6      $arr[$key] = $value;
 7    }
 8    return $arr;
 9  }
10
11  static function missing_fields($post, $not_nullable){
12    $missing = [];
13    foreach($not_nullable as $column){
14      if($post[$column] == NULL || $post[$column] == ""){
15        $missing[$column] = "This field cannot be empty!";
16      }
17    }
18    return $missing;
19  }
20  
21  function create_permission_radials():string{
22    $db = new Lollipop\SQLDatabase("86.92.67.21", "friedel", "hailiwa", "lollipop");
23    //select the available permissions from the database
24    $all_p = $db->all(Permissions::class);
25    $radials = "";
26    foreach($all_p as $db_permission){
27      $radials .= "<div class=\"mb-3 form-check\">
28                  <input type=\"checkbox\" class=\"form-check-input\" name=\"permissions[]\" value=" . $db_permission->id . "\">
29                  <input type='hidden' value='-1' name='{$db_permission->name}'>
30                  <label class=\"form-check-label\" for=" . $db_permission->name . ">" . $db_permission->name . "</label>
31                  </div> ";
32    }
33    return $radials;
34  }
35}