4require_once(
'./Services/Exceptions/classes/class.ilException.php');
5require_once(
'Services/Utilities/classes/class.ilStr.php');
6require_once(
'class.ilDataCollectionCache.php');
7require_once(
'class.ilDataCollectionFieldProp.php');
128 return '/^[a-zA-Z\d \/\-.,äöüÄÖÜàéèÀÉÈç¢]*$/i';
130 return 'A-Z a-z 0-9 /-.,';
143 $result =
$ilDB->query(
'SELECT id FROM il_dcl_field WHERE title = ' .
$ilDB->quote(
$title,
'text') .
' AND table_id = '
180 $this->table_id = $a_id;
201 if (substr($a_title, 0, 1) ==
"_" && substr($a_title, 0, 2) !=
"__") {
202 $a_title =
"_" . $a_title;
204 $this->title = $a_title;
224 $this->description = $a_desc;
245 $this->datatype = NULL;
246 $this->datatypeId = $a_id;
270 $this->required = $a_required;
291 $this->
property[$a_id] = $a_value;
307 $this->unique =
$unique ? 1 : 0;
319 if ($this->property == NULL) {
333 if (
$visible ==
true && $this->order === NULL) {
347 if (
$filterable ==
true && $this->order === NULL) {
404 return $this->datatype->getTitle();
414 return $this->datatype->getStorageLocation();
419 if ($this->datatype == NULL) {
429 if (! isset($this->visible)) {
438 if ($this->visible == NULL) {
448 if (! isset($this->filterable)) {
457 if ($this->filterable == NULL) {
470 $query =
" SELECT view.table_id, def.field_order, def.is_set FROM il_dcl_viewdefinition def
471 INNER JOIN il_dcl_view view ON view.id = def.view_id AND view.type = " .
$ilDB->quote($view,
"integer") .
"
472 WHERE def.field LIKE '" . $this->
id .
"' AND view.table_id = " . $ilDB->quote($this->table_id,
"integer");
474 $rec =
$ilDB->fetchAssoc($set);
475 $prop = $rec[
'is_set'];
479 $this->visible = $prop;
482 $this->editable = $prop;
485 $this->filterable = $prop;
488 $this->exportable = $prop;
492 if (! $this->order) {
493 $this->order = $rec[
'field_order'];
504 if (! isset($this->editable)) {
521 if (! isset($this->exportable)) {
533 if ($this->editable == NULL) {
543 if ($this->exportable == NULL) {
572 $query =
"SELECT * FROM il_dcl_field WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
574 $rec =
$ilDB->fetchAssoc($set);
591 $this->
setId($rec[
"id"]);
610 throw new ilException(
"The field does not have a related table!");
613 $id =
$ilDB->nextId(
"il_dcl_field");
615 $query =
"INSERT INTO il_dcl_field (" .
"id" .
", table_id" .
", datatype_id" .
", title" .
", description" .
", required" .
", is_unique"
616 .
", is_locked" .
" ) VALUES (" . $ilDB->quote($this->
getId(),
"integer") .
"," . $ilDB->quote($this->
getTableId(),
"integer") .
","
617 . $ilDB->quote($this->
getDatatypeId(),
"integer") .
"," . $ilDB->quote($this->
getTitle(),
"text") .
","
619 . $ilDB->quote($this->
isUnique(),
"integer") .
"," . $ilDB->quote($this->
getLocked() ? 1 : 0,
"integer") .
")";
620 $ilDB->manipulate(
$query);
635 $ilDB->update(
"il_dcl_field", array(
640 "datatype_id" => array(
648 "description" => array(
656 "is_unique" => array(
660 "is_locked" => array(
683 foreach ($this->property as $key => $value) {
684 $ilDB->update(
'il_dcl_field_prop', array(
694 'datatype_prop_id' => array(
751 if ($set && $this->order === NULL) {
757 if ($set && $this->order === NULL) {
763 if ($set && $this->order === NULL) {
775 if (! isset($this->order)) {
779 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = " .
$ilDB->quote($view,
"integer")
780 .
" AND il_dcl_view.table_id = " .
$ilDB->quote($this->
getTableId(),
"integer") .
" WHERE def.view_id = il_dcl_view.id AND def.field = "
781 . $ilDB->quote($this->
getId(),
"text");
783 $ilDB->manipulate(
$query);
785 $query =
"INSERT INTO il_dcl_viewdefinition (view_id, field, field_order, is_set) SELECT id, " .
$ilDB->quote($this->
getId(),
"text") .
", "
786 . $ilDB->quote($this->
getOrder(),
"integer") .
", " . $ilDB->quote($set,
"integer") .
" FROM il_dcl_view WHERE il_dcl_view.type = "
787 .
$ilDB->quote($view,
"integer") .
" AND il_dcl_view.table_id = " .
$ilDB->quote($this->
getTableId(),
"integer");
789 $ilDB->manipulate(
$query);
799 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = " .
$ilDB->quote($view,
"integer")
800 .
" AND il_dcl_view.table_id = " .
$ilDB->quote($this->
getTableId(),
"integer") .
" WHERE def.view_id = il_dcl_view.id AND def.field = "
801 . $ilDB->quote($this->
getId(),
"text");
803 $ilDB->manipulate(
$query);
819 $query =
"DELETE FROM il_dcl_field_prop WHERE field_id = " .
$ilDB->quote($this->
getId(),
"text");
820 $ilDB->manipulate(
$query);
822 $query =
"DELETE FROM il_dcl_field WHERE id = " .
$ilDB->quote($this->
getId(),
"text");
823 $ilDB->manipulate(
$query);
831 if (! isset($this->order)) {
888 $query =
"SELECT datatype_prop_id,
891 FROM il_dcl_field_prop fp
892 LEFT JOIN il_dcl_datatype_prop AS p ON p.id = fp.datatype_prop_id
893 WHERE fp.field_id = " .
$ilDB->quote($this->
getId(),
"integer");
897 while ($rec =
$ilDB->fetchAssoc($set)) {
909 if ($this->property == NULL) {
918 $this->
property =
$data;
944 if ($value == NULL) {
958 $regex = $properties[$regex_id];
959 if (substr($regex, 0, 1) !=
"/") {
960 $regex =
"/" . $regex;
962 if (substr($regex, - 1) !=
"/") {
966 if ($properties[$length] <
ilStr::strLen($value) AND is_numeric($properties[$length])) {
971 $properties[$regex_id] !=
null &&
972 !preg_match($regex, $value)
978 if ($properties[
$url]) {
979 if ($json = json_decode($value)) {
980 $value = $json->link;
982 if (substr($value, 0, 3) ===
'www') {
983 $value =
'http://' . $value;
985 if (! filter_var($value, FILTER_VALIDATE_URL) && ! filter_var($value, FILTER_VALIDATE_EMAIL)) {
993 foreach ($table->getRecords() as $record) {
994 if ($this->
normalizeValue($record->getRecordFieldValue($this->getId())) == $this->normalizeValue($value)
995 && ($record->getId() != $record_id || $record_id == 0)
1003 && ($record->getId() != $record_id
1011 $datestring = $value[
"date"] .
" " . $value[
"time"];
1013 if ($record->getRecordFieldValue($this->getId()) == $datestring && ($record->getId() != $record_id || $record_id == 0)) {
1030 if (is_string($value)) {
1031 $value = trim(preg_replace(
"/\\s+/uism",
" ", $value));
1045 $this->
setTitle($original->getTitle());
1049 $this->
setLocked($original->getLocked());
1052 $this->
setOrder($original->getOrder());
1054 $this->
setUnique($original->isUnique());
1066 if ($orgProps == NULL) {
1069 foreach ($orgProps as
$id => $value) {
1071 $fieldprop_obj->setDatatypePropertyId(
$id);
1072 $fieldprop_obj->setFieldId($this->
getId());
1079 $fieldprop_obj->setValue($value);
1080 $fieldprop_obj->doCreate();
static getTableCache($table_id=0)
static getFieldCache($field_id=0)
Class ilDataCollectionDatatype.
static checkValidity($type_id, $value)
now only distinguishes between number and text values
const INPUTFORMAT_DATETIME
const INPUTFORMAT_REFERENCE
Class ilDataCollectionFieldProp.
Class ilDataCollectionField.
static _getTitleValidChars($a_as_regex=true)
All valid chars for filed titles.
static _getFieldIdByTitle($title, $table_id)
checkValidity($value, $record_id=NULL)
const PROPERTYID_LINK_DETAIL_PAGE_TEXT
setTableId($a_id)
Set table id.
const PROPERTYID_REFERENCE_LINK
getDatatypeId()
Get datatype_id.
getProperties()
Get all properties of a field.
getDescription()
Get description.
deleteViewDefinition($view)
const PROPERTYID_LINK_DETAIL_PAGE_MOB
const PROPERTYID_REFERENCE
const PROPERTYID_DISPLAY_COPY_LINK_ACTION_MENU
getTableId()
Get table id.
const PROPERTYID_SUPPORTED_FILE_TYPES
getPropertyvalues()
Get Property Values.
const PROPERTYID_URL
LINK OR EMAIL!
updateViewDefinition($view)
updateViewDefinition
setTitle($a_title)
Set title.
loadViewDefinition($view)
loadViewDefinition
const PROPERTYID_LEARNING_PROGRESS
loadProperties()
Get all properties of a field.
setVisible($visible)
setVisible
setExportable($exportable)
doCreate()
Create new field.
setFilterable($filterable)
setFilterable
setId($a_id)
Set field id.
setDescription($a_desc)
Set description.
cloneProperties(ilDataCollectionField $originalField)
const PROPERTYID_ILIAS_REFERENCE_LINK
getRequired()
Get Required Required.
const PROPERTYID_TEXTAREA
setRequired($a_required)
Set Required.
setPropertyvalue($a_value, $a_id)
Set Property Value.
cloneStructure($original_id)
const PROPERTYID_FORMULA_EXPRESSION
setDatatypeId($a_id)
Set datatype id.
const PROPERTYID_N_REFERENCE
updateProperties()
Update properties of this field in Database.
static _getDatatypeForId($id)
gives you the datatype id of a specified standard field.
static _tableExists($table_id)
Base class for ILIAS Exception handling.