ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjNotificationSettings.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
13 {
17 
21  protected $obj_id;
22 
26  protected $mode = 0;
27 
31  protected $db;
32 
38  public function __construct($a_obj_id)
39  {
40  global $DIC;
41 
42  $this->obj_id = $a_obj_id;
43  $this->db = $DIC->database();
44  $this->read();
45  }
46 
52  public function setMode($a_val)
53  {
54  $this->mode = $a_val;
55  }
56 
62  public function getMode()
63  {
64  return $this->mode;
65  }
66 
70  public function save()
71  {
72  $db = $this->db;
73 
74  if ($this->obj_id > 0) {
75  $db->replace(
76  "obj_noti_settings",
77  array("obj_id" => array("integer", $this->obj_id)),
78  array("noti_mode" => array("integer", (int) $this->getMode()))
79  );
80  }
81  }
82 
86  public function read()
87  {
88  $db = $this->db;
89 
90  $set = $db->query(
91  "SELECT * FROM obj_noti_settings " .
92  " WHERE obj_id = " . $db->quote($this->obj_id, "integer")
93  );
94  $rec = $db->fetchAssoc($set);
95  $this->setMode((int) $rec["noti_mode"]);
96  }
97 
98 
102  public function delete()
103  {
104  $db = $this->db;
105 
106  $db->manipulate("DELETE FROM obj_noti_settings WHERE " .
107  " obj_id = " . $db->quote($this->obj_id, "integer"));
108  }
109 }
global $DIC
Definition: saml.php:7
Handles general object notification settings, see e.g.