ILIAS  Release_4_1_x_branch Revision 61804
 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-2009 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 
163  function getDiskUsage()
164  {
165  require_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
166  return ilObjMediaCastAccess::_lookupDiskUsage($this->id);
167  }
168 
172  function create()
173  {
174  global $ilDB;
175 
176  parent::create();
177 
178  $query = "INSERT INTO il_media_cast_data (".
179  " id".
180  ", is_online".
181  ", public_files".
182  ", downloadable".
183  ", def_access".
184  " ) VALUES (".
185  $ilDB->quote($this->getId(), "integer")
186  .",".$ilDB->quote((int) $this->getOnline(), "integer")
187  .",".$ilDB->quote((int) $this->getPublicFiles(), "integer")
188  .",".$ilDB->quote((int) $this->getDownloadable(), "integer")
189  .",".$ilDB->quote((int) $this->getDefaultAccess(), "integer")
190  .")";
191  $ilDB->manipulate($query);
192 
193  }
194 
201  function update()
202  {
203  global $ilDB;
204 
205  if (!parent::update())
206  {
207  return false;
208  }
209 
210  // update media cast data
211  $query = "UPDATE il_media_cast_data SET ".
212  " is_online = ".$ilDB->quote((int) $this->getOnline(), "integer").
213  ", public_files = ".$ilDB->quote((int) $this->getPublicFiles(), "integer").
214  ", downloadable = ".$ilDB->quote((int) $this->getDownloadable(), "integer").
215  ", def_access = ".$ilDB->quote((int) $this->getDefaultAccess(), "integer").
216  " WHERE id = ".$ilDB->quote((int) $this->getId(), "integer");
217 
218  $ilDB->manipulate($query);
219 
220  return true;
221  }
222 
226  function read()
227  {
228  global $ilDB;
229 
230  parent::read();
231  $this->readItems();
232 
233  $query = "SELECT * FROM il_media_cast_data WHERE id = ".
234  $ilDB->quote($this->getId(), "integer");
235  $set = $ilDB->query($query);
236  $rec = $ilDB->fetchAssoc($set);
237 
238  $this->setOnline($rec["is_online"]);
239  $this->setPublicFiles($rec["public_files"]);
240  $this->setDownloadable($rec["downloadable"]);
241  $this->setDefaultAccess($rec["def_access"]);
242 
243  }
244 
245 
252  function delete()
253  {
254  global $ilDB;
255 
256  // always call parent delete function first!!
257  if (!parent::delete())
258  {
259  return false;
260  }
261 
262  // delete all items
263  $med_items = $this->getItemsArray();
264  foreach ($med_items as $item)
265  {
266  include_once("./Services/News/classes/class.ilNewsItem.php");
267  $news_item = new ilNewsItem($item["id"]);
268  $news_item->delete();
269  }
270 
271  // delete record of table il_media_cast_data
272  $query = "DELETE FROM il_media_cast_data".
273  " WHERE id = ".$ilDB->quote($this->getId(), "integer");
274  $ilDB->manipulate($query);
275 
276  return true;
277  }
278 
288  function initDefaultRoles()
289  {
290  global $rbacadmin;
291 
292  // create a local role folder
293  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
294 
295  // create moderator role and assign role to rolefolder...
296  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
297  //$roles[] = $roleObj->getId();
298 
299  //unset($rfoldObj);
300  //unset($roleObj);
301 
302  return $roles ? $roles : array();
303  }
304 
318  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
319  {
320  global $tree;
321 
322  switch ($a_event)
323  {
324  case "link":
325 
326  //var_dump("<pre>",$a_params,"</pre>");
327  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
328  //exit;
329  break;
330 
331  case "cut":
332 
333  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
334  //exit;
335  break;
336 
337  case "copy":
338 
339  //var_dump("<pre>",$a_params,"</pre>");
340  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
341  //exit;
342  break;
343 
344  case "paste":
345 
346  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
347  //exit;
348  break;
349 
350  case "new":
351 
352  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
353  //exit;
354  break;
355  }
356 
357  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
358  if ($a_node_id==$_GET["ref_id"])
359  {
360  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
361  $parent_type = $parent_obj->getType();
362  if($parent_type == $this->getType())
363  {
364  $a_node_id = (int) $tree->getParentId($a_node_id);
365  }
366  }
367 
368  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
369  }
370 
374  function readItems($a_oldest_first = false)
375  {
376  global $ilDB;
377 
378  //
379  include_once("./Services/News/classes/class.ilNewsItem.php");
380  $it = new ilNewsItem();
381  $it->setContextObjId($this->getId());
382  $it->setContextObjType($this->getType());
383  $this->itemsarray = $it->queryNewsForContext(false, 0, "", false, $a_oldest_first);
384 
385  return $this->itemsarray;
386  }
387 
388 
389 } // END class.ilObjMediaCast
390 ?>