48     public static function hasDBField(
string $a_field_id): bool
    54         $set = 
$ilDB->query(
"SELECT field_id FROM udf_definition" .
    55             " WHERE field_id = " . 
$ilDB->quote($a_field_id, 
"integer"));
    56         return (
bool) 
$ilDB->numRows($set);
    62     protected static function getDBField(
string $a_field_id): array 
    68         $set = 
$ilDB->query(
"SELECT * FROM udf_definition" .
    69             " WHERE field_id = " . 
$ilDB->quote($a_field_id, 
"integer"));
    70         return $ilDB->fetchAssoc($set);
    79         return in_array($a_field_type, 
$valid);
    87         ?array $a_access = null,
    88         ?array $a_existing = null
    90         $map = [
"visible", 
"changeable", 
"searchable", 
"required", 
"export",
    91             "course_export", 
"group_export", 
"registration_visible", 
"visible_lua",
    92             "changeable_lua", 
"certificate"];
    93         foreach ($map as $prop) {
    94             if (isset($a_access[$prop])) {
    95                 $fields[$prop] = [
"integer", (
int) $a_access[$prop]];
    96             } elseif (isset($a_existing[$prop])) {
    97                 $fields[$prop] = [
"integer", (
int) $a_existing[$prop]];
    99                 $fields[$prop] = [
"integer", 0];
   110         array $a_access = null,
   111         array $a_options = null
   115         $ilDB = $DIC[
'ilDB'];
   117         $field_id = 
$ilDB->nextId(
"udf_definition");
   120         if (!self::isValidFieldType($a_type)) {
   131             "field_id" => [
"integer", $field_id],
   132             "field_type" => [
"integer", $a_type],
   133             "field_name" => [
"text", trim($a_title)],
   134             "field_values" => [
"text", serialize((array) $a_options)]
   137         self::handleAccesss($fields, $a_access);
   139         $ilDB->insert(
"udf_definition", $fields);
   150         array $a_access = null,
   151         array $a_options = null
   155         $ilDB = $DIC[
'ilDB'];
   157         if (self::hasDBField($a_field_id)) {
   158             $old = self::getDBField($a_field_id);
   165                 "field_name" => [
"text", trim($a_title)],
   166                 "field_values" => [
"text", serialize((array) $a_options)]
   169             self::handleAccesss($fields, $a_access, $old);
   174                 [
"field_id" => [
"integer", $a_field_id]]
   189         $ilDB = $DIC[
'ilDB'];
   191         if (self::hasDBField($a_field_id)) {
   194             $ilDB->manipulate(
"DELETE FROM udf_definition" .
   195                 " WHERE field_id = " . 
$ilDB->quote($a_field_id, 
"integer"));
 
const UDF_TYPE_TEXT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static handleAccesss(array &$fields, ?array $a_access=null, ?array $a_existing=null)
Convert access array to DB columns. 
 
static createDBField(int $a_type, string $a_title, array $a_access=null, array $a_options=null)
Create field db entry. 
 
static getDBField(string $a_field_id)
Get existing field values. 
 
static isValidFieldType(int $a_field_type)
Validate field type. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static hasDBField(string $a_field_id)
Check if field has db entry. 
 
checkPermission(int $a_user_id, int $a_context_type, int $a_context_id, int $a_action_id, int $a_action_sub_id)
Check permission. 
 
static updateDBField(int $a_field_id, string $a_title, array $a_access=null, array $a_options=null)
Update field db entry. 
 
static deleteDBField(int $a_field_id)
Delete field db entry.