ILIAS  release_8 Revision v8.24
class.ilDclDatetimeFieldModel.php
Go to the documentation of this file.
1<?php
2
20{
26 $filter_value = "",
27 ?ilDclBaseFieldModel $sort_field = null
29 global $DIC;
30 $ilDB = $DIC['ilDB'];
31
32 $date_from = (isset($filter_value['from']) && is_object($filter_value['from'])) ? $filter_value['from'] : null;
33 $date_to = (isset($filter_value['to']) && is_object($filter_value['to'])) ? $filter_value['to'] : null;
34
35 $join_str
36 = "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 = "
37 . $ilDB->quote($this->getId(), 'integer') . ") ";
38 $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 ";
39 if ($date_from) {
40 $join_str .= "AND filter_stloc_{$this->getId()}.value >= " . $ilDB->quote($date_from, 'date') . " ";
41 }
42 if ($date_to) {
43 $join_str .= "AND filter_stloc_{$this->getId()}.value <= " . $ilDB->quote($date_to, 'date') . " ";
44 }
45 $join_str .= ") ";
46
47 $sql_obj = new ilDclRecordQueryObject();
48 $sql_obj->setJoinStatement($join_str);
49
50 return $sql_obj;
51 }
52
57 public function checkValidity($value, ?int $record_id = null): bool
58 {
59 if ($value == null) {
60 return true;
61 }
62
63 if ($this->isUnique()) {
64 $table = ilDclCache::getTableCache($this->getTableId());
65 $datestring = $value . ' 00:00:00';
66 foreach ($table->getRecords() as $record) {
67 if ($record->getRecordFieldValue($this->getId()) == $datestring && ($record->getId() != $record_id || $record_id == 0)) {
69 }
70 }
71 }
72
73 return true;
74 }
75}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getTableCache(int $table_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRecordQueryFilterObject( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query.
checkValidity($value, ?int $record_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28