ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ObjectDBRepo.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2022 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
6 
11 {
12  protected \ilDBInterface $db;
13 
14  public function __construct(\ilDBInterface $db)
15  {
16  $this->db = $db;
17  }
18 
19  public function filterObjIdsByType(array $obj_ids, string $type): array
20  {
21  $db = $this->db;
22  $set = $db->queryF(
23  "SELECT obj_id FROM object_data " .
24  " WHERE " . $db->in("obj_id", $obj_ids, false, "integer") .
25  " AND type = %s",
26  array("text"),
27  array($type)
28  );
29  $result_obj_ids = [];
30  while ($rec = $db->fetchAssoc($set)) {
31  $result_obj_ids[] = $rec["obj_id"];
32  }
33  return $result_obj_ids;
34  }
35 
36  public function filterObjIdsByOnline(array $obj_ids): array
37  {
38  return $this->_filterObjIdsByOnlineOffline($obj_ids, true);
39  }
40 
41  public function filterObjIdsByOffline(array $obj_ids): array
42  {
43  return $this->_filterObjIdsByOnlineOffline($obj_ids, false);
44  }
45 
46  protected function _filterObjIdsByOnlineOffline(array $obj_ids, bool $online = true): array
47  {
48  $db = $this->db;
49  $online_where = ($online)
50  ? " (offline <> " . $db->quote(1, "integer") . " OR offline IS NULL) "
51  : " offline = " . $db->quote(1, "integer") . " ";
52  $result = null;
53  $set = $db->queryF(
54  "SELECT obj_id FROM object_data " .
55  " WHERE " . $db->in("obj_id", $obj_ids, false, "integer") .
56  " AND " . $online_where,
57  [],
58  []
59  );
60  $result_obj_ids = [];
61  while ($rec = $db->fetchAssoc($set)) {
62  $result_obj_ids[] = $rec["obj_id"];
63  }
64  return array_intersect($obj_ids, $result_obj_ids);
65  }
66 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
_filterObjIdsByOnlineOffline(array $obj_ids, bool $online=true)
filterObjIdsByType(array $obj_ids, string $type)
quote($value, string $type)
queryF(string $query, array $types, array $values)