ILIAS  Release_4_4_x_branch Revision 61816
 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 setSettingsSubTabs($a_active)
87  {
88  // general properties
89  $this->tabs_gui->addSubTab("properties",
90  $this->lng->txt("blog_properties"),
91  $this->ctrl->getLinkTarget($this, 'edit'));
92 
93  $this->tabs_gui->addSubTab("style",
94  $this->lng->txt("obj_sty"),
95  $this->ctrl->getLinkTarget($this, 'editStyleProperties'));
96 
97  $this->tabs_gui->activateSubTab($a_active);
98  }
99 
100  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
101  {
102  global $lng, $ilSetting;
103 
104  $this->setSettingsSubTabs("properties");
105 
106  if($this->id_type == self::REPOSITORY_NODE_ID)
107  {
108  $appr = new ilCheckboxInputGUI($lng->txt("blog_enable_approval"), "approval");
109  $appr->setInfo($lng->txt("blog_enable_approval_info"));
110  $a_form->addItem($appr);
111  }
112 
113  $notes = new ilCheckboxInputGUI($lng->txt("blog_enable_notes"), "notes");
114  $a_form->addItem($notes);
115 
116  if($ilSetting->get('enable_global_profiles'))
117  {
118  $rss = new ilCheckboxInputGUI($lng->txt("blog_enable_rss"), "rss");
119  $rss->setInfo($lng->txt("blog_enable_rss_info"));
120  $a_form->addItem($rss);
121  }
122 
123  $ppic = new ilCheckboxInputGUI($lng->txt("blog_profile_picture"), "ppic");
124  $a_form->addItem($ppic);
125 
126  $blga_set = new ilSetting("blga");
127  if($blga_set->get("banner"))
128  {
129  include_once "Services/Form/classes/class.ilFileInputGUI.php";
131 
132  $dimensions = " (".$blga_set->get("banner_width")."x".
133  $blga_set->get("banner_height").")";
134 
135  $img = new ilImageFileInputGUI($lng->txt("blog_banner").$dimensions, "banner");
136  $a_form->addItem($img);
137 
138  // show existing file
139  $file = $this->object->getImageFullPath(true);
140  if($file)
141  {
142  $img->setImage($file);
143  }
144  }
145 
146  $bg_color = new ilColorPickerInputGUI($lng->txt("blog_background_color"), "bg_color");
147  $a_form->addItem($bg_color);
148 
149  $font_color = new ilColorPickerInputGUI($lng->txt("blog_font_color"), "font_color");
150  $a_form->addItem($font_color);
151  }
152 
153  protected function getEditFormCustomValues(array &$a_values)
154  {
155  if($this->id_type == self::REPOSITORY_NODE_ID)
156  {
157  $a_values["approval"] = $this->object->hasApproval();
158  }
159  $a_values["notes"] = $this->object->getNotesStatus();
160  $a_values["ppic"] = $this->object->hasProfilePicture();
161  $a_values["bg_color"] = $this->object->getBackgroundColor();
162  $a_values["font_color"] = $this->object->getFontColor();
163  $a_values["banner"] = $this->object->getImage();
164  $a_values["rss"] = $this->object->hasRSS();
165  }
166 
167  protected function updateCustom(ilPropertyFormGUI $a_form)
168  {
169  if($this->id_type == self::REPOSITORY_NODE_ID)
170  {
171  $this->object->setApproval($a_form->getInput("approval"));
172  }
173  $this->object->setNotesStatus($a_form->getInput("notes"));
174  $this->object->setProfilePicture($a_form->getInput("ppic"));
175  $this->object->setBackgroundColor($a_form->getInput("bg_color"));
176  $this->object->setFontColor($a_form->getInput("font_color"));
177  $this->object->setRSS($a_form->getInput("rss"));
178 
179  // banner field is optional
180  $banner = $a_form->getItemByPostVar("banner");
181  if($banner)
182  {
183  if($_FILES["banner"]["tmp_name"])
184  {
185  $this->object->uploadImage($_FILES["banner"]);
186  }
187  else if($banner->getDeletionFlag())
188  {
189  $this->object->deleteImage();
190  }
191  }
192  }
193 
194  function setTabs()
195  {
196  global $lng, $ilHelp;
197 
198  if($this->id_type == self::WORKSPACE_NODE_ID)
199  {
200  $this->ctrl->setParameter($this,"wsp_id",$this->node_id);
201  }
202 
203  $ilHelp->setScreenIdComponent("blog");
204 
205  if ($this->checkPermissionBool("read"))
206  {
207  $this->tabs_gui->addTab("content",
208  $lng->txt("content"),
209  $this->ctrl->getLinkTarget($this, ""));
210  }
211 
212  if ($this->checkPermissionBool("read"))
213  {
214  $this->tabs_gui->addTab("id_info",
215  $lng->txt("info_short"),
216  $this->ctrl->getLinkTargetByClass(array("ilobjbloggui", "ilinfoscreengui"), "showSummary"));
217  }
218 
219  if ($this->checkPermissionBool("write"))
220  {
221  $this->tabs_gui->addTab("settings",
222  $lng->txt("settings"),
223  $this->ctrl->getLinkTarget($this, "edit"));
224 
225  if($this->id_type == self::REPOSITORY_NODE_ID)
226  {
227  $this->tabs_gui->addTab("contributors",
228  $lng->txt("blog_contributors"),
229  $this->ctrl->getLinkTarget($this, "contributors"));
230  }
231 
232  if($this->id_type == self::REPOSITORY_NODE_ID)
233  {
234  $this->tabs_gui->addTab("export",
235  $lng->txt("export"),
236  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
237  }
238  }
239 
240  if($this->mayContribute())
241  {
242  $this->tabs_gui->addNonTabbedLink("preview", $lng->txt("blog_preview"),
243  $this->ctrl->getLinkTarget($this, "preview"));
244  }
245 
246  // will add permissions if needed
247  parent::setTabs();
248  }
249 
250  function executeCommand()
251  {
252  global $ilCtrl, $tpl, $ilTabs, $lng, $ilNavigationHistory;
253 
254  // goto link to blog posting
255  if($_GET["gtp"])
256  {
257  $page_id = (int)$_GET["gtp"];
258  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
259  if(ilBlogPosting::exists($this->object_id, $page_id))
260  {
261  // #12312
262  $ilCtrl->setCmdClass("ilblogpostinggui");
263  $_GET["blpg"] = $page_id;
264  $ilCtrl->setCmd("previewFullscreen");
265  }
266  else
267  {
268  ilUtil::sendFailure($lng->txt("blog_posting_not_found"));
269  }
270  }
271 
272  $next_class = $ilCtrl->getNextClass($this);
273  $cmd = $ilCtrl->getCmd();
274 
275  if($this->id_type == self::REPOSITORY_NODE_ID)
276  {
277  $tpl->getStandardTemplate();
278 
279  // add entry to navigation history
280  if(!$this->getCreationMode() &&
281  $this->getAccessHandler()->checkAccess("read", "", $this->node_id))
282  {
283  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset");
284  $ilNavigationHistory->addItem($this->node_id, $link, "blog");
285  }
286  }
287 
288  switch($next_class)
289  {
290  case 'ilblogpostinggui':
291  // #9680
292  if($this->id_type == self::REPOSITORY_NODE_ID)
293  {
294  $this->setLocator();
295  }
296  else
297  {
298  include_once "Services/Form/classes/class.ilFileInputGUI.php";
300  }
301  $ilTabs->setBackTarget($lng->txt("back"),
302  $ilCtrl->getLinkTarget($this, ""));
303 
305  $this->object->getStyleSheetId(), "blog");
306 
307  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
308  $bpost_gui = new ilBlogPostingGUI($this->node_id,
309  $this->getAccessHandler(),
310  $_GET["blpg"],
311  $_GET["old_nr"],
312  ($this->object->getNotesStatus() && !$this->disable_notes),
313  $this->mayContribute($_GET["blpg"]),
314  $style_sheet_id);
315 
316  // keep preview mode through notes gui (has its own commands)
317  switch($cmd)
318  {
319  // blog preview
320  case "previewFullscreen":
321  $ilCtrl->setParameter($this, "prvm", "fsc");
322  break;
323 
324  // blog in portfolio
325  case "previewEmbedded":
326  $ilCtrl->setParameter($this, "prvm", "emb");
327  break;
328 
329  // edit
330  default:
331  $this->setContentStyleSheet();
332 
333  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
334  $this->tabs_gui->addNonTabbedLink("preview", $lng->txt("blog_preview"),
335  $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "previewFullscreen"));
336  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", "");
337  break;
338  }
339 
340  $ret = $ilCtrl->forwardCommand($bpost_gui);
341  if ($ret != "")
342  {
343  // keep preview mode through notes gui
344  if($_REQUEST["prvm"])
345  {
346  $cmd = "preview".(($_REQUEST["prvm"] == "fsc") ? "Fullscreen" : "Embedded");
347  }
348 
349  // $is_owner = $this->object->getOwner() == $ilUser->getId();
350  $is_owner = $this->mayContribute();
351  $is_active = $bpost_gui->getBlogPosting()->getActive();
352 
353  // do not show inactive postings
354  if(($cmd == "previewFullscreen" || $cmd == "previewEmbedded")
355  && !$is_owner && !$is_active)
356  {
357  $this->ctrl->redirect($this, "preview");
358  }
359 
360  switch($cmd)
361  {
362  // blog preview
363  case "previewFullscreen":
364  $this->addHeaderAction($cmd);
365  $this->filterInactivePostings();
366  $nav = $this->renderNavigation($this->items, "preview", $cmd);
367  $this->renderFullScreen($ret, $nav);
368  break;
369 
370  // blog in portfolio
371  case "previewEmbedded":
372  $this->filterInactivePostings();
373  $nav = $this->renderNavigation($this->items, "gethtml", $cmd);
374  return $this->buildEmbedded($ret, $nav);
375 
376  // ilias/editor
377  default:
378  // infos about draft status / snippet
379  $info = array();
380  if(!$is_active)
381  {
382  // single author blog (owner) in personal workspace
383  if($this->id_type == self::WORKSPACE_NODE_ID)
384  {
385  $info[] = $lng->txt("blog_draft_info");
386  }
387  else
388  {
389  $info[] = $lng->txt("blog_draft_info_contributors");
390  }
391  }
392  if($cmd != "history" && !$bpost_gui->getBlogPosting()->getFirstParagraphText())
393  {
394  $info[] = $lng->txt("blog_new_posting_info");
395  }
396  if($this->object->hasApproval() && !$bpost_gui->getBlogPosting()->isApproved())
397  {
398  // #9737
399  $info[] = $lng->txt("blog_posting_edit_approval_info");
400  }
401  if(sizeof($info))
402  {
403  ilUtil::sendInfo(implode("<br />", $info));
404  }
405  // revert to edit cmd to avoid confusion
406  $this->addHeaderAction("render");
407  $tpl->setContent($ret);
408  $nav = $this->renderNavigation($this->items, "render", $cmd, null, $is_owner);
409  $tpl->setRightContent($nav);
410  break;
411  }
412  }
413  break;
414 
415  case "ilinfoscreengui":
416  $this->prepareOutput();
417  $this->infoScreenForward();
418  break;
419 
420  case "ilnotegui":
421  $this->preview();
422  break;
423 
424  case "ilcommonactiondispatchergui":
425  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
427  $this->ctrl->forwardCommand($gui);
428  break;
429 
430  case "ilpermissiongui":
431  $this->prepareOutput();
432  $ilTabs->activateTab("id_permissions");
433  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
434  $perm_gui = new ilPermissionGUI($this);
435  $this->ctrl->forwardCommand($perm_gui);
436  break;
437 
438  case "ilobjectcopygui":
439  include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
440  $cp = new ilObjectCopyGUI($this);
441  $cp->setType("blog");
442  $this->ctrl->forwardCommand($cp);
443  break;
444 
445  case 'ilrepositorysearchgui':
446  $this->prepareOutput();
447  $ilTabs->activateTab("contributors");
448  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
449  $rep_search = new ilRepositorySearchGUI();
450  $rep_search->setTitle($this->lng->txt("blog_add_contributor"));
451  $rep_search->setCallback($this,'addContributor');
452  $this->ctrl->setReturn($this,'contributors');
453  $ret =& $this->ctrl->forwardCommand($rep_search);
454  break;
455 
456  case 'ilexportgui':
457  $this->prepareOutput();
458  $ilTabs->activateTab("export");
459  include_once("./Services/Export/classes/class.ilExportGUI.php");
460  $exp_gui = new ilExportGUI($this);
461  $exp_gui->addFormat("xml");
462  $exp_gui->addFormat("html", null, $this, "buildExportFile"); // #13419
463  $ret = $ilCtrl->forwardCommand($exp_gui);
464  break;
465 
466  case "ilobjstylesheetgui":
467  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
468  $this->ctrl->setReturn($this, "editStyleProperties");
469  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
470  $style_gui->omitLocator();
471  if ($cmd == "create" || $_GET["new_type"]=="sty")
472  {
473  $style_gui->setCreationMode(true);
474  }
475 
476  if ($cmd == "confirmedDelete")
477  {
478  $this->object->setStyleSheetId(0);
479  $this->object->update();
480  }
481 
482  $ret = $this->ctrl->forwardCommand($style_gui);
483 
484  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
485  {
486  $style_id = $ret;
487  $this->object->setStyleSheetId($style_id);
488  $this->object->update();
489  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
490  }
491  break;
492 
493  default:
494  if($cmd != "gethtml")
495  {
496  // desktop item handling, must be toggled before header action
497  if($cmd == "addToDesk" || $cmd == "removeFromDesk")
498  {
499  $this->{$cmd."Object"}();
500  if($_GET["prvm"])
501  {
502  $cmd = "preview";
503  }
504  else
505  {
506  $cmd = "render";
507  }
508  $ilCtrl->setCmd($cmd);
509  }
510  $this->addHeaderAction($cmd);
511  }
512  return parent::executeCommand();
513  }
514 
515  return true;
516  }
517 
523  function infoScreen()
524  {
525  $this->ctrl->setCmd("showSummary");
526  $this->ctrl->setCmdClass("ilinfoscreengui");
527  $this->infoScreenForward();
528  }
529 
533  function infoScreenForward()
534  {
535  global $ilTabs, $ilErr;
536 
537  $ilTabs->activateTab("id_info");
538 
539  if (!$this->checkPermissionBool("visible"))
540  {
541  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
542  }
543 
544  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
545  $info = new ilInfoScreenGUI($this);
546 
547  $info->enablePrivateNotes();
548 
549  if ($this->checkPermissionBool("read"))
550  {
551  $info->enableNews();
552  }
553 
554  // no news editing for files, just notifications
555  $info->enableNewsEditing(false);
556  if ($this->checkPermissionBool("write"))
557  {
558  $news_set = new ilSetting("news");
559  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
560 
561  if ($enable_internal_rss)
562  {
563  $info->setBlockProperty("news", "settings", true);
564  $info->setBlockProperty("news", "public_notifications_option", true);
565  }
566  }
567 
568  // standard meta data
569  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
570 
571  if($this->id_type == self::WORKSPACE_NODE_ID)
572  {
573  $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
574  }
575 
576  $this->ctrl->forwardCommand($info);
577  }
578 
582  function createPosting()
583  {
584  global $ilCtrl, $ilUser;
585 
586  $title = trim(ilUtil::stripSlashes($_POST["title"]));
587  if($title)
588  {
589  // create new posting
590  include_once("./Modules/Blog/classes/class.ilBlogPosting.php");
591  $posting = new ilBlogPosting();
592  $posting->setTitle($title);
593  $posting->setBlogId($this->object->getId());
594  $posting->setActive(false);
595  $posting->setAuthor($ilUser->getId());
596  $posting->create();
597 
598  // switch month list to current month (will include new posting)
599  $ilCtrl->setParameter($this, "bmn", date("Y-m"));
600 
601  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $posting->getId());
602  $ilCtrl->redirectByClass("ilblogpostinggui", "edit");
603  }
604  else
605  {
606  $ilCtrl->redirect($this, "render");
607  }
608  }
609 
610  // --- ObjectGUI End
611 
612 
616  function render()
617  {
618  global $tpl, $ilTabs, $ilCtrl, $lng, $ilToolbar, $ilUser, $tree;
619 
620  if(!$this->checkPermissionBool("read"))
621  {
622  ilUtil::sendInfo($lng->txt("no_permission"));
623  return;
624  }
625 
626  $ilTabs->activateTab("content");
627 
628  // toolbar
629  if($this->mayContribute())
630  {
631  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "createPosting"));
632 
633  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
634  $title = new ilTextInputGUI($lng->txt("title"), "title");
635  $ilToolbar->addInputItem($title, $lng->txt("title"));
636 
637  $ilToolbar->addFormButton($lng->txt("blog_add_posting"), "createPosting");
638 
639  // exercise blog?
640  include_once "Modules/Exercise/classes/class.ilObjExercise.php";
641  $exercises = ilObjExercise::findUserFiles($ilUser->getId(), $this->node_id);
642  if($exercises)
643  {
644  $info = array();
645  foreach($exercises as $exercise)
646  {
647  // #9988
648  $active_ref = false;
649  foreach(ilObject::_getAllReferences($exercise["obj_id"]) as $ref_id)
650  {
651  if(!$tree->isSaved($ref_id))
652  {
653  $active_ref = true;
654  break;
655  }
656  }
657  if($active_ref)
658  {
659  $part = $this->getExerciseInfo($exercise["ass_id"]);
660  if($part)
661  {
662  $info[] = $part;
663  }
664  }
665  }
666  if(sizeof($info))
667  {
668  ilUtil::sendInfo(implode("<br />", $info));
669  }
670  }
671  }
672 
673  $list_items = $this->getListItems();
674 
675  $list = $nav = "";
676  if($list_items)
677  {
678  // $is_owner = ($this->object->getOwner() == $ilUser->getId());
679  $is_owner = $this->mayContribute();
680  $list = $this->renderList($list_items, $this->month, "preview", null, $is_owner);
681  $nav = $this->renderNavigation($this->items, "render", "preview", null, $is_owner);
682  }
683 
684  $this->setContentStyleSheet();
685 
686  $tpl->setContent($list);
687  $tpl->setRightContent($nav);
688  }
689 
690  function getExerciseInfo($a_assignment_id)
691  {
692  global $lng, $ilCtrl, $ilUser;
693 
694  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
695  $ass = new ilExAssignment($a_assignment_id);
696  $exercise_id = $ass->getExerciseId();
697  if(!$exercise_id)
698  {
699  return;
700  }
701 
702  // is the assignment still open?
703  $times_up = false;
704  if($ass->getDeadline() && $ass->getDeadline() - time() <= 0)
705  {
706  $times_up = true;
707  }
708 
709  // exercise goto
710  include_once "./Services/Link/classes/class.ilLink.php";
711  $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
712  $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
713 
714  $info = sprintf($lng->txt("blog_exercise_info"),
715  $ass->getTitle(),
716  "<a href=\"".$exc_link."\">".
717  ilObject::_lookupTitle($exercise_id)."</a>");
718 
719  // submit button
720  if(!$times_up)
721  {
722  $ilCtrl->setParameter($this, "exc", $exercise_id);
723  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
724  $submit_link = $ilCtrl->getLinkTarget($this, "finalize");
725  $ilCtrl->setParameter($this, "ass", "");
726  $ilCtrl->setParameter($this, "exc", "");
727  $info .= " <a class=\"submit emphsubmit\" href=\"".$submit_link."\">".$lng->txt("blog_finalize_blog")."</a>";
728  }
729 
730  // submitted files
731  $submitted = ilExAssignment::getDeliveredFiles($exercise_id, $a_assignment_id, $ilUser->getId(), true);
732  if($submitted)
733  {
734  $submitted = array_pop($submitted);
735 
736  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
737  $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcSubFile");
738  $ilCtrl->setParameter($this, "ass", "");
739 
742 
743  $info .= "<br />".sprintf($lng->txt("blog_exercise_submitted_info"),
745  "<a href=\"".$dl_link."\" class=\"submit\">".$lng->txt("download")."</a>");
746 
748  }
749 
750 
751  // work instructions incl. files
752 
753  $tooltip = "";
754 
755  $ass = $ass->getInstruction();
756  if($ass)
757  {
758  $tooltip .= nl2br($ass);
759  }
760 
761  $ass_files = ilExAssignment::getFiles($exercise_id, $a_assignment_id);
762  if (count($ass_files) > 0)
763  {
764  $tooltip .= "<br /><br />";
765 
766  foreach($ass_files as $file)
767  {
768  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
769  $ilCtrl->setParameter($this, "file", urlencode($file["name"]));
770  $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcAssFile");
771  $ilCtrl->setParameter($this, "file", "");
772  $ilCtrl->setParameter($this, "ass", "");
773 
774  $tooltip .= $file["name"].": <a href=\"".$dl_link."\">".
775  $lng->txt("download")."</a>";
776  }
777  }
778 
779  if($tooltip)
780  {
781  $ol_id = "exc_ass_".$a_assignment_id;
782 
783  include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
784  $overlay = new ilOverlayGUI($ol_id);
785 
786  // overlay
787  $overlay->setAnchor($ol_id."_tr");
788  $overlay->setTrigger($ol_id."_tr", "click", $ol_id."_tr");
789  $overlay->add();
790 
791  $info .= "<div id=\"".$ol_id."_tr\"><a href=\"#\">".$lng->txt("exc_instruction")."</a></div>".
792  "<div id=\"".$ol_id."\" style=\"display:none; padding:10px;\" class=\"ilOverlay\">".$tooltip."</div>";
793  }
794 
795  return "<div>".$info."</div>";
796  }
797 
799  {
800  if($_GET["ass"] && $_GET["file"])
801  {
802  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
803  $ass = new ilExAssignment((int)$_GET["ass"]);
804 
805  $ass_files = ilExAssignment::getFiles($ass->getExerciseId(), $ass->getId());
806  if (count($ass_files) > 0)
807  {
808  foreach($ass_files as $file)
809  {
810  if($file["name"] == $_GET["file"])
811  {
812  ilUtil::deliverFile($file["fullpath"], $file["name"]);
813  }
814  }
815  }
816  }
817  }
818 
820  {
821  global $ilUser;
822 
823  if($_GET["ass"])
824  {
825  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
826  $ass = new ilExAssignment((int)$_GET["ass"]);
827 
828  $submitted = ilExAssignment::getDeliveredFiles($ass->getExerciseId(), $ass->getId(), $ilUser->getId());
829  if (count($submitted) > 0)
830  {
831  $submitted = array_pop($submitted);
832 
833  $user_data = ilObjUser::_lookupName($submitted["user_id"]);
834  $title = ilObject::_lookupTitle($submitted["obj_id"])." - ".
835  $ass->getTitle()." - ".
836  $user_data["firstname"]." ".
837  $user_data["lastname"]." (".
838  $user_data["login"].").zip";
839 
840  ilUtil::deliverFile($submitted["filename"], $title);
841  }
842  }
843  }
844 
850  function getHTML()
851  {
852  // getHTML() is called by ilRepositoryGUI::show()
853  if($this->id_type == self::REPOSITORY_NODE_ID)
854  {
855  return;
856  }
857 
858  // there is no way to do a permissions check here, we have no wsp
859 
860  $this->filterInactivePostings();
861 
862  $list_items = $this->getListItems();
863 
864  $list = $nav = "";
865  if($list_items)
866  {
867  $list = $this->renderList($list_items, $this->month, "previewEmbedded");
868  $nav = $this->renderNavigation($this->items, "gethtml", "previewEmbedded");
869  }
870 
871  return $this->buildEmbedded($list, $nav);
872  }
873 
879  protected function getListItems()
880  {
881  if($this->author)
882  {
883  $list_items = array();
884  foreach($this->items as $month => $items)
885  {
886  foreach($items as $id => $item)
887  {
888  if($item["author"] == $this->author)
889  {
890  $list_items[$id] = $item;
891  }
892  }
893  }
894  }
895  else if($this->keyword)
896  {
897  $list_items = $this->filterItemsByKeyword($this->items, $this->keyword);
898  }
899  else
900  {
901  $list_items = $this->items[$this->month];
902  }
903  return $list_items;
904  }
905 
909  function preview()
910  {
911  global $lng;
912 
913  if(!$this->checkPermissionBool("read"))
914  {
915  ilUtil::sendInfo($lng->txt("no_permission"));
916  return;
917  }
918 
919  $this->filterInactivePostings();
920 
921  $list_items = $this->getListItems();
922 
923  $list = $nav = "";
924  if($list_items)
925  {
926  $list = $this->renderList($list_items, $this->month, "previewFullscreen");
927  $nav = $this->renderNavigation($this->items, "preview", "previewFullscreen");
928  }
929 
930  $this->renderFullScreen($list, $nav);
931  }
932 
936  function export()
937  {
938  $zip = $this->buildExportFile();
939 
940  ilUtil::deliverFile($zip, $this->object->getTitle().".zip", '', false, true);
941  }
942 
943 
944  // --- helper functions
945 
953  protected function buildEmbedded($a_content, $a_nav)
954  {
955  $wtpl = new ilTemplate("tpl.blog_embedded.html", true, true, "Modules/Blog");
956  $wtpl->setVariable("VAL_LIST", $a_content);
957  $wtpl->setVariable("VAL_NAVIGATION", $a_nav);
958  return $wtpl->get();
959  }
960 
967  function renderFullScreen($a_content, $a_navigation)
968  {
969  global $tpl, $ilUser, $ilTabs, $ilLocator;
970 
971  $owner = $this->object->getOwner();
972 
973  $ilTabs->clearTargets();
974  $ilLocator->clearItems();
975  $tpl->setLocator();
976 
977  // back (edit)
978  if($owner == $ilUser->getId())
979  {
980  // from shared/deeplink
981  if($this->id_type == self::WORKSPACE_NODE_ID)
982  {
983  $back = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&wsp_id=".$this->node_id;
984  }
985  // from editor (#10073)
986  else if($this->mayContribute())
987  {
988  $prvm = $_GET["prvm"];
989  $this->ctrl->setParameter($this, "prvm", "");
990  if(!$_GET["blpg"])
991  {
992  $back = $this->ctrl->getLinkTarget($this, "");
993  }
994  else
995  {
996  $this->ctrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
997  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
998  $back = $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "preview");
999  }
1000  $this->ctrl->setParameter($this, "prvm", $prvm);
1001  }
1002  }
1003  // back
1004  else if($ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID)
1005  {
1006  // workspace (always shared)
1007  if($this->id_type == self::WORKSPACE_NODE_ID)
1008  {
1009  $back = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=".$owner;
1010  }
1011  // contributor
1012  else if($this->mayContribute())
1013  {
1014  $back = $this->ctrl->getLinkTarget($this, "");
1015  }
1016  // listgui / parent container
1017  else
1018  {
1019  global $tree;
1020  $parent_id = $tree->getParentId($this->node_id);
1021  include_once "Services/Link/classes/class.ilLink.php";
1023  }
1024  }
1025  $tpl->setTopBar($back);
1026 
1027  $this->renderFullscreenHeader($tpl, $owner);
1028 
1029  $this->setContentStyleSheet();
1030 
1031  // content
1032  $tpl->setContent($a_content);
1033  $tpl->setRightContent($a_navigation);
1034  $tpl->setFrameFixedWidth(true);
1035 
1036  echo $tpl->show("DEFAULT", true, true);
1037  exit();
1038  }
1039 
1047  protected function renderFullscreenHeader($a_tpl, $a_user_id, $a_export = false)
1048  {
1049  // repository blogs are multi-author
1050  $name = null;
1051  if($this->id_type != self::REPOSITORY_NODE_ID)
1052  {
1053  $name = ilObjUser::_lookupName($a_user_id);
1054  $name = $name["lastname"].", ".($t = $name["title"] ? $t . " " : "").$name["firstname"];
1055  }
1056 
1057  // show banner?
1058  $banner = false;
1059  $blga_set = new ilSetting("blga");
1060  if($blga_set->get("banner"))
1061  {
1062  $banner = $this->object->getImageFullPath();
1063  $banner_width = $blga_set->get("banner_width");
1064  $banner_height = $blga_set->get("banner_height");
1065  if($a_export)
1066  {
1067  $banner = basename($banner);
1068  }
1069  }
1070 
1071  $ppic = null;
1072  if($this->object->hasProfilePicture())
1073  {
1074  $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "big");
1075  if($a_export)
1076  {
1077  $ppic = basename($ppic);
1078  }
1079  }
1080 
1081  include_once("./Services/User/classes/class.ilUserUtil.php");
1082  $a_tpl->setFullscreenHeader($this->object->getTitle(),
1083  $name,
1084  $ppic,
1085  $banner,
1086  $this->object->getBackgroundColor(),
1087  $this->object->getFontColor(),
1088  $banner_width,
1089  $banner_height,
1090  $a_export);
1091  $a_tpl->setBodyClass("std ilExternal ilBlog");
1092 
1093  }
1094 
1101  protected function buildPostingList($a_obj_id)
1102  {
1103  $author_found = false;
1104 
1105  $items = array();
1106  foreach(ilBlogPosting::getAllPostings($a_obj_id) as $posting)
1107  {
1108  if($this->author && $posting["author"] == $this->author)
1109  {
1110  $author_found = true;
1111  }
1112 
1113  $month = substr($posting["created"]->get(IL_CAL_DATE), 0, 7);
1114  $items[$month][$posting["id"]] = $posting;
1115  }
1116 
1117  if($this->author && !$author_found)
1118  {
1119  $this->author = null;
1120  }
1121 
1122  return $items;
1123  }
1124 
1135  function renderList(array $items, $a_month, $a_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
1136  {
1137  global $lng, $ilCtrl;
1138 
1139  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1140  $wtpl = new ilTemplate("tpl.blog_list.html", true, true, "Modules/Blog");
1141 
1142  // title according to current "filter"/navigation
1143  if($this->keyword)
1144  {
1145  $title = $lng->txt("blog_keyword").": ".$this->keyword;
1146  }
1147  else if($this->author)
1148  {
1149  include_once "Services/User/classes/class.ilUserUtil.php";
1150  $title = $lng->txt("blog_author").": ".ilUserUtil::getNamePresentation($this->author);
1151  }
1152  else
1153  {
1154  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1155  $title = ilCalendarUtil::_numericMonthToString((int)substr($a_month, 5)).
1156  " ".substr($a_month, 0, 4);
1157  }
1158  $wtpl->setVariable("TXT_CURRENT_MONTH", $title);
1159 
1160  $can_approve = ($this->object->hasApproval() && $this->checkPermissionBool("write"));
1161  $can_deactivate = $this->checkPermissionBool("write");
1162 
1163  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
1164  foreach($items as $item)
1165  {
1166  // only published items
1167  $is_active = ilBlogPosting::_lookupActive($item["id"], "blp");
1168  if(!$is_active && !$a_show_inactive)
1169  {
1170  continue;
1171  }
1172 
1173  if(!$a_link_template)
1174  {
1175  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1176  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $item["id"]);
1177  $preview = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_cmd);
1178  }
1179  else
1180  {
1181  $preview = $this->buildExportLink($a_link_template, "posting", $item["id"]);
1182  }
1183 
1184  // actions
1185  $item_contribute = $this->mayContribute($item["id"], $item["author"]);
1186  if(($item_contribute || $can_approve || $can_deactivate) && !$a_link_template && $a_cmd == "preview")
1187  {
1188  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
1189  $alist = new ilAdvancedSelectionListGUI();
1190  $alist->setId($item["id"]);
1191  $alist->setListTitle($lng->txt("actions"));
1192 
1193  if($is_active && $this->object->hasApproval() && !$item["approved"])
1194  {
1195  if($can_approve)
1196  {
1197  $ilCtrl->setParameter($this, "apid", $item["id"]);
1198  $alist->addItem($lng->txt("blog_approve"), "approve",
1199  $ilCtrl->getLinkTarget($this, "approve"));
1200  $ilCtrl->setParameter($this, "apid", "");
1201  }
1202 
1203  $wtpl->setVariable("APPROVAL", $lng->txt("blog_needs_approval"));
1204  }
1205 
1206  if($item_contribute)
1207  {
1208  $alist->addItem($lng->txt("edit_content"), "edit",
1209  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit"));
1210 
1211  // #11858
1212  if($is_active)
1213  {
1214  $alist->addItem($lng->txt("blog_toggle_draft"), "deactivate",
1215  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deactivatePageToList"));
1216  }
1217  else
1218  {
1219  $alist->addItem($lng->txt("blog_toggle_final"), "activate",
1220  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "activatePageToList"));
1221  }
1222 
1223  $alist->addItem($lng->txt("rename"), "rename",
1224  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edittitle"));
1225  $alist->addItem($lng->txt("blog_edit_keywords"), "keywords",
1226  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords"));
1227  $alist->addItem($lng->txt("blog_edit_date"), "editdate",
1228  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editdate"));
1229  $alist->addItem($lng->txt("delete"), "delete",
1230  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen"));
1231  }
1232  else if($can_deactivate)
1233  {
1234  // #10513
1235  if($is_active)
1236  {
1237  $ilCtrl->setParameter($this, "apid", $item["id"]);
1238  $alist->addItem($lng->txt("blog_toggle_draft_admin"), "deactivate",
1239  $ilCtrl->getLinkTarget($this, "deactivateAdmin"));
1240  $ilCtrl->setParameter($this, "apid", "");
1241  }
1242 
1243  $alist->addItem($lng->txt("delete"), "delete",
1244  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen"));
1245  }
1246 
1247  $wtpl->setCurrentBlock("actions");
1248  $wtpl->setVariable("ACTION_SELECTOR", $alist->getHTML());
1249  $wtpl->parseCurrentBlock();
1250  }
1251 
1252  // comments
1253  if($this->object->getNotesStatus() && !$a_link_template && !$this->disable_notes)
1254  {
1255  // count (public) notes
1256  include_once("Services/Notes/classes/class.ilNote.php");
1257  $count = sizeof(ilNote::_getNotesOfObject($this->obj_id,
1258  $item["id"], "blp", IL_NOTE_PUBLIC));
1259 
1260  if($a_cmd != "preview")
1261  {
1262  $wtpl->setCurrentBlock("comments");
1263  $wtpl->setVariable("TEXT_COMMENTS", $lng->txt("blog_comments"));
1264  $wtpl->setVariable("URL_COMMENTS", $preview);
1265  $wtpl->setVariable("COUNT_COMMENTS", $count);
1266  $wtpl->parseCurrentBlock();
1267  }
1268  /* we disabled comments in edit mode (should always be done via pagegui)
1269  else
1270  {
1271  $hash = ilCommonActionDispatcherGUI::buildAjaxHash(ilCommonActionDispatcherGUI::TYPE_WORKSPACE,
1272  $this->node_id, "blog", $this->obj_id, "blp", $item["id"]);
1273  $notes_link = "#\" onclick=\"".ilNoteGUI::getListCommentsJSCall($hash);
1274  }
1275  */
1276  }
1277 
1278  // permanent link
1279  if($a_cmd != "preview" && $a_cmd != "previewEmbedded")
1280  {
1281  if($this->id_type == self::WORKSPACE_NODE_ID)
1282  {
1283  $goto = $this->getAccessHandler()->getGotoLink($this->node_id, $this->obj_id, "_".$item["id"]);
1284  }
1285  else
1286  {
1287  include_once "Services/Link/classes/class.ilLink.php";
1288  $goto = ilLink::_getStaticLink($this->node_id, $this->getType(), true, "_".$item["id"]);
1289  }
1290  $wtpl->setCurrentBlock("permalink");
1291  $wtpl->setVariable("URL_PERMALINK", $goto);
1292  $wtpl->setVariable("TEXT_PERMALINK", $lng->txt("blog_permanent_link"));
1293  $wtpl->parseCurrentBlock();
1294  }
1295 
1296  $snippet = ilBlogPostingGUI::getSnippet($item["id"]);
1297 
1298  if($snippet)
1299  {
1300  $wtpl->setCurrentBlock("more");
1301  $wtpl->setVariable("URL_MORE", $preview);
1302  $wtpl->setVariable("TEXT_MORE", $lng->txt("blog_list_more"));
1303  $wtpl->parseCurrentBlock();
1304  }
1305 
1306  $wtpl->setCurrentBlock("posting");
1307 
1308  if(!$is_active)
1309  {
1310  $wtpl->setVariable("DRAFT_CLASS", " ilBlogListItemDraft");
1311  }
1312 
1313  $author = "";
1314  if($this->id_type == self::REPOSITORY_NODE_ID)
1315  {
1316  $author_id = $item["author"];
1317  if($author_id)
1318  {
1319  include_once "Services/User/classes/class.ilUserUtil.php";
1320  $author = ilUserUtil::getNamePresentation($author_id)." - ";
1321  }
1322  }
1323 
1324  // title
1325  $wtpl->setVariable("URL_TITLE", $preview);
1326  $wtpl->setVariable("TITLE", $item["title"]);
1327  $wtpl->setVariable("DATETIME", $author.
1328  ilDatePresentation::formatDate($item["created"], IL_CAL_DATE));
1329 
1330  // content
1331  $wtpl->setVariable("CONTENT", $snippet);
1332 
1333  $wtpl->parseCurrentBlock();
1334  }
1335 
1336  // notes
1337  /*
1338  if($a_cmd == "previewFullscreen" && $this->object->getNotesStatus())
1339  {
1340  $wtpl->setVariable("NOTES", $this->getNotesHTML());
1341  }
1342  */
1343 
1344  // permalink
1345  if($a_cmd == "previewFullscreen")
1346  {
1347  $wtpl->setVariable("PERMALINK", $this->getPermanentLinkWidget(null, true));
1348  }
1349 
1350  return $wtpl->get();
1351  }
1352 
1353  /*
1354  function getNotesHTML()
1355  {
1356  global $ilCtrl, $ilUser;
1357 
1358  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1359  $notes_gui = new ilNoteGUI($this->object->getId(), 0, "blog");
1360  // $notes_gui->enablePrivateNotes();
1361  $notes_gui->enablePublicNotes();
1362 
1363  if($this->checkPermissionBool("write"))
1364  {
1365  $notes_gui->enablePublicNotesDeletion(true);
1366  }
1367 
1368  $html = $notes_gui->getNotesHTML();
1369  $next_class = $ilCtrl->getNextClass($this);
1370  if ($next_class == "ilnotegui")
1371  {
1372  $html = $ilCtrl->forwardCommand($notes_gui);
1373  }
1374  else
1375  {
1376  $html = $notes_gui->getNotesHTML();
1377  }
1378  return $html;
1379  }
1380  */
1381 
1392  function renderNavigation(array $items, $a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
1393  {
1394  global $ilCtrl, $ilSetting;
1395 
1396  $max_detail_postings = 10;
1397 
1398  $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true,
1399  "Modules/Blog");
1400 
1401  $wtpl->setVariable("NAVIGATION_TITLE", $this->lng->txt("blog_navigation"));
1402 
1403  $ilCtrl->setParameter($this, "blpg", "");
1404 
1405  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1406  $counter = 0;
1407  foreach($items as $month => $postings)
1408  {
1409  $month_name = ilCalendarUtil::_numericMonthToString((int)substr($month, 5)).
1410  " ".substr($month, 0, 4);
1411 
1412  if(!$a_link_template)
1413  {
1414  $ilCtrl->setParameter($this, "bmn", $month);
1415  $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1416  }
1417  else
1418  {
1419  $month_url = $this->buildExportLink($a_link_template, "list", $month);
1420  }
1421 
1422  // list postings for month
1423  if($counter < $max_detail_postings)
1424  {
1425  foreach($postings as $id => $posting)
1426  {
1427  $is_active = ilBlogPosting::_lookupActive($id, "blp");
1428  if(!$is_active && !$a_show_inactive)
1429  {
1430  continue;
1431  }
1432 
1433  $counter++;
1434 
1435  $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1436  ", ".*/ $posting["title"];
1437 
1438  if(!$a_link_template)
1439  {
1440  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1441  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1442  $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1443  }
1444  else
1445  {
1446  $url = $this->buildExportLink($a_link_template, "posting", $id);
1447  }
1448 
1449  if(!$is_active)
1450  {
1451  $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1452  }
1453  else if($this->object->hasApproval() && !$posting["approved"])
1454  {
1455  $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1456  }
1457 
1458  $wtpl->setCurrentBlock("navigation_item");
1459  $wtpl->setVariable("NAV_ITEM_URL", $url);
1460  $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1461  $wtpl->parseCurrentBlock();
1462  }
1463 
1464  $wtpl->setCurrentBlock("navigation_month_details");
1465  $wtpl->setVariable("NAV_MONTH", $month_name);
1466  $wtpl->setVariable("URL_MONTH", $month_url);
1467  $wtpl->parseCurrentBlock();
1468  }
1469  // summarized month
1470  else
1471  {
1472  $wtpl->setCurrentBlock("navigation_month");
1473  $wtpl->setVariable("MONTH_NAME", $month_name);
1474  $wtpl->setVariable("URL_MONTH", $month_url);
1475  $wtpl->setVariable("MONTH_COUNT", sizeof($postings));
1476  $wtpl->parseCurrentBlock();
1477  }
1478  }
1479 
1480  $ilCtrl->setParameter($this, "bmn", $this->month);
1481  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
1482 
1483 
1484  // authors
1485  if($this->id_type == self::REPOSITORY_NODE_ID)
1486  {
1487  $authors = array();
1488  foreach($this->items as $month => $items)
1489  {
1490  foreach($items as $item)
1491  {
1492  if(($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp")) && $item["author"])
1493  {
1494  $authors[] = $item["author"];
1495  }
1496  }
1497  }
1498 
1499  $authors = array_unique($authors);
1500  if(sizeof($authors) > 1)
1501  {
1502  include_once "Services/User/classes/class.ilUserUtil.php";
1503 
1504  $list = array();
1505  foreach($authors as $user_id)
1506  {
1507  if($user_id)
1508  {
1509  $ilCtrl->setParameter($this, "ath", $user_id);
1510  $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1511  $ilCtrl->setParameter($this, "ath", "");
1512 
1513  $name = ilUserUtil::getNamePresentation($user_id, true);
1514  $idx = trim(strip_tags($name))."///".$user_id; // #10934
1515  $list[$idx] = array($name, $url);
1516  }
1517  }
1518  ksort($list);
1519 
1520  $wtpl->setVariable("AUTHORS_TITLE", $this->lng->txt("blog_authors"));
1521 
1522  $wtpl->setCurrentBlock("author");
1523  foreach($list as $author)
1524  {
1525  $wtpl->setVariable("TXT_AUTHOR", $author[0]);
1526  $wtpl->setVariable("URL_AUTHOR", $author[1]);
1527  $wtpl->parseCurrentBlock();
1528  }
1529  }
1530  }
1531 
1532  if(!$a_link_template)
1533  {
1534  // keywords
1535  $may_edit_keywords = ($_GET["blpg"] && $this->mayContribute($_GET["blpg"]) &&
1536  !$a_link_template && $a_list_cmd != "preview" && $a_list_cmd != "gethtml");
1537  $keywords = $this->getKeywords($a_show_inactive, $_GET["blpg"]);
1538  if($keywords || $may_edit_keywords)
1539  {
1540  $wtpl->setVariable("KEYWORDS_TITLE", $this->lng->txt("blog_keywords"));
1541 
1542  if($keywords)
1543  {
1544  $max = max($keywords);
1545  include_once "Services/Tagging/classes/class.ilTagging.php";
1546 
1547  $wtpl->setCurrentBlock("keyword");
1548  foreach($keywords as $keyword => $counter)
1549  {
1550  $ilCtrl->setParameter($this, "kwd", urlencode($keyword)); // #15885
1551  $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1552  $ilCtrl->setParameter($this, "kwd", "");
1553 
1554  $wtpl->setVariable("TXT_KEYWORD", $keyword);
1555  $wtpl->setVariable("SIZE_KEYWORD", ilTagging::calculateFontSize($counter, $max));
1556  $wtpl->setVariable("URL_KEYWORD", $url);
1557  $wtpl->parseCurrentBlock();
1558  }
1559  }
1560  else
1561  {
1562  $wtpl->setVariable("TXT_NO_KEYWORDS", $this->lng->txt("blog_no_keywords"));
1563  }
1564 
1565  if($may_edit_keywords)
1566  {
1567  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
1568  $wtpl->setVariable("URL_EDIT_KEYWORDS",
1569  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords"));
1570  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", "");
1571  $wtpl->setVariable("TXT_EDIT_KEYWORDS", $this->lng->txt("blog_edit_keywords"));
1572  }
1573  }
1574 
1575  // rss
1576  if($this->object->hasRSS() &&
1577  $ilSetting->get('enable_global_profiles') &&
1578  $a_list_cmd == "preview")
1579  {
1580  // #10827
1581  $blog_id = $this->node_id;
1582  if($this->id_type != self::WORKSPACE_NODE_ID)
1583  {
1584  $blog_id .= "_cll";
1585  }
1586  $url = ILIAS_HTTP_PATH."/feed.php?blog_id=".$blog_id.
1587  "&client_id=".rawurlencode(CLIENT_ID);
1588 
1589  $wtpl->setCurrentBlock("rss");
1590  $wtpl->setVariable("URL_RSS", $url);
1591  $wtpl->setVariable("IMG_RSS", ilUtil::getImagePath("rss.png"));
1592  $wtpl->parseCurrentBlock();
1593  }
1594  }
1595 
1596  return $wtpl->get();
1597  }
1598 
1606  function getKeywords($a_show_inactive, $a_posting_id = null)
1607  {
1608  $keywords = array();
1609  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
1610  if($a_posting_id)
1611  {
1612  foreach(ilBlogPostingGUI::getKeywords($this->obj_id, $a_posting_id) as $keyword)
1613  {
1614  $keywords[$keyword]++;
1615  }
1616  }
1617  else
1618  {
1619  foreach($this->items as $month => $items)
1620  {
1621  foreach($items as $item)
1622  {
1623  if($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp"))
1624  {
1625  foreach(ilBlogPostingGUI::getKeywords($this->obj_id, $item["id"]) as $keyword)
1626  {
1627  $keywords[$keyword]++;
1628  }
1629  }
1630  }
1631  }
1632  }
1633 
1634  // #15881
1635  $tmp = array();
1636  foreach($keywords as $keyword => $counter)
1637  {
1638  $tmp[] = array("keyword"=>$keyword, "counter"=>$counter);
1639  }
1640  $tmp = ilUtil::sortArray($tmp, "keyword", "ASC");
1641 
1642  $keywords = array();
1643  foreach($tmp as $item)
1644  {
1645  $keywords[$item["keyword"]] = $item["counter"];
1646  }
1647  return $keywords;
1648  }
1649 
1655  function buildExportFile()
1656  {
1657  // create export file
1658  include_once("./Services/Export/classes/class.ilExport.php");
1659  ilExport::_createExportDirectory($this->object->getId(), "html", "blog");
1660  $exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "blog");
1661 
1662  $subdir = $this->object->getType()."_".$this->object->getId();
1663  $export_dir = $exp_dir."/".$subdir;
1664 
1665  // initialize temporary target directory
1666  ilUtil::delDir($export_dir);
1667  ilUtil::makeDir($export_dir);
1668 
1669  // system style html exporter
1670  include_once("./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
1671  $this->sys_style_html_export = new ilSystemStyleHTMLExport($export_dir);
1672  $this->sys_style_html_export->addImage("icon_blog_b.png");
1673  $this->sys_style_html_export->export();
1674 
1675  // init co page html exporter
1676  include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1677  $this->co_page_html_export = new ilCOPageHTMLExport($export_dir);
1678  $this->co_page_html_export->setContentStyleId($this->object->getStyleSheetId());
1679  $this->co_page_html_export->createDirectories();
1680  $this->co_page_html_export->exportStyles();
1681  $this->co_page_html_export->exportSupportScripts();
1682 
1683  // banner / profile picture
1684  $blga_set = new ilSetting("blga");
1685  if($blga_set->get("banner"))
1686  {
1687  $banner = $this->object->getImageFullPath();
1688  if($banner)
1689  {
1690  copy($banner, $export_dir."/".basename($banner));
1691  }
1692  }
1693  $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big");
1694  if($ppic)
1695  {
1696  $ppic = array_shift(explode("?", $ppic));
1697  copy($ppic, $export_dir."/".basename($ppic));
1698  }
1699 
1700  // export pages
1701  $this->exportHTMLPages($export_dir);
1702 
1703  // zip everything
1704  if (true)
1705  {
1706  // zip it all
1707  $date = time();
1708  $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "blog").
1709  "/".$date."__".IL_INST_ID."__".
1710  $this->object->getType()."_".$this->object->getId().".zip";
1711  ilUtil::zip($export_dir, $zip_file);
1712  ilUtil::delDir($export_dir);
1713  }
1714 
1715  return $zip_file;
1716  }
1717 
1727  function exportHTMLPages($a_target_directory, $a_link_template = null, $a_tpl_callback = null, $a_co_page_html_export = null, $a_index_name = "index.html")
1728  {
1729  if(!$a_link_template)
1730  {
1731  $a_link_template = "bl{TYPE}_{ID}.html";
1732  }
1733 
1734  if($a_co_page_html_export)
1735  {
1736  $this->co_page_html_export = $a_co_page_html_export;
1737  }
1738 
1739  $nav = $this->renderNavigation($this->items, "", "", $a_link_template);
1740 
1741  // month list
1742  $has_index = false;
1743  foreach(array_keys($this->items) as $month)
1744  {
1745  $file = $this->buildExportLink($a_link_template, "list", $month);
1746  $list = $this->renderList($this->items[$month], $month, "render", $a_link_template);
1747 
1748  if(!$a_tpl_callback)
1749  {
1750  $tpl = $this->buildExportTemplate();
1751  }
1752  else
1753  {
1754  $tpl = call_user_func($a_tpl_callback);
1755  }
1756 
1757  $file = $this->writeExportFile($a_target_directory, $file,
1758  $tpl, $list, $nav);
1759 
1760  if(!$has_index)
1761  {
1762  copy($file, $a_target_directory."/".$a_index_name);
1763  $has_index = true;
1764  }
1765  }
1766 
1767  // single postings
1768  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
1769  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1770  $pages = ilBlogPosting::getAllPostings($this->object->getId(), 0);
1771  foreach ($pages as $page)
1772  {
1773  if (ilBlogPosting::_exists("blp", $page["id"]))
1774  {
1775  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
1776  $blp_gui = new ilBlogPostingGUI(0, null, $page["id"]);
1777  $blp_gui->setOutputMode("offline");
1778  $blp_gui->setFullscreenLink("fullscreen.html"); // #12930 - see page.xsl
1779  $blp_gui->add_date = true;
1780  $page_content = $blp_gui->showPage();
1781 
1782  $back = $this->buildExportLink($a_link_template, "list",
1783  substr($page["created"]->get(IL_CAL_DATE), 0, 7));
1784 
1785  $file = $this->buildExportLink($a_link_template, "posting", $page["id"]);
1786 
1787  if(!$a_tpl_callback)
1788  {
1789  $tpl = $this->buildExportTemplate();
1790  }
1791  else
1792  {
1793  $tpl = call_user_func($a_tpl_callback);
1794  }
1795 
1796  $this->writeExportFile($a_target_directory, $file, $tpl,
1797  $page_content, $nav, $back);
1798 
1799  $this->co_page_html_export->collectPageElements("blp:pg", $page["id"]);
1800  }
1801  }
1802  $this->co_page_html_export->exportPageElements();
1803  }
1804 
1813  protected function buildExportLink($a_template, $a_type, $a_id)
1814  {
1815  if($a_type == "list")
1816  {
1817  $a_type = "m";
1818  }
1819  else
1820  {
1821  $a_type = "p";
1822  }
1823  $link = str_replace("{TYPE}", $a_type, $a_template);
1824  return str_replace("{ID}", $a_id, $link);
1825  }
1826 
1833  protected function buildExportTemplate($a_back_url = "")
1834  {
1835  global $ilTabs, $lng;
1836 
1837  $tpl = $this->co_page_html_export->getPreparedMainTemplate();
1838 
1839  $tpl->getStandardTemplate();
1840 
1841  $ilTabs->clearTargets();
1842  if($a_back_url)
1843  {
1844  $ilTabs->setBackTarget($lng->txt("back"), $a_back_url);
1845  }
1846 
1847  $this->renderFullscreenHeader($tpl, $this->object->getOwner(), true);
1848  $tpl->setFrameFixedWidth(true);
1849 
1850  return $tpl;
1851  }
1852 
1863  protected function writeExportFile($a_target_directory, $a_file, $a_tpl, $a_content, $a_right_content = null)
1864  {
1865  $file = $a_target_directory."/".$a_file;
1866  // return if file is already existing
1867  if (@is_file($file))
1868  {
1869  return;
1870  }
1871 
1872  // export template: page content
1873  $ep_tpl = new ilTemplate("tpl.export_page.html", true, true,
1874  "Modules/Blog");
1875  $ep_tpl->setVariable("PAGE_CONTENT", $a_content);
1876 
1877  // export template: right content
1878  if($a_right_content)
1879  {
1880  $ep_tpl->setVariable("RIGHT_CONTENT", $a_right_content);
1881  }
1882 
1883  $a_tpl->setContent($ep_tpl->get());
1884 
1885  $content = $a_tpl->get("DEFAULT", false, false, false,
1886  true, true, true);
1887 
1888  // open file
1889  if (!file_put_contents($file, $content))
1890  {
1891  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
1892  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
1893  }
1894 
1895  // set file permissions
1896  chmod($file, 0770);
1897 
1898  return $file;
1899  }
1900 
1904  protected function finalize()
1905  {
1906  global $ilCtrl, $lng;
1907 
1908  // to make exercise gui load assignment
1909  $_GET["ass_id"] = $_REQUEST["ass"];
1910 
1911  // #11173 - ref_id is needed for notifications
1912  $exc_ref_id = array_shift(ilObject::_getAllReferences($_REQUEST["exc"]));
1913 
1914  include_once "Modules/Exercise/classes/class.ilObjExerciseGUI.php";
1915  $exc_gui = new ilObjExerciseGUI(null, $exc_ref_id, true);
1916  $exc_gui->submitBlog($this->node_id);
1917 
1918  ilUtil::sendSuccess($lng->txt("blog_finalized"), true);
1919  $ilCtrl->redirect($this, "render");
1920  }
1921 
1922  function getNotesSubId()
1923  {
1924  if($_REQUEST["blpg"])
1925  {
1926  return $_REQUEST["blpg"];
1927  }
1928  return 0;
1929  }
1930 
1931  function disableNotes($a_value = false)
1932  {
1933  $this->disable_notes = (bool)$a_value;
1934  }
1935 
1936  protected function addHeaderAction($a_cmd)
1937  {
1938  global $ilUser, $ilCtrl;
1939 
1940  // preview?
1941  if($a_cmd == "preview" || $a_cmd == "previewFullscreen" || $_GET["prvm"])
1942  {
1943  // notification
1944  if($ilUser->getId() != ANONYMOUS_USER_ID)
1945  {
1946  if(!$_GET["prvm"])
1947  {
1948  $ilCtrl->setParameter($this, "prvm", "fsc");
1949  }
1950  $this->insertHeaderAction($this->initHeaderAction(null, null, true));
1951  if(!$_GET["prvm"])
1952  {
1953  $ilCtrl->setParameter($this, "prvm", "");
1954  }
1955  }
1956  }
1957  else
1958  {
1959  return parent::addHeaderAction();
1960  }
1961  }
1962 
1963  protected function initHeaderAction($sub_type = null, $sub_id = null, $a_is_preview = false)
1964  {
1965  global $ilUser, $ilCtrl;
1966 
1967  if(!$this->obj_id)
1968  {
1969  return false;
1970  }
1971 
1972  $sub_type = $sub_id = null;
1973  if($_GET["blpg"])
1974  {
1975  $sub_type = "blp";
1976  $sub_id = $_GET["blpg"];
1977  }
1978 
1979  $lg = parent::initHeaderAction($sub_type, $sub_id);
1980 
1981  if($a_is_preview)
1982  {
1983  $lg->enableComments(false);
1984  $lg->enableNotes(false);
1985  $lg->enableTags(false);
1986 
1987  include_once "./Services/Notification/classes/class.ilNotification.php";
1989  {
1990  $ilCtrl->setParameter($this, "ntf", 1);
1991  $link = $ilCtrl->getLinkTarget($this, "setNotification");
1992  $ilCtrl->setParameter($this, "ntf", "");
1993  $lg->addCustomCommand($link, "blog_notification_toggle_off");
1994 
1995  $lg->addHeaderIcon("not_icon",
1996  ilUtil::getImagePath("notification_on.png"),
1997  $this->lng->txt("blog_notification_activated"));
1998  }
1999  else
2000  {
2001  $ilCtrl->setParameter($this, "ntf", 2);
2002  $link = $ilCtrl->getLinkTarget($this, "setNotification");
2003  $ilCtrl->setParameter($this, "ntf", "");
2004  $lg->addCustomCommand($link, "blog_notification_toggle_on");
2005 
2006  $lg->addHeaderIcon("not_icon",
2007  ilUtil::getImagePath("notification_off.png"),
2008  $this->lng->txt("blog_notification_deactivated"));
2009  }
2010 
2011  // #11758
2012  if($this->mayContribute())
2013  {
2014  $ilCtrl->setParameter($this, "prvm", "");
2015 
2016  $ilCtrl->setParameter($this, "bmn", "");
2017  $ilCtrl->setParameter($this, "blpg", "");
2018  $link = $ilCtrl->getLinkTarget($this, "");
2019  $ilCtrl->setParameter($this, "blpg", $sub_id);
2020  $ilCtrl->setParameter($this, "bmn", $this->month);
2021  $lg->addCustomCommand($link, "blog_edit"); // #11868
2022 
2023  if($sub_id && $this->mayContribute($sub_id))
2024  {
2025  $link = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit");
2026  $lg->addCustomCommand($link, "blog_edit_posting");
2027  }
2028 
2029  $ilCtrl->setParameter($this, "prvm", "fsc");
2030  }
2031 
2032  $ilCtrl->setParameter($this, "ntf", "");
2033  }
2034 
2035  return $lg;
2036  }
2037 
2038  protected function setNotification()
2039  {
2040  global $ilUser, $ilCtrl;
2041 
2042  include_once "./Services/Notification/classes/class.ilNotification.php";
2043  switch($_GET["ntf"])
2044  {
2045  case 1:
2047  break;
2048 
2049  case 2:
2051  break;
2052  }
2053 
2054  $ilCtrl->redirect($this, "preview");
2055  }
2056 
2064  static function lookupSubObjectTitle($a_blog_id, $a_posting_id)
2065  {
2066  // page might be deleted, so setting halt on errors to false
2067  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2068  $post = new ilBlogPosting($a_posting_id);
2069  if($post->getBlogId() == $a_blog_id)
2070  {
2071  return $post->getTitle();
2072  }
2073  }
2074 
2080  protected function filterInactivePostings()
2081  {
2082  foreach($this->items as $month => $postings)
2083  {
2084  foreach($postings as $id => $item)
2085  {
2086  if(!ilBlogPosting::_lookupActive($id, "blp"))
2087  {
2088  unset($this->items[$month][$id]);
2089  }
2090  else if($this->object->hasApproval() && !$item["approved"])
2091  {
2092  unset($this->items[$month][$id]);
2093  }
2094  }
2095  if(!sizeof($this->items[$month]))
2096  {
2097  unset($this->items[$month]);
2098  }
2099  }
2100 
2101  if($this->items && !isset($this->items[$this->month]))
2102  {
2103  $this->month = array_shift(array_keys($this->items));
2104  }
2105  }
2106 
2107  protected function filterItemsByKeyWord(array $a_items, $a_keyword)
2108  {
2109  $res = array();
2110  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
2111  foreach($a_items as $month => $items)
2112  {
2113  foreach($items as $item)
2114  {
2115  if(in_array($a_keyword,
2116  ilBlogPostingGUI::getKeywords($this->obj_id, $item["id"])))
2117  {
2118  $res[] = $item;
2119  }
2120  }
2121  }
2122  return $res;
2123  }
2124 
2132  protected function mayContribute($a_posting_id = null, $a_author_id = null)
2133  {
2134  global $ilUser;
2135 
2136  // single author blog (owner) in personal workspace
2137  if($this->id_type == self::WORKSPACE_NODE_ID)
2138  {
2139  return $this->checkPermissionBool("write");
2140  }
2141 
2142  if($this->checkPermissionBool("contribute"))
2143  {
2144  // check owner of posting
2145  if($a_posting_id)
2146  {
2147  if(!$a_author_id)
2148  {
2149  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2150  $post = new ilBlogPosting($a_posting_id);
2151  $a_author_id = $post->getAuthor();
2152  }
2153  if($ilUser->getId() == $a_author_id)
2154  {
2155  return true;
2156  }
2157  else
2158  {
2159  return false;
2160  }
2161  }
2162 
2163  return true;
2164  }
2165  return false;
2166  }
2167 
2168  function addLocatorItems()
2169  {
2170  global $ilLocator;
2171 
2172  if (is_object($this->object))
2173  {
2174  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
2175  }
2176  }
2177 
2178  function approve()
2179  {
2180  if($this->checkPermissionBool("write") && (int)$_GET["apid"])
2181  {
2182  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2183  $post = new ilBlogPosting((int)$_GET["apid"]);
2184  $post->setApproved(true);
2185  $post->update();
2186 
2187  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2188  }
2189 
2190  $this->ctrl->redirect($this, "render");
2191  }
2192 
2193 
2194  //
2195  // contributors
2196  //
2197 
2198  function contributors()
2199  {
2200  global $ilTabs, $ilToolbar, $ilCtrl, $lng, $tpl;
2201 
2202  if(!$this->checkPermissionBool("write"))
2203  {
2204  return;
2205  }
2206 
2207  $ilTabs->activateTab("contributors");
2208 
2209  // add member
2210  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
2212  $this,
2213  $ilToolbar,
2214  array(
2215  'auto_complete_name' => $lng->txt('user'),
2216  'submit_name' => $lng->txt('add'),
2217  'add_search' => true,
2218  'add_from_container' => $this->node_id
2219  )
2220  );
2221 
2222  $other_roles = $this->object->getRolesWithContribute($this->node_id);
2223  if($other_roles)
2224  {
2225  ilUtil::sendInfo(sprintf($lng->txt("blog_contribute_other_roles"), implode(", ", $other_roles)));
2226  }
2227 
2228  include_once "Modules/Blog/classes/class.ilContributorTableGUI.php";
2229  $tbl = new ilContributorTableGUI($this, "contributors", $this->object->getLocalContributorRole($this->node_id));
2230 
2231  $tpl->setContent($tbl->getHTML());
2232  }
2233 
2237  public function addUserFromAutoComplete()
2238  {
2239  global $lng;
2240 
2241  if(!strlen(trim($_POST['user_login'])))
2242  {
2243  ilUtil::sendFailure($lng->txt('msg_no_search_string'));
2244  return $this->contributors();
2245  }
2246  $users = explode(',', $_POST['user_login']);
2247 
2248  $user_ids = array();
2249  foreach($users as $user)
2250  {
2251  $user_id = ilObjUser::_lookupId($user);
2252 
2253  if(!$user_id)
2254  {
2255  ilUtil::sendFailure($lng->txt('user_not_known'));
2256  return $this->contributors();
2257  }
2258 
2259  $user_ids[] = $user_id;
2260  }
2261 
2262  return $this->addContributor($user_ids);
2263  }
2264 
2270  public function addContributor($a_user_ids = array())
2271  {
2272  global $ilCtrl, $lng, $rbacreview, $rbacadmin;
2273 
2274  if(!$this->checkPermissionBool("write"))
2275  {
2276  return;
2277  }
2278 
2279  if(!count($a_user_ids))
2280  {
2281  ilUtil::sendFailure($lng->txt("no_checkbox"));
2282  return $this->contributors();
2283  }
2284 
2285  // get contributor role
2286  $contr_role_id = $this->object->getLocalContributorRole($this->node_id);
2287  if(!$contr_role_id)
2288  {
2289  ilUtil::sendFailure($lng->txt("missing_perm"));
2290  return $this->contributors();
2291  }
2292 
2293  foreach($a_user_ids as $user_id)
2294  {
2295  if(!$rbacreview->isAssigned($user_id, $contr_role_id))
2296  {
2297  $rbacadmin->assignUser($contr_role_id, $user_id);
2298  }
2299  }
2300 
2301  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
2302  $ilCtrl->redirect($this, "contributors");
2303  }
2304 
2308  public function removeContributor()
2309  {
2310  global $ilCtrl, $lng, $rbacadmin;
2311 
2312  $ids = $_POST["id"];
2313 
2314  if(!sizeof($ids))
2315  {
2316  ilUtil::sendFailure($lng->txt("select_one"), true);
2317  $ilCtrl->redirect($this, "contributors");
2318  }
2319 
2320  // get contributor role
2321  $contr_role_id = $this->object->getLocalContributorRole($this->node_id);
2322  if(!$contr_role_id)
2323  {
2324  ilUtil::sendFailure($lng->txt("missing_perm"));
2325  return $this->contributors();
2326  }
2327 
2328  foreach($ids as $user_id)
2329  {
2330  $rbacadmin->deassignUser($contr_role_id, $user_id);
2331  }
2332 
2333  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
2334  $this->ctrl->redirect($this, "contributors");
2335  }
2336 
2340  public function addToDeskObject()
2341  {
2342  global $lng;
2343 
2344  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
2346  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
2347  }
2348 
2352  public function removeFromDeskObject()
2353  {
2354  global $lng;
2355 
2356  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
2358  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
2359  }
2360 
2361  public function deactivateAdmin()
2362  {
2363  if($this->checkPermissionBool("write") && (int)$_GET["apid"])
2364  {
2365  // ilBlogPostingGUI::deactivatePage()
2366  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2367  $post = new ilBlogPosting((int)$_GET["apid"]);
2368  $post->setApproved(false);
2369  $post->setActive(false);
2370  $post->update(true, false, false);
2371 
2372  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2373  }
2374 
2375  $this->ctrl->redirect($this, "render");
2376  }
2377 
2378 
2382 
2383  function setContentStyleSheet($a_tpl = null)
2384  {
2385  global $tpl;
2386 
2387  if ($a_tpl != null)
2388  {
2389  $ctpl = $a_tpl;
2390  }
2391  else
2392  {
2393  $ctpl = $tpl;
2394  }
2395 
2396  $ctpl->setCurrentBlock("ContentStyle");
2397  $ctpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2398  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
2399  $ctpl->parseCurrentBlock();
2400  }
2401 
2403  {
2404  $this->checkPermission("write");
2405 
2406  $this->tabs_gui->activateTab("settings");
2407  $this->setSettingsSubTabs("style");
2408 
2409  $form = $this->initStylePropertiesForm();
2410  $this->tpl->setContent($form->getHTML());
2411  }
2412 
2414  {
2415  global $ilSetting;
2416 
2417  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
2418  $this->lng->loadLanguageModule("style");
2419 
2420  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2421  $form = new ilPropertyFormGUI();
2422 
2423  $fixed_style = $ilSetting->get("fixed_content_style_id");
2424  $style_id = $this->object->getStyleSheetId();
2425 
2426  if ($fixed_style > 0)
2427  {
2428  $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
2429  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
2430  $this->lng->txt("global_fixed").")");
2431  $form->addItem($st);
2432  }
2433  else
2434  {
2435  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
2436  $_GET["ref_id"]);
2437 
2438  $st_styles[0] = $this->lng->txt("default");
2439  ksort($st_styles);
2440 
2441  if ($style_id > 0)
2442  {
2443  // individual style
2444  if (!ilObjStyleSheet::_lookupStandard($style_id))
2445  {
2446  $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
2447  $st->setValue(ilObject::_lookupTitle($style_id));
2448  $form->addItem($st);
2449 
2450  // delete command
2451  $form->addCommandButton("editStyle", $this->lng->txt("style_edit_style"));
2452  $form->addCommandButton("deleteStyle", $this->lng->txt("style_delete_style"));
2453  }
2454  }
2455 
2456  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
2457  {
2458  $style_sel = new ilSelectInputGUI($this->lng->txt("style_current_style"),
2459  "style_id");
2460  $style_sel->setOptions($st_styles);
2461  $style_sel->setValue($style_id);
2462  $form->addItem($style_sel);
2463 
2464  $form->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
2465  $form->addCommandButton("createStyle", $this->lng->txt("sty_create_ind_style"));
2466  }
2467  }
2468 
2469  $form->setTitle($this->lng->txt("blog_style"));
2470  $form->setFormAction($this->ctrl->getFormAction($this));
2471 
2472  return $form;
2473  }
2474 
2475  function createStyle()
2476  {
2477  $this->ctrl->redirectByClass("ilobjstylesheetgui", "create");
2478  }
2479 
2480  function editStyle()
2481  {
2482  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
2483  }
2484 
2485  function deleteStyle()
2486  {
2487  $this->ctrl->redirectByClass("ilobjstylesheetgui", "delete");
2488  }
2489 
2491  {
2492  global $ilSetting;
2493 
2494  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
2495  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
2496  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
2497  || $this->object->getStyleSheetId() == 0))
2498  {
2499  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
2500  $this->object->update();
2501 
2502  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2503  }
2504  $this->ctrl->redirect($this, "editStyleProperties");
2505  }
2506 
2512  function _goto($a_target)
2513  {
2514  if(substr($a_target, -3) == "wsp")
2515  {
2516  $id = explode("_", $a_target);
2517 
2518  $_GET["baseClass"] = "ilSharedResourceGUI";
2519  $_GET["wsp_id"] = $id[0];
2520  if(sizeof($id) == 3)
2521  {
2522  $_GET["gtp"] = $id[1];
2523  }
2524  }
2525  else
2526  {
2527  $id = explode("_", $a_target);
2528 
2529  $_GET["baseClass"] = "ilRepositoryGUI";
2530  $_GET["ref_id"] = $id[0];
2531  $_GET["cmd"] = "preview";
2532  if(sizeof($id) == 2)
2533  {
2534  $_GET["gtp"] = $id[1];
2535  }
2536  }
2537 
2538  include("ilias.php");
2539  exit;
2540  }
2541 }
2542 
2543 ?>