ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjCourseReference.php
Go to the documentation of this file.
1<?php
2
29{
33 private $member_update = false;
34
35
42 public function __construct($a_id = 0, $a_call_by_reference = true)
43 {
44 global $ilDB;
45
46 $this->type = 'crsr';
47 parent::__construct($a_id, $a_call_by_reference);
48 }
49
53 public function enableMemberUpdate(bool $status)
54 {
55 $this->member_update = $status;
56 }
57
61 public function isMemberUpdateEnabled(): bool
62 {
64 }
65
70 public static function lookupMemberUpdateEnabled(int $obj_id): bool
71 {
72 global $DIC;
73
74 $db = $DIC->database();
75
76 $query = 'select member_update from crs_reference_settings where ' .
77 'obj_id = ' . $db->quote($obj_id, ilDBConstants::T_INTEGER);
78 $res = $db->query($query);
79 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
80 return (bool) $row->member_update;
81 }
82 return false;
83 }
84
85
89 public function create(): int
90 {
91 $id = parent::create();
92
93 $query = 'INSERT INTO crs_reference_settings (obj_id, member_update ) ' .
94 'VALUES ( ' .
95 $this->db->quote($id, ilDBConstants::T_INTEGER) . ', ' .
96 $this->db->quote((int) $this->isMemberUpdateEnabled(), ilDBConstants::T_INTEGER) . ' ' .
97 ')';
98 $this->db->manipulate($query);
99 return $id;
100 }
101
105 public function read(): void
106 {
107 parent::read();
108
109 $query = 'SELECT * FROM crs_reference_settings ' .
110 'WHERE obj_id = ' . $this->db->quote($this->getId(), ilDBConstants::T_INTEGER);
111 $res = $this->db->query($query);
112 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
113 $this->enableMemberUpdate($row->member_update);
114 }
115 }
116
120 public function update(): bool
121 {
122 parent::update();
123 $query = 'UPDATE crs_reference_settings ' .
124 'SET member_update = ' . $this->db->quote((int) $this->isMemberUpdateEnabled(), ilDBConstants::T_INTEGER) . ' ' .
125 'WHERE obj_id = ' . $this->db->quote((int) $this->getId(), ilDBConstants::T_INTEGER);
126 $this->db->manipulate($query);
127
128 ilLoggerFactory::getLogger('crs')->info($query);
129
130 return true;
131 }
132
136 public function delete(): bool
137 {
138 if (!parent::delete()) {
139 return false;
140 }
141 $query = 'DELETE FROM crs_reference_settings ' .
142 'WHERE obj_id = ' . $this->db->quote($this->getId(), ilDBConstants::T_INTEGER);
143 $this->db->manipulate($query);
144 return true;
145 }
146
147
151 public function cloneObject(int $a_target_id, int $a_copy_id = 0, bool $a_omit_tree = false): ?ilObject
152 {
153 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
154 $new_obj->enableMemberUpdate($this->isMemberUpdateEnabled());
155 $new_obj->update();
156
157 $lp_settings = new ilLPObjSettings($this->getId());
158 $lp_settings->cloneSettings($new_obj->getId());
159
160 return $new_obj;
161 }
162}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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...
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
cloneObject(int $a_target_id, int $a_copy_id=0, bool $a_omit_tree=false)
static lookupMemberUpdateEnabled(int $obj_id)
Class ilObject Basic functions for all objects.
ilDBInterface $db
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26