4 require_once(
'./Services/Exceptions/classes/class.ilException.php');
5 require_once(
'class.ilDataCollectionCache.php');
6 require_once(
'class.ilDataCollectionFieldProp.php');
127 return '/^[a-zA-Z\d \/\-.,äöüÄÖÜàéèÀÉÈç¢]*$/i';
129 return 'A-Z a-z 0-9 /-.,';
142 $result = $ilDB->query(
'SELECT id FROM il_dcl_field WHERE title = ' . $ilDB->quote(
$title,
'text') .
' AND table_id = '
145 while ($rec = $ilDB->fetchAssoc(
$result)) {
179 $this->table_id = $a_id;
200 if (substr($a_title, 0, 1) ==
"_" && substr($a_title, 0, 2) !=
"__") {
201 $a_title =
"_" . $a_title;
203 $this->title = $a_title;
223 $this->description = $a_desc;
244 $this->datatype = NULL;
245 $this->datatypeId = $a_id;
269 $this->required = $a_required;
290 $this->
property[$a_id] = $a_value;
306 $this->unique =
$unique ? 1 : 0;
318 if ($this->property == NULL) {
332 if (
$visible ==
true && $this->order === NULL) {
346 if (
$filterable ==
true && $this->order === NULL) {
403 return $this->datatype->getTitle();
413 return $this->datatype->getStorageLocation();
418 if ($this->datatype == NULL) {
428 if (!isset($this->visible)) {
437 if ($this->visible == NULL) {
447 if (!isset($this->filterable)) {
456 if ($this->filterable == NULL) {
469 $query =
" SELECT view.table_id, def.field_order, def.is_set FROM il_dcl_viewdefinition def
470 INNER JOIN il_dcl_view view ON view.id = def.view_id AND view.type = " . $ilDB->quote($view,
"integer") .
"
471 WHERE def.field LIKE '" . $this->
id .
"' AND view.table_id = " . $ilDB->quote($this->table_id,
"integer");
472 $set = $ilDB->query(
$query);
473 $rec = $ilDB->fetchAssoc($set);
474 $prop = $rec[
'is_set'];
477 case self::VIEW_VIEW:
478 $this->visible = $prop;
480 case self::EDIT_VIEW:
481 $this->editable = $prop;
483 case self::FILTER_VIEW:
484 $this->filterable = $prop;
486 case self::EXPORTABLE_VIEW:
487 $this->exportable = $prop;
492 $this->order = $rec[
'field_order'];
503 if (!isset($this->editable)) {
520 if (!isset($this->exportable)) {
532 if ($this->editable == NULL) {
542 if ($this->exportable == NULL) {
571 $query =
"SELECT * FROM il_dcl_field WHERE id = " . $ilDB->quote($this->
getId(),
"integer");
572 $set = $ilDB->query(
$query);
573 $rec = $ilDB->fetchAssoc($set);
590 $this->
setId($rec[
"id"]);
609 throw new ilException(
"The field does not have a related table!");
612 $id = $ilDB->nextId(
"il_dcl_field");
614 $query =
"INSERT INTO il_dcl_field (" .
"id" .
", table_id" .
", datatype_id" .
", title" .
", description" .
", required" .
", is_unique"
615 .
", is_locked" .
" ) VALUES (" . $ilDB->quote($this->
getId(),
"integer") .
"," . $ilDB->quote($this->
getTableId(),
"integer") .
","
616 . $ilDB->quote($this->
getDatatypeId(),
"integer") .
"," . $ilDB->quote($this->
getTitle(),
"text") .
","
618 . $ilDB->quote($this->
isUnique(),
"integer") .
"," . $ilDB->quote($this->
getLocked() ? 1 : 0,
"integer") .
")";
619 $ilDB->manipulate(
$query);
634 $ilDB->update(
"il_dcl_field", array(
635 "table_id" => array(
"integer", $this->
getTableId() ),
637 "title" => array(
"text", $this->
getTitle() ),
639 "required" => array(
"integer", $this->
getRequired() ),
640 "is_unique" => array(
"integer", $this->
isUnique() ),
641 "is_locked" => array(
"integer", $this->
getLocked() ? 1 : 0 ),
643 "id" => array(
"integer", $this->
getId() )
658 foreach ($this->property as $key => $value) {
659 $ilDB->update(
'il_dcl_field_prop', array(
660 'value' => array(
'integer', $value ),
662 'field_id' => array(
'integer', $this->
getId() ),
663 'datatype_prop_id' => array(
'integer', $key ),
712 case self::EDIT_VIEW:
715 case self::VIEW_VIEW:
717 if ($set && $this->order === NULL) {
721 case self::FILTER_VIEW:
723 if ($set && $this->order === NULL) {
727 case self::EXPORTABLE_VIEW:
729 if ($set && $this->order === NULL) {
741 if (!isset($this->order)) {
745 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = " . $ilDB->quote($view,
"integer")
746 .
" AND il_dcl_view.table_id = " . $ilDB->quote($this->
getTableId(),
"integer") .
" WHERE def.view_id = il_dcl_view.id AND def.field = "
747 . $ilDB->quote($this->
getId(),
"text");
749 $ilDB->manipulate(
$query);
751 $query =
"INSERT INTO il_dcl_viewdefinition (view_id, field, field_order, is_set) SELECT id, " . $ilDB->quote($this->
getId(),
"text") .
", "
752 . $ilDB->quote($this->
getOrder(),
"integer") .
", " . $ilDB->quote($set,
"integer") .
" FROM il_dcl_view WHERE il_dcl_view.type = "
753 . $ilDB->quote($view,
"integer") .
" AND il_dcl_view.table_id = " . $ilDB->quote($this->
getTableId(),
"integer");
755 $ilDB->manipulate(
$query);
765 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = " . $ilDB->quote($view,
"integer")
766 .
" AND il_dcl_view.table_id = " . $ilDB->quote($this->
getTableId(),
"integer") .
" WHERE def.view_id = il_dcl_view.id AND def.field = "
767 . $ilDB->quote($this->
getId(),
"text");
769 $ilDB->manipulate(
$query);
785 $query =
"DELETE FROM il_dcl_field_prop WHERE field_id = " . $ilDB->quote($this->
getId(),
"text");
786 $ilDB->manipulate(
$query);
788 $query =
"DELETE FROM il_dcl_field WHERE id = " . $ilDB->quote($this->
getId(),
"text");
789 $ilDB->manipulate(
$query);
797 if (!isset($this->order)) {
854 $query =
"SELECT datatype_prop_id,
857 FROM il_dcl_field_prop fp
858 LEFT JOIN il_dcl_datatype_prop AS p ON p.id = fp.datatype_prop_id
859 WHERE fp.field_id = " . $ilDB->quote($this->
getId(),
"integer");
861 $set = $ilDB->query(
$query);
863 while ($rec = $ilDB->fetchAssoc($set)) {
875 if ($this->property == NULL) {
884 $this->
property = $data;
909 if ($value == NULL) {
923 $regex = $properties[$regex_id];
924 if (substr($regex, 0, 1) !=
"/") {
925 $regex =
"/" . $regex;
927 if (substr($regex, - 1) !=
"/") {
931 if ($properties[$length] < mb_strlen($value,
'UTF-8') AND is_numeric($properties[$length])) {
934 if (!($properties[$regex_id] == NULL OR @preg_match($regex, $value))) {
938 if ($properties[$url]
939 && !(preg_match(
'~(^(news|(ht|f)tp(s?)\://){1}\S+)~i', $value)
940 || 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))
946 if ($this->
isUnique() && $record_id === NULL) {
949 foreach ($table->getRecords() as $record) {
950 if ($record->getRecordFieldValue($this->getId()) == $value && ($record->getId() != $record_id || $record_id == 0)) {
956 if (strtolower($record->getRecordFieldValue($this->getId())) == strtolower($value)
957 && ($record->getId() != $record_id
965 $datestring = $value[
"date"] .
" " . $value[
"time"];
967 if ($record->getRecordFieldValue($this->getId()) == $datestring && ($record->getId() != $record_id || $record_id == 0)) {
985 $this->
setTitle($original->getTitle());
989 $this->
setLocked($original->getLocked());
992 $this->
setOrder($original->getOrder());
1006 if ($orgProps == NULL) {
1009 foreach ($orgProps as
$id => $value) {
1011 $fieldprop_obj->setDatatypePropertyId(
$id);
1012 $fieldprop_obj->setFieldId($this->
getId());
1019 $fieldprop_obj->setValue($value);
1020 $fieldprop_obj->doCreate();