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