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