ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclDatetimeFieldModel.php
Go to the documentation of this file.
1<?php
2require_once("./Modules/DataCollection/classes/Fields/Base/class.ilDclBaseFieldModel.php");
3require_once("./Modules/DataCollection/classes/Helpers/class.ilDclRecordQueryObject.php");
4
18 public function getRecordQueryFilterObject($filter_value = "", ilDclBaseFieldModel $sort_field = null) {
19 global $DIC;
20 $ilDB = $DIC['ilDB'];
21
22 $date_from = (isset($filter_value['from']) && is_object($filter_value['from'])) ? $filter_value['from'] : NULL;
23 $date_to = (isset($filter_value['to']) && is_object($filter_value['to'])) ? $filter_value['to'] : NULL;
24
25 $join_str = "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 = "
26 . $ilDB->quote($this->getId(), 'integer') . ") ";
27 $join_str .= "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 ";
28 if ($date_from) {
29 $join_str .= "AND filter_stloc_{$this->getId()}.value >= " . $ilDB->quote($date_from, 'date') . " ";
30 }
31 if ($date_to) {
32 $join_str .= "AND filter_stloc_{$this->getId()}.value <= " . $ilDB->quote($date_to, 'date') . " ";
33 }
34 $join_str .= ") ";
35
36 $sql_obj = new ilDclRecordQueryObject();
37 $sql_obj->setJoinStatement($join_str);
38
39 return $sql_obj;
40 }
41
42
43 public function checkValidity($value, $record_id = NULL) {
44 if ($value == NULL) {
45 return true;
46 }
47
48 if ($this->isUnique()) {
49 $table = ilDclCache::getTableCache($this->getTableId());
50 $datestring = $value . ' 00:00:00';
51 foreach ($table->getRecords() as $record) {
52
53 if ($record->getRecordFieldValue($this->getId()) == $datestring && ($record->getId() != $record_id || $record_id == 0)) {
55 }
56 }
57 }
58 }
59}
An exception for terminatinating execution or to throw for unit testing.
Class ilDclBaseFieldModel.
static getTableCache($table_id=0)
Class ilDclBooleanFieldModel.
checkValidity($value, $record_id=NULL)
Check if input is valid.
getRecordQueryFilterObject($filter_value="", ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query.
Class ilDclBaseFieldModel.
Class ilDclRecordQueryObject.
global $ilDB
global $DIC