ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.NoteSettingsDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Notes;
22
27{
28 protected \ilDBInterface $db;
30
31 public function __construct(
34 ) {
35 $this->db = $db;
36 $this->data = $data;
37 }
38
42 public function commentsActive(
43 int $obj_id
44 ): bool {
45 $db = $this->db;
46 $set = $db->query(
47 "SELECT rep_obj_id FROM note_settings " .
48 " WHERE rep_obj_id = " . $db->quote($obj_id, "integer") .
49 " AND activated = " . $db->quote(1, "integer")
50 );
51 if ($db->fetchAssoc($set)) {
52 return true;
53 }
54 return false;
55 }
56
57 public function commentsActiveMultiple(
58 array $obj_ids
59 ): array {
60 $db = $this->db;
61
62 $set = $db->query("SELECT * FROM note_settings " .
63 " WHERE " . $db->in("rep_obj_id", $obj_ids, false, "integer") .
64 " AND obj_id = 0 ");
65 $activations = [];
66 while ($rec = $db->fetchAssoc($set)) {
67 if ($rec["activated"]) {
68 $activations[$rec["rep_obj_id"]] = true;
69 }
70 }
71
72 return $activations;
73 }
74
75
79 public function activateComments(
80 int $obj_id,
81 int $sub_obj_id,
82 string $obj_type,
83 bool $a_activate = true
84 ): void {
85 $db = $this->db;
86
87 if ($obj_type === "") {
88 $obj_type = "-";
89 }
90
91 $db->replace(
92 "note_settings",
93 [
94 "rep_obj_id" => ["integer", $obj_id],
95 "obj_id" => ["integer", $sub_obj_id],
96 "obj_type" => ["string", $obj_type],
97 ],
98 [
99 "activated" => ["integer", (int) $a_activate]
100 ]
101 );
102 }
103}
__construct(InternalDataService $data, \ilDBInterface $db)
activateComments(int $obj_id, int $sub_obj_id, string $obj_type, bool $a_activate=true)
Activate notes feature.
commentsActive(int $obj_id)
Are comments activated for object?
Interface ilDBInterface.
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...