ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjNotificationSettings.php
Go to the documentation of this file.
1<?php
2
25{
27 public const MODE_DEF_ON_OPT_OUT = 1;
28 public const MODE_DEF_ON_NO_OPT_OUT = 2;
29
30 protected int $obj_id;
31 protected int $mode = 0;
32 protected ilDBInterface $db;
33
34 public function __construct(int $a_obj_id)
35 {
36 global $DIC;
37
38 $this->obj_id = $a_obj_id;
39 $this->db = $DIC->database();
40 $this->read();
41 }
42
43 public function setMode(int $a_val): void
44 {
45 $this->mode = $a_val;
46 }
47
48 public function getMode(): int
49 {
50 return $this->mode;
51 }
52
53 public function save(): void
54 {
55 $db = $this->db;
56
57 if ($this->obj_id > 0) {
58 $db->replace(
59 "obj_noti_settings",
60 array("obj_id" => array("integer", $this->obj_id)),
61 array("noti_mode" => array("integer", $this->getMode()))
62 );
63 }
64 }
65
66 public function read(): void
67 {
68 $db = $this->db;
69
70 $set = $db->query(
71 "SELECT * FROM obj_noti_settings " .
72 " WHERE obj_id = " . $db->quote($this->obj_id, "integer")
73 );
74 $rec = $db->fetchAssoc($set);
75 $this->setMode((int) ($rec["noti_mode"] ?? 0));
76 }
77
78 public function delete(): void
79 {
80 $db = $this->db;
81
82 $db->manipulate("DELETE FROM obj_noti_settings WHERE " .
83 " obj_id = " . $db->quote($this->obj_id, "integer"));
84 }
85}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilDBInterface.
replace(string $table, array $primary_keys, array $other_columns)
Replace into method.
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
global $DIC
Definition: shib_login.php:26