4 require_once
'./Services/Exceptions/classes/class.ilException.php';
5 require_once
"class.ilDataCollectionCache.php";
6 require_once
"class.ilDataCollectionFieldProp.php";
137 return '/^[a-zA-Z\d \/\-.,äöüÄÖÜàéèÀÉÈç¢]*$/i';
141 return 'A-Z a-z 0-9 /-.,';
153 $result = $ilDB->query(
'SELECT id FROM il_dcl_field WHERE title = ' . $ilDB->quote(
$title,
'text') .
' AND table_id = ' . $ilDB->quote(
$table_id,
'integer'));
155 while($rec = $ilDB->fetchAssoc(
$result)) {
188 $this->table_id = $a_id;
209 if(substr($a_title,0,1) ==
"_" && substr($a_title, 0, 2) !=
"__")
210 $a_title =
"_".$a_title;
211 $this->title = $a_title;
231 $this->desc = $a_desc;
252 $this->datatype = NULL;
253 $this->datatypeId = $a_id;
277 $this->required = $a_required;
298 $this->
property[$a_id] = $a_value;
314 $this->unique =
$unique ? 1 : 0;
325 if($this->property == null)
336 if(
$visible ==
true && $this->order === NULL)
406 return $this->datatype->getTitle();
416 return $this->datatype->getStorageLocation();
424 if($this->datatype == NULL)
435 if(!isset($this->visible))
448 if($this->visible == NULL)
459 if(!isset($this->filterable))
472 if($this->filterable == NULL)
486 $query =
" SELECT view.table_id, def.field_order, def.is_set FROM il_dcl_viewdefinition def
487 INNER JOIN il_dcl_view view ON view.id = def.view_id AND view.type = ".$ilDB->quote($view,
"integer").
"
488 WHERE def.field LIKE '".$this->
id.
"' AND view.table_id = ".$ilDB->quote($this->table_id,
"integer");
489 $set = $ilDB->query(
$query);
490 $rec = $ilDB->fetchAssoc($set);
491 $prop = $rec[
'is_set'];
495 case self::VIEW_VIEW:
496 $this->visible = $prop;
498 case self::EDIT_VIEW:
499 $this->editable = $prop;
501 case self::FILTER_VIEW:
502 $this->filterable = $prop;
507 $this->order = $rec[
'field_order'];
516 if(!isset($this->editable))
537 if($this->editable == NULL)
548 return (array) $this;
567 $query =
"SELECT * FROM il_dcl_field WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
568 $set = $ilDB->query(
$query);
569 $rec = $ilDB->fetchAssoc($set);
586 $this->
setId($rec[
"id"]);
605 throw new ilException(
"The field does not have a related table!");
607 $id = $ilDB->nextId(
"il_dcl_field");
609 $query =
"INSERT INTO il_dcl_field (".
619 $ilDB->quote($this->
getId(),
"integer")
620 .
",".$ilDB->quote($this->
getTableId(),
"integer")
622 .
",".$ilDB->quote($this->
getTitle(),
"text")
625 .
",".$ilDB->quote($this->
isUnique(),
"integer")
626 .
",".$ilDB->quote($this->
getLocked()?1:0,
"integer")
628 $ilDB->manipulate(
$query);
642 $ilDB->update(
"il_dcl_field", array(
643 "table_id" => array(
"integer", $this->
getTableId()),
645 "title" => array(
"text", $this->
getTitle()),
647 "required" => array(
"integer",$this->
getRequired()),
648 "is_unique" => array(
"integer",$this->
isUnique()),
649 "is_locked" => array(
"integer",$this->
getLocked()?1:0)
651 "id" => array(
"integer", $this->
getId())
664 foreach ($this->property as $key => $value) {
665 $ilDB->update(
'il_dcl_field_prop', array(
666 'value' => array(
'integer', $value),
668 'field_id' => array(
'integer', $this->
getId()),
669 'datatype_prop_id' => array(
'integer', $key),
712 case self::EDIT_VIEW:
715 case self::VIEW_VIEW:
717 if($set && $this->order === NULL)
720 case self::FILTER_VIEW:
722 if($set && $this->order === NULL)
732 if(!isset($this->order))
735 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = "
736 .$ilDB->quote($view,
"integer").
" AND il_dcl_view.table_id = "
737 .$ilDB->quote($this->
getTableId(),
"integer").
" WHERE def.view_id = il_dcl_view.id AND def.field = "
738 .$ilDB->quote($this->
getId(),
"text");
740 $ilDB->manipulate(
$query);
742 $query =
"INSERT INTO il_dcl_viewdefinition (view_id, field, field_order, is_set) SELECT id, "
743 .$ilDB->quote($this->
getId(),
"text").
", "
744 .$ilDB->quote($this->
getOrder(),
"integer").
", "
745 .$ilDB->quote($set,
"integer").
" FROM il_dcl_view WHERE il_dcl_view.type = "
746 .$ilDB->quote($view,
"integer").
" AND il_dcl_view.table_id = "
747 .$ilDB->quote($this->
getTableId(),
"integer");
749 $ilDB->manipulate(
$query);
760 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = "
761 .$ilDB->quote($view,
"integer").
" AND il_dcl_view.table_id = "
762 .$ilDB->quote($this->
getTableId(),
"integer").
" WHERE def.view_id = il_dcl_view.id AND def.field = "
763 .$ilDB->quote($this->
getId(),
"text");
765 $ilDB->manipulate(
$query);
780 $query =
"DELETE FROM il_dcl_field_prop WHERE field_id = ".$ilDB->quote($this->
getId(),
"text");
781 $ilDB->manipulate(
$query);
783 $query =
"DELETE FROM il_dcl_field WHERE id = ".$ilDB->quote($this->
getId(),
"text");
784 $ilDB->manipulate(
$query);
793 if(!isset($this->order))
829 $query =
"SELECT datatype_prop_id,
832 FROM il_dcl_field_prop fp
833 LEFT JOIN il_dcl_datatype_prop AS p ON p.id = fp.datatype_prop_id
834 WHERE fp.field_id = ".$ilDB->quote($this->
getId(),
"integer");
836 $set = $ilDB->query(
$query);
838 while($rec = $ilDB->fetchAssoc($set))
851 if($this->property == null)
858 $this->
property =
$data;
901 $regex = $properties[$regex_id];
902 if(substr($regex,0,1) !=
"/")
904 if(substr($regex, -1) !=
"/")
906 if($properties[$length] < strlen($value) && is_numeric($properties[$length]))
908 if(!($properties[$regex_id] == NULL || @preg_match($regex, $value)))
911 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)))
920 if($arrMimeType[0] !=
"image") {
926 if($this->
isUnique() && $record_id === null)
930 foreach($table->getRecords() as $record)
932 if($record->getRecordFieldValue($this->getId()) == $value && ($record->getId() != $record_id || $record_id == 0))
938 if(strtolower($record->getRecordFieldValue($this->getId())) == strtolower($value) && ($record->getId() != $record_id || $record_id == 0))
947 $datestring = $value[
"date"].
" ".$value[
"time"];
949 if($record->getRecordFieldValue($this->getId()) == $datestring && ($record->getId() != $record_id || $record_id == 0))
966 $this->
setTitle($original->getTitle());
970 $this->
setLocked($original->getLocked());
973 $this->
setOrder($original->getOrder());
984 $orgProps = $originalField->getProperties();
985 if($orgProps == NULL)
987 foreach($orgProps as
$id => $value){
989 $fieldprop_obj->setDatatypePropertyId(
$id);
990 $fieldprop_obj->setFieldId($this->
getId());
995 $fieldprop_obj->setValue($value);
996 $fieldprop_obj->doCreate();