ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjCourseReference.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/ContainerReference/classes/class.ilContainerReference.php');
25
36{
40 private $member_update = false;
41
42
49 public function __construct($a_id = 0, $a_call_by_reference = true)
50 {
51 global $ilDB;
52
53 $this->type = 'crsr';
54 parent::__construct($a_id, $a_call_by_reference);
55 }
56
60 public function enableMemberUpdate(bool $status)
61 {
62 $this->member_update = $status;
63 }
64
68 public function isMemberUpdateEnabled() : bool
69 {
71 }
72
77 public static function lookupMemberUpdateEnabled(int $obj_id) : bool
78 {
79 global $DIC;
80
81 $db = $DIC->database();
82
83 $query = 'select member_update from crs_reference_settings where ' .
84 'obj_id = ' . $db->quote($obj_id, ilDBConstants::T_INTEGER);
85 $res = $db->query($query);
86 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87 return (bool) $row->member_update;
88 }
89 return false;
90 }
91
92
96 public function create()
97 {
98 $id = parent::create();
99
100 $query = 'INSERT INTO crs_reference_settings (obj_id, member_update ) ' .
101 'VALUES ( ' .
102 $this->db->quote($id, ilDBConstants::T_INTEGER) . ', ' .
103 $this->db->quote((int) $this->isMemberUpdateEnabled(), ilDBConstants::T_INTEGER) . ' ' .
104 ')';
105 $this->db->manipulate($query);
106 return $id;
107 }
108
112 public function read()
113 {
114 parent::read();
115
116 $query = 'SELECT * FROM crs_reference_settings ' .
117 'WHERE obj_id = ' . $this->db->quote($this->getId(), ilDBConstants::T_INTEGER);
118 $res = $this->db->query($query);
119 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
120 $this->enableMemberUpdate($row->member_update);
121 }
122 }
123
127 public function update()
128 {
129 parent::update();
130 $query = 'UPDATE crs_reference_settings ' .
131 'SET member_update = ' . $this->db->quote((int) $this->isMemberUpdateEnabled(), ilDBConstants::T_INTEGER) . ' ' .
132 'WHERE obj_id = ' . $this->db->quote((int) $this->getId(), ilDBConstants::T_INTEGER);
133 $this->db->manipulate($query);
134
136
137 return true;
138 }
139
143 public function delete()
144 {
145 if (!parent::delete()) {
146 return false;
147 }
148 $query = 'DELETE FROM crs_reference_settings ' .
149 'WHERE obj_id = ' . $this->db->quote($this->getId(), ilDBConstants::T_INTEGER);
150 $this->db->manipulate($query);
151 return true;
152 }
153
154
158 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
159 {
160 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
161 $new_obj->enableMemberUpdate($this->isMemberUpdateEnabled());
162 $new_obj->update();
163 return $new_obj;
164 }
165}
An exception for terminatinating execution or to throw for unit testing.
static getLogger($a_component_id)
Get component logger.
update()
update object in db@access public boolean true on success
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone course reference.@access public
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
static lookupMemberUpdateEnabled(int $obj_id)
getId()
get object id @access public
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46