4 require_once(
'./Services/Exceptions/classes/class.ilException.php');
5 require_once(
'Services/Utilities/classes/class.ilStr.php');
6 require_once(
'class.ilDataCollectionCache.php');
7 require_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 = ' 146 while ($rec = $ilDB->fetchAssoc(
$result)) {
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) {
370 $l = self::PROPERTYID_LENGTH;
381 $t = self::PROPERTYID_TEXTAREA;
392 $p = self::PROPERTYID_LEARNING_PROGRESS;
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");
473 $set = $ilDB->query(
$query);
474 $rec = $ilDB->fetchAssoc($set);
475 $prop = $rec[
'is_set'];
478 case self::VIEW_VIEW:
479 $this->visible = $prop;
481 case self::EDIT_VIEW:
482 $this->editable = $prop;
484 case self::FILTER_VIEW:
485 $this->filterable = $prop;
487 case self::EXPORTABLE_VIEW:
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");
573 $set = $ilDB->query(
$query);
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(
746 case self::EDIT_VIEW:
749 case self::VIEW_VIEW:
751 if ($set && $this->order === NULL) {
755 case self::FILTER_VIEW:
757 if ($set && $this->order === NULL) {
761 case self::EXPORTABLE_VIEW:
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)) {
852 $id = self::PROPERTYID_REFERENCE;
863 $id = self::PROPERTYID_N_REFERENCE;
874 $id = self::PROPERTYID_N_REFERENCE;
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");
895 $set = $ilDB->query(
$query);
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) {
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();
const PROPERTYID_N_REFERENCE
const INPUTFORMAT_DATETIME
Class ilDataCollectionDatatype.
Base class for ILIAS Exception handling.
checkValidity($value, $record_id=NULL)
deleteViewDefinition($view)
setRequired($a_required)
Set Required.
Class ilDataCollectionFieldProp.
const PROPERTYID_ILIAS_REFERENCE_LINK
static _tableExists($table_id)
const PROPERTYID_REFERENCE_LINK
const PROPERTYID_TEXTAREA
getDatatypeId()
Get datatype_id.
const PROPERTYID_LINK_DETAIL_PAGE_MOB
static checkValidity($type_id, $value)
now only distinguishes between number and text values
static _getTitleValidChars($a_as_regex=true)
All valid chars for filed titles.
getProperties()
Get all properties of a field.
setVisible($visible)
setVisible
updateProperties()
Update properties of this field in Database.
setDatatypeId($a_id)
Set datatype id.
getRequired()
Get Required Required.
updateViewDefinition($view)
updateViewDefinition
static _getDatatypeForId($id)
gives you the datatype id of a specified standard field.
const PROPERTYID_URL
LINK OR EMAIL!
setTitle($a_title)
Set title.
static getFieldCache($field_id=0)
const PROPERTYID_LEARNING_PROGRESS
static _getFieldIdByTitle($title, $table_id)
const PROPERTYID_FORMULA_EXPRESSION
loadProperties()
Get all properties of a field.
setPropertyvalue($a_value, $a_id)
Set Property Value.
loadViewDefinition($view)
loadViewDefinition
const PROPERTYID_LINK_DETAIL_PAGE_TEXT
setFilterable($filterable)
setFilterable
const PROPERTYID_DISPLAY_COPY_LINK_ACTION_MENU
Class ilDataCollectionField.
setDescription($a_desc)
Set description.
cloneProperties(ilDataCollectionField $originalField)
setId($a_id)
Set field id.
getTableId()
Get table id.
setTableId($a_id)
Set table id.
setExportable($exportable)
doCreate()
Create new field.
cloneStructure($original_id)
const INPUTFORMAT_REFERENCE
getPropertyvalues()
Get Property Values.
static getTableCache($table_id=0)
getDescription()
Get description.
const PROPERTYID_SUPPORTED_FILE_TYPES
const PROPERTYID_REFERENCE