ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjMediaCastGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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.ilObjectGUI.php";
25 
36 {
37 
38  private $additionalPurposes = array ("VideoPortable", "AudioPortable");
39  private $purposeSuffixes = array ();
40 
45  function ilObjMediaCastGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
46  {
47  global $ilCtrl, $lng;
48 
49  $this->type = "mcst";
50  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
51  $lng->loadLanguageModule("mcst");
52  $lng->loadLanguageModule("news");
53 
54  $ilCtrl->saveParameter($this, "item_id");
55 
56  include_once ("./Modules/MediaCast/classes/class.ilMediaCastSettings.php");
58  $this->purposeSuffixes = $settings->getPurposeSuffixes();
59  }
60 
61  function &executeCommand()
62  {
63  global $ilUser;
64 
65  $next_class = $this->ctrl->getNextClass($this);
66  $cmd = $this->ctrl->getCmd();
67  $this->prepareOutput();
68 
69  switch($next_class)
70  {
71  case "ilinfoscreengui":
72  $this->checkPermission("visible");
73  $this->infoScreen(); // forwards command
74  break;
75 
76  case 'ilpermissiongui':
77  include_once("./classes/class.ilPermissionGUI.php");
78  $perm_gui =& new ilPermissionGUI($this);
79  $ret =& $this->ctrl->forwardCommand($perm_gui);
80  break;
81 
82  default:
83  if(!$cmd)
84  {
85  $cmd = "infoScreen";
86  }
87  $cmd .= "Object";
88  if ($cmd != "infoScreenObject")
89  {
90  $this->checkPermission("read");
91  }
92  else
93  {
94  $this->checkPermission("visible");
95  }
96  $this->$cmd();
97 
98  break;
99  }
100 
101  return true;
102  }
103 
108  function saveObject()
109  {
110  global $rbacadmin;
111 
112  // create and insert forum in objecttree
113  $newObj = parent::saveObject();
114 
115  // setup rolefolder & default local roles
116  //$roles = $newObj->initDefaultRoles();
117 
118  // ...finally assign role to creator of object
119  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
120 
121  // put here object specific stuff
122 
123  // always send a message
124  ilUtil::sendInfo($this->lng->txt("object_added"),true);
125 
126  ilUtil::redirect("ilias.php?baseClass=ilMediaCastHandlerGUI&ref_id=".$newObj->getRefId()."&cmd=editSettings");
127  }
128 
129 
133  function listItemsObject()
134  {
135  global $tpl, $lng, $ilAccess;
136 
137  $this->checkPermission("read");
138 
139  $med_items = $this->object->getItemsArray();
140 
141  include_once("./Modules/MediaCast/classes/class.ilMediaCastTableGUI.php");
142  $table_gui = new ilMediaCastTableGUI($this, "listItems");
143 
144  $table_gui->setTitle($lng->txt("mcst_media_cast"));
145  $table_gui->setData($med_items);
146 
147  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
148  {
149  $table_gui->addCommandButton("addCastItem", $lng->txt("add"));
150  $table_gui->addMultiCommand("confirmDeletionItems", $lng->txt("delete"));
151  $table_gui->setSelectAllCheckbox("item_id");
152  }
153 
154  include_once("./Services/Block/classes/class.ilBlockSetting.php");
155  $public_feed = ilBlockSetting::_lookup("news", "public_feed",
156  0, $this->object->getId());
157 
158  // rss icon/link
159  if ($public_feed)
160  {
161  $news_set = new ilSetting("news");
162  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
163 
164 
165  if ($enable_internal_rss)
166  {
167  // create dummy object in db (we need an id)
168  $items = $this->object->getItemsArray();
169  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
170  $html = "";
171  foreach (ilObjMediaCast::$purposes as $purpose)
172  {
173 
174  foreach ($items as $id => $item)
175  {
176  $mob = new ilObjMediaObject($item["mob_id"]);
177  $mob->read();
178  if ($mob->hasPurposeItem($purpose))
179  {
180  if ($html == "") {
181  $html = "<TABLE cellpadding='1' cellspacing='0'><TR>";
182  }
183  $url = ILIAS_HTTP_PATH."/feed.php?client_id=".rawurlencode(CLIENT_ID)."&"."ref_id=".$_GET["ref_id"]."&purpose=$purpose";
184  $title = $lng->txt("news_feed_url");
185  $icon = ilUtil::getImagePath("rss_icon_".strtolower($purpose).".gif");
186  $target = "_blank";
187 
188  $row1 .= "<TD><A href='$url' target='$target'><img src='$icon' alt='$title'/></A></TD>";
189  if ($this->object->getPublicFiles())
190  {
191  $url = preg_replace("/https?/i","itpc",$url);
192  $title = $lng->txt("news_feed_url");
193  $icon = ilUtil::getImagePath("itunes_icon.gif");
194  $row2 .= "<TD><A href='$url' target='$target'><img src='$icon' alt='$title'/></A></TD>";
195  }
196  break;
197  }
198 
199  }
200  }
201  if ($html != "") {
202  $html .= $row1."</TR>";
203  if ($row2 != "")
204  $html .= "<TR>".$row2."</TR>";
205  $html .= "</TABLE>";
206  $table_gui->setHeaderHTML($html);
207  }
208  }
209  }
210 
211  $tpl->setContent($table_gui->getHTML());
212 
213  }
214 
218  function addCastItemObject()
219  {
220  global $tpl;
221 
222  $this->checkPermission("write");
223 
224  $this->initAddCastItemForm();
225  $tpl->setContent($this->form_gui->getHTML());
226  }
227 
232  {
233  global $tpl;
234  $this->checkPermission("write");
235  $this->initAddCastItemForm("edit");
236  $this->getCastItemValues();
237  $tpl->setContent($this->form_gui->getHTML());
238  }
239 
243  function initAddCastItemForm($a_mode = "create")
244  {
245  global $lng, $ilCtrl;
246 
247  $this->checkPermission("write");
248 
249  $lng->loadLanguageModule("mcst");
250 
251  $news_set = new ilSetting("news");
252  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
253 
254  include("Services/Form/classes/class.ilPropertyFormGUI.php");
255  $this->form_gui = new ilPropertyFormGUI();
256  $this->form_gui->setMultipart(true);
257 
258  // Property Title
259  $text_input = new ilTextInputGUI($lng->txt("title"), "title");
260  $text_input->setMaxLength(200);
261  $this->form_gui->addItem($text_input);
262 
263  // Property Content
264  $text_area = new ilTextAreaInputGUI($lng->txt("description"), "description");
265  $text_area->setRequired(false);
266  $this->form_gui->addItem($text_area);
267 
268  // Property Visibility
269  if ($enable_internal_rss)
270  {
271  $radio_group = new ilRadioGroupInputGUI($lng->txt("access_scope"), "visibility");
272  $radio_option = new ilRadioOption($lng->txt("access_users"), "users");
273  $radio_group->addOption($radio_option);
274  $radio_option = new ilRadioOption($lng->txt("access_public"), "public");
275  $radio_group->addOption($radio_option);
276  $radio_group->setInfo($lng->txt("mcst_visibility_info"));
277  $radio_group->setRequired(true);
278  $radio_group->setValue($this->object->getDefaultAccess() == 0 ? "users" : "public");
279  $this->form_gui->addItem($radio_group);
280  }
281 
282  // Duration
283  $dur = new ilDurationInputGUI($lng->txt("mcst_duration"), "duration");
284  $dur->setInfo($lng->txt("mcst_duration_info"));
285  $dur->setShowDays(false);
286  $dur->setShowHours(true);
287  $dur->setShowSeconds(true);
288  $this->form_gui->addItem($dur);
289 
290  foreach (ilObjMediaCast::$purposes as $purpose)
291  {
293  $section->setTitle($lng->txt("mcst_".strtolower($purpose)."_title"));
294  $this->form_gui->addItem($section);
295  if ($a_mode != "create")
296  {
297  $value = new ilHiddenInputGUI("value_".$purpose);
298  $label = new ilNonEditableValueGUI($lng->txt("value"));
299  $label->setPostVar("label_value_".$purpose);
300  $label->setInfo($lng->txt("mcst_current_value_info"));
301  $this->form_gui->addItem($label);
302  $this->form_gui->addItem($value);
303 
304  }
305  $file = new ilFileInputGUI($lng->txt("file"), "file_".$purpose);
306  $file->setSuffixes($this->purposeSuffixes[$purpose]);
307  $this->form_gui->addItem($file);
308  $text_input = new ilRegExpInputGUI($lng->txt("url"), "url_".$purpose);
309  $text_input->setPattern("/https?\:\/\/.+/i");
310  $text_input->setInfo($lng->txt("mcst_reference_info"));
311  $this->form_gui->addItem($text_input);
312  if ($purpose != "Standard")
313  {
314  $clearCheckBox = new ilCheckboxInputGUI();
315  $clearCheckBox->setPostVar("delete_".$purpose);
316  $clearCheckBox->setTitle($lng->txt("mcst_clear_purpose_title"));
317  $this->form_gui->addItem($clearCheckBox);
318  }
319 
320  }
321 
322  // save/cancel button
323  if ($a_mode == "create")
324  {
325  $this->form_gui->setTitle($lng->txt("mcst_add_new_item"));
326  $this->form_gui->addCommandButton("saveCastItem", $lng->txt("save"));
327  }
328  else
329  {
330  $this->form_gui->setTitle($lng->txt("mcst_edit_item"));
331  $this->form_gui->addCommandButton("updateCastItem", $lng->txt("save"));
332  }
333  $this->form_gui->addCommandButton("listItems", $lng->txt("cancel"));
334  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveCastItem"));
335 
336  }
337 
341  public function getCastItemValues()
342  {
343  global $lng;
344  $values = array();
345  $mediaItems = $this->getMediaItems($_GET["item_id"]);
346  if (count ($mediaItems) > 0)
347  {
348  foreach ($mediaItems as $med)
349  {
350  if (!isset ($values["title"]))
351  {
352  // first item, so set title, description, ...
353  $values["title"] = $this->mcst_item->getTitle();
354  $values["description"] = $this->mcst_item->getContent();
355  $values["visibility"] = $this->mcst_item->getVisibility();
356  $length = explode(":", $this->mcst_item->getPlaytime());
357  $values["duration"] = array("hh" => $length[0], "mm" => $length[1], "ss" => $length[2]);
358  }
359 
360  $values["value_".$med->getPurpose()] = (strlen($med->getLocation())> 100) ? "...".substr($med->getLocation(), strlen($med->getLocation()) - 100) : $med->getLocation();
361  $values["label_value_".$med->getPurpose()] = (strlen($med->getLocation())> 100) ? "...".substr($med->getLocation(), strlen($med->getLocation()) - 100) : $med->getLocation();
362  }
363  }
364  foreach (ilObjMediaCast::$purposes as $purpose) {
365  if (!isset ($values["value_".$purpose]))
366  {
367  $values["label_value_".$purpose] = $lng->txt("none");
368  $values["value_".$purpose] = $lng->txt("none");
369  }
370  }
371  $this->form_gui->setValuesByArray($values);
372  }
373 
378  {
379  global $tpl, $ilCtrl, $ilUser, $lng;
380 
381  $this->checkPermission("write");
382 
383  $this->initAddCastItemForm();
384 
385  if ($_POST["url_Standard"] == "" && !$_FILES['file_Standard']['tmp_name']) {
386  ilUtil::sendInfo($lng->txt("msg_input_either_file_or_url"));
387  $this->populateFormFromPost();
388  } else if ($this->form_gui->checkInput())
389  {
390 
391  // create dummy object in db (we need an id)
392  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
393  $mob = new ilObjMediaObject();
394  $mob->create();
395 
396  //handle standard purpose
397  $file = $this->createMediaItemForPurpose($mob, "Standard");
398 
399  // set title and description
400  // set title to basename of file if left empty
401  $title = $this->form_gui->getInput("title") != "" ? $this->form_gui->getInput("title") : basename($file);
402  $description = $this->form_gui->getInput("description");
403  $mob->setTitle($title);
404  $mob->setDescription($description);
405 
406 
407  // determine duration for standard purpose
408  $duration = $this->getDuration($file);
409 
410  // handle other purposes
411  foreach ($this->additionalPurposes as $purpose)
412  {
413  // check if some purpose has been uploaded
414  $file_gui = $this->form_gui->getInput("file_".$purpose);
415  $url_gui = $this->form_gui->getInput("url_".$purpose);
416  if ($url_gui || $file_gui["size"] > 0)
417  {
418  $this->createMediaItemForPurpose ($mob, $purpose);
419  }
420  }
421 
422  $mob->update();
423 
424  //
425  // @todo: save usage
426  //
427 
428  $news_set = new ilSetting("news");
429  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
430 
431  // create new media cast item
432  include_once("./Services/News/classes/class.ilNewsItem.php");
433  $mc_item = new ilNewsItem();
434  $mc_item->setMobId($mob->getId());
435  $mc_item->setContentType(NEWS_AUDIO);
436  $mc_item->setContextObjId($this->object->getId());
437  $mc_item->setContextObjType($this->object->getType());
438  $mc_item->setUserId($ilUser->getId());
439  $mc_item->setPlaytime($duration);
440  $mc_item->setTitle($title);
441  $mc_item->setContent($description);
442  $mc_item->setLimitation(false);
443  if ($enable_internal_rss)
444  {
445  $mc_item->setVisibility($this->form_gui->getInput("visibility"));
446  }
447  else
448  {
449  $mc_item->setVisibility("users");
450  }
451  $mc_item->create();
452 
453  $ilCtrl->redirect($this, "listItems");
454  }
455  else
456  {
457  $this->populateFormFromPost();
458  }
459  }
460 
467  private function getDuration($file)
468  {
469  $duration = isset($this->form_gui) ? $this->form_gui->getInput("duration") : "";
470  if ($duration["hh"] == 0 && $duration["mm"] == 0 && $duration["ss"] == 0 && is_file($file))
471  {
472  include_once("./Services/MediaObjects/classes/class.ilMediaAnalyzer.php");
473  $ana = new ilMediaAnalyzer();
474  $ana->setFile($file);
475  $ana->analyzeFile();
476  $dur = $ana->getPlaytimeString();
477  $dur = explode(":", $dur);
478  $duration["mm"] = $dur[0];
479  $duration["ss"] = $dur[1];
480  }
481  $duration = str_pad($duration["hh"], 2 , "0", STR_PAD_LEFT).":".
482  str_pad($duration["mm"], 2 , "0", STR_PAD_LEFT).":".
483  str_pad($duration["ss"], 2 , "0", STR_PAD_LEFT);
484  return $duration;
485  }
486 
493  private function createMediaItemForPurpose ($mob, $purpose)
494  {
495  $mediaItem = new ilMediaItem();
496  $mob->addMediaItem($mediaItem);
497  $mediaItem->setPurpose($purpose);
498  return $this->updateMediaItem($mob, $mediaItem);
499  }
500 
508  private function updateMediaItem ($mob, & $mediaItem) {
509  $purpose = $mediaItem->getPurpose();
510  $url_gui = $this->form_gui->getInput ("url_".$purpose);
511  $file_gui = $this->form_gui->getInput ("file_".$purpose);
512  if ($url_gui)
513  {
514  // http
515  $file = $this->form_gui->getInput ("url_".$purpose);
516  $title = basename ($file);
517  $location = $this->form_gui->getInput ("url_".$purpose);
518  $locationType = "Reference";
519  } elseif ($file_gui["size"] > 0){
520  // lokal
521  // determine and create mob directory, move uploaded file to directory
522  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
523  if (!is_dir($mob_dir))
524  $mob->createDirectory();
525 
526  $file_name = ilUtil::getASCIIFilename($_FILES['file_'.$purpose]['name']);
527  $file_name = str_replace(" ", "_", $file_name);
528 
529  $file = $mob_dir."/".$file_name;
530  $title = $file_name;
531  $locationType = "LocalFile";
532  $location = $title;
533  ilUtil::moveUploadedFile($_FILES['file_'.$purpose]['tmp_name'], $file_name, $file);
534  ilUtil::renameExecutables($mob_dir);
535  }
536 
537  if (isset($file))
538  {
539  // get mime type
541 
542  // set real meta and object data
543  $mediaItem->setFormat($format);
544  $mediaItem->setLocation($location);
545  $mediaItem->setLocationType($locationType);
546  $mediaItem->setHAlign("Left");
547  $mediaItem->setHeight(self::isAudio($format)?0:180);
548  }
549 
550 
551  if ($purpose == "Standard")
552  {
553  if (isset($title))
554  $mob->setTitle ($title);
555  if (isset($format))
556  $mob->setDescription($format);
557  }
558 
559  return $file;
560  }
561 
566  {
567  global $tpl, $lng, $ilCtrl, $ilUser, $log;
568 
569  $this->checkPermission("write");
570 
571  $this->initAddCastItemForm("edit");
572 
573  if ($this->form_gui->checkInput())
574  {
575  // create new media cast item
576  include_once("./Services/News/classes/class.ilNewsItem.php");
577  $mc_item = new ilNewsItem($_GET["item_id"]);
578  $mob_id = $mc_item->getMobId();
579 
580  // create dummy object in db (we need an id)
581  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
582  $mob = new ilObjMediaObject($mob_id);
583 
584 
585  foreach (ilObjMediaCast::$purposes as $purpose)
586  {
587  if ($this->form_gui->getInput("delete_".$purpose))
588  {
589  $mob->removeMediaItem($purpose);
590  $log->write ("Mcst: deleting purpose $purpose");
591  continue;
592  }
593  $media_item = $mob->getMediaItem($purpose);
594  $url_gui = $this->form_gui->getInput("url_".$purpose);
595  $file_gui = $this->form_gui->getInput("file_".$purpose);
596 
597  if ($media_item == null)
598  {
599  if ($purpose != "Standard" &&
600  ($url_gui || $file_gui["size"]>0))
601  {
602  // check if we added an additional purpose when updating
603  // either by url or by file
604  $file = $this->createMediaItemForPurpose($mob, $purpose);
605  }
606  } else
607  {
608  $file = $this->updateMediaItem($mob, $media_item);
609  }
610 
611  if ($purpose == "Standard")
612  {
613  $duration = $this->getDuration($file);
614  $title = $this->form_gui->getInput("title") != "" ? $this->form_gui->getInput("title") : basename($file);
615  $description = $this->form_gui->getInput("description");
616 
617  $mob->setTitle($title);
618  $mob->setDescription($description);
619 
620  }
621  }
622 
623  // set real meta and object data
624  $mob->update();
625 
626  //
627  // @todo: save usage
628  //
629 
630  $news_set = new ilSetting("news");
631  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
632 
633  $mc_item->setUserId($ilUser->getId());
634  if (isset($duration))
635  {
636  $mc_item->setPlaytime($duration);
637  }
638  $mc_item->setTitle($title);
639  $mc_item->setContent($description);
640  if ($enable_internal_rss)
641  {
642  $mc_item->setVisibility($this->form_gui->getInput("visibility"));
643  }
644  $mc_item->update();
645 
646  $ilCtrl->redirect($this, "listItems");
647  }
648  else
649  {
650  $this->populateFormFromPost();
651  }
652  }
653 
658  {
659  global $ilCtrl, $lng, $tpl;
660 
661  $this->checkPermission("write");
662 
663  if (!is_array($_POST["item_id"]))
664  {
665  $this->listItemsObject();
666  return;
667  }
668 
669  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
670  $c_gui = new ilConfirmationGUI();
671 
672  // set confirm/cancel commands
673  $c_gui->setFormAction($ilCtrl->getFormAction($this, "deleteItems"));
674  $c_gui->setHeaderText($lng->txt("info_delete_sure"));
675  $c_gui->setCancel($lng->txt("cancel"), "listItems");
676  $c_gui->setConfirm($lng->txt("confirm"), "deleteItems");
677 
678  // add items to delete
679  include_once("./Services/News/classes/class.ilNewsItem.php");
680  foreach($_POST["item_id"] as $item_id)
681  {
682  $item = new ilNewsItem($item_id);
683  $c_gui->addItem("item_id[]", $item_id, $item->getTitle(),
684  ilUtil::getImagePath("icon_mcst.gif"));
685  }
686 
687  $tpl->setContent($c_gui->getHTML());
688  }
689 
693  function deleteItemsObject()
694  {
695  global $ilCtrl;
696 
697  $this->checkPermission("write");
698 
699  // delete all selected news items
700  foreach($_POST["item_id"] as $item_id)
701  {
702  $mc_item = new ilNewsItem($item_id);
703  $mc_item->delete();
704  }
705 
706  $ilCtrl->redirect($this, "listItems");
707  }
708 
713  {
714  global $ilCtrl;
715  $this->checkPermission("read");
716 
717  $mc_item = new ilNewsItem($_GET["item_id"]);
718  $mob = $mc_item->getMobId();
719  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
720  $mob = new ilObjMediaObject($mob);
721  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
722  $purpose = $_GET["purpose"];
723  $m_item = $mob->getMediaItem($purpose);
724  if ($m_item->getLocationType() != "Reference")
725  {
726  $file = $mob_dir."/".$m_item->getLocation();
727  if (file_exists($file) && is_file($file))
728  {
729  ilUtil::deliverFile($file, $m_item->getLocation());
730  }
731  else {
732  ilUtil::sendInfo("File not found!",true);
733  $ilCtrl->redirect($this, "listItems");
734  }
735  }
736  else
737  {
738  ilUtil::redirect($m_item->getLocation());
739  }
740  exit;
741  }
742 
747  {
748  global $ilCtrl;
749 
750  $mc_item = new ilNewsItem($_GET["item_id"]);
751  $mob = $mc_item->getMobId();
752  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
753  $mob = new ilObjMediaObject($mob);
754  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
755  $m_item = $mob->getMediaItem("Standard");
756  $file = $mob_dir."/".$m_item->getLocation();
757  $duration = $this->getDuration($file);
758 
759  $mc_item->setPlaytime($duration);
760  $mc_item->update();
761 
762  $ilCtrl->redirect($this, "listItems");
763  }
764 
770  function infoScreenObject()
771  {
772  $this->checkPermission("visible");
773  $this->ctrl->setCmd("showSummary");
774  $this->ctrl->setCmdClass("ilinfoscreengui");
775  $this->infoScreen();
776  }
777 
781  function infoScreen()
782  {
783  global $ilAccess, $ilUser;
784 
785  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId()))
786  {
787  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
788  }
789 
790  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
791  $info = new ilInfoScreenGUI($this);
792 
793  $info->enablePrivateNotes();
794 
795  /*
796  $info->enableNews();
797  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
798  {
799  //$info->enableNewsEditing();
800  $info->setBlockProperty("news", "settings", true);
801  }*/
802 
803  // general information
804  $this->lng->loadLanguageModule("meta");
805  $this->lng->loadLanguageModule("mcst");
806  $med_items = $this->object->getItemsArray();
807  $info->addSection($this->lng->txt("meta_general"));
808  $info->addProperty($this->lng->txt("mcst_nr_items"),
809  (int) count($med_items));
810 
811  if (count($med_items) > 0)
812  {
813  $cur = current($med_items);
814  $last = ilDatePresentation::formatDate(new ilDateTime($cur["creation_date"], IL_CAL_DATETIME));
815  }
816  else
817  {
818  $last = "-";
819  }
820 
821  $info->addProperty($this->lng->txt("mcst_last_submission"), $last);
822 
823  // forward the command
824  $this->ctrl->forwardCommand($info);
825  }
826 
832  function getTabs(&$tabs_gui)
833  {
834  global $ilCtrl, $ilAccess;
835 
836  // list items
837  if ($ilAccess->checkAccess('read', "", $this->object->getRefId()))
838  {
839  $tabs_gui->addTarget("view_content",
840  $this->ctrl->getLinkTarget($this, "listItems"), array("", "listItems"),
841  array(strtolower(get_class($this)), ""));
842  }
843 
844  // info screen
845  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
846  {
847  $force_active = ($ilCtrl->getNextClass() == "ilinfoscreengui"
848  || $_GET["cmd"] == "infoScreen")
849  ? true
850  : false;
851  $tabs_gui->addTarget("info_short",
852  $this->ctrl->getLinkTargetByClass(
853  "ilinfoscreengui", "showSummary"),
854  "showSummary",
855  "", "", $force_active);
856  }
857 
858  // settings
859  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
860  {
861  $tabs_gui->addTarget("settings",
862  $this->ctrl->getLinkTarget($this, "editSettings"), array("editSettings"),
863  array(strtolower(get_class($this)), ""));
864  }
865 
866  // edit permissions
867  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
868  {
869  $tabs_gui->addTarget("perm_settings",
870  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"), array("perm","info","owner"), 'ilpermissiongui');
871  }
872  }
873 
878  {
879  global $tpl;
880 
881  $this->checkPermission("write");
882 
883  $this->initSettingsForm();
884  $tpl->setContent($this->form_gui->getHtml());
885  }
886 
890  function initSettingsForm()
891  {
892  global $tpl, $lng, $ilCtrl;
893 
894  $lng->loadLanguageModule("mcst");
895 
896  include("Services/Form/classes/class.ilPropertyFormGUI.php");
897  $this->form_gui = new ilPropertyFormGUI();
898  $this->form_gui->setTitle($lng->txt("mcst_settings"));
899 
900  // Title
901  $tit = new ilTextInputGUI($lng->txt("title"), "title");
902  $tit->setValue($this->object->getTitle());
903  $tit->setRequired(true);
904  $this->form_gui->addItem($tit);
905 
906  // description
907  $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
908  $des->setValue($this->object->getLongDescription());
909  $this->form_gui->addItem($des);
910 
911  // Online
912  $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
913  $online->setChecked($this->object->getOnline());
914  $this->form_gui->addItem($online);
915 
916  // Downloadable
917  $downloadable = new ilCheckboxInputGUI($lng->txt("mcst_downloadable"), "downloadable");
918  $downloadable->setChecked($this->object->getDownloadable());
919  $downloadable->setInfo($lng->txt("mcst_downloadable_info"));
920  $this->form_gui->addItem($downloadable);
921 
922  $news_set = new ilSetting("news");
923  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
924 
925  //Default Visibility
926  $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "defaultaccess");
927  $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "0");
928  $radio_group->addOption($radio_option);
929  $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "1");
930  $radio_group->addOption($radio_option);
931  $radio_group->setInfo($lng->txt("news_news_item_visibility_info"));
932  $radio_group->setRequired(false);
933  $radio_group->setValue($this->object->getDefaultAccess());
934  #$ch->addSubItem($radio_group);
935  $this->form_gui->addItem($radio_group);
936 
937  //Extra Feed
938  include_once("./Services/Block/classes/class.ilBlockSetting.php");
939  $public_feed = ilBlockSetting::_lookup("news", "public_feed", 0, $this->object->getId());
940  $ch = new ilCheckboxInputGUI($lng->txt("news_public_feed"), "extra_feed");
941  $ch->setInfo($lng->txt("news_public_feed_info"));
942  $ch->setChecked($public_feed);
943  $this->form_gui->addItem($ch);
944 
945  // Include Files in Pubic Items
946  $incl_files = new ilCheckboxInputGUI($lng->txt("mcst_incl_files_in_rss"), "public_files");
947  $incl_files->setChecked($this->object->getPublicFiles());
948  $incl_files->setInfo($lng->txt("mcst_incl_files_in_rss_info"));
949  #$ch->addSubItem($incl_files);
950  $this->form_gui->addItem($incl_files);
951 
952  // Form action and save button
953  $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
954  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
955  }
956 
961  {
962  global $ilCtrl;
963 
964  $this->checkPermission("write");
965 
966  $this->initSettingsForm();
967  if ($this->form_gui->checkInput())
968  {
969  $news_set = new ilSetting("news");
970  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
971 
972  $this->object->setTitle($this->form_gui->getInput("title"));
973  $this->object->setDescription($this->form_gui->getInput("description"));
974  $this->object->setOnline($this->form_gui->getInput("online"));
975  $this->object->setDownloadable($this->form_gui->getInput("downloadable"));
976 
977  if ($enable_internal_rss)
978  {
979  $this->object->setPublicFiles($this->form_gui->getInput("public_files"));
980  $this->object->setDefaultAccess($this->form_gui->getInput("defaultaccess"));
981  }
982  $this->object->update();
983 
984  if ($enable_internal_rss)
985  {
986  include_once("./Services/Block/classes/class.ilBlockSetting.php");
987  ilBlockSetting::_write("news", "public_feed",
988  $this->form_gui->getInput("extra_feed"),
989  0, $this->object->getId());
990  }
991 
992  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
993  $ilCtrl->redirect($this, "editSettings");
994  }
995  else
996  {
997  $this->form_gui->setValuesByPost();
998  $this->tpl->setContent($this->form_gui->getHTML());
999  }
1000  }
1001 
1002  // add media cast to locator
1003  function addLocatorItems()
1004  {
1005  global $ilLocator;
1006 
1007  if (is_object($this->object))
1008  {
1009  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "listItems"), "", $_GET["ref_id"]);
1010  }
1011  }
1012 
1013  function _goto($a_target)
1014  {
1015  global $ilAccess, $ilErr, $lng;
1016 
1017  if ($ilAccess->checkAccess("read", "", $a_target))
1018  {
1019  $_GET["cmd"] = "listItems";
1020  $_GET["ref_id"] = $a_target;
1021  $_GET["baseClass"] = "ilmediacasthandlergui";
1022  $_GET["cmdClass"] = "ilobjmediacastgui";
1023  include("ilias.php");
1024  exit;
1025  }
1026  else if ($ilAccess->checkAccess("visible", "", $a_target))
1027  {
1028  $_GET["cmd"] = "infoScreen";
1029  $_GET["ref_id"] = $a_target;
1030  include("repository.php");
1031  exit;
1032  }
1033  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1034  {
1035  $_GET["cmd"] = "frameset";
1036  $_GET["target"] = "";
1037  $_GET["ref_id"] = ROOT_FOLDER_ID;
1038  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1039  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1040  include("repository.php");
1041  exit;
1042  }
1043 
1044  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1045 
1046  }
1047 
1054  protected static function isAudio($extension) {
1055  return strpos($extension,"audio") !== false;
1056  }
1057 
1064  protected function getMediaItem ($id) {
1065  include_once("./Services/News/classes/class.ilNewsItem.php");
1066  $this->mcst_item = new ilNewsItem($id);
1067  // create dummy object in db (we need an id)
1068  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1069  $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1070  return $mob->getMediaItem("Standard");
1071  }
1072 
1079  protected function getMediaItems ($id) {
1080  include_once("./Services/News/classes/class.ilNewsItem.php");
1081  $this->mcst_item = new ilNewsItem($id);
1082  // create dummy object in db (we need an id)
1083  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1084  $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1085  return $mob->getMediaItems();
1086  }
1087 
1088  private function populateFormFromPost()
1089  {
1090  global $tpl;
1091  //issue: we have to display the current settings
1092  // problem: POST does not contain values of disabled textfields
1093  // solution: use hidden field and label to display-> here we need to synchronize the labels
1094  // with the values from the hidden fields.
1095  foreach (ilObjMediaCast::$purposes as $purpose)
1096  {
1097  if ($_POST["value_".$purpose])
1098  {
1099  $_POST["label_value_".$purpose] = $_POST["value_".$purpose];
1100  }
1101  }
1102 
1103  $this->form_gui->setValuesByPost();
1104  $tpl->setContent($this->form_gui->getHTML());
1105  }
1106 }
1107 ?>