ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjPortfolioTemplate.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
12  protected $activation_limited; // [bool]
13  protected $activation_visibility; // [bool]
14  protected $activation_starting_time; // [integer]
15  protected $activation_ending_time; // [integer]
16 
17  public function initType()
18  {
19  $this->type = "prtt";
20  }
21 
22  protected function doRead()
23  {
24  parent::doRead();
25 
26  if ($this->ref_id) {
27  $activation = ilObjectActivation::getItem($this->ref_id);
28  switch ($activation["timing_type"]) {
30  $this->setActivationLimited(true);
31  $this->setActivationStartDate($activation["timing_start"]);
32  $this->setActivationEndDate($activation["timing_end"]);
33  $this->setActivationVisibility($activation["visible"]);
34  break;
35 
36  default:
37  $this->setActivationLimited(false);
38  break;
39  }
40  }
41  }
42 
43  protected function doCreate()
44  {
45  parent::doCreate();
46  $this->updateActivation();
47  }
48 
49  protected function doUpdate()
50  {
51  parent::doUpdate();
52  $this->updateActivation();
53  }
54 
55  protected function deleteAllPages()
56  {
57  // delete pages
59  foreach ($pages as $page) {
60  $page_obj = new ilPortfolioTemplatePage($page["id"]);
61  $page_obj->setPortfolioId($this->id);
62  $page_obj->delete();
63  }
64  }
65 
66  protected function doCloneObject($new_obj, $a_target_id, $a_copy_id = null)
67  {
68  //copy online status if object is not the root copy object
69  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
70 
71  if (!$cp_options->isRootNode($this->getRefId())) {
72  $new_obj->setOnline($this->isOnline());
73  }
74 
75  self::cloneBasics($this, $new_obj);
76 
77  // copy pages
78  foreach (ilPortfolioPage::getAllPortfolioPages($this->getId()) as $page) {
79  // see ilObjWiki::cloneObject();
80 
81  $page = new ilPortfolioTemplatePage($page["id"]);
82 
83  $new_page = new ilPortfolioTemplatePage();
84  $new_page->setPortfolioId($new_obj->getId());
85  $new_page->setTitle($page->getTitle());
86  $new_page->setType($page->getType());
87  $new_page->setOrderNr($page->getOrderNr());
88  $new_page->create();
89 
90  $page->copy($new_page->getId(), "", 0, true);
91  }
92  }
93 
94 
95  //
96  // ACTIVATION
97  //
98 
99  protected function updateActivation()
100  {
101  // moved activation to ilObjectActivation
102  if ($this->ref_id) {
103  ilObjectActivation::getItem($this->ref_id);
104 
105  $item = new ilObjectActivation;
106  if (!$this->isActivationLimited()) {
108  } else {
109  $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
110  $item->setTimingStart($this->getActivationStartDate());
111  $item->setTimingEnd($this->getActivationEndDate());
112  $item->toggleVisible($this->getActivationVisibility());
113  }
114 
115  $item->update($this->ref_id);
116  }
117  }
118 
119  public function isActivationLimited()
120  {
121  return (bool) $this->activation_limited;
122  }
123 
124  public function setActivationLimited($a_value)
125  {
126  $this->activation_limited = (bool) $a_value;
127  }
128 
129  public function setActivationVisibility($a_value)
130  {
131  $this->activation_visibility = (bool) $a_value;
132  }
133 
134  public function getActivationVisibility()
135  {
137  }
138 
139  public function setActivationStartDate($starting_time = null)
140  {
141  $this->activation_starting_time = $starting_time;
142  }
143 
144  public function setActivationEndDate($ending_time = null)
145  {
146  $this->activation_ending_time = $ending_time;
147  }
148 
149  public function getActivationStartDate()
150  {
151  return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : null;
152  }
153 
154  public function getActivationEndDate()
155  {
156  return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : null;
157  }
158 
159 
160  //
161  // HELPER
162  //
163 
164  public static function getAvailablePortfolioTemplates($a_permission = "read")
165  {
166  global $DIC;
167 
168  $ilUser = $DIC->user();
169  $ilAccess = $DIC->access();
170 
171  $res = array();
172 
173  foreach (ilObject::_getObjectsByType("prtt") as $obj) {
174  $has_permission = false;
175 
176  if ($obj["owner"] == $ilUser->getId()) {
177  $has_permission = true;
178  } else {
179  foreach (ilObject::_getAllReferences($obj["obj_id"]) as $ref_id) {
180  if ($ilAccess->checkAccess($a_permission, "", $ref_id)) {
181  $has_permission = true;
182  break;
183  }
184  }
185  }
186 
187  if ($has_permission) {
188  $res[$obj["obj_id"]] = $obj["title"];
189  }
190  }
191 
192  asort($res);
193  return $res;
194  }
195 }
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
static getItem($a_ref_id)
Get item data.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
static _getAllReferences($a_id)
get all reference ids of object
static _getInstance($a_copy_id)
Get instance of copy wizard options.
foreach($_POST as $key=> $value) $res
getId()
get object id public
global $DIC
Definition: goto.php:24
Page for portfolio template.
static getAvailablePortfolioTemplates($a_permission="read")
setTimingType($a_type)
Set timing type.
$ilUser
Definition: imgupload.php:18
setActivationStartDate($starting_time=null)
Class ilObjectActivation.
doCloneObject($new_obj, $a_target_id, $a_copy_id=null)