ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilDclDateFieldModel.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
26  public function getRecordQueryFilterObject(
27  $filter_value = "",
28  ?ilDclBaseFieldModel $sort_field = null
30 
31  $date_from = (isset($filter_value['from']) && is_object($filter_value['from'])) ? $filter_value['from'] : null;
32  $date_to = (isset($filter_value['to']) && is_object($filter_value['to'])) ? $filter_value['to'] : null;
33 
34  $join_str
35  = "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 = "
36  . $this->db->quote($this->getId(), 'integer') . ") ";
37  $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 ";
38  if ($date_from) {
39  $join_str .= "AND filter_stloc_{$this->getId()}.value >= " . $this->db->quote($date_from, 'date') . " ";
40  }
41  if ($date_to) {
42  $join_str .= "AND filter_stloc_{$this->getId()}.value <= " . $this->db->quote($date_to, 'date') . " ";
43  }
44  $join_str .= ") ";
45 
46  $sql_obj = new ilDclRecordQueryObject();
47  $sql_obj->setJoinStatement($join_str);
48 
49  return $sql_obj;
50  }
51 
52  protected function areEqual($value_1, $value_2): bool
53  {
54  if ($value_1 === null || $value_2 === null) {
55  return false;
56  }
57  return date('Y-m-d', strtotime($value_1)) === date('Y-m-d', strtotime($value_2));
58  }
59 }
areEqual($value_1, $value_2)
getRecordQueryFilterObject( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)