ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjItemGroup.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once "Services/Object/classes/class.ilObject2.php";
6require_once "Services/Object/classes/class.ilObjectActivation.php";
7
8include_once("./Modules/ItemGroup/classes/class.ilItemGroupAR.php");
9
10
20{
24 protected $obj_def;
25
26 protected $access_type; // [int]
27 protected $access_begin; // [timestamp]
28 protected $access_end; // [timestamp]
29 protected $access_visibility; // [bool]
30 protected $item_data_ar = null; // active record
31
39 public function __construct($a_id = 0, $a_reference = true)
40 {
41 global $DIC;
42
43 $this->log = $DIC["ilLog"];
44 $tree = $DIC->repositoryTree();
45 $objDefinition = $DIC["objDefinition"];
46 $ilDB = $DIC->database();
47
48 $this->tree = $tree;
49 $this->obj_def = $objDefinition;
50 $this->db = $ilDB;
51
52 $this->item_data_ar = new ilItemGroupAR();
53
54 parent::__construct($a_id, $a_reference);
55 }
56
62 public function setId($a_val)
63 {
64 parent::setId($a_val);
65 $this->item_data_ar->setId($a_val);
66 }
67
71 public function initType()
72 {
73 $this->type = "itgr";
74 }
75
81 public function setHideTitle($a_val)
82 {
83 $this->item_data_ar->setHideTitle($a_val);
84 }
85
91 public function getHideTitle()
92 {
93 return $this->item_data_ar->getHideTitle();
94 }
95
101 public function setBehaviour($a_val)
102 {
103 $this->item_data_ar->setBehaviour($a_val);
104 }
105
111 public function getBehaviour()
112 {
113 return $this->item_data_ar->getBehaviour();
114 }
115
119 protected function doRead()
120 {
121 $this->item_data_ar = new ilItemGroupAR($this->getId());
122 }
123
127 protected function doCreate()
128 {
129 if ($this->getId()) {
130 $this->item_data_ar->setId($this->getId());
131 $this->item_data_ar->create();
132 }
133 }
134
138 protected function doUpdate()
139 {
140 if ($this->getId()) {
141 $this->item_data_ar->update();
142 }
143 }
144
148 protected function doDelete()
149 {
150 if ($this->getId()) {
151 $this->item_data_ar->delete();
152 }
153 }
154
162 protected function doCloneObject($new_obj, $a_target_id, $a_copy_id = null, $a_omit_tree = false)
163 {
164 $new_obj->setHideTitle($this->getHideTitle());
165 $new_obj->setBehaviour($this->getBehaviour());
166 $new_obj->update();
167 }
168
175 public function cloneDependencies($a_target_id, $a_copy_id)
176 {
178
179 $ilLog->write(__METHOD__ . ': Cloning item group dependencies -' . $a_source_id . '-');
180
181 parent::cloneDependencies($a_target_id, $a_copy_id);
182
183 include_once('./Modules/ItemGroup/classes/class.ilItemGroupItems.php');
184 $ig_items = new ilItemGroupItems($a_target_id);
185 $ig_items->cloneItems($this->getRefId(), $a_copy_id);
186
187 return true;
188 }
189
196 public static function fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id)
197 {
198 global $DIC;
199
200 $ilLog = $DIC["ilLog"];
201
202 $ilLog->write(__METHOD__ . ': Fix item group references in ' . $a_source_container->getType());
203
204 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
205 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
206 $mappings = $cwo->getMappings();
207
208 $new_container_ref_id = $mappings[$a_source_container->getRefId()];
209 $ilLog->write(__METHOD__ . ': 2-' . $new_container_ref_id . '-');
210 $new_container_obj_id = ilObject::_lookupObjId($new_container_ref_id);
211
212 include_once("./Services/COPage/classes/class.ilPageObject.php");
213 include_once("./Services/Container/classes/class.ilContainerPage.php");
214 $ilLog->write(__METHOD__ . ': 3' . $new_container_obj_id . '-');
215 if (ilPageObject::_exists("cont", $new_container_obj_id)) {
216 $ilLog->write(__METHOD__ . ': 4');
217 $new_page = new ilContainerPage($new_container_obj_id);
218 $new_page->buildDom();
219 include_once("./Services/COPage/classes/class.ilPCResources.php");
221 $new_page->update();
222 }
223 $ilLog->write(__METHOD__ . ': 5');
224 }
225
232 public static function lookupHideTitle($a_id)
233 {
234 return self::lookup($a_id, "hide_title");
235 }
236
243 public static function lookupBehaviour($a_id)
244 {
245 return self::lookup($a_id, "behaviour");
246 }
247
254 protected static function lookup($a_id, $a_key)
255 {
256 global $DIC;
257
258 $ilDB = $DIC->database();
259
260 $set = $ilDB->query(
261 "SELECT " . $a_key . " FROM itgr_data " .
262 " WHERE id = " . $ilDB->quote($a_id, "integer")
263 );
264 $rec = $ilDB->fetchAssoc($set);
265 return $rec[$a_key];
266 }
267}
An exception for terminatinating execution or to throw for unit testing.
Container page object.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
Item group active record class.
Class ilObjItemGroup.
setBehaviour($a_val)
Set behaviour (see ilItemGroupBehaviour)
cloneDependencies($a_target_id, $a_copy_id)
Clone dependencies.
doCloneObject($new_obj, $a_target_id, $a_copy_id=null, $a_omit_tree=false)
Clone obj item group.
setId($a_val)
Set ID.
__construct($a_id=0, $a_reference=true)
Constructor.
setHideTitle($a_val)
Set hide title.
getHideTitle()
Get hide title.
static lookup($a_id, $a_key)
Lookup hide title.
static lookupBehaviour($a_id)
Lookup behaviour.
static fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id)
Fix container item group references after a container has been cloned.
getBehaviour()
Get hide title.
static lookupHideTitle($a_id)
Lookup hide title.
Class ilObject2 This is an intermediate progress of ilObject class.
getRefId()
get reference id @access public
static _lookupObjId($a_id)
getId()
get object id @access public
static modifyItemGroupRefIdsByMapping($a_page, $mappings)
Modify ref ids by mapping.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilDB
$DIC
Definition: xapitoken.php:46