ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDclReferenceFieldModel.php
Go to the documentation of this file.
1<?php
2
10{
11 const PROP_REFERENCE = 'table_id';
12 const PROP_N_REFERENCE = 'multiple_selection';
13
22 public function getRecordQuerySortObject($direction = "asc", $sort_by_status = false)
23 {
24 global $DIC;
25 $ilDB = $DIC['ilDB'];
26
27 if ($this->hasProperty(self::PROP_N_REFERENCE)) {
28 return null;
29 }
30
31 $ref_field = ilDclCache::getFieldCache($this->getProperty(self::PROP_REFERENCE));
32
33 $select_str = "stloc_{$this->getId()}_joined.value AS field_{$this->getId()},";
34 $join_str = "LEFT JOIN il_dcl_record_field AS record_field_{$this->getId()} ON (record_field_{$this->getId()}.record_id = record.id AND record_field_{$this->getId()}.field_id = "
35 . $ilDB->quote($this->getId(), 'integer') . ") ";
36 $join_str .= "LEFT JOIN il_dcl_stloc{$this->getStorageLocation()}_value AS stloc_{$this->getId()} ON (stloc_{$this->getId()}.record_field_id = record_field_{$this->getId()}.id) ";
37 $join_str .= "LEFT JOIN il_dcl_record_field AS record_field_{$this->getId()}_joined ON (record_field_{$this->getId()}_joined.record_id = stloc_{$this->getId()}.value AND record_field_{$this->getId()}_joined.field_id = "
38 . $ilDB->quote($ref_field->getId(), 'integer') . ") ";
39 $join_str .= "LEFT JOIN il_dcl_stloc{$ref_field->getStorageLocation()}_value AS stloc_{$this->getId()}_joined ON (stloc_{$this->getId()}_joined.record_field_id = record_field_{$this->getId()}_joined.id) ";
40
41 $sql_obj = new ilDclRecordQueryObject();
42 $sql_obj->setSelectStatement($select_str);
43 $sql_obj->setJoinStatement($join_str);
44 $sql_obj->setOrderStatement("field_{$this->getId()} " . $direction);
45
46
47 return $sql_obj;
48 }
49
50
58 public function getRecordQueryFilterObject($filter_value = "", ilDclBaseFieldModel $sort_field = null)
59 {
60 global $DIC;
61 $ilDB = $DIC['ilDB'];
62
64
65 $join_str =
66 " INNER JOIN il_dcl_record_field AS filter_record_field_{$this->getId()} ON (filter_record_field_{$this->getId()}.record_id = record.id AND filter_record_field_{$this->getId()}.field_id = "
67 . $ilDB->quote($this->getId(), 'integer') . ") ";
68
69 if ($n_ref) {
70 $join_str .=
71 " INNER JOIN il_dcl_stloc{$this->getStorageLocation()}_value AS filter_stloc_{$this->getId()} ON (filter_stloc_{$this->getId()}.record_field_id = filter_record_field_{$this->getId()}.id AND filter_stloc_{$this->getId()}.value LIKE "
72 . $ilDB->quote("%$filter_value%", 'text') . ") ";
73 } else {
74 $join_str .=
75 " INNER JOIN il_dcl_stloc{$this->getStorageLocation()}_value AS filter_stloc_{$this->getId()} ON (filter_stloc_{$this->getId()}.record_field_id = filter_record_field_{$this->getId()}.id AND filter_stloc_{$this->getId()}.value = "
76 . $ilDB->quote($filter_value, 'integer') . ") ";
77 }
78
79 $sql_obj = new ilDclRecordQueryObject();
80 $sql_obj->setJoinStatement($join_str);
81
82 return $sql_obj;
83 }
84
88 public function getValidFieldProperties()
89 {
91 }
92
96 public function allowFilterInListView()
97 {
98 //A reference-field is not filterable if the referenced field is of datatype MOB or File
99 $ref_field = $this->getFieldRef();
100 return !($ref_field->getDatatypeId() == ilDclDatatype::INPUTFORMAT_MOB
101 || $ref_field->getDatatypeId() == ilDclDatatype::INPUTFORMAT_FILE);
102 }
103
104 public function getFieldRef()
105 {
107 }
108
109
110 public function afterClone($records)
111 {
114 $reference_clone = ilDclCache::getCloneOf((int) $clone->getProperty(ilDclBaseFieldModel::PROP_REFERENCE), ilDclCache::TYPE_FIELD);
115 if ($reference_clone) {
116 $this->setProperty(ilDclBaseFieldModel::PROP_REFERENCE, $reference_clone->getId());
117 $this->updateProperties();
118 }
119 parent::afterClone($records);
120 }
121}
An exception for terminatinating execution or to throw for unit testing.
Class ilDclBaseFieldModel.
updateProperties()
Update properties of this field in Database.
setProperty($key, $value)
Set a property for a field (does not save)
hasProperty($key)
Checks if a certain property for a field is set.
getProperty($key)
Returns a certain property of a field.
static getCloneOf($id, $type)
static getFieldCache($field_id=0)
Class ilDclRecordQueryObject.
Class ilDclReferenceFieldModel.
getRecordQueryFilterObject($filter_value="", ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query.
getRecordQuerySortObject($direction="asc", $sort_by_status=false)
Returns a query-object for building the record-loader-sql-query.
global $DIC
Definition: saml.php:7
$records
Definition: simple_test.php:22
global $ilDB