ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjMediaCast.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once "./classes/class.ilObject.php";
25 
33 class ilObjMediaCast extends ilObject
34 {
35  public static $purposes = array ("Standard","VideoPortable", "AudioPortable");
36  protected $online = false;
37  protected $publicfiles = false;
38  protected $downloadable = true;
44  protected $defaultAccess = 0;
45 
52  function ilObjMediaCast($a_id = 0,$a_call_by_reference = true)
53  {
54  $this->type = "mcst";
55  $this->ilObject($a_id,$a_call_by_reference);
56  $mcst_set = new ilSetting("mcst");
57  $this->setDefaultAccess($mcst_set->get("defaultaccess") == "users" ? 0 : 1);
58  }
59 
65  function setOnline($a_online)
66  {
67  $this->online = $a_online;
68  }
69 
75  function getOnline()
76  {
77  return $this->online;
78  }
79 
85  function setPublicFiles($a_publicfiles)
86  {
87  $this->publicfiles = $a_publicfiles;
88  }
89 
95  function getPublicFiles()
96  {
97  return $this->publicfiles;
98  }
99 
105  function setItemsArray($a_itemsarray)
106  {
107  $this->itemsarray = $a_itemsarray;
108  }
109 
115  function getItemsArray()
116  {
117  return $this->itemsarray;
118  }
119 
125  function setDownloadable($a_downloadable)
126  {
127  $this->downloadable = $a_downloadable;
128  }
134  function getDownloadable()
135  {
136  return $this->downloadable;
137  }
138 
144  function getDefaultAccess() {
145  return $this->defaultAccess;
146  }
147 
153  function setDefaultAccess($value) {
154  $this->defaultAccess = (int) $value == 0 ? 0 : 1;
155  }
156 
157 
158 
162  function create()
163  {
164  global $ilDB;
165 
166  parent::create();
167 
168  $query = "INSERT INTO il_media_cast_data (".
169  " id".
170  ", online".
171  ", public_files".
172  ", downloadable".
173  ", access".
174  " ) VALUES (".
175  $ilDB->quote($this->getId())
176  .",".$ilDB->quote($this->getOnline())
177  .",".$ilDB->quote($this->getPublicFiles())
178  .",".$ilDB->quote($this->getDownloadable())
179  .",".$ilDB->quote($this->getDefaultAccess())
180  .")";
181  $ilDB->query($query);
182 
183  }
184 
191  function update()
192  {
193  global $ilDB;
194 
195  if (!parent::update())
196  {
197  return false;
198  }
199 
200  // update media cast data
201  $query = "UPDATE il_media_cast_data SET ".
202  " online = ".$ilDB->quote($this->getOnline()).
203  ", public_files = ".$ilDB->quote($this->getPublicFiles()).
204  ", downloadable = ".$ilDB->quote($this->getDownloadable()).
205  ", access = ".$ilDB->quote($this->getDefaultAccess()).
206  " WHERE id = ".$ilDB->quote($this->getId());
207 
208  $ilDB->query($query);
209 
210  return true;
211  }
212 
216  function read()
217  {
218  global $ilDB;
219 
220  parent::read();
221  $this->readItems();
222 
223  $query = "SELECT * FROM il_media_cast_data WHERE id = ".
224  $ilDB->quote($this->getId());
225  $set = $ilDB->query($query);
226  $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
227 
228  $this->setOnline($rec["online"]);
229  $this->setPublicFiles($rec["public_files"]);
230  $this->setDownloadable($rec["downloadable"]);
231  $this->setDefaultAccess($rec["access"]);
232 
233  }
234 
235 
242  function delete()
243  {
244  global $ilDB;
245 
246  // always call parent delete function first!!
247  if (!parent::delete())
248  {
249  return false;
250  }
251 
252  // delete all items
253  $med_items = $this->getItemsArray();
254  foreach ($med_items as $item)
255  {
256  include_once("./Services/News/classes/class.ilNewsItem.php");
257  $news_item = new ilNewsItem($item["id"]);
258  $news_item->delete();
259  }
260 
261  // delete record of table il_media_cast_data
262  $query = "DELETE FROM il_media_cast_data".
263  " WHERE id = ".$ilDB->quote($this->getId());
264  $ilDB->query($query);
265 
266  return true;
267  }
268 
278  function initDefaultRoles()
279  {
280  global $rbacadmin;
281 
282  // create a local role folder
283  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
284 
285  // create moderator role and assign role to rolefolder...
286  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
287  //$roles[] = $roleObj->getId();
288 
289  //unset($rfoldObj);
290  //unset($roleObj);
291 
292  return $roles ? $roles : array();
293  }
294 
308  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
309  {
310  global $tree;
311 
312  switch ($a_event)
313  {
314  case "link":
315 
316  //var_dump("<pre>",$a_params,"</pre>");
317  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
318  //exit;
319  break;
320 
321  case "cut":
322 
323  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
324  //exit;
325  break;
326 
327  case "copy":
328 
329  //var_dump("<pre>",$a_params,"</pre>");
330  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
331  //exit;
332  break;
333 
334  case "paste":
335 
336  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
337  //exit;
338  break;
339 
340  case "new":
341 
342  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
343  //exit;
344  break;
345  }
346 
347  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
348  if ($a_node_id==$_GET["ref_id"])
349  {
350  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
351  $parent_type = $parent_obj->getType();
352  if($parent_type == $this->getType())
353  {
354  $a_node_id = (int) $tree->getParentId($a_node_id);
355  }
356  }
357 
358  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
359  }
360 
364  function readItems()
365  {
366  global $ilDB;
367 
368  //
369  include_once("./Services/News/classes/class.ilNewsItem.php");
370  $it = new ilNewsItem();
371  $it->setContextObjId($this->getId());
372  $it->setContextObjType($this->getType());
373  $this->itemsarray = $it->queryNewsForContext(false);
374 
375  return $this->itemsarray;
376  }
377 
378 
379 } // END class.ilObjMediaCast
380 ?>