ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ObjectDBRepo.php
Go to the documentation of this file.
1<?php
2
20
25{
26 protected \ilDBInterface $db;
27
28 public function __construct(\ilDBInterface $db)
29 {
30 $this->db = $db;
31 }
32
33 public function filterObjIdsByType(array $obj_ids, string $type): array
34 {
35 $db = $this->db;
36 $set = $db->queryF(
37 "SELECT obj_id FROM object_data " .
38 " WHERE " . $db->in("obj_id", $obj_ids, false, "integer") .
39 " AND type = %s",
40 array("text"),
41 array($type)
42 );
43 $result_obj_ids = [];
44 while ($rec = $db->fetchAssoc($set)) {
45 $result_obj_ids[] = $rec["obj_id"];
46 }
47 return $result_obj_ids;
48 }
49
50 public function filterObjIdsByOnline(array $obj_ids): array
51 {
52 return $this->_filterObjIdsByOnlineOffline($obj_ids, true);
53 }
54
55 public function filterObjIdsByOffline(array $obj_ids): array
56 {
57 return $this->_filterObjIdsByOnlineOffline($obj_ids, false);
58 }
59
60 protected function _filterObjIdsByOnlineOffline(array $obj_ids, bool $online = true): array
61 {
62 $db = $this->db;
63 $online_where = ($online)
64 ? " (offline <> " . $db->quote(1, "integer") . " OR offline IS NULL) "
65 : " offline = " . $db->quote(1, "integer") . " ";
66 $result = null;
67 $set = $db->queryF(
68 "SELECT obj_id FROM object_data " .
69 " WHERE " . $db->in("obj_id", $obj_ids, false, "integer") .
70 " AND " . $online_where,
71 [],
72 []
73 );
74 $result_obj_ids = [];
75 while ($rec = $db->fetchAssoc($set)) {
76 $result_obj_ids[] = $rec["obj_id"];
77 }
78 return array_intersect($obj_ids, $result_obj_ids);
79 }
80}
_filterObjIdsByOnlineOffline(array $obj_ids, bool $online=true)
filterObjIdsByType(array $obj_ids, string $type)
Interface ilDBInterface.
quote($value, string $type)
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...