ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
32  include_once "./Services/Object/classes/class.ilObjectActivation.php";
33  $activation = ilObjectActivation::getItem($this->ref_id);
34  switch($activation["timing_type"])
35  {
37  $this->setActivationLimited(true);
38  $this->setActivationStartDate($activation["timing_start"]);
39  $this->setActivationEndDate($activation["timing_end"]);
40  $this->setActivationVisibility($activation["visible"]);
41  break;
42 
43  default:
44  $this->setActivationLimited(false);
45  break;
46  }
47  }
48  }
49 
50  protected function doCreate()
51  {
52  parent::doCreate();
53  $this->updateActivation();
54  }
55 
56  protected function doUpdate()
57  {
58  parent::doUpdate();
59  $this->updateActivation();
60  }
61 
62  protected function deleteAllPages()
63  {
64  // delete pages
65  include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
67  foreach($pages as $page)
68  {
69  $page_obj = new ilPortfolioTemplatePage($page["id"]);
70  $page_obj->setPortfolioId($this->id);
71  $page_obj->delete();
72  }
73  }
74 
75  protected function doCloneObject($new_obj, $a_target_id, $a_copy_id = null)
76  {
77  //copy online status if object is not the root copy object
78  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
79 
80  if(!$cp_options->isRootNode($this->getRefId()))
81  {
82  $new_obj->setOnline($this->isOnline());
83  }
84 
85  self::cloneBasics($this, $new_obj);
86 
87  // copy pages
88  include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
89  foreach(ilPortfolioPage::getAllPortfolioPages($this->getId()) as $page)
90  {
91  // see ilObjWiki::cloneObject();
92 
93  $page = new ilPortfolioTemplatePage($page["id"]);
94 
95  $new_page = new ilPortfolioTemplatePage();
96  $new_page->setPortfolioId($new_obj->getId());
97  $new_page->setTitle($page->getTitle());
98  $new_page->setType($page->getType());
99  $new_page->setOrderNr($page->getOrderNr());
100  $new_page->create();
101 
102  $page->copy($new_page->getId(), "", 0, true);
103  }
104  }
105 
106 
107  //
108  // ACTIVATION
109  //
110 
111  protected function updateActivation()
112  {
113  // moved activation to ilObjectActivation
114  if($this->ref_id)
115  {
116  include_once "./Services/Object/classes/class.ilObjectActivation.php";
117  ilObjectActivation::getItem($this->ref_id);
118 
119  $item = new ilObjectActivation;
120  if(!$this->isActivationLimited())
121  {
123  }
124  else
125  {
126  $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
127  $item->setTimingStart($this->getActivationStartDate());
128  $item->setTimingEnd($this->getActivationEndDate());
129  $item->toggleVisible($this->getActivationVisibility());
130  }
131 
132  $item->update($this->ref_id);
133  }
134  }
135 
136  public function isActivationLimited()
137  {
138  return (bool)$this->activation_limited;
139  }
140 
141  public function setActivationLimited($a_value)
142  {
143  $this->activation_limited = (bool)$a_value;
144  }
145 
146  public function setActivationVisibility($a_value)
147  {
148  $this->activation_visibility = (bool) $a_value;
149  }
150 
151  public function getActivationVisibility()
152  {
154  }
155 
156  public function setActivationStartDate($starting_time = NULL)
157  {
158  $this->activation_starting_time = $starting_time;
159  }
160 
161  public function setActivationEndDate($ending_time = NULL)
162  {
163  $this->activation_ending_time = $ending_time;
164  }
165 
166  public function getActivationStartDate()
167  {
168  return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : NULL;
169  }
170 
171  public function getActivationEndDate()
172  {
173  return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : NULL;
174  }
175 
176 
177  //
178  // HELPER
179  //
180 
181  public static function getAvailablePortfolioTemplates($a_permission = "read")
182  {
183  global $ilUser, $ilAccess;
184 
185  $res = array();
186 
187  foreach(ilObject::_getObjectsByType("prtt") as $obj)
188  {
189  $has_permission = false;
190 
191  if($obj["owner"] == $ilUser->getId())
192  {
193  $has_permission = true;
194  }
195  else
196  {
197  foreach(ilObject::_getAllReferences($obj["obj_id"]) as $ref_id)
198  {
199  if($ilAccess->checkAccess($a_permission, "", $ref_id))
200  {
201  $has_permission = true;
202  break;
203  }
204  }
205  }
206 
207  if($has_permission)
208  {
209  $res[$obj["obj_id"]] = $obj["title"];
210  }
211  }
212 
213  asort($res);
214  return $res;
215  }
216 }
217 
218 ?>
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.
$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.
Class ilObjectActivation.
doCloneObject($new_obj, $a_target_id, $a_copy_id=null)
setActivationStartDate($starting_time=NULL)