ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.MetadataDBRepo.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 filterObjIdsByCopyright(array $obj_ids, string $copyright_id): array
20  {
21  $identifier = \ilMDCopyrightSelectionEntry::createIdentifier($copyright_id);
24  );
25 
26  if ($identifier === $default_identifier) {
27  return $this->filterObjIdsByDefaultCopyright($obj_ids, $default_identifier);
28  }
29 
30  $db = $this->db;
31  $set = $db->queryF(
32  "SELECT DISTINCT(rbac_id) FROM il_meta_rights " .
33  " WHERE " . $db->in("rbac_id", $obj_ids, false, "integer") .
34  " AND description = %s ",
35  array("text"),
36  array($identifier)
37  );
38  $result_obj_ids = [];
39  while ($rec = $db->fetchAssoc($set)) {
40  $result_obj_ids[] = $rec["rbac_id"];
41  }
42  return array_intersect($obj_ids, $result_obj_ids);
43  }
44 
45  protected function filterObjIdsByDefaultCopyright(
46  array $obj_ids,
47  string $default_identifier
48  ): array {
49  /*
50  * Objects with no entry in il_meta_rights need to be treated like they
51  * have the default copyright.
52  */
53  $db = $this->db;
54  $set = $db->queryF(
55  "SELECT DISTINCT(rbac_id) FROM il_meta_rights " .
56  " WHERE " . $db->in("rbac_id", $obj_ids, false, "integer") .
57  " AND NOT description = %s ",
58  array("text"),
59  array($default_identifier)
60  );
61  $filtered_out_obj_ids = [];
62  while ($rec = $db->fetchAssoc($set)) {
63  $filtered_out_obj_ids[] = $rec["rbac_id"];
64  }
65  return array_diff($obj_ids, $filtered_out_obj_ids);
66  }
67 }
filterObjIdsByDefaultCopyright(array $obj_ids, string $default_identifier)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
queryF(string $query, array $types, array $values)
filterObjIdsByCopyright(array $obj_ids, string $copyright_id)