ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjBlogGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./Services/Object/classes/class.ilObject2GUI.php";
6 require_once "./Modules/Blog/classes/class.ilBlogPosting.php";
7 require_once "./Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php";
8 
23 {
24  protected $month; // [string]
25  protected $items; // [array]
26  protected $keyword; // [string]
27  protected $author; // [int]
28 
29  function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
30  {
31  global $lng, $ilCtrl;
32 
33  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
34 
35  if($this->object)
36  {
37  $this->month = (string)$_REQUEST["bmn"];
38  $this->keyword = (string)$_REQUEST["kwd"];
39  $this->author = (int)$_REQUEST["ath"];
40 
41  // gather postings by month
42  $this->items = $this->buildPostingList($this->object->getId());
43  if($this->items)
44  {
45  // current month (if none given or empty)
46  if(!$this->month || !$this->items[$this->month])
47  {
48  $this->month = array_keys($this->items);
49  $this->month = array_shift($this->month);
50  }
51  }
52 
53  $ilCtrl->setParameter($this, "bmn", $this->month);
54  }
55 
56  $lng->loadLanguageModule("blog");
57  $ilCtrl->saveParameter($this, "prvm");
58  }
59 
60  function getType()
61  {
62  return "blog";
63  }
64 
65  protected function initCreationForms($a_new_type)
66  {
67  $forms = parent::initCreationForms($a_new_type);
68 
69  if($this->id_type == self::WORKSPACE_NODE_ID)
70  {
71  unset($forms[self::CFORM_IMPORT]);
72  unset($forms[self::CFORM_CLONE]);
73  }
74 
75  return $forms;
76  }
77 
78  protected function afterSave(ilObject $a_new_object)
79  {
80  global $ilCtrl;
81 
82  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
83  $ilCtrl->redirect($this, "");
84  }
85 
86  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
87  {
88  global $lng, $ilSetting;
89 
90  if($this->id_type == self::REPOSITORY_NODE_ID)
91  {
92  $appr = new ilCheckboxInputGUI($lng->txt("blog_enable_approval"), "approval");
93  $appr->setInfo($lng->txt("blog_enable_approval_info"));
94  $a_form->addItem($appr);
95  }
96 
97  $notes = new ilCheckboxInputGUI($lng->txt("blog_enable_notes"), "notes");
98  $a_form->addItem($notes);
99 
100  if($ilSetting->get('enable_global_profiles'))
101  {
102  $rss = new ilCheckboxInputGUI($lng->txt("blog_enable_rss"), "rss");
103  $rss->setInfo($lng->txt("blog_enable_rss_info"));
104  $a_form->addItem($rss);
105  }
106 
107  $ppic = new ilCheckboxInputGUI($lng->txt("blog_profile_picture"), "ppic");
108  $a_form->addItem($ppic);
109 
110  $blga_set = new ilSetting("blga");
111  if($blga_set->get("banner"))
112  {
113  $dimensions = " (".$blga_set->get("banner_width")."x".
114  $blga_set->get("banner_height").")";
115 
116  $img = new ilImageFileInputGUI($lng->txt("blog_banner").$dimensions, "banner");
117  $a_form->addItem($img);
118 
119  // show existing file
120  $file = $this->object->getImageFullPath(true);
121  if($file)
122  {
123  $img->setImage($file);
124  }
125  }
126 
127  $bg_color = new ilColorPickerInputGUI($lng->txt("blog_background_color"), "bg_color");
128  $a_form->addItem($bg_color);
129 
130  $font_color = new ilColorPickerInputGUI($lng->txt("blog_font_color"), "font_color");
131  $a_form->addItem($font_color);
132  }
133 
134  protected function getEditFormCustomValues(array &$a_values)
135  {
136  if($this->id_type == self::REPOSITORY_NODE_ID)
137  {
138  $a_values["approval"] = $this->object->hasApproval();
139  }
140  $a_values["notes"] = $this->object->getNotesStatus();
141  $a_values["ppic"] = $this->object->hasProfilePicture();
142  $a_values["bg_color"] = $this->object->getBackgroundColor();
143  $a_values["font_color"] = $this->object->getFontColor();
144  $a_values["banner"] = $this->object->getImage();
145  $a_values["rss"] = $this->object->hasRSS();
146  }
147 
148  protected function updateCustom(ilPropertyFormGUI $a_form)
149  {
150  if($this->id_type == self::REPOSITORY_NODE_ID)
151  {
152  $this->object->setApproval($a_form->getInput("approval"));
153  }
154  $this->object->setNotesStatus($a_form->getInput("notes"));
155  $this->object->setProfilePicture($a_form->getInput("ppic"));
156  $this->object->setBackgroundColor($a_form->getInput("bg_color"));
157  $this->object->setFontColor($a_form->getInput("font_color"));
158  $this->object->setRSS($a_form->getInput("rss"));
159 
160  // banner field is optional
161  $banner = $a_form->getItemByPostVar("banner");
162  if($banner)
163  {
164  if($_FILES["banner"]["tmp_name"])
165  {
166  $this->object->uploadImage($_FILES["banner"]);
167  }
168  else if($banner->getDeletionFlag())
169  {
170  $this->object->deleteImage();
171  }
172  }
173  }
174 
175  function setTabs()
176  {
177  global $lng, $ilHelp;
178 
179  if($this->id_type == self::WORKSPACE_NODE_ID)
180  {
181  $this->ctrl->setParameter($this,"wsp_id",$this->node_id);
182  }
183 
184  $ilHelp->setScreenIdComponent("blog");
185 
186  if ($this->checkPermissionBool("read"))
187  {
188  $this->tabs_gui->addTab("content",
189  $lng->txt("content"),
190  $this->ctrl->getLinkTarget($this, ""));
191  }
192 
193  if ($this->checkPermissionBool("read"))
194  {
195  $this->tabs_gui->addTab("id_info",
196  $lng->txt("info_short"),
197  $this->ctrl->getLinkTargetByClass(array("ilobjbloggui", "ilinfoscreengui"), "showSummary"));
198  }
199 
200  if ($this->checkPermissionBool("write"))
201  {
202  $this->tabs_gui->addTab("settings",
203  $lng->txt("settings"),
204  $this->ctrl->getLinkTarget($this, "edit"));
205 
206  if($this->id_type == self::REPOSITORY_NODE_ID)
207  {
208  $this->tabs_gui->addTab("contributors",
209  $lng->txt("blog_contributors"),
210  $this->ctrl->getLinkTarget($this, "contributors"));
211  }
212 
213  if($this->id_type == self::REPOSITORY_NODE_ID)
214  {
215  $this->tabs_gui->addTab("export",
216  $lng->txt("export"),
217  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
218  }
219  }
220 
221  if($this->mayContribute())
222  {
223  $this->tabs_gui->addNonTabbedLink("preview", $lng->txt("blog_preview"),
224  $this->ctrl->getLinkTarget($this, "preview"));
225  }
226 
227  // will add permissions if needed
228  parent::setTabs();
229  }
230 
231  function executeCommand()
232  {
233  global $ilCtrl, $tpl, $ilTabs, $lng, $ilUser, $ilNavigationHistory;
234 
235  // goto link to blog posting
236  if($_GET["gtp"])
237  {
238  $page_id = (int)$_GET["gtp"];
239  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
240  if(ilBlogPosting::exists($this->object_id, $page_id))
241  {
242  // #12312
243  $ilCtrl->setCmdClass("ilblogpostinggui");
244  $_GET["blpg"] = $page_id;
245  $ilCtrl->setCmd("previewFullscreen");
246  }
247  else
248  {
249  ilUtil::sendFailure($lng->txt("blog_posting_not_found"));
250  }
251  }
252 
253  $next_class = $ilCtrl->getNextClass($this);
254  $cmd = $ilCtrl->getCmd();
255 
256  if($this->id_type == self::REPOSITORY_NODE_ID)
257  {
258  $tpl->getStandardTemplate();
259 
260  // add entry to navigation history
261  if(!$this->getCreationMode() &&
262  $this->getAccessHandler()->checkAccess("read", "", $this->node_id))
263  {
264  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset");
265  $ilNavigationHistory->addItem($this->node_id, $link, "blog");
266  }
267  }
268 
269  switch($next_class)
270  {
271  case 'ilblogpostinggui':
272  // #9680
273  if($this->id_type == self::REPOSITORY_NODE_ID)
274  {
275  $this->setLocator();
276  }
277  $ilTabs->setBackTarget($lng->txt("back"),
278  $ilCtrl->getLinkTarget($this, ""));
279 
280  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
281  $bpost_gui = new ilBlogPostingGUI($this->node_id,
282  $this->getAccessHandler(),
283  $_GET["blpg"],
284  $_GET["old_nr"],
285  ($this->object->getNotesStatus() && !$this->disable_notes),
286  $this->mayContribute($_GET["blpg"]));
287 
288  // needed for editor
290 
291  // keep preview mode through notes gui (has its own commands)
292  switch($cmd)
293  {
294  // blog preview
295  case "previewFullscreen":
296  $ilCtrl->setParameter($this, "prvm", "fsc");
297  break;
298 
299  // blog in portfolio
300  case "previewEmbedded":
301  $ilCtrl->setParameter($this, "prvm", "emb");
302  break;
303 
304  // edit
305  default:
306  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
307  $this->tabs_gui->addNonTabbedLink("preview", $lng->txt("blog_preview"),
308  $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "previewFullscreen"));
309  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", "");
310  break;
311  }
312 
313  $ret = $ilCtrl->forwardCommand($bpost_gui);
314  if ($ret != "")
315  {
316  // keep preview mode through notes gui
317  if($_REQUEST["prvm"])
318  {
319  $cmd = "preview".(($_REQUEST["prvm"] == "fsc") ? "Fullscreen" : "Embedded");
320  }
321 
322  // $is_owner = $this->object->getOwner() == $ilUser->getId();
323  $is_owner = $this->mayContribute();
324  $is_active = $bpost_gui->getBlogPosting()->getActive();
325 
326  // do not show inactive postings
327  if(($cmd == "previewFullscreen" || $cmd == "previewEmbedded")
328  && !$is_owner && !$is_active)
329  {
330  $this->ctrl->redirect($this, "preview");
331  }
332 
333  switch($cmd)
334  {
335  // blog preview
336  case "previewFullscreen":
337  $this->addHeaderAction($cmd);
338  $this->filterInactivePostings();
339  $nav = $this->renderNavigation($this->items, "preview", $cmd);
340  $this->renderFullScreen($ret, $nav);
341  break;
342 
343  // blog in portfolio
344  case "previewEmbedded":
345  $this->filterInactivePostings();
346  $nav = $this->renderNavigation($this->items, "gethtml", $cmd);
347  return $this->buildEmbedded($ret, $nav);
348 
349  // ilias/editor
350  default:
351  // infos about draft status / snippet
352  $info = array();
353  if(!$is_active)
354  {
355  // single author blog (owner) in personal workspace
356  if($this->id_type == self::WORKSPACE_NODE_ID)
357  {
358  $info[] = $lng->txt("blog_draft_info");
359  }
360  else
361  {
362  $info[] = $lng->txt("blog_draft_info_contributors");
363  }
364  }
365  if($cmd != "history" && !$bpost_gui->getBlogPosting()->getFirstParagraphText())
366  {
367  $info[] = $lng->txt("blog_new_posting_info");
368  }
369  if($this->object->hasApproval() && !$bpost_gui->getBlogPosting()->isApproved())
370  {
371  // #9737
372  $info[] = $lng->txt("blog_posting_edit_approval_info");
373  }
374  if(sizeof($info))
375  {
376  ilUtil::sendInfo(implode("<br />", $info));
377  }
378  // revert to edit cmd to avoid confusion
379  $this->addHeaderAction("render");
380  $tpl->setContent($ret);
381  $nav = $this->renderNavigation($this->items, "render", $cmd, null, $is_owner);
382  $tpl->setRightContent($nav);
383  break;
384  }
385  }
386  break;
387 
388  case "ilinfoscreengui":
389  $this->prepareOutput();
390  $this->infoScreenForward();
391  break;
392 
393  case "ilnotegui":
394  $this->preview();
395  break;
396 
397  case "ilcommonactiondispatchergui":
398  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
400  $this->ctrl->forwardCommand($gui);
401  break;
402 
403  case "ilpermissiongui":
404  $this->prepareOutput();
405  $ilTabs->activateTab("id_permissions");
406  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
407  $perm_gui = new ilPermissionGUI($this);
408  $this->ctrl->forwardCommand($perm_gui);
409  break;
410 
411  case "ilobjectcopygui":
412  include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
413  $cp = new ilObjectCopyGUI($this);
414  $cp->setType("blog");
415  $this->ctrl->forwardCommand($cp);
416  break;
417 
418  case 'ilrepositorysearchgui':
419  $this->prepareOutput();
420  $ilTabs->activateTab("contributors");
421  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
422  $rep_search = new ilRepositorySearchGUI();
423  $rep_search->setTitle($this->lng->txt("blog_add_contributor"));
424  $rep_search->setCallback($this,'addContributor');
425  $this->ctrl->setReturn($this,'contributors');
426  $ret =& $this->ctrl->forwardCommand($rep_search);
427  break;
428 
429  case 'ilexportgui':
430  $this->prepareOutput();
431  $ilTabs->activateTab("export");
432  include_once("./Services/Export/classes/class.ilExportGUI.php");
433  $exp_gui = new ilExportGUI($this);
434  $exp_gui->addFormat("xml");
435  $ret = $ilCtrl->forwardCommand($exp_gui);
436  break;
437 
438  default:
439  if($cmd != "gethtml")
440  {
441  // desktop item handling, must be toggled before header action
442  if($cmd == "addToDesk" || $cmd == "removeFromDesk")
443  {
444  $this->{$cmd."Object"}();
445  if($_GET["prvm"])
446  {
447  $cmd = "preview";
448  }
449  else
450  {
451  $cmd = "render";
452  }
453  $ilCtrl->setCmd($cmd);
454  }
455  $this->addHeaderAction($cmd);
456  }
457  return parent::executeCommand();
458  }
459 
460  return true;
461  }
462 
468  function infoScreen()
469  {
470  $this->ctrl->setCmd("showSummary");
471  $this->ctrl->setCmdClass("ilinfoscreengui");
472  $this->infoScreenForward();
473  }
474 
478  function infoScreenForward()
479  {
480  global $ilTabs, $ilErr;
481 
482  $ilTabs->activateTab("id_info");
483 
484  if (!$this->checkPermissionBool("visible"))
485  {
486  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
487  }
488 
489  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
490  $info = new ilInfoScreenGUI($this);
491 
492  $info->enablePrivateNotes();
493 
494  if ($this->checkPermissionBool("read"))
495  {
496  $info->enableNews();
497  }
498 
499  // no news editing for files, just notifications
500  $info->enableNewsEditing(false);
501  if ($this->checkPermissionBool("write"))
502  {
503  $news_set = new ilSetting("news");
504  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
505 
506  if ($enable_internal_rss)
507  {
508  $info->setBlockProperty("news", "settings", true);
509  $info->setBlockProperty("news", "public_notifications_option", true);
510  }
511  }
512 
513  // standard meta data
514  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
515 
516  if($this->id_type == self::WORKSPACE_NODE_ID)
517  {
518  $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
519  }
520 
521  $this->ctrl->forwardCommand($info);
522  }
523 
527  function createPosting()
528  {
529  global $ilCtrl, $ilUser;
530 
531  $title = trim(ilUtil::stripSlashes($_POST["title"]));
532  if($title)
533  {
534  // create new posting
535  include_once("./Modules/Blog/classes/class.ilBlogPosting.php");
536  $posting = new ilBlogPosting();
537  $posting->setTitle($title);
538  $posting->setBlogId($this->object->getId());
539  $posting->setActive(false);
540  $posting->setAuthor($ilUser->getId());
541  $posting->create();
542 
543  // switch month list to current month (will include new posting)
544  $ilCtrl->setParameter($this, "bmn", date("Y-m"));
545 
546  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $posting->getId());
547  $ilCtrl->redirectByClass("ilblogpostinggui", "edit");
548  }
549  else
550  {
551  $ilCtrl->redirect($this, "render");
552  }
553  }
554 
555  // --- ObjectGUI End
556 
557 
561  function render()
562  {
563  global $tpl, $ilTabs, $ilCtrl, $lng, $ilToolbar, $ilUser, $tree;
564 
565  if(!$this->checkPermissionBool("read"))
566  {
567  ilUtil::sendInfo($lng->txt("no_permission"));
568  return;
569  }
570 
571  $ilTabs->activateTab("content");
572 
573  // toolbar
574  if($this->mayContribute())
575  {
576  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "createPosting"));
577 
578  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
579  $title = new ilTextInputGUI($lng->txt("title"), "title");
580  $ilToolbar->addInputItem($title, $lng->txt("title"));
581 
582  $ilToolbar->addFormButton($lng->txt("blog_add_posting"), "createPosting");
583 
584  // exercise blog?
585  include_once "Modules/Exercise/classes/class.ilObjExercise.php";
586  $exercises = ilObjExercise::findUserFiles($ilUser->getId(), $this->node_id);
587  if($exercises)
588  {
589  $info = array();
590  foreach($exercises as $exercise)
591  {
592  // #9988
593  $active_ref = false;
594  foreach(ilObject::_getAllReferences($exercise["obj_id"]) as $ref_id)
595  {
596  if(!$tree->isSaved($ref_id))
597  {
598  $active_ref = true;
599  break;
600  }
601  }
602  if($active_ref)
603  {
604  $part = $this->getExerciseInfo($exercise["ass_id"]);
605  if($part)
606  {
607  $info[] = $part;
608  }
609  }
610  }
611  if(sizeof($info))
612  {
613  ilUtil::sendInfo(implode("<br />", $info));
614  }
615  }
616  }
617 
618  $list_items = $this->getListItems();
619 
620  $list = $nav = "";
621  if($list_items)
622  {
623  // $is_owner = ($this->object->getOwner() == $ilUser->getId());
624  $is_owner = $this->mayContribute();
625  $list = $this->renderList($list_items, $this->month, "preview", null, $is_owner);
626  $nav = $this->renderNavigation($this->items, "render", "preview", null, $is_owner);
627  }
628 
629  $tpl->setContent($list);
630  $tpl->setRightContent($nav);
631  }
632 
633  function getExerciseInfo($a_assignment_id)
634  {
635  global $lng, $ilCtrl, $ilUser;
636 
637  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
638  $ass = new ilExAssignment($a_assignment_id);
639  $exercise_id = $ass->getExerciseId();
640  if(!$exercise_id)
641  {
642  return;
643  }
644 
645  // is the assignment still open?
646  $times_up = false;
647  if($ass->getDeadline() && $ass->getDeadline() - time() <= 0)
648  {
649  $times_up = true;
650  }
651 
652  // exercise goto
653  include_once "./Services/Link/classes/class.ilLink.php";
654  $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
655  $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
656 
657  $info = sprintf($lng->txt("blog_exercise_info"),
658  $ass->getTitle(),
659  "<a href=\"".$exc_link."\">".
660  ilObject::_lookupTitle($exercise_id)."</a>");
661 
662  // submit button
663  if(!$times_up)
664  {
665  $ilCtrl->setParameter($this, "exc", $exercise_id);
666  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
667  $submit_link = $ilCtrl->getLinkTarget($this, "finalize");
668  $ilCtrl->setParameter($this, "ass", "");
669  $ilCtrl->setParameter($this, "exc", "");
670  $info .= " <a class=\"submit\" href=\"".$submit_link."\">".$lng->txt("blog_finalize_blog")."</a>";
671  }
672 
673  // submitted files
674  $submitted = ilExAssignment::getDeliveredFiles($exercise_id, $a_assignment_id, $ilUser->getId(), true);
675  if($submitted)
676  {
677  $submitted = array_pop($submitted);
678 
679  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
680  $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcSubFile");
681  $ilCtrl->setParameter($this, "ass", "");
682 
685 
686  $info .= "<br />".sprintf($lng->txt("blog_exercise_submitted_info"),
688  "<a href=\"".$dl_link."\">".$lng->txt("download")."</a>");
689 
691  }
692 
693 
694  // work instructions incl. files
695 
696  $tooltip = "";
697 
698  $ass = $ass->getInstruction();
699  if($ass)
700  {
701  $tooltip .= nl2br($ass);
702  }
703 
704  $ass_files = ilExAssignment::getFiles($exercise_id, $a_assignment_id);
705  if (count($ass_files) > 0)
706  {
707  $tooltip .= "<br /><br />";
708 
709  foreach($ass_files as $file)
710  {
711  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
712  $ilCtrl->setParameter($this, "file", urlencode($file["name"]));
713  $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcAssFile");
714  $ilCtrl->setParameter($this, "file", "");
715  $ilCtrl->setParameter($this, "ass", "");
716 
717  $tooltip .= $file["name"].": <a href=\"".$dl_link."\">".
718  $lng->txt("download")."</a>";
719  }
720  }
721 
722  if($tooltip)
723  {
724  $ol_id = "exc_ass_".$a_assignment_id;
725 
726  include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
727  $overlay = new ilOverlayGUI($ol_id);
728 
729  // overlay
730  $overlay->setAnchor($ol_id."_tr");
731  $overlay->setTrigger($ol_id."_tr", "click", $ol_id."_tr");
732  $overlay->setAutoHide(false);
733  // $overlay->setCloseElementId($cl_id);
734  $overlay->add();
735 
736  // trigger
737  $overlay->addTrigger($ol_id."_tr", "click", $ol_id."_tr");
738 
739  $info .= "<div id=\"".$ol_id."_tr\"><a href=\"#\">".$lng->txt("exc_instruction")."</a></div>".
740  "<div id=\"".$ol_id."\" style=\"display:none; background-color:white; border: 1px solid #bbb; padding: 10px;\">".$tooltip."</div>";
741  }
742 
743  return "<div>".$info."</div>";
744  }
745 
747  {
748  if($_GET["ass"] && $_GET["file"])
749  {
750  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
751  $ass = new ilExAssignment((int)$_GET["ass"]);
752 
753  $ass_files = ilExAssignment::getFiles($ass->getExerciseId(), $ass->getId());
754  if (count($ass_files) > 0)
755  {
756  foreach($ass_files as $file)
757  {
758  if($file["name"] == $_GET["file"])
759  {
760  ilUtil::deliverFile($file["fullpath"], $file["name"]);
761  }
762  }
763  }
764  }
765  }
766 
768  {
769  global $ilUser;
770 
771  if($_GET["ass"])
772  {
773  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
774  $ass = new ilExAssignment((int)$_GET["ass"]);
775 
776  $submitted = ilExAssignment::getDeliveredFiles($ass->getExerciseId(), $ass->getId(), $ilUser->getId());
777  if (count($submitted) > 0)
778  {
779  $submitted = array_pop($submitted);
780 
781  $user_data = ilObjUser::_lookupName($submitted["user_id"]);
782  $title = ilObject::_lookupTitle($submitted["obj_id"])." - ".
783  $ass->getTitle()." - ".
784  $user_data["firstname"]." ".
785  $user_data["lastname"]." (".
786  $user_data["login"].").zip";
787 
788  ilUtil::deliverFile($submitted["filename"], $title);
789  }
790  }
791  }
792 
798  function getHTML()
799  {
800  // getHTML() is called by ilRepositoryGUI::show()
801  if($this->id_type == self::REPOSITORY_NODE_ID)
802  {
803  return;
804  }
805 
806  // there is no way to do a permissions check here, we have no wsp
807 
808  $this->filterInactivePostings();
809 
810  $list_items = $this->getListItems();
811 
812  $list = $nav = "";
813  if($list_items)
814  {
815  $list = $this->renderList($list_items, $this->month, "previewEmbedded");
816  $nav = $this->renderNavigation($this->items, "gethtml", "previewEmbedded");
817  }
818 
819  return $this->buildEmbedded($list, $nav);
820  }
821 
827  protected function getListItems()
828  {
829  if($this->author)
830  {
831  $list_items = array();
832  foreach($this->items as $month => $items)
833  {
834  foreach($items as $id => $item)
835  {
836  if($item["author"] == $this->author)
837  {
838  $list_items[$id] = $item;
839  }
840  }
841  }
842  }
843  else if($this->keyword)
844  {
845  $list_items = $this->filterItemsByKeyword($this->items, $this->keyword);
846  }
847  else
848  {
849  $list_items = $this->items[$this->month];
850  }
851  return $list_items;
852  }
853 
857  function preview()
858  {
859  global $lng;
860 
861  if(!$this->checkPermissionBool("read"))
862  {
863  ilUtil::sendInfo($lng->txt("no_permission"));
864  return;
865  }
866 
867  $this->filterInactivePostings();
868 
869  $list_items = $this->getListItems();
870 
871  $list = $nav = "";
872  if($list_items)
873  {
874  $list = $this->renderList($list_items, $this->month, "previewFullscreen");
875  $nav = $this->renderNavigation($this->items, "preview", "previewFullscreen");
876  }
877 
878  $this->renderFullScreen($list, $nav);
879  }
880 
884  function export()
885  {
886  $zip = $this->buildExportFile();
887 
888  ilUtil::deliverFile($zip, $this->object->getTitle().".zip", '', false, true);
889  }
890 
891 
892  // --- helper functions
893 
901  protected function buildEmbedded($a_content, $a_nav)
902  {
903  $wtpl = new ilTemplate("tpl.blog_embedded.html", true, true, "Modules/Blog");
904  $wtpl->setVariable("VAL_LIST", $a_content);
905  $wtpl->setVariable("VAL_NAVIGATION", $a_nav);
906  return $wtpl->get();
907  }
908 
915  function renderFullScreen($a_content, $a_navigation)
916  {
917  global $tpl, $ilUser, $ilTabs, $ilLocator;
918 
919  $owner = $this->object->getOwner();
920 
921  $ilTabs->clearTargets();
922  $ilLocator->clearItems();
923  $tpl->setLocator();
924 
925  // back (edit)
926  if($owner == $ilUser->getId())
927  {
928  // from shared/deeplink
929  if($this->id_type == self::WORKSPACE_NODE_ID)
930  {
931  $back = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&wsp_id=".$this->node_id;
932  }
933  // from editor (#10073)
934  else if($this->mayContribute())
935  {
936  $prvm = $_GET["prvm"];
937  $this->ctrl->setParameter($this, "prvm", "");
938  if(!$_GET["blpg"])
939  {
940  $back = $this->ctrl->getLinkTarget($this, "");
941  }
942  else
943  {
944  $this->ctrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
945  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
946  $back = $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "preview");
947  }
948  $this->ctrl->setParameter($this, "prvm", $prvm);
949  }
950  }
951  // back
952  else if($ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID)
953  {
954  // workspace (always shared)
955  if($this->id_type == self::WORKSPACE_NODE_ID)
956  {
957  $back = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=".$owner;
958  }
959  // contributor
960  else if($this->mayContribute())
961  {
962  $back = $this->ctrl->getLinkTarget($this, "");
963  }
964  // listgui / parent container
965  else
966  {
967  global $tree;
968  $parent_id = $tree->getParentId($this->node_id);
969  include_once "Services/Link/classes/class.ilLink.php";
971  }
972  }
973  $tpl->setTopBar($back);
974 
975  $this->renderFullscreenHeader($tpl, $owner);
976 
977  // content
978  $tpl->setContent($a_content);
979  $tpl->setRightContent($a_navigation);
980  $tpl->setFrameFixedWidth(true);
981 
982  echo $tpl->show("DEFAULT", true, true);
983  exit();
984  }
985 
993  protected function renderFullscreenHeader($a_tpl, $a_user_id, $a_export = false)
994  {
995  // repository blogs are multi-author
996  $name = null;
997  if($this->id_type != self::REPOSITORY_NODE_ID)
998  {
999  $name = ilObjUser::_lookupName($a_user_id);
1000  $name = $name["lastname"].", ".($t = $name["title"] ? $t . " " : "").$name["firstname"];
1001  }
1002 
1003  // show banner?
1004  $banner = false;
1005  $blga_set = new ilSetting("blga");
1006  if($blga_set->get("banner"))
1007  {
1008  $banner = $this->object->getImageFullPath();
1009  $banner_width = $blga_set->get("banner_width");
1010  $banner_height = $blga_set->get("banner_height");
1011  if($a_export)
1012  {
1013  $banner = basename($banner);
1014  }
1015  }
1016 
1017  $ppic = null;
1018  if($this->object->hasProfilePicture())
1019  {
1020  $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "big");
1021  if($a_export)
1022  {
1023  $ppic = basename($ppic);
1024  }
1025  }
1026 
1027  include_once("./Services/User/classes/class.ilUserUtil.php");
1028  $a_tpl->setFullscreenHeader($this->object->getTitle(),
1029  $name,
1030  $ppic,
1031  $banner,
1032  $this->object->getBackgroundColor(),
1033  $this->object->getFontColor(),
1034  $banner_width,
1035  $banner_height,
1036  $a_export);
1037  $a_tpl->setBodyClass("std ilExternal ilBlog");
1038 
1039  }
1040 
1047  protected function buildPostingList($a_obj_id)
1048  {
1049  $author_found = false;
1050 
1051  $items = array();
1052  foreach(ilBlogPosting::getAllPostings($a_obj_id) as $posting)
1053  {
1054  if($this->author && $posting["author"] == $this->author)
1055  {
1056  $author_found = true;
1057  }
1058 
1059  $month = substr($posting["created"]->get(IL_CAL_DATE), 0, 7);
1060  $items[$month][$posting["id"]] = $posting;
1061  }
1062 
1063  if($this->author && !$author_found)
1064  {
1065  $this->author = null;
1066  }
1067 
1068  return $items;
1069  }
1070 
1081  function renderList(array $items, $a_month, $a_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
1082  {
1083  global $lng, $ilCtrl;
1084 
1085  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1086  $wtpl = new ilTemplate("tpl.blog_list.html", true, true, "Modules/Blog");
1087 
1088  // title according to current "filter"/navigation
1089  if($this->keyword)
1090  {
1091  $title = $lng->txt("blog_keyword").": ".$this->keyword;
1092  }
1093  else if($this->author)
1094  {
1095  include_once "Services/User/classes/class.ilUserUtil.php";
1096  $title = $lng->txt("blog_author").": ".ilUserUtil::getNamePresentation($this->author);
1097  }
1098  else
1099  {
1100  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1101  $title = ilCalendarUtil::_numericMonthToString((int)substr($a_month, 5)).
1102  " ".substr($a_month, 0, 4);
1103  }
1104  $wtpl->setVariable("TXT_CURRENT_MONTH", $title);
1105 
1106  $can_approve = ($this->object->hasApproval() && $this->checkPermissionBool("write"));
1107  $can_deactivate = $this->checkPermissionBool("write");
1108 
1109  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
1110  foreach($items as $item)
1111  {
1112  // only published items
1113  $is_active = ilBlogPosting::_lookupActive($item["id"], "blp");
1114  if(!$is_active && !$a_show_inactive)
1115  {
1116  continue;
1117  }
1118 
1119  if(!$a_link_template)
1120  {
1121  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1122  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $item["id"]);
1123  $preview = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_cmd);
1124  }
1125  else
1126  {
1127  $preview = $this->buildExportLink($a_link_template, "posting", $item["id"]);
1128  }
1129 
1130  // actions
1131  $item_contribute = $this->mayContribute($item["id"], $item["author"]);
1132  if(($item_contribute || $can_approve || $can_deactivate) && !$a_link_template && $a_cmd == "preview")
1133  {
1134  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
1135  $alist = new ilAdvancedSelectionListGUI();
1136  $alist->setId($item["id"]);
1137  $alist->setListTitle($lng->txt("actions"));
1138 
1139  if($is_active && $this->object->hasApproval() && !$item["approved"])
1140  {
1141  if($can_approve)
1142  {
1143  $ilCtrl->setParameter($this, "apid", $item["id"]);
1144  $alist->addItem($lng->txt("blog_approve"), "approve",
1145  $ilCtrl->getLinkTarget($this, "approve"));
1146  $ilCtrl->setParameter($this, "apid", "");
1147  }
1148 
1149  $wtpl->setVariable("APPROVAL", $lng->txt("blog_needs_approval"));
1150  }
1151 
1152  if($item_contribute)
1153  {
1154  $alist->addItem($lng->txt("edit_content"), "edit",
1155  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit"));
1156  $alist->addItem($lng->txt("rename"), "rename",
1157  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edittitle"));
1158  $alist->addItem($lng->txt("blog_edit_keywords"), "keywords",
1159  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords"));
1160  $alist->addItem($lng->txt("blog_edit_date"), "editdate",
1161  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editdate"));
1162  $alist->addItem($lng->txt("delete"), "delete",
1163  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen"));
1164  }
1165  else if($can_deactivate)
1166  {
1167  // #10513
1168  if($is_active)
1169  {
1170  $ilCtrl->setParameter($this, "apid", $item["id"]);
1171  $alist->addItem($lng->txt("blog_toggle_draft_admin"), "deactivate",
1172  $ilCtrl->getLinkTarget($this, "deactivateAdmin"));
1173  $ilCtrl->setParameter($this, "apid", "");
1174  }
1175 
1176  $alist->addItem($lng->txt("delete"), "delete",
1177  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen"));
1178  }
1179 
1180  $wtpl->setCurrentBlock("actions");
1181  $wtpl->setVariable("ACTION_SELECTOR", $alist->getHTML());
1182  $wtpl->parseCurrentBlock();
1183  }
1184 
1185  // comments
1186  if($this->object->getNotesStatus() && !$a_link_template && !$this->disable_notes)
1187  {
1188  // count (public) notes
1189  include_once("Services/Notes/classes/class.ilNote.php");
1190  $count = sizeof(ilNote::_getNotesOfObject($this->obj_id,
1191  $item["id"], "blp", IL_NOTE_PUBLIC));
1192 
1193  if($a_cmd != "preview")
1194  {
1195  $wtpl->setCurrentBlock("comments");
1196  $wtpl->setVariable("TEXT_COMMENTS", $lng->txt("blog_comments"));
1197  $wtpl->setVariable("URL_COMMENTS", $preview);
1198  $wtpl->setVariable("COUNT_COMMENTS", $count);
1199  $wtpl->parseCurrentBlock();
1200  }
1201  /* we disabled comments in edit mode (should always be done via pagegui)
1202  else
1203  {
1204  $hash = ilCommonActionDispatcherGUI::buildAjaxHash(ilCommonActionDispatcherGUI::TYPE_WORKSPACE,
1205  $this->node_id, "blog", $this->obj_id, "blp", $item["id"]);
1206  $notes_link = "#\" onclick=\"".ilNoteGUI::getListCommentsJSCall($hash);
1207  }
1208  */
1209  }
1210 
1211  // permanent link
1212  if($a_cmd != "preview" && $a_cmd != "previewEmbedded")
1213  {
1214  if($this->id_type == self::WORKSPACE_NODE_ID)
1215  {
1216  $goto = $this->getAccessHandler()->getGotoLink($this->node_id, $this->obj_id, "_".$item["id"]);
1217  }
1218  else
1219  {
1220  include_once "Services/Link/classes/class.ilLink.php";
1221  $goto = ilLink::_getStaticLink($this->node_id, $this->getType(), true, "_".$item["id"]);
1222  }
1223  $wtpl->setCurrentBlock("permalink");
1224  $wtpl->setVariable("URL_PERMALINK", $goto);
1225  $wtpl->setVariable("TEXT_PERMALINK", $lng->txt("blog_permanent_link"));
1226  $wtpl->parseCurrentBlock();
1227  }
1228 
1229  $snippet = ilBlogPostingGUI::getSnippet($item["id"]);
1230 
1231  if($snippet)
1232  {
1233  $wtpl->setCurrentBlock("more");
1234  $wtpl->setVariable("URL_MORE", $preview);
1235  $wtpl->setVariable("TEXT_MORE", $lng->txt("blog_list_more"));
1236  $wtpl->parseCurrentBlock();
1237  }
1238 
1239  $wtpl->setCurrentBlock("posting");
1240 
1241  if(!$is_active)
1242  {
1243  $wtpl->setVariable("DRAFT_CLASS", " ilBlogListItemDraft");
1244  }
1245 
1246  $author = "";
1247  if($this->id_type == self::REPOSITORY_NODE_ID)
1248  {
1249  $author_id = $item["author"];
1250  if($author_id)
1251  {
1252  include_once "Services/User/classes/class.ilUserUtil.php";
1253  $author = ilUserUtil::getNamePresentation($author_id)." - ";
1254  }
1255  }
1256 
1257  // title
1258  $wtpl->setVariable("URL_TITLE", $preview);
1259  $wtpl->setVariable("TITLE", $item["title"]);
1260  $wtpl->setVariable("DATETIME", $author.
1261  ilDatePresentation::formatDate($item["created"], IL_CAL_DATE));
1262 
1263  // content
1264  $wtpl->setVariable("CONTENT", $snippet);
1265 
1266  $wtpl->parseCurrentBlock();
1267  }
1268 
1269  // notes
1270  /*
1271  if($a_cmd == "previewFullscreen" && $this->object->getNotesStatus())
1272  {
1273  $wtpl->setVariable("NOTES", $this->getNotesHTML());
1274  }
1275  */
1276 
1277  // permalink
1278  if($a_cmd == "previewFullscreen")
1279  {
1280  $wtpl->setVariable("PERMALINK", $this->getPermanentLinkWidget(null, true));
1281  }
1282 
1283  return $wtpl->get();
1284  }
1285 
1286  /*
1287  function getNotesHTML()
1288  {
1289  global $ilCtrl, $ilUser;
1290 
1291  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1292  $notes_gui = new ilNoteGUI($this->object->getId(), 0, "blog");
1293  // $notes_gui->enablePrivateNotes();
1294  $notes_gui->enablePublicNotes();
1295 
1296  if($this->checkPermissionBool("write"))
1297  {
1298  $notes_gui->enablePublicNotesDeletion(true);
1299  }
1300 
1301  $html = $notes_gui->getNotesHTML();
1302  $next_class = $ilCtrl->getNextClass($this);
1303  if ($next_class == "ilnotegui")
1304  {
1305  $html = $ilCtrl->forwardCommand($notes_gui);
1306  }
1307  else
1308  {
1309  $html = $notes_gui->getNotesHTML();
1310  }
1311  return $html;
1312  }
1313  */
1314 
1325  function renderNavigation(array $items, $a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
1326  {
1327  global $ilCtrl, $ilSetting;
1328 
1329  $max_detail_postings = 10;
1330 
1331  $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true,
1332  "Modules/Blog");
1333 
1334  $wtpl->setVariable("NAVIGATION_TITLE", $this->lng->txt("blog_navigation"));
1335 
1336  $ilCtrl->setParameter($this, "blpg", "");
1337 
1338  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1339  $counter = 0;
1340  foreach($items as $month => $postings)
1341  {
1342  $month_name = ilCalendarUtil::_numericMonthToString((int)substr($month, 5)).
1343  " ".substr($month, 0, 4);
1344 
1345  if(!$a_link_template)
1346  {
1347  $ilCtrl->setParameter($this, "bmn", $month);
1348  $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1349  }
1350  else
1351  {
1352  $month_url = $this->buildExportLink($a_link_template, "list", $month);
1353  }
1354 
1355  // list postings for month
1356  if($counter < $max_detail_postings)
1357  {
1358  foreach($postings as $id => $posting)
1359  {
1360  $is_active = ilBlogPosting::_lookupActive($id, "blp");
1361  if(!$is_active && !$a_show_inactive)
1362  {
1363  continue;
1364  }
1365 
1366  $counter++;
1367 
1368  $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1369  ", ".*/ $posting["title"];
1370 
1371  if(!$a_link_template)
1372  {
1373  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1374  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1375  $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1376  }
1377  else
1378  {
1379  $url = $this->buildExportLink($a_link_template, "posting", $id);
1380  }
1381 
1382  if(!$is_active)
1383  {
1384  $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1385  }
1386  else if($this->object->hasApproval() && !$posting["approved"])
1387  {
1388  $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1389  }
1390 
1391  $wtpl->setCurrentBlock("navigation_item");
1392  $wtpl->setVariable("NAV_ITEM_URL", $url);
1393  $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1394  $wtpl->parseCurrentBlock();
1395  }
1396 
1397  $wtpl->setCurrentBlock("navigation_month_details");
1398  $wtpl->setVariable("NAV_MONTH", $month_name);
1399  $wtpl->setVariable("URL_MONTH", $month_url);
1400  $wtpl->parseCurrentBlock();
1401  }
1402  // summarized month
1403  else
1404  {
1405  $wtpl->setCurrentBlock("navigation_month");
1406  $wtpl->setVariable("MONTH_NAME", $month_name);
1407  $wtpl->setVariable("URL_MONTH", $month_url);
1408  $wtpl->setVariable("MONTH_COUNT", sizeof($postings));
1409  $wtpl->parseCurrentBlock();
1410  }
1411  }
1412 
1413  $ilCtrl->setParameter($this, "bmn", $this->month);
1414  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
1415 
1416 
1417  // authors
1418  if($this->id_type == self::REPOSITORY_NODE_ID)
1419  {
1420  $authors = array();
1421  foreach($this->items as $month => $items)
1422  {
1423  foreach($items as $item)
1424  {
1425  if(($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp")) && $item["author"])
1426  {
1427  $authors[] = $item["author"];
1428  }
1429  }
1430  }
1431 
1432  $authors = array_unique($authors);
1433  if(sizeof($authors) > 1)
1434  {
1435  include_once "Services/User/classes/class.ilUserUtil.php";
1436 
1437  $list = array();
1438  foreach($authors as $user_id)
1439  {
1440  if($user_id)
1441  {
1442  $ilCtrl->setParameter($this, "ath", $user_id);
1443  $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1444  $ilCtrl->setParameter($this, "ath", "");
1445 
1446  $name = ilUserUtil::getNamePresentation($user_id, true);
1447  $idx = trim(strip_tags($name))."///".$user_id; // #10934
1448  $list[$idx] = array($name, $url);
1449  }
1450  }
1451  ksort($list);
1452 
1453  $wtpl->setVariable("AUTHORS_TITLE", $this->lng->txt("blog_authors"));
1454 
1455  $wtpl->setCurrentBlock("author");
1456  foreach($list as $author)
1457  {
1458  $wtpl->setVariable("TXT_AUTHOR", $author[0]);
1459  $wtpl->setVariable("URL_AUTHOR", $author[1]);
1460  $wtpl->parseCurrentBlock();
1461  }
1462  }
1463  }
1464 
1465  if(!$a_link_template) // #12850
1466  {
1467  // keywords
1468  $may_edit_keywords = ($_GET["blpg"] && $this->mayContribute($_GET["blpg"]) &&
1469  !$a_link_template && $a_list_cmd != "preview" && $a_list_cmd != "gethtml");
1470  $keywords = $this->getKeywords($a_show_inactive, $_GET["blpg"]);
1471  if($keywords || $may_edit_keywords)
1472  {
1473  $wtpl->setVariable("KEYWORDS_TITLE", $this->lng->txt("blog_keywords"));
1474 
1475  if($keywords)
1476  {
1477  $max = max($keywords);
1478  include_once "Services/Tagging/classes/class.ilTagging.php";
1479 
1480  $wtpl->setCurrentBlock("keyword");
1481  foreach($keywords as $keyword => $counter)
1482  {
1483  $ilCtrl->setParameter($this, "kwd", $keyword);
1484  $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1485  $ilCtrl->setParameter($this, "kwd", "");
1486 
1487  $wtpl->setVariable("TXT_KEYWORD", $keyword);
1488  $wtpl->setVariable("SIZE_KEYWORD", ilTagging::calculateFontSize($counter, $max));
1489  $wtpl->setVariable("URL_KEYWORD", $url);
1490  $wtpl->parseCurrentBlock();
1491  }
1492  }
1493  else
1494  {
1495  $wtpl->setVariable("TXT_NO_KEYWORDS", $this->lng->txt("blog_no_keywords"));
1496  }
1497 
1498  if($may_edit_keywords)
1499  {
1500  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
1501  $wtpl->setVariable("URL_EDIT_KEYWORDS",
1502  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords"));
1503  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", "");
1504  $wtpl->setVariable("TXT_EDIT_KEYWORDS", $this->lng->txt("blog_edit_keywords"));
1505  }
1506  }
1507 
1508  // rss
1509  if($this->object->hasRSS() && $ilSetting->get('enable_global_profiles') &&
1510  !$a_link_template && $a_list_cmd == "preview")
1511  {
1512  // #10827
1513  $blog_id = $this->node_id;
1514  if($this->id_type != self::WORKSPACE_NODE_ID)
1515  {
1516  $blog_id .= "_cll";
1517  }
1518  $url = ILIAS_HTTP_PATH."/feed.php?blog_id=".$blog_id.
1519  "&client_id=".rawurlencode(CLIENT_ID);
1520 
1521  $wtpl->setCurrentBlock("rss");
1522  $wtpl->setVariable("URL_RSS", $url);
1523  $wtpl->setVariable("IMG_RSS", ilUtil::getImagePath("rss.png"));
1524  $wtpl->parseCurrentBlock();
1525  }
1526  }
1527 
1528  return $wtpl->get();
1529  }
1530 
1538  function getKeywords($a_show_inactive, $a_posting_id = null)
1539  {
1540  $keywords = array();
1541  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
1542  if($a_posting_id)
1543  {
1544  foreach(ilBlogPostingGUI::getKeywords($this->obj_id, $a_posting_id) as $keyword)
1545  {
1546  $keywords[$keyword]++;
1547  }
1548  }
1549  else
1550  {
1551  foreach($this->items as $month => $items)
1552  {
1553  foreach($items as $item)
1554  {
1555  if($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp"))
1556  {
1557  foreach(ilBlogPostingGUI::getKeywords($this->obj_id, $item["id"]) as $keyword)
1558  {
1559  $keywords[$keyword]++;
1560  }
1561  }
1562  }
1563  }
1564  }
1565  ksort($keywords);
1566  return $keywords;
1567  }
1568 
1574  function buildExportFile()
1575  {
1576  // create export file
1577  include_once("./Services/Export/classes/class.ilExport.php");
1578  ilExport::_createExportDirectory($this->object->getId(), "html", "blog");
1579  $exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "blog");
1580 
1581  $subdir = $this->object->getType()."_".$this->object->getId();
1582  $export_dir = $exp_dir."/".$subdir;
1583 
1584  // initialize temporary target directory
1585  ilUtil::delDir($export_dir);
1586  ilUtil::makeDir($export_dir);
1587 
1588  // system style html exporter
1589  include_once("./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
1590  $this->sys_style_html_export = new ilSystemStyleHTMLExport($export_dir);
1591  $this->sys_style_html_export->addImage("icon_blog_b.png");
1592  $this->sys_style_html_export->export();
1593 
1594  // init co page html exporter
1595  include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1596  $this->co_page_html_export = new ilCOPageHTMLExport($export_dir);
1597  $this->co_page_html_export->createDirectories();
1598  $this->co_page_html_export->exportStyles();
1599  $this->co_page_html_export->exportSupportScripts();
1600 
1601  // banner / profile picture
1602  $blga_set = new ilSetting("blga");
1603  if($blga_set->get("banner"))
1604  {
1605  $banner = $this->object->getImageFullPath();
1606  copy($banner, $export_dir."/".basename($banner));
1607  }
1608  $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big");
1609  if($ppic)
1610  {
1611  $ppic = array_shift(explode("?", $ppic));
1612  copy($ppic, $export_dir."/".basename($ppic));
1613  }
1614 
1615  // export pages
1616  $this->exportHTMLPages($export_dir);
1617 
1618  // zip everything
1619  if (true)
1620  {
1621  // zip it all
1622  $date = time();
1623  $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "blog").
1624  "/".$date."__".IL_INST_ID."__".
1625  $this->object->getType()."_".$this->object->getId().".zip";
1626  ilUtil::zip($export_dir, $zip_file);
1627  ilUtil::delDir($export_dir);
1628  }
1629 
1630  return $zip_file;
1631  }
1632 
1642  function exportHTMLPages($a_target_directory, $a_link_template = null, $a_tpl_callback = null, $a_co_page_html_export = null, $a_index_name = "index.html")
1643  {
1644  if(!$a_link_template)
1645  {
1646  $a_link_template = "bl{TYPE}_{ID}.html";
1647  }
1648 
1649  if($a_co_page_html_export)
1650  {
1651  $this->co_page_html_export = $a_co_page_html_export;
1652  }
1653 
1654  $nav = $this->renderNavigation($this->items, "", "", $a_link_template);
1655 
1656  // month list
1657  $has_index = false;
1658  foreach(array_keys($this->items) as $month)
1659  {
1660  $file = $this->buildExportLink($a_link_template, "list", $month);
1661  $list = $this->renderList($this->items[$month], $month, "render", $a_link_template);
1662 
1663  if(!$a_tpl_callback)
1664  {
1665  $tpl = $this->buildExportTemplate();
1666  }
1667  else
1668  {
1669  $tpl = call_user_func($a_tpl_callback);
1670  }
1671 
1672  $file = $this->writeExportFile($a_target_directory, $file,
1673  $tpl, $list, $nav);
1674 
1675  if(!$has_index)
1676  {
1677  copy($file, $a_target_directory."/".$a_index_name);
1678  $has_index = true;
1679  }
1680  }
1681 
1682  // single postings
1683  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
1684  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1685  $pages = ilBlogPosting::getAllPostings($this->object->getId(), 0);
1686  foreach ($pages as $page)
1687  {
1688  if (ilPageObject::_exists("blp", $page["id"]))
1689  {
1690  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
1691  $blp_gui = new ilBlogPostingGUI(0, null, $page["id"]);
1692  $blp_gui->setOutputMode("offline");
1693  $blp_gui->setFullscreenLink("fullscreen.html"); // #12930 - see page.xsl
1694  $blp_gui->add_date = true;
1695  $page_content = $blp_gui->showPage();
1696 
1697  $back = $this->buildExportLink($a_link_template, "list",
1698  substr($page["created"]->get(IL_CAL_DATE), 0, 7));
1699 
1700  $file = $this->buildExportLink($a_link_template, "posting", $page["id"]);
1701 
1702  if(!$a_tpl_callback)
1703  {
1704  $tpl = $this->buildExportTemplate();
1705  }
1706  else
1707  {
1708  $tpl = call_user_func($a_tpl_callback);
1709  }
1710 
1711  $this->writeExportFile($a_target_directory, $file, $tpl,
1712  $page_content, $nav, $back);
1713 
1714  $this->co_page_html_export->collectPageElements("blp:pg", $page["id"]);
1715  }
1716  }
1717  $this->co_page_html_export->exportPageElements();
1718  }
1719 
1728  protected function buildExportLink($a_template, $a_type, $a_id)
1729  {
1730  if($a_type == "list")
1731  {
1732  $a_type = "m";
1733  }
1734  else
1735  {
1736  $a_type = "p";
1737  }
1738  $link = str_replace("{TYPE}", $a_type, $a_template);
1739  return str_replace("{ID}", $a_id, $link);
1740  }
1741 
1748  protected function buildExportTemplate($a_back_url = "")
1749  {
1750  global $ilTabs, $lng;
1751 
1752  $tpl = $this->co_page_html_export->getPreparedMainTemplate();
1753 
1754  $tpl->getStandardTemplate();
1755 
1756  $ilTabs->clearTargets();
1757  if($a_back_url)
1758  {
1759  $ilTabs->setBackTarget($lng->txt("back"), $a_back_url);
1760  }
1761 
1762  $this->renderFullscreenHeader($tpl, $this->object->getOwner(), true);
1763  $tpl->setFrameFixedWidth(true);
1764 
1765  return $tpl;
1766  }
1767 
1778  protected function writeExportFile($a_target_directory, $a_file, $a_tpl, $a_content, $a_right_content = null)
1779  {
1780  $file = $a_target_directory."/".$a_file;
1781  // return if file is already existing
1782  if (@is_file($file))
1783  {
1784  return;
1785  }
1786 
1787  // export template: page content
1788  $ep_tpl = new ilTemplate("tpl.export_page.html", true, true,
1789  "Modules/Blog");
1790  $ep_tpl->setVariable("PAGE_CONTENT", $a_content);
1791 
1792  // export template: right content
1793  if($a_right_content)
1794  {
1795  $ep_tpl->setVariable("RIGHT_CONTENT", $a_right_content);
1796  }
1797 
1798  $a_tpl->setContent($ep_tpl->get());
1799 
1800  $content = $a_tpl->get("DEFAULT", false, false, false,
1801  true, true, true);
1802 
1803  // open file
1804  if (!file_put_contents($file, $content))
1805  {
1806  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
1807  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
1808  }
1809 
1810  // set file permissions
1811  chmod($file, 0770);
1812 
1813  return $file;
1814  }
1815 
1819  protected function finalize()
1820  {
1821  global $ilCtrl, $lng;
1822 
1823  // to make exercise gui load assignment
1824  $_GET["ass_id"] = $_REQUEST["ass"];
1825 
1826  // #11173 - ref_id is needed for notifications
1827  $exc_ref_id = array_shift(ilObject::_getAllReferences($_REQUEST["exc"]));
1828 
1829  include_once "Modules/Exercise/classes/class.ilObjExerciseGUI.php";
1830  $exc_gui = new ilObjExerciseGUI(null, $exc_ref_id, true);
1831  $exc_gui->submitBlog($this->node_id);
1832 
1833  ilUtil::sendSuccess($lng->txt("blog_finalized"), true);
1834  $ilCtrl->redirect($this, "render");
1835  }
1836 
1837  function getNotesSubId()
1838  {
1839  if($_REQUEST["blpg"])
1840  {
1841  return $_REQUEST["blpg"];
1842  }
1843  return 0;
1844  }
1845 
1846  function disableNotes($a_value = false)
1847  {
1848  $this->disable_notes = (bool)$a_value;
1849  }
1850 
1851  protected function addHeaderAction($a_cmd)
1852  {
1853  global $ilUser, $ilCtrl;
1854 
1855  // preview?
1856  if($a_cmd == "preview" || $_GET["prvm"])
1857  {
1858  // notification
1859  if($ilUser->getId() != ANONYMOUS_USER_ID)
1860  {
1861  if(!$_GET["prvm"])
1862  {
1863  $ilCtrl->setParameter($this, "prvm", "fsc");
1864  }
1865  $this->insertHeaderAction($this->initHeaderAction(null, null, true));
1866  if(!$_GET["prvm"])
1867  {
1868  $ilCtrl->setParameter($this, "prvm", "");
1869  }
1870  }
1871  }
1872  else
1873  {
1874  return parent::addHeaderAction();
1875  }
1876  }
1877 
1878  protected function initHeaderAction($sub_type = null, $sub_id = null, $a_is_preview = false)
1879  {
1880  global $ilUser, $ilCtrl;
1881 
1882  if(!$this->obj_id)
1883  {
1884  return false;
1885  }
1886 
1887  $sub_type = $sub_id = null;
1888  if($_GET["blpg"])
1889  {
1890  $sub_type = "blp";
1891  $sub_id = $_GET["blpg"];
1892  }
1893 
1894  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
1895 
1896  if($a_is_preview)
1897  {
1898  $lg->enableComments(false);
1899  $lg->enableNotes(false);
1900  $lg->enableTags(false);
1901 
1902  include_once "./Services/Notification/classes/class.ilNotification.php";
1904  {
1905  $ilCtrl->setParameter($this, "ntf", 1);
1906  $link = $ilCtrl->getLinkTarget($this, "setNotification");
1907  $lg->addCustomCommand($link, "blog_notification_toggle_off");
1908 
1909  $lg->addHeaderIcon("not_icon",
1910  ilUtil::getImagePath("notification_on.png"),
1911  $this->lng->txt("blog_notification_activated"));
1912  }
1913  else
1914  {
1915  $ilCtrl->setParameter($this, "ntf", 2);
1916  $link = $ilCtrl->getLinkTarget($this, "setNotification");
1917  $lg->addCustomCommand($link, "blog_notification_toggle_on");
1918 
1919  $lg->addHeaderIcon("not_icon",
1920  ilUtil::getImagePath("notification_off.png"),
1921  $this->lng->txt("blog_notification_deactivated"));
1922  }
1923 
1924  $ilCtrl->setParameter($this, "ntf", "");
1925  }
1926 
1927  return $lg;
1928  }
1929 
1930  protected function setNotification()
1931  {
1932  global $ilUser, $ilCtrl;
1933 
1934  include_once "./Services/Notification/classes/class.ilNotification.php";
1935  switch($_GET["ntf"])
1936  {
1937  case 1:
1939  break;
1940 
1941  case 2:
1943  break;
1944  }
1945 
1946  $ilCtrl->redirect($this, "preview");
1947  }
1948 
1956  static function lookupSubObjectTitle($a_blog_id, $a_posting_id)
1957  {
1958  // page might be deleted, so setting halt on errors to false
1959  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
1960  $post = new ilBlogPosting($a_posting_id, 0, false);
1961  if($post->getBlogId() == $a_blog_id)
1962  {
1963  return $post->getTitle();
1964  }
1965  }
1966 
1972  protected function filterInactivePostings()
1973  {
1974  foreach($this->items as $month => $postings)
1975  {
1976  foreach($postings as $id => $item)
1977  {
1978  if(!ilBlogPosting::_lookupActive($id, "blp"))
1979  {
1980  unset($this->items[$month][$id]);
1981  }
1982  else if($this->object->hasApproval() && !$item["approved"])
1983  {
1984  unset($this->items[$month][$id]);
1985  }
1986  }
1987  if(!sizeof($this->items[$month]))
1988  {
1989  unset($this->items[$month]);
1990  }
1991  }
1992 
1993  if($this->items && !isset($this->items[$this->month]))
1994  {
1995  $this->month = array_shift(array_keys($this->items));
1996  }
1997  }
1998 
1999  protected function filterItemsByKeyWord(array $a_items, $a_keyword)
2000  {
2001  $res = array();
2002  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
2003  foreach($a_items as $month => $items)
2004  {
2005  foreach($items as $item)
2006  {
2007  if(in_array($a_keyword,
2008  ilBlogPostingGUI::getKeywords($this->obj_id, $item["id"])))
2009  {
2010  $res[] = $item;
2011  }
2012  }
2013  }
2014  return $res;
2015  }
2016 
2024  protected function mayContribute($a_posting_id = null, $a_author_id = null)
2025  {
2026  global $ilUser;
2027 
2028  // single author blog (owner) in personal workspace
2029  if($this->id_type == self::WORKSPACE_NODE_ID)
2030  {
2031  return $this->checkPermissionBool("write");
2032  }
2033 
2034  if($this->checkPermissionBool("contribute"))
2035  {
2036  // check owner of posting
2037  if($a_posting_id)
2038  {
2039  if(!$a_author_id)
2040  {
2041  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2042  $post = new ilBlogPosting($a_posting_id, 0, false);
2043  $a_author_id = $post->getAuthor();
2044  }
2045  if($ilUser->getId() == $a_author_id)
2046  {
2047  return true;
2048  }
2049  else
2050  {
2051  return false;
2052  }
2053  }
2054 
2055  return true;
2056  }
2057  return false;
2058  }
2059 
2060  function addLocatorItems()
2061  {
2062  global $ilLocator;
2063 
2064  if (is_object($this->object))
2065  {
2066  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
2067  }
2068  }
2069 
2070  function approve()
2071  {
2072  if($this->checkPermissionBool("write") && (int)$_GET["apid"])
2073  {
2074  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2075  $post = new ilBlogPosting((int)$_GET["apid"]);
2076  $post->setApproved(true);
2077  $post->update();
2078 
2079  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2080  }
2081 
2082  $this->ctrl->redirect($this, "render");
2083  }
2084 
2085 
2086  //
2087  // contributors
2088  //
2089 
2090  function contributors()
2091  {
2092  global $ilTabs, $ilToolbar, $ilCtrl, $lng, $tpl;
2093 
2094  if(!$this->checkPermissionBool("write"))
2095  {
2096  return;
2097  }
2098 
2099  $ilTabs->activateTab("contributors");
2100 
2101  // add member
2102  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
2104  $this,
2105  $ilToolbar,
2106  array(
2107  'auto_complete_name' => $lng->txt('user'),
2108  'submit_name' => $lng->txt('add')
2109  )
2110  );
2111 
2112  $ilToolbar->addSpacer();
2113 
2114  $ilToolbar->addButton(
2115  $lng->txt("blog_search_users"),
2116  $ilCtrl->getLinkTargetByClass('ilRepositorySearchGUI',''));
2117  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
2118 
2119  $parent_container_id = $this->object->getParentContainerId($this->node_id);
2120  if ($parent_container_id)
2121  {
2122  $ilCtrl->setParameterByClass('ilRepositorySearchGUI', "list_obj", $parent_container_id);
2123 
2124  $ilToolbar->addSpacer();
2125 
2126  $ilToolbar->addButton($lng->txt("blog_contributor_container_add"),
2127  $ilCtrl->getLinkTarget($this, "addContributorContainer"));
2128  }
2129 
2130  $other_roles = $this->object->getRolesWithContribute($this->node_id);
2131  if($other_roles)
2132  {
2133  ilUtil::sendInfo(sprintf($lng->txt("blog_contribute_other_roles"), implode(", ", $other_roles)));
2134  }
2135 
2136  include_once "Modules/Blog/classes/class.ilContributorTableGUI.php";
2137  $tbl = new ilContributorTableGUI($this, "contributors", $this->object->getLocalContributorRole($this->node_id));
2138 
2139  $tpl->setContent($tbl->getHTML());
2140  }
2141 
2142  public function addContributorContainer()
2143  {
2144  global $ilTabs, $ilCtrl, $tpl;
2145 
2146  if(!$this->checkPermissionBool("write"))
2147  {
2148  return;
2149  }
2150 
2151  $ilTabs->activateTab("contributors");
2152 
2153  $members = $this->object->getParentMemberIds($this->node_id);
2154  if(!$members)
2155  {
2156  $ilCtrl->redirect($this, "contributors");
2157  }
2158 
2159  include_once "Modules/Blog/classes/class.ilContributorTableGUI.php";
2160  $tbl = new ilContributorTableGUI($this, "addContributorContainer",
2161  $this->object->getLocalContributorRole($this->node_id), $members);
2162 
2163  $tpl->setContent($tbl->getHTML());
2164  }
2165 
2170  {
2171  global $ilCtrl, $lng;
2172 
2173  $ids = $_POST["id"];
2174 
2175  if(!sizeof($ids))
2176  {
2177  ilUtil::sendFailure($lng->txt("select_one"), true);
2178  $ilCtrl->redirect($this, "addContributorContainer");
2179  }
2180 
2181  return $this->addContributor($ids);
2182  }
2183 
2187  public function addUserFromAutoComplete()
2188  {
2189  global $lng;
2190 
2191  if(!strlen(trim($_POST['user_login'])))
2192  {
2193  ilUtil::sendFailure($lng->txt('msg_no_search_string'));
2194  return $this->contributors();
2195  }
2196  $users = explode(',', $_POST['user_login']);
2197 
2198  $user_ids = array();
2199  foreach($users as $user)
2200  {
2201  $user_id = ilObjUser::_lookupId($user);
2202 
2203  if(!$user_id)
2204  {
2205  ilUtil::sendFailure($lng->txt('user_not_known'));
2206  return $this->contributors();
2207  }
2208 
2209  $user_ids[] = $user_id;
2210  }
2211 
2212  return $this->addContributor($user_ids);
2213  }
2214 
2220  public function addContributor($a_user_ids = array())
2221  {
2222  global $ilCtrl, $lng, $rbacreview, $rbacadmin;
2223 
2224  if(!$this->checkPermissionBool("write"))
2225  {
2226  return;
2227  }
2228 
2229  if(!count($a_user_ids))
2230  {
2231  ilUtil::sendFailure($lng->txt("no_checkbox"));
2232  return $this->contributors();
2233  }
2234 
2235  // get contributor role
2236  $contr_role_id = $this->object->getLocalContributorRole($this->node_id);
2237  if(!$contr_role_id)
2238  {
2239  ilUtil::sendFailure($lng->txt("missing_perm"));
2240  return $this->contributors();
2241  }
2242 
2243  foreach($a_user_ids as $user_id)
2244  {
2245  if(!$rbacreview->isAssigned($user_id, $contr_role_id))
2246  {
2247  $rbacadmin->assignUser($contr_role_id, $user_id);
2248  }
2249  }
2250 
2251  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
2252  $ilCtrl->redirect($this, "contributors");
2253  }
2254 
2258  public function removeContributor()
2259  {
2260  global $ilCtrl, $lng, $rbacadmin;
2261 
2262  $ids = $_POST["id"];
2263 
2264  if(!sizeof($ids))
2265  {
2266  ilUtil::sendFailure($lng->txt("select_one"), true);
2267  $ilCtrl->redirect($this, "contributors");
2268  }
2269 
2270  // get contributor role
2271  $contr_role_id = $this->object->getLocalContributorRole($this->node_id);
2272  if(!$contr_role_id)
2273  {
2274  ilUtil::sendFailure($lng->txt("missing_perm"));
2275  return $this->contributors();
2276  }
2277 
2278  foreach($ids as $user_id)
2279  {
2280  $rbacadmin->deassignUser($contr_role_id, $user_id);
2281  }
2282 
2283  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
2284  $this->ctrl->redirect($this, "contributors");
2285  }
2286 
2290  public function addToDeskObject()
2291  {
2292  global $lng;
2293 
2294  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
2296  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
2297  }
2298 
2302  public function removeFromDeskObject()
2303  {
2304  global $lng;
2305 
2306  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
2308  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
2309  }
2310 
2311  public function deactivateAdmin()
2312  {
2313  if($this->checkPermissionBool("write") && (int)$_GET["apid"])
2314  {
2315  // ilBlogPostingGUI::deactivatePage()
2316  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2317  $post = new ilBlogPosting((int)$_GET["apid"]);
2318  $post->setApproved(false);
2319  $post->setActive(false);
2320  $post->update(true, false, false);
2321 
2322  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2323  }
2324 
2325  $this->ctrl->redirect($this, "render");
2326  }
2327 
2333  function _goto($a_target)
2334  {
2335  if(substr($a_target, -3) == "wsp")
2336  {
2337  $id = explode("_", $a_target);
2338 
2339  $_GET["baseClass"] = "ilSharedResourceGUI";
2340  $_GET["wsp_id"] = $id[0];
2341  if(sizeof($id) == 3)
2342  {
2343  $_GET["gtp"] = $id[1];
2344  }
2345  }
2346  else
2347  {
2348  $id = explode("_", $a_target);
2349 
2350  $_GET["baseClass"] = "ilRepositoryGUI";
2351  $_GET["ref_id"] = $id[0];
2352  $_GET["cmd"] = "preview";
2353  if(sizeof($id) == 2)
2354  {
2355  $_GET["gtp"] = $id[1];
2356  }
2357  }
2358 
2359  include("ilias.php");
2360  exit;
2361  }
2362 }
2363 
2364 ?>