4 require_once
'./Services/Exceptions/classes/class.ilException.php';
5 require_once
"class.ilDataCollectionCache.php";
6 require_once
"class.ilDataCollectionFieldProp.php";
145 return '/^[a-zA-Z\d \/\-.,äöüÄÖÜàéèÀÉÈç¢]*$/i';
149 return 'A-Z a-z 0-9 /-.,';
160 $result = $ilDB->query(
'SELECT id FROM il_dcl_field WHERE title = ' . $ilDB->quote(
$title,
'text') .
' AND table_id = ' . $ilDB->quote(
$table_id,
'integer'));
162 while($rec = $ilDB->fetchAssoc(
$result)) {
196 $this->table_id = $a_id;
217 if(substr($a_title,0,1) ==
"_" && substr($a_title, 0, 2) !=
"__")
218 $a_title =
"_".$a_title;
219 $this->title = $a_title;
239 $this->desc = $a_desc;
260 $this->datatype = NULL;
261 $this->datatypeId = $a_id;
285 $this->required = $a_required;
306 $this->
property[$a_id] = $a_value;
322 $this->unique =
$unique ? 1 : 0;
333 if($this->property == null)
344 if(
$visible ==
true && $this->order === NULL)
414 return $this->datatype->getTitle();
424 return $this->datatype->getStorageLocation();
432 if($this->datatype == NULL)
443 if(!isset($this->visible))
456 if($this->visible == NULL)
467 if(!isset($this->filterable))
480 if($this->filterable == NULL)
494 $query =
" SELECT view.table_id, def.field_order, def.is_set FROM il_dcl_viewdefinition def
495 INNER JOIN il_dcl_view view ON view.id = def.view_id AND view.type = ".$ilDB->quote($view,
"integer").
"
496 WHERE def.field LIKE '".$this->
id.
"' AND view.table_id = ".$ilDB->quote($this->table_id,
"integer");
497 $set = $ilDB->query(
$query);
498 $rec = $ilDB->fetchAssoc($set);
499 $prop = $rec[
'is_set'];
503 case self::VIEW_VIEW:
504 $this->visible = $prop;
506 case self::EDIT_VIEW:
507 $this->editable = $prop;
509 case self::FILTER_VIEW:
510 $this->filterable = $prop;
512 case self::EXPORTABLE_VIEW:
513 $this->exportable = $prop;
518 $this->order = $rec[
'field_order'];
527 if(!isset($this->editable))
544 if(!isset($this->exportable))
553 if($this->editable == NULL)
564 if($this->exportable == NULL)
575 return (array) $this;
594 $query =
"SELECT * FROM il_dcl_field WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
595 $set = $ilDB->query(
$query);
596 $rec = $ilDB->fetchAssoc($set);
613 $this->
setId($rec[
"id"]);
632 throw new ilException(
"The field does not have a related table!");
634 $id = $ilDB->nextId(
"il_dcl_field");
636 $query =
"INSERT INTO il_dcl_field (".
646 $ilDB->quote($this->
getId(),
"integer")
647 .
",".$ilDB->quote($this->
getTableId(),
"integer")
649 .
",".$ilDB->quote($this->
getTitle(),
"text")
652 .
",".$ilDB->quote($this->
isUnique(),
"integer")
653 .
",".$ilDB->quote($this->
getLocked()?1:0,
"integer")
655 $ilDB->manipulate(
$query);
670 $ilDB->update(
"il_dcl_field", array(
671 "table_id" => array(
"integer", $this->
getTableId()),
673 "title" => array(
"text", $this->
getTitle()),
675 "required" => array(
"integer",$this->
getRequired()),
676 "is_unique" => array(
"integer",$this->
isUnique()),
677 "is_locked" => array(
"integer",$this->
getLocked()?1:0),
679 "id" => array(
"integer", $this->
getId())
693 foreach ($this->property as $key => $value) {
694 $ilDB->update(
'il_dcl_field_prop', array(
695 'value' => array(
'integer', $value),
697 'field_id' => array(
'integer', $this->
getId()),
698 'datatype_prop_id' => array(
'integer', $key),
745 case self::EDIT_VIEW:
748 case self::VIEW_VIEW:
750 if($set && $this->order === NULL)
753 case self::FILTER_VIEW:
755 if($set && $this->order === NULL)
758 case self::EXPORTABLE_VIEW:
760 if($set && $this->order === NULL)
770 if(!isset($this->order))
773 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = "
774 .$ilDB->quote($view,
"integer").
" AND il_dcl_view.table_id = "
775 .$ilDB->quote($this->
getTableId(),
"integer").
" WHERE def.view_id = il_dcl_view.id AND def.field = "
776 .$ilDB->quote($this->
getId(),
"text");
778 $ilDB->manipulate(
$query);
780 $query =
"INSERT INTO il_dcl_viewdefinition (view_id, field, field_order, is_set) SELECT id, "
781 .$ilDB->quote($this->
getId(),
"text").
", "
782 .$ilDB->quote($this->
getOrder(),
"integer").
", "
783 .$ilDB->quote($set,
"integer").
" FROM il_dcl_view WHERE il_dcl_view.type = "
784 .$ilDB->quote($view,
"integer").
" AND il_dcl_view.table_id = "
785 .$ilDB->quote($this->
getTableId(),
"integer");
787 $ilDB->manipulate(
$query);
798 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = "
799 .$ilDB->quote($view,
"integer").
" AND il_dcl_view.table_id = "
800 .$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);
832 if(!isset($this->order))
889 $query =
"SELECT datatype_prop_id,
892 FROM il_dcl_field_prop fp
893 LEFT JOIN il_dcl_datatype_prop AS p ON p.id = fp.datatype_prop_id
894 WHERE fp.field_id = ".$ilDB->quote($this->
getId(),
"integer");
896 $set = $ilDB->query(
$query);
898 while($rec = $ilDB->fetchAssoc($set))
911 if($this->property == null)
918 $this->
property = $data;
959 include_once
'Services/Utilities/classes/class.ilStr.php';
962 $regex = $properties[$regex_id];
963 if(substr($regex,0,1) !=
"/")
965 if(substr($regex, -1) !=
"/")
967 if($properties[$length] <
ilStr::strLen($value) && is_numeric($properties[$length]))
969 if(!($properties[$regex_id] == NULL || @preg_match($regex, $value)))
972 if($properties[$url] && !(preg_match(
'~(^(news|(ht|f)tp(s?)\://){1}\S+)~i', $value) || preg_match(
"/^[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i", $value)))
981 if($arrMimeType[0] !=
"image") {
987 if($this->
isUnique() && $record_id === null)
991 foreach($table->getRecords() as $record)
993 if($record->getRecordFieldValue($this->getId()) == $value && ($record->getId() != $record_id || $record_id == 0))
999 if(strtolower($record->getRecordFieldValue($this->getId())) == strtolower($value) && ($record->getId() != $record_id || $record_id == 0))
1008 $datestring = $value[
"date"].
" ".$value[
"time"];
1010 if($record->getRecordFieldValue($this->getId()) == $datestring && ($record->getId() != $record_id || $record_id == 0))
1027 $this->
setTitle($original->getTitle());
1031 $this->
setLocked($original->getLocked());
1034 $this->
setOrder($original->getOrder());
1036 $this->
setUnique($original->isUnique());
1046 $orgProps = $originalField->getProperties();
1047 if($orgProps == NULL)
1049 foreach($orgProps as
$id => $value){
1051 $fieldprop_obj->setDatatypePropertyId(
$id);
1052 $fieldprop_obj->setFieldId($this->
getId());
1057 $fieldprop_obj->setValue($value);
1058 $fieldprop_obj->doCreate();