5 include_once(
"./Services/Component/classes/class.ilPlugin.php");
43 require_once
"Services/User/classes/class.ilUDFPermissionHelper.php";
80 $set =
$ilDB->query(
"SELECT field_id FROM udf_definition" .
81 " WHERE field_id = " .
$ilDB->quote($a_field_id,
"integer"));
82 return (
bool)
$ilDB->numRows($set);
97 $set =
$ilDB->query(
"SELECT * FROM udf_definition" .
98 " WHERE field_id = " .
$ilDB->quote($a_field_id,
"integer"));
99 return $ilDB->fetchAssoc($set);
111 require_once
"Services/User/classes/class.ilUserDefinedFields.php";
115 return in_array($a_field_type,
$valid);
124 protected static function handleAccesss(array &$fields, array $a_access = null, array $a_existing = null)
126 $map = array(
"visible",
"changeable",
"searchable",
"required",
"export",
127 "course_export",
"group_export",
"registration_visible",
"visible_lua",
128 "changeable_lua",
"certificate");
129 foreach (
$map as $prop) {
130 if (isset($a_access[$prop])) {
131 $fields[$prop] = array(
"integer", (
int) $a_access[$prop]);
132 } elseif (isset($a_existing[$prop])) {
133 $fields[$prop] = array(
"integer", (
int) $a_existing[$prop]);
135 $fields[$prop] = array(
"integer", 0);
153 $ilDB = $DIC[
'ilDB'];
155 $field_id =
$ilDB->nextId(
"udf_definition");
159 if (!self::isValidFieldType(
$a_type)) {
170 "field_id" => array(
"integer", $field_id),
171 "field_type" => array(
"integer",
$a_type),
172 "field_name" => array(
"text", trim($a_title)),
173 "field_values" => array(
"text", serialize((array) $a_options))
176 self::handleAccesss($fields, $a_access);
178 $ilDB->insert(
"udf_definition", $fields);
192 public static function updateDBField($a_field_id, $a_title, array $a_access = null, array $a_options = null)
196 $ilDB = $DIC[
'ilDB'];
198 if (self::hasDBField($a_field_id)) {
199 $old = self::getDBField($a_field_id);
206 "field_name" => array(
"text", trim($a_title)),
207 "field_values" => array(
"text", serialize((array) $a_options))
210 self::handleAccesss($fields, $a_access, $old);
215 array(
"field_id" => array(
"integer", $a_field_id))
233 $ilDB = $DIC[
'ilDB'];
235 if (self::hasDBField($a_field_id)) {
238 $ilDB->manipulate(
"DELETE FROM udf_definition" .
239 " WHERE field_id = " .
$ilDB->quote($a_field_id,
"integer"));
static isValidFieldType($a_field_type)
Validate field type.
checkPermission($a_user_id, $a_context_type, $a_context_id, $a_action_id, $a_action_sub_id)
Check permission.
static handleAccesss(array &$fields, array $a_access=null, array $a_existing=null)
Convert access array to DB columns.
static updateDBField($a_field_id, $a_title, array $a_access=null, array $a_options=null)
Update field db entry.
static createDBField($a_type, $a_title, array $a_access=null, array $a_options=null)
Create field db entry.
static getDBField($a_field_id)
Get existing field values.
static deleteDBField($a_field_id)
Delete field db entry.
static hasDBField($a_field_id)
Check if field has db entry.
Abstract parent class for all udf claiming plugin classes.