ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjPortfolioTemplate.php
Go to the documentation of this file.
1<?php
2
23{
24 protected bool $activation_limited = false;
25 protected bool $activation_visibility = false;
26 protected int $activation_starting_time = 0;
27 protected int $activation_ending_time = 0;
28
29 protected function initType(): void
30 {
31 $this->type = "prtt";
32 }
33
34 protected function doRead(): void
35 {
36 parent::doRead();
37
38 if (($this->ref_id ?? 0) > 0) {
39 $activation = ilObjectActivation::getItem($this->ref_id);
40 switch ($activation["timing_type"]) {
42 $this->setActivationLimited(true);
43 $this->setActivationStartDate($activation["timing_start"]);
44 $this->setActivationEndDate($activation["timing_end"]);
45 $this->setActivationVisibility($activation["visible"]);
46 break;
47
48 default:
49 $this->setActivationLimited(false);
50 break;
51 }
52 }
53 }
54
55 protected function doCreate(bool $clone_mode = false): void
56 {
57 parent::doCreate($clone_mode);
58 $this->updateActivation();
59 }
60
61 protected function doUpdate(): void
62 {
63 parent::doUpdate();
64 $this->updateActivation();
65 }
66
67 protected function deleteAllPages(): void
68 {
69 // delete pages
71 foreach ($pages as $page) {
72 $page_obj = new ilPortfolioTemplatePage($page["id"]);
73 $page_obj->setPortfolioId($this->id);
74 $page_obj->delete();
75 }
76 }
77
78 protected function doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id = null): void
79 {
80 assert($new_obj instanceof ilObjPortfolioTemplate);
81 //copy online status if object is not the root copy object
82 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
83
84 if (!$cp_options->isRootNode($this->getRefId())) {
85 $new_obj->setOnline($this->isOnline());
86 }
87
88 self::cloneBasics($this, $new_obj);
89
90 // copy pages
91 foreach (ilPortfolioPage::getAllPortfolioPages($this->getId()) as $page) {
92 // see ilObjWiki::cloneObject();
93
94 $page = new ilPortfolioTemplatePage($page["id"]);
95
96 $new_page = new ilPortfolioTemplatePage();
97 $new_page->setPortfolioId($new_obj->getId());
98 $new_page->setTitle($page->getTitle());
99 $new_page->setType($page->getType());
100 $new_page->setOrderNr($page->getOrderNr());
101 $new_page->create(false);
102
103 $page->copy($new_page->getId(), "", $new_obj->getId(), true, $a_copy_id);
104 }
105 }
106
107
108 //
109 // ACTIVATION
110 //
111
112 protected function updateActivation(): void
113 {
114 // moved activation to ilObjectActivation
115 if (($this->ref_id ?? 0) > 0) {
116 ilObjectActivation::getItem($this->ref_id);
117
118 $item = new ilObjectActivation();
119 if (!$this->isActivationLimited()) {
120 $item->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
121 } else {
122 $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
123 $item->setTimingStart($this->getActivationStartDate());
124 $item->setTimingEnd($this->getActivationEndDate());
125 $item->toggleVisible($this->getActivationVisibility());
126 }
127
128 $item->update($this->ref_id);
129 }
130 }
131
132 public function isActivationLimited(): bool
133 {
135 }
136
137 public function setActivationLimited(bool $a_value): void
138 {
139 $this->activation_limited = $a_value;
140 }
141
142 public function setActivationVisibility(bool $a_value): void
143 {
144 $this->activation_visibility = $a_value;
145 }
146
147 public function getActivationVisibility(): bool
148 {
150 }
151
152 public function setActivationStartDate(?int $starting_time = null): void
153 {
154 $this->activation_starting_time = $starting_time;
155 }
156
157 public function setActivationEndDate(?int $ending_time = null): void
158 {
159 $this->activation_ending_time = $ending_time;
160 }
161
162 public function getActivationStartDate(): ?int
163 {
164 return ($this->activation_starting_time > 0) ? $this->activation_starting_time : null;
165 }
166
167 public function getActivationEndDate(): ?int
168 {
169 return ($this->activation_ending_time > 0) ? $this->activation_ending_time : null;
170 }
171
172 //
173 // HELPER
174 //
175
176 public static function getAvailablePortfolioTemplates(
177 string $a_permission = "read"
178 ): array {
179 global $DIC;
180
181 $ilUser = $DIC->user();
182 $ilAccess = $DIC->access();
183
184 $res = array();
185
186 foreach (ilObject::_getObjectsByType("prtt") as $obj) {
187 $has_permission = false;
188
189 if ($obj["owner"] == $ilUser->getId()) {
190 $has_permission = true;
191 } else {
192 foreach (ilObject::_getAllReferences($obj["obj_id"]) as $ref_id) {
193 if ($ilAccess->checkAccess($a_permission, "", $ref_id)) {
194 $has_permission = true;
195 break;
196 }
197 }
198 }
199
200 if ($has_permission) {
201 $res[$obj["obj_id"]] = $obj["title"];
202 }
203 }
204
205 asort($res);
206 return $res;
207 }
208}
static _getInstance(int $a_copy_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static cloneBasics(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target)
Clone basic settings.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=null)
doCreate(bool $clone_mode=false)
setActivationEndDate(?int $ending_time=null)
static getAvailablePortfolioTemplates(string $a_permission="read")
setActivationStartDate(?int $starting_time=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectActivation.
static getItem(int $ref_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _getObjectsByType(string $obj_type="", ?int $owner=null)
static getAllPortfolioPages(int $a_portfolio_id)
Get pages of portfolio.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26