ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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";
66  $pages = ilPortfolioTemplatePage::getAllPages($this->id);
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  self::cloneBasics($this, $new_obj);
78 
79  // copy pages
80  include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
81  foreach(ilPortfolioPage::getAllPages($this->getId()) as $page)
82  {
83  // see ilObjWiki::cloneObject();
84 
85  $page = new ilPortfolioTemplatePage($page["id"]);
86 
87  $new_page = new ilPortfolioTemplatePage();
88  $new_page->setPortfolioId($new_obj->getId());
89  $new_page->setTitle($page->getTitle());
90  $new_page->setType($page->getType());
91  $new_page->setOrderNr($page->getOrderNr());
92  $new_page->create();
93 
94  $page->copy($new_page->getId(), "", 0, true);
95  }
96  }
97 
98 
99  //
100  // ACTIVATION
101  //
102 
103  protected function updateActivation()
104  {
105  // moved activation to ilObjectActivation
106  if($this->ref_id)
107  {
108  include_once "./Services/Object/classes/class.ilObjectActivation.php";
109  ilObjectActivation::getItem($this->ref_id);
110 
111  $item = new ilObjectActivation;
112  if(!$this->isActivationLimited())
113  {
115  }
116  else
117  {
118  $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
119  $item->setTimingStart($this->getActivationStartDate());
120  $item->setTimingEnd($this->getActivationEndDate());
121  $item->toggleVisible($this->getActivationVisibility());
122  }
123 
124  $item->update($this->ref_id);
125  }
126  }
127 
128  public function isActivationLimited()
129  {
130  return (bool)$this->activation_limited;
131  }
132 
133  public function setActivationLimited($a_value)
134  {
135  $this->activation_limited = (bool)$a_value;
136  }
137 
138  public function setActivationVisibility($a_value)
139  {
140  $this->activation_visibility = (bool) $a_value;
141  }
142 
143  public function getActivationVisibility()
144  {
146  }
147 
148  public function setActivationStartDate($starting_time = NULL)
149  {
150  $this->activation_starting_time = $starting_time;
151  }
152 
153  public function setActivationEndDate($ending_time = NULL)
154  {
155  $this->activation_ending_time = $ending_time;
156  }
157 
158  public function getActivationStartDate()
159  {
160  return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : NULL;
161  }
162 
163  public function getActivationEndDate()
164  {
165  return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : NULL;
166  }
167 
168 
169  //
170  // HELPER
171  //
172 
173  public static function getAvailablePortfolioTemplates($a_permission = "read")
174  {
175  global $ilUser, $ilAccess;
176 
177  $res = array();
178 
179  foreach(ilObject::_getObjectsByType("prtt") as $obj)
180  {
181  $has_permission = false;
182 
183  if($obj["owner"] == $ilUser->getId() && false)
184  {
185  $has_permission = true;
186  }
187  else
188  {
189  foreach(ilObject::_getAllReferences($obj["obj_id"]) as $ref_id)
190  {
191  if($ilAccess->checkAccess($a_permission, "", $ref_id))
192  {
193  $has_permission = true;
194  break;
195  }
196  }
197  }
198 
199  if($has_permission)
200  {
201  $res[$obj["obj_id"]] = $obj["title"];
202  }
203  }
204 
205  asort($res);
206  return $res;
207  }
208 }
209 
210 ?>
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
Page for portfolio template.
static getAvailablePortfolioTemplates($a_permission="read")
setTimingType($a_type)
Set timing type.
static getAllPages($a_portfolio_id)
Get pages of portfolio.
global $ilUser
Definition: imgupload.php:15
Class ilObjectActivation.
doCloneObject($new_obj, $a_target_id, $a_copy_id=null)
setActivationStartDate($starting_time=NULL)