ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilObjCourseReference.php
Go to the documentation of this file.
1 <?php
28 {
32  private $member_update = false;
33 
34 
41  public function __construct($a_id = 0, $a_call_by_reference = true)
42  {
43  global $ilDB;
44 
45  $this->type = 'crsr';
46  parent::__construct($a_id, $a_call_by_reference);
47  }
48 
52  public function enableMemberUpdate(bool $status)
53  {
54  $this->member_update = $status;
55  }
56 
60  public function isMemberUpdateEnabled(): bool
61  {
62  return $this->member_update;
63  }
64 
69  public static function lookupMemberUpdateEnabled(int $obj_id): bool
70  {
71  global $DIC;
72 
73  $db = $DIC->database();
74 
75  $query = 'select member_update from crs_reference_settings where ' .
76  'obj_id = ' . $db->quote($obj_id, ilDBConstants::T_INTEGER);
77  $res = $db->query($query);
78  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
79  return (bool) $row->member_update;
80  }
81  return false;
82  }
83 
84 
88  public function create(): int
89  {
90  $id = parent::create();
91 
92  $query = 'INSERT INTO crs_reference_settings (obj_id, member_update ) ' .
93  'VALUES ( ' .
94  $this->db->quote($id, ilDBConstants::T_INTEGER) . ', ' .
95  $this->db->quote((int) $this->isMemberUpdateEnabled(), ilDBConstants::T_INTEGER) . ' ' .
96  ')';
97  $this->db->manipulate($query);
98  return $id;
99  }
100 
104  public function read(): void
105  {
106  parent::read();
107 
108  $query = 'SELECT * FROM crs_reference_settings ' .
109  'WHERE obj_id = ' . $this->db->quote($this->getId(), ilDBConstants::T_INTEGER);
110  $res = $this->db->query($query);
111  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
112  $this->enableMemberUpdate($row->member_update);
113  }
114  }
115 
119  public function update(): bool
120  {
121  parent::update();
122  $query = 'UPDATE crs_reference_settings ' .
123  'SET member_update = ' . $this->db->quote((int) $this->isMemberUpdateEnabled(), ilDBConstants::T_INTEGER) . ' ' .
124  'WHERE obj_id = ' . $this->db->quote((int) $this->getId(), ilDBConstants::T_INTEGER);
125  $this->db->manipulate($query);
126 
127  ilLoggerFactory::getLogger('crs')->info($query);
128 
129  return true;
130  }
131 
135  public function delete(): bool
136  {
137  if (!parent::delete()) {
138  return false;
139  }
140  $query = 'DELETE FROM crs_reference_settings ' .
141  'WHERE obj_id = ' . $this->db->quote($this->getId(), ilDBConstants::T_INTEGER);
142  $this->db->manipulate($query);
143  return true;
144  }
145 
146 
150  public function cloneObject(int $a_target_id, int $a_copy_id = 0, bool $a_omit_tree = false): ?ilObject
151  {
152  $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
153  $new_obj->enableMemberUpdate($this->isMemberUpdateEnabled());
154  $new_obj->update();
155  return $new_obj;
156  }
157 }
static lookupMemberUpdateEnabled(int $obj_id)
$res
Definition: ltiservices.php:66
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
quote($value, string $type)
cloneObject(int $a_target_id, int $a_copy_id=0, bool $a_omit_tree=false)
ilDBInterface $db
global $DIC
Definition: shib_login.php:26
query(string $query)
Run a (read-only) Query on the database.
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)