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;
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(
636 "table_id" => array(
"integer", $this->
getTableId() ),
638 "title" => array(
"text", $this->
getTitle() ),
640 "required" => array(
"integer", $this->
getRequired() ),
641 "is_unique" => array(
"integer", $this->
isUnique() ),
642 "is_locked" => array(
"integer", $this->
getLocked() ? 1 : 0 ),
644 "id" => array(
"integer", $this->
getId() )
659 foreach ($this->property as $key => $value) {
660 $ilDB->update(
'il_dcl_field_prop', array(
661 'value' => array(
'integer', $value ),
663 'field_id' => array(
'integer', $this->
getId() ),
664 'datatype_prop_id' => array(
'integer', $key ),
713 case self::EDIT_VIEW:
716 case self::VIEW_VIEW:
718 if ($set && $this->order === NULL) {
722 case self::FILTER_VIEW:
724 if ($set && $this->order === NULL) {
728 case self::EXPORTABLE_VIEW:
730 if ($set && $this->order === NULL) {
742 if (!isset($this->order)) {
746 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = " . $ilDB->quote($view,
"integer")
747 .
" AND il_dcl_view.table_id = " . $ilDB->quote($this->
getTableId(),
"integer") .
" WHERE def.view_id = il_dcl_view.id AND def.field = " 748 . $ilDB->quote($this->
getId(),
"text");
750 $ilDB->manipulate(
$query);
752 $query =
"INSERT INTO il_dcl_viewdefinition (view_id, field, field_order, is_set) SELECT id, " . $ilDB->quote($this->
getId(),
"text") .
", " 753 . $ilDB->quote($this->
getOrder(),
"integer") .
", " . $ilDB->quote($set,
"integer") .
" FROM il_dcl_view WHERE il_dcl_view.type = " 754 . $ilDB->quote($view,
"integer") .
" AND il_dcl_view.table_id = " . $ilDB->quote($this->
getTableId(),
"integer");
756 $ilDB->manipulate(
$query);
766 $query =
"DELETE def FROM il_dcl_viewdefinition def INNER JOIN il_dcl_view ON il_dcl_view.type = " . $ilDB->quote($view,
"integer")
767 .
" AND il_dcl_view.table_id = " . $ilDB->quote($this->
getTableId(),
"integer") .
" WHERE def.view_id = il_dcl_view.id AND def.field = " 768 . $ilDB->quote($this->
getId(),
"text");
770 $ilDB->manipulate(
$query);
786 $query =
"DELETE FROM il_dcl_field_prop WHERE field_id = " . $ilDB->quote($this->
getId(),
"text");
787 $ilDB->manipulate(
$query);
789 $query =
"DELETE FROM il_dcl_field WHERE id = " . $ilDB->quote($this->
getId(),
"text");
790 $ilDB->manipulate(
$query);
798 if (!isset($this->order)) {
819 $id = self::PROPERTYID_REFERENCE;
830 $id = self::PROPERTYID_N_REFERENCE;
841 $id = self::PROPERTYID_N_REFERENCE;
855 $query =
"SELECT datatype_prop_id, 858 FROM il_dcl_field_prop fp 859 LEFT JOIN il_dcl_datatype_prop AS p ON p.id = fp.datatype_prop_id 860 WHERE fp.field_id = " . $ilDB->quote($this->
getId(),
"integer");
862 $set = $ilDB->query(
$query);
864 while ($rec = $ilDB->fetchAssoc($set)) {
876 if ($this->property == NULL) {
885 $this->
property =
$data;
910 if ($value == NULL) {
924 $regex = $properties[$regex_id];
925 if (substr($regex, 0, 1) !=
"/") {
926 $regex =
"/" . $regex;
928 if (substr($regex, - 1) !=
"/") {
932 if ($properties[$length] <
ilStr::strLen($value) AND is_numeric($properties[$length])) {
935 if (!($properties[$regex_id] == NULL OR @preg_match($regex, $value))) {
939 if ($properties[$url]
940 && !(preg_match(
'~(^(www|news|(ht|f)tp(s?)\://){1}\S+)~i', $value)
941 || 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))
947 if ($this->
isUnique() && $record_id === NULL) {
950 foreach ($table->getRecords() as $record) {
951 if ($record->getRecordFieldValue($this->getId()) == $value && ($record->getId() != $record_id || $record_id == 0)) {
957 if (strtolower($record->getRecordFieldValue($this->getId())) == strtolower($value)
958 && ($record->getId() != $record_id
966 $datestring = $value[
"date"] .
" " . $value[
"time"];
968 if ($record->getRecordFieldValue($this->getId()) == $datestring && ($record->getId() != $record_id || $record_id == 0)) {
986 $this->
setTitle($original->getTitle());
990 $this->
setLocked($original->getLocked());
993 $this->
setOrder($original->getOrder());
1007 if ($orgProps == NULL) {
1010 foreach ($orgProps as
$id => $value) {
1012 $fieldprop_obj->setDatatypePropertyId(
$id);
1013 $fieldprop_obj->setFieldId($this->
getId());
1020 $fieldprop_obj->setValue($value);
1021 $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