ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjBlogGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
32
43{
44 protected ?Settings $blog_settings = null;
50 protected string $rendered_content = "";
51 protected \ILIAS\Notes\Service $notes;
52 protected \ILIAS\Blog\ReadingTime\BlogSettingsGUI $reading_time_gui;
54
56 protected ilHelpGUI $help;
57 protected ilTabsGUI $tabs;
60
61 protected string $month = "";
62 protected array $items = [];
63 protected string $keyword = "";
64 protected ?int $author = null;
65 protected bool $month_default = false;
66 protected int $blpg = 0;
67 protected int $old_nr = 0;
68 protected int $ppage = 0;
69 protected int $user_page = 0;
70 protected string $prvm; //preview mode (fsc|emb)
71 protected int $ntf = 0;
72 protected int $apid = 0;
73 protected string $new_type = "";
74 protected bool $disable_notes = false;
76 protected \ILIAS\DI\UIServices $ui;
77 protected \ILIAS\Style\Content\GUIService $content_style_gui;
78 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
79
80 public function __construct(
81 int $a_id = 0,
82 int $a_id_type = self::REPOSITORY_NODE_ID,
83 int $a_parent_node_id = 0
84 ) {
85 global $DIC;
86
87 // other services
88 $cs = $DIC->contentStyle();
89 $this->tool_context = $DIC->globalScreen()->tool()->context();
90 $this->notes = $DIC->notes();
91
92 // internal service
93 $service = $DIC->blog()->internal();
94
95 $this->domain = $domain = $service->domain();
96 $this->gui = $gui = $service->gui();
97
98 $this->settings = $domain->settings();
99 $this->user = $domain->user();
100 $this->tree = $domain->repositoryTree();
101 $this->rbac_review = $domain->rbac()->review();
102 $this->rbacadmin = $domain->rbac()->admin();
103 $this->lng = $domain->lng();
104
105 $gui = $service->gui();
106 $this->gui = $gui;
107 $this->help = $gui->help();
108 $this->tabs = $gui->tabs();
109 $this->toolbar = $gui->toolbar();
110 $this->ui = $gui->ui();
111 $this->locator = $gui->locator();
112
113 $this->nav_history = $DIC["ilNavigationHistory"];
114 $this->ctrl = $gui->ctrl();
115
116 $this->blog_request = $gui->standardRequest();
117
119 $this->blpg = $req->getBlogPage();
120 $this->old_nr = $req->getOldNr();
121 $this->ppage = $req->getPPage();
122 $this->user_page = $req->getUserPage();
123 $this->new_type = $req->getNewType();
124 $this->prvm = $req->getPreviewMode();
125 $this->ntf = $req->getNotification();
126 $this->apid = $req->getApId();
127 $this->month = $req->getMonth();
128 $this->keyword = $req->getKeyword();
129 $this->author = $req->getAuthor();
130
131 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
132
133 $blog_page = $this->blog_request->getBlogPage();
134 if ($blog_page > 0 &&
135 ilBlogPosting::lookupBlogId($blog_page) !== $this->object->getId()) {
136 throw new ilException("Posting ID does not match blog.");
137 }
138
139 $blog_id = 0;
140 if ($this->object) {
141 // gather postings by month
142 $this->items = $this->buildPostingList($this->object->getId());
143 if ($this->items) {
144 // current month (if none given or empty)
145 if (!$this->month || !isset($this->items[$this->month]) || $this->items[$this->month] === []) {
146 $m = array_keys($this->items);
147 $this->month = array_shift($m);
148 $this->month_default = true;
149 }
150 }
151
152 $this->ctrl->setParameter($this, "bmn", $this->month);
153 $blog_id = $this->object->getId();
154 }
155
156 $this->lng->loadLanguageModule("blog");
157 $this->ctrl->saveParameter($this, "prvm");
158
159 $this->content_style_gui = $cs->gui();
160 if (is_object($this->object)) {
161 if ($this->id_type !== self::REPOSITORY_NODE_ID) {
162 $this->content_style_domain = $cs->domain()->styleForObjId($this->object->getId());
163 } else {
164 $this->content_style_domain = $cs->domain()->styleForRefId($this->object->getRefId());
165 }
166 $this->blog_settings =
167 $domain->blogSettings()->getByObjId($this->object->getId());
168 }
169
170 $this->reading_time_gui = $gui->readingTime()->settingsGUI($blog_id);
171 $this->reading_time_manager = $domain->readingTime();
172 $this->notes = $DIC->notes();
173 $owner = $this->object?->getOwner() ?? 0;
174 $this->perm = $domain->perm(
175 $this->getAccessHandler(),
176 $this->node_id,
177 $this->id_type,
178 $this->user->getId(),
179 $owner
180 );
181 $this->profile = $domain->profile();
182 $this->profile_gui = $gui->profile();
183 }
184
185 public function getType(): string
186 {
187 return "blog";
188 }
189
190 public function getItems(): array
191 {
192 return $this->items;
193 }
194
195 protected function afterSave(ilObject $new_object): void
196 {
197 $ilCtrl = $this->ctrl;
198
199 $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
200 $ilCtrl->redirect($this, "");
201 }
202
203 protected function setSettingsSubTabs(string $a_active): void
204 {
207
208 // general properties
209 $this->tabs_gui->addSubTab(
210 "properties",
211 $this->lng->txt("general"),
212 $this->ctrl->getLinkTarget($this, 'edit')
213 );
214
215 $this->tabs_gui->addSubTab(
216 "side_blocks",
217 $this->lng->txt("blog_side_blocks"),
218 $this->ctrl->getLinkTargetByClass(
219 [\ILIAS\Blog\Settings\BlockSettingsGUI::class],
220 ""
221 )
222 );
223
224 $this->tabs_gui->addSubTab(
225 "style",
226 $this->lng->txt("obj_sty"),
227 $this->ctrl->getLinkTargetByClass("ilobjectcontentstylesettingsgui", "")
228 );
229
230 // notification settings for blogs in courses and groups
231 if ($this->id_type === self::REPOSITORY_NODE_ID) {
232 $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
233 $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
234
235 if ($grp_ref_id > 0 || $crs_ref_id > 0) {
236 if ($access->checkAccess('write', '', $this->ref_id)) {
237 $this->tabs_gui->addSubTab(
238 'notifications',
239 $this->lng->txt("notifications"),
240 $this->ctrl->getLinkTargetByClass("ilobjnotificationsettingsgui", '')
241 );
242 }
243 }
244 }
245
246 $this->tabs_gui->activateSubTab($a_active);
247 }
248
249 public function edit(): void
250 {
251 $this->ctrl->redirectByClass(SettingsGUI::class, "");
252 }
253
254 protected function setTabs(): void
255 {
257 $ilHelp = $this->help;
258
259 if ($this->id_type === self::WORKSPACE_NODE_ID) {
260 $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
261 }
262
263 $ilHelp->setScreenIdComponent("blog");
264
265 if ($this->checkPermissionBool("read")) {
266 $this->ctrl->setParameterByClass(self::class, "bmn", null);
267 $this->tabs_gui->addTab(
268 "content",
269 $lng->txt("content"),
270 $this->ctrl->getLinkTarget($this, "")
271 );
272 }
273 if ($this->checkPermissionBool("read")) {
274 $this->tabs_gui->addTab(
275 "id_info",
276 $lng->txt("info_short"),
277 $this->ctrl->getLinkTargetByClass(array("ilobjbloggui", "ilinfoscreengui"), "showSummary")
278 );
279 }
280
281 if ($this->checkPermissionBool("write")) {
282 $this->tabs_gui->addTab(
283 "settings",
284 $lng->txt("settings"),
285 $this->ctrl->getLinkTargetByClass(
286 [SettingsGUI::class],
287 ""
288 )
289 );
290
291 if ($this->id_type === self::REPOSITORY_NODE_ID) {
292 $this->tabs_gui->addTab(
293 "contributors",
294 $lng->txt("blog_contributors"),
295 $this->ctrl->getLinkTarget($this, "contributors")
296 );
297 }
298
299 if ($this->id_type === self::REPOSITORY_NODE_ID) {
300 $mdgui = new ilObjectMetaDataGUI($this->object, null, null, $this->call_by_reference);
301 $mdtab = $mdgui->getTab();
302 if ($mdtab) {
303 $this->tabs_gui->addTab(
304 "meta_data",
305 $this->lng->txt("meta_data"),
306 $mdtab
307 );
308 }
309 $this->tabs_gui->addTab(
310 "export",
311 $lng->txt("export"),
312 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
313 );
314 }
315 }
316
317 if ($this->perm->mayContribute()) {
318 $this->tabs_gui->addNonTabbedLink(
319 "preview",
320 $lng->txt("blog_preview"),
321 $this->ctrl->getLinkTarget($this, "preview")
322 );
323 }
324 parent::setTabs();
325 }
326
327 public function executeCommand(): void
328 {
329 $ilCtrl = $this->ctrl;
331 $ilTabs = $this->tabs;
333 $ilNavigationHistory = $this->nav_history;
334
335
336 $next_class = $ilCtrl->getNextClass($this);
337
338 if ($next_class !== "ilexportgui") {
339 $this->triggerAssignmentTool();
340 }
341
342 $cmd = $ilCtrl->getCmd();
343
344 // add entry to navigation history
345 if (($this->id_type === self::REPOSITORY_NODE_ID) && !$this->getCreationMode() &&
346 $this->getAccessHandler()->checkAccess("read", "", $this->node_id)) {
347 // see #22067
348 $link = $ilCtrl->getLinkTargetByClass(["ilrepositorygui", "ilObjBlogGUI"], "preview");
349 $ilNavigationHistory->addItem($this->node_id, $link, "blog");
350 }
351 switch ($next_class) {
352 case 'ilblogpostinggui':
353 $this->ctrl->saveParameter($this, "user_page");
355
356 if (!$this->checkPermissionBool("read")) {
357 $this->tpl->setOnScreenMessage('info', $lng->txt("no_permission"));
358 return;
359 }
360
361 // #9680
362 if ($this->id_type === self::REPOSITORY_NODE_ID) {
363 $this->setLocator();
364 }
365
366 $style_sheet_id = $this->content_style_domain->getEffectiveStyleId();
367
368 $bpost_gui = new ilBlogPostingGUI(
369 $this->node_id,
370 $this->getAccessHandler(),
371 $this->blpg,
372 $this->old_nr,
373 ($this->object->getNotesStatus() && !$this->disable_notes),
374 $this->perm->mayEditPosting($this->blpg),
375 $style_sheet_id
376 );
377
378 // keep preview mode through notes gui (has its own commands)
379 switch ($cmd) {
380 // blog preview
381 case "previewFullscreen":
382 $ilCtrl->setParameter($this, "prvm", "fsc");
383 break;
384
385 default:
386 $this->setContentStyleSheet();
387
388
389 $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $this->blpg);
390 $this->tabs_gui->addNonTabbedLink(
391 "preview",
392 $lng->txt("blog_preview"),
393 $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "previewFullscreen")
394 );
395 $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", "");
396 break;
397 }
398
399 // keep preview mode through notes gui
400 if ($this->prvm) {
401 $cmd = "previewFullscreen";
402 }
403 if (in_array($cmd, array("previewFullscreen"))) {
404 $this->renderToolbarNavigation($this->items, true);
405 }
406 $ret = $ilCtrl->forwardCommand($bpost_gui);
407 if (!$ilTabs->back_target) {
408 $ilCtrl->setParameter($this, "bmn", "");
409 $ilTabs->setBackTarget(
410 $lng->txt("back"),
411 $ilCtrl->getLinkTarget($this, "")
412 );
413 }
414
415 if ($ret != "") {
416 // $is_owner = $this->object->getOwner() == $ilUser->getId();
417 $is_owner = $this->perm->mayContribute();
418 $is_active = $bpost_gui->getBlogPosting()->getActive();
419
420 // do not show inactive postings
421 if (($cmd === "previewFullscreen")
422 && !$is_owner && !$is_active) {
423 $this->ctrl->redirect($this, "preview");
424 }
425
426 switch ($cmd) {
427 // blog preview
428 case "previewFullscreen":
429 $this->addHeaderActionForCommand($cmd);
430 $this->filterInactivePostings();
431 $nav = $this->renderNavigation("preview", $cmd);
432 $this->renderFullScreen($ret, $nav);
433 break;
434
435 default:
436 // infos about draft status / snippet
437 $info = array();
438 if (!$is_active) {
439 // single author blog (owner) in personal workspace
440 if ($this->id_type === self::WORKSPACE_NODE_ID) {
441 $info[] = $lng->txt("blog_draft_info");
442 } else {
443 $info[] = $lng->txt("blog_draft_info_contributors");
444 }
445 }
446 $public_action = false;
447 if ($cmd !== "history" && $cmd !== "edit" && $is_active && empty($info)) {
448 $info[] = $lng->txt("blog_new_posting_info");
449 $public_action = true;
450 }
451 if ($this->blog_settings->getApproval() && !$bpost_gui->getBlogPosting()->isApproved()) {
452 // #9737
453 $info[] = $lng->txt("blog_posting_edit_approval_info");
454 }
455 if ($public_action) {
456 $this->tpl->setOnScreenMessage('success', implode("<br />", $info));
457 } else {
458 if (count($info) > 0) {
459 $this->tpl->setOnScreenMessage('info', implode("<br />", $info));
460 }
461 }
462
463 // revert to edit cmd to avoid confusion
464 $tpl->setContent($ret);
465 if ($cmd !== "edit") {
466 $this->addHeaderActionForCommand("render");
467 $nav = $this->renderNavigation("render", $cmd, "", $is_owner);
468 $tpl->setRightContent($nav);
469 } else {
470 $this->tabs->setBackTarget("", "");
471 }
472 break;
473 }
474 }
475 break;
476
477 case "ilinfoscreengui":
478 $this->prepareOutput();
479 $this->addHeaderActionForCommand("render");
480 $this->infoScreenForward();
481 break;
482
483 case "ilnotegui":
484 $this->preview();
485 break;
486
487 case "ilcommonactiondispatchergui":
489 $gui->enableCommentsSettings(false);
490 $this->prepareOutput();
491 $this->ctrl->forwardCommand($gui);
492 break;
493
494 case "ilpermissiongui":
495 $this->prepareOutput();
496 $ilTabs->activateTab("id_permissions");
497 $perm_gui = new ilPermissionGUI($this);
498 $this->ctrl->forwardCommand($perm_gui);
499 break;
500
501 case "ilobjectcopygui":
502 $this->prepareOutput();
503 $cp = new ilObjectCopyGUI($this);
504 $cp->setType("blog");
505 $this->ctrl->forwardCommand($cp);
506 break;
507
508 case 'ilrepositorysearchgui':
509 $this->prepareOutput();
510 $ilTabs->activateTab("contributors");
511 $rep_search = new ilRepositorySearchGUI();
512 $rep_search->setTitle($this->lng->txt("blog_add_contributor"));
513 $rep_search->setCallback($this, 'addContributor', $this->object->getAllLocalRoles($this->node_id));
514 $this->ctrl->setReturn($this, 'contributors');
515 $this->ctrl->forwardCommand($rep_search);
516 break;
517
518 case 'ilexportgui':
519 $this->showExportGUI();
520 break;
521
522 case "ilobjectcontentstylesettingsgui":
523 $this->checkPermission("write");
524 $this->prepareOutput();
525 $this->addHeaderAction();
526 $ilTabs->activateTab("settings");
527 $this->setSettingsSubTabs("style");
528
529
530 if ($this->id_type === self::REPOSITORY_NODE_ID) {
531 $settings_gui = $this->content_style_gui
532 ->objectSettingsGUIForRefId(
533 null,
534 $this->object->getRefId()
535 );
536 } else {
537 $settings_gui = $this->content_style_gui
538 ->objectSettingsGUIForObjId(
539 null,
540 $this->object->getId()
541 );
542 }
543 $this->ctrl->forwardCommand($settings_gui);
544 break;
545
546
547 case "ilblogexercisegui":
548 $this->ctrl->setReturn($this, "render");
549 $gui = $this->gui->exercise()->ilBlogExerciseGUI($this->node_id);
550 $this->ctrl->forwardCommand($gui);
551 break;
552
553 case 'ilobjnotificationsettingsgui':
554 $this->prepareOutput();
555 $ilTabs->activateTab("settings");
556 $this->setSettingsSubTabs("notifications");
557 $gui = new ilObjNotificationSettingsGUI($this->object->getRefId());
558 $this->ctrl->forwardCommand($gui);
559 break;
560
561 case strtolower(ilObjectMetaDataGUI::class):
562 $this->checkPermission("write");
563 $this->prepareOutput();
564 $ilTabs->activateTab("meta_data");
565 $gui = new ilObjectMetaDataGUI($this->object, null, null, $this->call_by_reference);
566 $this->ctrl->forwardCommand($gui);
567 break;
568
569 case strtolower(SettingsGUI::class):
570 $this->checkPermission("write");
571 $this->prepareOutput();
572 $ilTabs->activateTab("settings");
573 $this->setSettingsSubTabs("properties");
574 $gui = $this->gui->settings()->settingsGUI(
575 $this->obj_id,
576 $this->id_type === self::REPOSITORY_NODE_ID
577 );
578 $this->ctrl->forwardCommand($gui);
579 break;
580
581 case strtolower(\ILIAS\Blog\Settings\BlockSettingsGUI::class):
582 $this->checkPermission("write");
583 $this->prepareOutput();
584 $ilTabs->activateTab("settings");
585 $this->setSettingsSubTabs("side_blocks");
586 $gui = $this->gui->settings()->blockSettingsGUI(
587 $this->obj_id,
588 $this->id_type === self::REPOSITORY_NODE_ID
589 );
590 $this->ctrl->forwardCommand($gui);
591 break;
592
593 default:
594 if ($cmd !== "gethtml") {
595 // desktop item handling, must be toggled before header action
596 if ($cmd === "addToDesk" || $cmd === "removeFromDesk") {
597 $this->{$cmd . "Object"}();
598 if ($this->prvm) {
599 $cmd = "preview";
600 } else {
601 $cmd = "render";
602 }
603 // $ilCtrl->setCmd($cmd);
604 }
605 $this->addHeaderActionForCommand($cmd);
606 }
607 parent::executeCommand();
608 }
609 }
610
611 protected function showExportGUI(): void
612 {
613 $this->prepareOutput();
614 $this->tabs->activateTab("export");
615 $exp_gui = new ilExportGUI($this);
616 $this->ctrl->forwardCommand($exp_gui);
617 }
618
619 protected function createExportFileWithComments(): void
620 {
621 $this->buildExportFile(true);
622 $this->prepareOutput();
623 $this->tabs->activateTab("export");
624 $this->ctrl->redirectByClass(ilExportGUI::class, ilExportGUI::CMD_LIST_EXPORT_FILES);
625 }
626
627 protected function createExportFile(): void
628 {
629 $this->buildExportFile();
630 $this->prepareOutput();
631 $this->tabs->activateTab("export");
632 $this->ctrl->redirectByClass(ilExportGUI::class, ilExportGUI::CMD_LIST_EXPORT_FILES);
633 }
634
635 protected function triggerAssignmentTool(): void
636 {
637 $be = $this->domain->exercise($this->node_id);
638 $be_gui = $this->gui->exercise()->ilBlogExerciseGUI($this->node_id);
639 $assignments = $be->getAssignmentsOfBlog();
640 if (count($assignments) > 0) {
641 $ass_ids = array_map(static function ($i) {
642 return $i["ass_id"];
643 }, $assignments);
644 $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO, true);
645 $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_IDS, $ass_ids);
646 $this->tool_context->current()->addAdditionalData(
648 $be_gui->getActionButtons()
649 );
650 }
651 }
652
656 public function infoScreen(): void
657 {
658 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
659 }
660
661 public function infoScreenForward(): void
662 {
663 $ilTabs = $this->tabs;
664
665 $ilTabs->activateTab("id_info");
666
667 $this->checkPermission("visible");
668
669 $info = new ilInfoScreenGUI($this);
670
671 if ($this->id_type !== self::WORKSPACE_NODE_ID) {
672 $info->enablePrivateNotes();
673 }
674
675 if ($this->checkPermissionBool("read")) {
676 $info->enableNews();
677 }
678
679 // no news editing for files, just notifications
680 $info->enableNewsEditing(false);
681 if ($this->checkPermissionBool("write")) {
682 $news_set = new ilSetting("news");
683 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
684
685 if ($enable_internal_rss) {
686 $info->setBlockProperty("news", "settings", "1");
687 $info->setBlockProperty("news", "public_notifications_option", "1");
688 }
689 }
690
691 // standard meta data
692 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
693
694 $this->ctrl->forwardCommand($info);
695 }
696
700 public function createPosting(): void
701 {
702 $ilCtrl = $this->ctrl;
703 $ilUser = $this->user;
704
705 $title = $this->blog_request->getTitle();
706 if ($title) {
707 // create new posting
708 $posting = new ilBlogPosting();
709 $posting->setTitle($title);
710 $posting->setBlogId($this->object->getId());
711 $posting->setActive(false);
712 $posting->setAuthor($ilUser->getId());
713 $posting->create(false);
714
715 // switch month list to current month (will include new posting)
716 $ilCtrl->setParameter($this, "bmn", date("Y-m"));
717
718 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $posting->getId());
719 $ilCtrl->redirectByClass("ilblogpostinggui", "edit");
720 } else {
721 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_title"), true);
722 $ilCtrl->redirect($this, "render");
723 }
724 }
725
729 public function render(): void
730 {
732 $ilTabs = $this->tabs;
733 $ilCtrl = $this->ctrl;
735 $ilToolbar = new ilToolbarGUI();
736
737 if (!$this->checkPermissionBool("read")) {
738 $this->tpl->setOnScreenMessage('info', $lng->txt("no_permission"));
739 return;
740 }
741
742 $ilTabs->activateTab("content");
743
744 // toolbar
745 if ($this->perm->mayContribute()) {
746 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "createPosting"));
747
748 $title = new ilTextInputGUI($lng->txt("title"), "title");
749 $title->setSize(30);
750 $ilToolbar->addStickyItem($title, true);
752 document.getElementById('title').setAttribute('data-blog-input', 'posting-title');
753 document.getElementById('title').setAttribute('placeholder', ' ');
754 ");
755
756 $this->gui->button(
757 $lng->txt("blog_add_posting"),
758 "createPosting"
759 )->submit()->toToolbar(true, $ilToolbar);
760
761 // #18763
762 $keys = array_keys($this->items);
763 $first = array_shift($keys);
764 if ($first != $this->month) {
765 $ilToolbar->addSeparator();
766
767 $ilCtrl->setParameter($this, "bmn", $first);
768 $url = $ilCtrl->getLinkTarget($this, "");
769 $ilCtrl->setParameter($this, "bmn", $this->month);
770
771 $this->gui->link(
772 $lng->txt("blog_show_latest"),
773 $url
774 )->emphasised()->toToolbar(true, $ilToolbar);
775 }
776
777 // print/pdf
778 $print_view = $this->getPrintView();
779 $modal_elements = $print_view->getModalElements(
780 $this->ctrl->getLinkTarget(
781 $this,
782 "printViewSelection"
783 )
784 );
785 $ilToolbar->addSeparator();
786 $ilToolbar->addComponent($modal_elements->button);
787 $ilToolbar->addComponent($modal_elements->modal);
788 }
789
790 // $is_owner = ($this->object->getOwner() == $ilUser->getId());
791 $is_owner = $this->perm->mayContribute();
792
793 $list_items = $this->getListItems($is_owner);
794
795 $list = $nav = "";
796 if ($list_items) {
797 $list = $this->renderList($list_items, "preview", "", $is_owner);
798 $nav = $this->renderNavigation("render", "edit", "", $is_owner);
799 }
800
801 $this->setContentStyleSheet();
802
803 $tpl->setContent($ilToolbar->getHTML() . $list);
804 $tpl->setRightContent($nav);
805 }
806
807
811 protected function getListItems(
812 bool $a_show_inactive = false
813 ): array {
814 if ($this->author) {
815 $list_items = array();
816 foreach ($this->items as $month => $items) {
817 foreach ($items as $id => $item) {
818 if ($item["author"] == $this->author ||
819 (isset($item["editors"]) && in_array($this->author, $item["editors"]))) {
820 $list_items[$id] = $item;
821 }
822 }
823 }
824 } elseif ($this->keyword) {
825 $list_items = $this->filterItemsByKeyword($this->items, $this->keyword);
826 } else {
827 $max = $this->blog_settings->getOverviewPostings();
828 if ($this->month_default && $max) {
829 $list_items = array();
830 foreach ($this->items as $month => $postings) {
831 foreach ($postings as $id => $item) {
832 if (!$a_show_inactive &&
834 continue;
835 }
836 $list_items[$id] = $item;
837
838 if (count($list_items) >= $max) {
839 break(2);
840 }
841 }
842 }
843 } else {
844 $list_items = $this->items[$this->month] ?? [];
845 }
846 }
847 return $list_items;
848 }
849
853 public function preview(): void
854 {
856 $toolbar = $this->toolbar;
857
858 if (!$this->checkPermissionBool("read")) {
859 $this->tpl->setOnScreenMessage('info', $lng->txt("no_permission"));
860 return;
861 }
862
863 $this->filterInactivePostings();
864
865 $list_items = $this->getListItems();
866
867 $list = $nav = "";
868 if ($list_items) {
869 $list = $this->renderList($list_items, "previewFullscreen");
870 $nav = $this->renderNavigation("preview", "previewFullscreen");
871 $this->renderToolbarNavigation($this->items);
872 }
873
874 $this->renderFullScreen($list, $nav);
875 }
876
880 public function export(
881 bool $a_with_comments = false
882 ): void {
883 $zip = $this->buildExportFile($a_with_comments);
884 ilFileDelivery::deliverFileLegacy($zip, $this->object->getTitle() . ".zip", '', false, true);
885 }
886
887
888 // --- helper functions
889
893 public function renderFullScreen(
894 string $a_content,
895 string $a_navigation
896 ): void {
897 $tpl = $this->tpl;
898 $ilUser = $this->user;
899 $ilTabs = $this->tabs;
900 $ilLocator = $this->locator;
901
902 $owner = $this->object->getOwner();
903
904 $ilTabs->clearTargets();
905 $tpl->setLocator();
906
907 $back_caption = "";
908 $back = "";
909
910 // back (edit)
911 if ($owner === $ilUser->getId()) {
912 // from shared/deeplink
913 if ($this->id_type === self::WORKSPACE_NODE_ID) {
914 $back = "ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace&wsp_id=" . $this->node_id;
915 }
916 // from editor (#10073)
917 elseif ($this->perm->mayContribute()) {
918 $this->ctrl->setParameter($this, "prvm", "");
919 if ($this->blpg === 0) {
920 $back = $this->ctrl->getLinkTarget($this, "");
921 } else {
922 $this->ctrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
923 $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $this->blpg);
924 $back = $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "preview");
925 }
926 $this->ctrl->setParameter($this, "prvm", $this->prvm);
927 }
928
929 $back_caption = $this->lng->txt("blog_back_to_blog_owner");
930 }
931 // back
932 elseif ($ilUser->getId() && $ilUser->getId() !== ANONYMOUS_USER_ID) {
933 // workspace (always shared)
934 if ($this->id_type === self::WORKSPACE_NODE_ID) {
935 $back = "ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace&dsh=" . $owner;
936 }
937 // contributor
938 elseif ($this->perm->mayContribute()) {
939 $back = $this->ctrl->getLinkTarget($this, "");
940 $back_caption = $this->lng->txt("blog_back_to_blog_owner");
941 }
942 // listgui / parent container
943 else {
944 $tree = $this->tree;
945 $parent_id = $tree->getParentId($this->node_id);
946 $back = ilLink::_getStaticLink($parent_id);
947 }
948 }
949
950 $this->renderFullscreenHeader($tpl, $owner);
951
952 // #13564
953 $this->ctrl->setParameter($this, "bmn", "");
954 //$tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
955 $this->ctrl->setParameter($this, "bmn", $this->month);
956
957 $this->setContentStyleSheet();
958
959 // content
960 $tpl->setContent($a_content);
961 $tpl->setRightContent($a_navigation);
962 }
963
964 public function renderFullscreenHeader(
966 int $a_user_id,
967 bool $a_export = false
968 ): void {
969 $ilUser = $this->user;
970
971 if (!$a_export) {
973 $this->object->getType(),
974 $this->node_id,
975 $this->object->getId(),
976 $ilUser->getId()
977 );
978 }
979
980 // repository blogs are multi-author
981 $name = "";
982 if ($this->id_type !== self::REPOSITORY_NODE_ID) {
983 $name = ilObjUser::_lookupName($a_user_id);
984 $name = $name["lastname"] . ", " . $name["firstname"];
985 }
986
987 $ppic = "";
988 if ($this->blog_settings?->getProfilePicture() && !$a_export) {
989 // repository (multi-user)
990 if ($this->id_type === self::REPOSITORY_NODE_ID) {
991 // #15030
992 if ($this->blpg > 0 && !$a_export) {
993 $post = new ilBlogPosting($this->blpg);
994 $author_id = $post->getAuthor();
995 if ($author_id) {
996 $ppic = $this->profile_gui->getPicturePath($author_id);
997 $name = $this->profile_gui->getNamePresentation($author_id);
998 //$name = $name["lastname"] . ", " . $name["firstname"];
999 }
1000 }
1001 }
1002 // workspace (author == owner)
1003 else {
1004 $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
1005 if ($a_export) {
1006 $ppic = basename($ppic);
1007 }
1008 }
1009 } else {
1010 $ppic = ilUtil::getImagePath("standard/icon_blog.svg");
1011 }
1012 $a_tpl->resetHeaderBlock(false);
1013 $a_tpl->setTitleIcon($ppic);
1014 $a_tpl->setTitle($this->object->getTitle());
1015 if ($this->id_type === self::REPOSITORY_NODE_ID) {
1016 $a_tpl->setDescription($this->object->getDescription());
1017 } else {
1018 $a_tpl->setDescription($name);
1019 }
1020 }
1021
1025 protected function buildPostingList(
1026 int $a_obj_id
1027 ): array {
1028 $author_found = false;
1029
1030 $items = array();
1031 foreach (ilBlogPosting::getAllPostings($a_obj_id) as $posting) {
1032 if ($this->author &&
1033 ($posting["author"] == $this->author ||
1034 (is_array($posting["editors"] ?? false) && in_array($this->author, $posting["editors"])))) {
1035 $author_found = true;
1036 }
1037
1038 $month = substr($posting["created"]->get(IL_CAL_DATE), 0, 7);
1039 $items[$month][$posting["id"]] = $posting;
1040 }
1041
1042 if ($this->author && !$author_found) {
1043 $this->author = null;
1044 }
1045
1046 return $items;
1047 }
1048
1052 public function renderList(
1053 array $items,
1054 string $a_cmd = "preview",
1055 string $a_link_template = "",
1056 bool $a_show_inactive = false,
1057 string $a_export_directory = ""
1058 ): string {
1059 $lng = $this->lng;
1060 $ilCtrl = $this->ctrl;
1061 $ilUser = $this->user;
1062 $ui_factory = $this->ui->factory();
1063 $ui_renderer = $this->ui->renderer();
1064
1065 $wtpl = new ilTemplate("tpl.blog_list.html", true, true, "components/ILIAS/Blog");
1066
1067 $is_admin = $this->perm->canManage();
1068
1069 $last_month = null;
1070 $is_empty = true;
1071 foreach ($items as $item) {
1072 // only published items
1073 $is_active = ilBlogPosting::_lookupActive($item["id"], "blp");
1074 if (!$is_active && !$a_show_inactive) {
1075 continue;
1076 }
1077
1078 $is_empty = false;
1079
1080 $month = "";
1081 if (!$this->keyword && !$this->author) {
1082 $month = substr($item["created"]->get(IL_CAL_DATE), 0, 7);
1083 }
1084
1085 if (!$last_month || $last_month != $month) {
1086 if ($last_month) {
1087 $wtpl->setCurrentBlock("month_bl");
1088 $wtpl->parseCurrentBlock();
1089 }
1090
1091 // title according to current "filter"/navigation
1092 if ($this->keyword) {
1093 $title = $lng->txt("blog_keyword") . ": " . $this->keyword;
1094 } elseif ($this->author) {
1095 $title = $lng->txt("blog_author") . ": " . $this->profile_gui->getNamePresentation($this->author);
1096 } else {
1097 $title = $this->gui->presentation()->util()->getMonthPresentation($month);
1098 $last_month = $month;
1099 }
1100
1101 $wtpl->setVariable("TXT_CURRENT_MONTH", $title);
1102 }
1103
1104 if (!$a_link_template) {
1105 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1106 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $item["id"]);
1107 $preview = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_cmd);
1108 } else {
1109 $preview = $this->buildExportLink($a_link_template, "posting", (string) $item["id"]);
1110 }
1111 $more_link = $preview;
1112
1113 // actions
1114 $posting_edit = $this->perm->mayEditPosting($item["id"], $item["author"]);
1115 if (($posting_edit || $is_admin) && !$a_link_template && $a_cmd === "preview") {
1116 $actions = [];
1117
1118 if ($is_active && $this->blog_settings->getApproval() && !$item["approved"]) {
1119 if ($is_admin) {
1120 $ilCtrl->setParameter($this, "apid", $item["id"]);
1121 $actions[] = $ui_factory->link()->standard(
1122 $lng->txt("blog_approve"),
1123 $ilCtrl->getLinkTarget($this, "approve")
1124 );
1125 $ilCtrl->setParameter($this, "apid", "");
1126 }
1127
1128 $wtpl->setVariable("APPROVAL", $lng->txt("blog_needs_approval"));
1129 }
1130
1131 if ($posting_edit) {
1132 $actions[] = $ui_factory->link()->standard(
1133 $lng->txt("edit_content"),
1134 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit")
1135 );
1136 $more_link = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit");
1137
1138 // #11858
1139 if ($is_active) {
1140 $actions[] = $ui_factory->link()->standard(
1141 $lng->txt("blog_toggle_draft"),
1142 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deactivatePageToList")
1143 );
1144 } else {
1145 $actions[] = $ui_factory->link()->standard(
1146 $lng->txt("blog_toggle_final"),
1147 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "activatePageToList")
1148 );
1149 }
1150
1151 $actions[] = $ui_factory->link()->standard(
1152 $lng->txt("rename"),
1153 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edittitle")
1154 );
1155
1156 if ($this->blog_settings->getKeywords()) { // #13616
1157 $actions[] = $ui_factory->link()->standard(
1158 $lng->txt("blog_edit_keywords"),
1159 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords")
1160 );
1161 }
1162
1163 $actions[] = $ui_factory->link()->standard(
1164 $lng->txt("blog_edit_date"),
1165 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editdate")
1166 );
1167
1168 $actions[] = $ui_factory->link()->standard(
1169 $lng->txt("delete"),
1170 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen")
1171 );
1172 } elseif ($is_admin) {
1173 // #10513
1174 if ($is_active) {
1175 $ilCtrl->setParameter($this, "apid", $item["id"]);
1176 $actions[] = $ui_factory->link()->standard(
1177 $lng->txt("blog_toggle_draft_admin"),
1178 $ilCtrl->getLinkTarget($this, "deactivateAdmin")
1179 );
1180 $ilCtrl->setParameter($this, "apid", "");
1181 }
1182
1183 $actions[] = $ui_factory->link()->standard(
1184 $lng->txt("delete"),
1185 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen")
1186 );
1187 }
1188
1189 $dd = $ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt("actions"));
1190
1191 $wtpl->setCurrentBlock("actions");
1192 $wtpl->setVariable("ACTION_SELECTOR", $ui_renderer->render($dd));
1193 $wtpl->parseCurrentBlock();
1194 }
1195
1196 // comments
1197 if ($this->object->getNotesStatus() && !$a_link_template && !$this->disable_notes) {
1198 // count (public) notes
1199 $notes_context = $this->notes
1200 ->data()
1201 ->context(
1202 $this->obj_id,
1203 (int) $item["id"],
1204 "blp"
1205 );
1206 $count = $this->notes
1207 ->domain()
1208 ->getNrOfCommentsForContext($notes_context);
1209
1210 if ($a_cmd !== "preview") {
1211 $wtpl->setCurrentBlock("comments");
1212 $wtpl->setVariable("TEXT_COMMENTS", $lng->txt("blog_comments"));
1213 $wtpl->setVariable("URL_COMMENTS", $preview);
1214 $wtpl->setVariable("COUNT_COMMENTS", $count);
1215 $wtpl->parseCurrentBlock();
1216 }
1217 }
1218
1219 // permanent link
1220 if ($this->node_id !== null &&
1221 $a_cmd !== "preview") {
1222 if ($this->id_type === self::WORKSPACE_NODE_ID) {
1223 $goto = $this->gui->permanentLink(0, (int) $this->node_id)->getPermanentLink((int) $item["id"]);
1224 } else {
1225 $goto = $this->gui->permanentLink((int) $this->node_id)->getPermanentLink((int) $item["id"]);
1226 }
1227 $wtpl->setCurrentBlock("permalink");
1228 $wtpl->setVariable("URL_PERMALINK", $goto);
1229 $wtpl->setVariable("TEXT_PERMALINK", $lng->txt("blog_link"));
1230 $wtpl->parseCurrentBlock();
1231 }
1232
1234 $item["id"],
1235 $this->blog_settings->getAbstractShorten(),
1236 $this->blog_settings->getAbstractShortenLength(),
1237 "&hellip;",
1238 $this->blog_settings->getAbstractImage(),
1239 $this->blog_settings->getAbstractImageWidth(),
1240 $this->blog_settings->getAbstractImageHeight(),
1241 $a_export_directory
1242 );
1243
1244 if ($snippet) {
1245 $wtpl->setCurrentBlock("more");
1246 $wtpl->setVariable("URL_MORE", $more_link);
1247 $wtpl->setVariable("TEXT_MORE", $lng->txt("blog_list_more"));
1248 $wtpl->parseCurrentBlock();
1249 }
1250
1251
1252
1253 if (!$is_active) {
1254 $wtpl->setCurrentBlock("draft_text");
1255 $wtpl->setVariable("DRAFT_TEXT", $lng->txt("blog_draft_text"));
1256 $wtpl->parseCurrentBlock();
1257 $wtpl->setVariable("DRAFT_CLASS", " ilBlogListItemDraft");
1258 }
1259
1260 // reading time
1261 $reading_time = $this->reading_time_manager->getReadingTime(
1262 $this->object->getId(),
1263 $item["id"]
1264 );
1265 if (!is_null($reading_time)) {
1266 $this->lng->loadLanguageModule("copg");
1267 $wtpl->setCurrentBlock("reading_time");
1268 $wtpl->setVariable(
1269 "READING_TIME",
1270 $this->lng->txt("copg_est_reading_time") . ": " .
1271 sprintf($this->lng->txt("copg_x_minutes"), $reading_time)
1272 );
1273 $wtpl->parseCurrentBlock();
1274 }
1275
1276 $wtpl->setCurrentBlock("posting");
1277
1278 $author = "";
1279 if ($this->id_type === self::REPOSITORY_NODE_ID) {
1280 $authors = array();
1281
1282 $author_id = $item["author"];
1283 if ($author_id) {
1284 $authors[] = $this->profile_gui->getNamePresentation($author_id);
1285 }
1286
1287 if (isset($item["editors"])) {
1288 foreach ($item["editors"] as $editor_id) {
1289 $authors[] = $this->profile_gui->getNamePresentation($editor_id);
1290 }
1291 }
1292
1293 if ($authors) {
1294 $author = implode(", ", $authors) . " - ";
1295 }
1296 }
1297
1298 // title
1299 $wtpl->setVariable("URL_TITLE", $preview);
1300 $wtpl->setVariable("TITLE", $item["title"]);
1301
1302 $kw = ilBlogPosting::getKeywords($this->obj_id, $item["id"]);
1303 natcasesort($kw);
1304 $keywords = (count($kw) > 0)
1305 ? "<br>" . $this->lng->txt("keywords") . ": " . implode(", ", $kw)
1306 : "";
1307
1308 $wtpl->setVariable("DATETIME", $author .
1309 ilDatePresentation::formatDate($item["created"]) . $keywords);
1310
1311 // content
1312 $wtpl->setVariable("CONTENT", $snippet);
1313
1314 $wtpl->parseCurrentBlock();
1315 }
1316
1317 // permalink
1318 if ($a_cmd === "previewFullscreen") {
1319 $ref_id = ($this->id_type === self::WORKSPACE_NODE_ID)
1320 ? 0
1321 : $this->node_id;
1322 $wsp_id = ($this->id_type === self::WORKSPACE_NODE_ID)
1323 ? $this->node_id
1324 : 0;
1325 $this->gui->permanentLink($ref_id, $wsp_id)->setPermanentLink();
1326 }
1327
1328 if (!$is_empty || $a_show_inactive) {
1329 return $wtpl->get();
1330 }
1331 return "";
1332 }
1333
1337 protected function buildExportLink(
1338 string $a_template,
1339 string $a_type,
1340 string $a_id
1341 ): string {
1342 return BlogHtmlExport::buildExportLink($a_template, $a_type, $a_id, $this->getKeywords(false));
1343 }
1344
1345
1349 protected function renderNavigationByDate(
1350 array $a_items,
1351 string $a_list_cmd = "render",
1352 string $a_posting_cmd = "preview",
1353 ?string $a_link_template = null,
1354 bool $a_show_inactive = false,
1355 int $a_blpg = 0
1356 ): string {
1357 $ilCtrl = $this->ctrl;
1358
1359 $blpg = ($a_blpg > 0)
1360 ? $a_blpg
1361 : $this->blpg;
1362
1363
1364 // gather page active status
1365 foreach ($a_items as $month => $postings) {
1366 foreach (array_keys($postings) as $id) {
1367 $active = ilBlogPosting::_lookupActive($id, "blp");
1368 if (!$a_show_inactive && !$active) {
1369 unset($a_items[$month][$id]);
1370 } else {
1371 $a_items[$month][$id]["active"] = $active;
1372 }
1373 }
1374 if (!count($a_items[$month])) {
1375 unset($a_items[$month]);
1376 }
1377 }
1378
1379 // list month (incl. postings)
1380 if ($this->blog_settings->getNavMode() === ilObjBlog::NAV_MODE_LIST || $a_link_template) {
1381 $max_months = $this->blog_settings->getNavModeListMonths();
1382
1383 $wtpl = new ilTemplate("tpl.blog_list_navigation_by_date.html", true, true, "components/ILIAS/Blog");
1384
1385 $ilCtrl->setParameter($this, "blpg", "");
1386
1387 $counter = $mon_counter = $last_year = 0;
1388 foreach ($a_items as $month => $postings) {
1389 if (!$a_link_template && $max_months && $mon_counter >= $max_months) {
1390 break;
1391 }
1392
1393 $add_year = false;
1394 $year = substr($month, 0, 4);
1395 if (!$last_year || $year != $last_year) {
1396 // #13562
1397 $add_year = true;
1398 $last_year = $year;
1399 }
1400
1401 $mon_counter++;
1402
1403 $month_name = ilCalendarUtil::_numericMonthToString((int) substr($month, 5));
1404 if (!$a_link_template) {
1405 $ilCtrl->setParameter($this, "bmn", $month);
1406 $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1407 } else {
1408 $month_url = $this->buildExportLink($a_link_template, "list", (string) $month);
1409 }
1410
1411 // list postings for month
1412 //if($counter < $max_detail_postings)
1413 if ($mon_counter <= $this->blog_settings->getNavModeListMonthsWithPostings()) {
1414 if ($add_year) {
1415 $wtpl->setCurrentBlock("navigation_year_details");
1416 $wtpl->setVariable("YEAR", $year);
1417 $wtpl->parseCurrentBlock();
1418 }
1419
1420 foreach ($postings as $id => $posting) {
1421 //if($max_detail_postings && $counter >= $max_detail_postings)
1422 //{
1423 // break;
1424 //}
1425
1426 $counter++;
1427
1428 $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1429 ", ".*/ $posting["title"];
1430
1431 if (!$a_link_template) {
1432 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1433 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1434 $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1435 } else {
1436 $url = $this->buildExportLink($a_link_template, "posting", (string) $id);
1437 }
1438
1439 if (!$posting["active"]) {
1440 $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1441 } elseif ($this->blog_settings->getApproval() && !$posting["approved"]) {
1442 $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1443 }
1444
1445 $wtpl->setCurrentBlock("navigation_item");
1446 $wtpl->setVariable("NAV_ITEM_URL", $url);
1447 $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1448 $wtpl->parseCurrentBlock();
1449 }
1450
1451 $wtpl->setCurrentBlock("navigation_month_details");
1452 $wtpl->setVariable("NAV_MONTH", $month_name);
1453 $wtpl->setVariable("URL_MONTH", $month_url);
1454 }
1455 // summarized month
1456 else {
1457 if ($add_year) {
1458 $wtpl->setCurrentBlock("navigation_year");
1459 $wtpl->setVariable("YEAR", $year);
1460 $wtpl->parseCurrentBlock();
1461 }
1462
1463 $wtpl->setCurrentBlock("navigation_month");
1464 $wtpl->setVariable("MONTH_NAME", $month_name);
1465 $wtpl->setVariable("URL_MONTH", $month_url);
1466 $wtpl->setVariable("MONTH_COUNT", count($postings));
1467 }
1468 $wtpl->parseCurrentBlock();
1469 }
1470 if (!$a_link_template) {
1471 $this->ctrl->setParameterByClass(self::class, "bmn", null);
1472 $url = $this->ctrl->getLinkTargetByClass(self::class, $a_list_cmd);
1473 } else {
1474 $url = "index.html";
1475 }
1476
1477 $wtpl->setVariable(
1478 "STARTING_PAGE",
1479 $this->ui->renderer()->render(
1480 $this->ui->factory()->link()->standard(
1481 $this->lng->txt("blog_starting_page"),
1482 $url
1483 )
1484 )
1485 );
1486 }
1487 // single month
1488 else {
1489 $wtpl = new ilTemplate("tpl.blog_list_navigation_month.html", true, true, "components/ILIAS/Blog");
1490
1491 $ilCtrl->setParameter($this, "blpg", "");
1492
1493 $month_options = array();
1494 foreach ($a_items as $month => $postings) {
1495 $month_name = $this->gui->presentation()->util()->getMonthPresentation($month);
1496
1497 $month_options[$month] = $month_name;
1498
1499 if ($month == $this->month) {
1500 if (!$a_link_template) {
1501 $ilCtrl->setParameter($this, "bmn", $month);
1502 $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1503 } else {
1504 $month_url = $this->buildExportLink($a_link_template, "list", (string) $month);
1505 }
1506
1507 foreach ($postings as $id => $posting) {
1508 $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1509 ", ".*/ $posting["title"];
1510
1511 if (!$a_link_template) {
1512 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1513 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1514 $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1515 } else {
1516 $url = $this->buildExportLink($a_link_template, "posting", (string) $id);
1517 }
1518
1519 if (!$posting["active"]) {
1520 $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1521 } elseif ($this->blog_settings->getApproval() && !$posting["approved"]) {
1522 $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1523 }
1524
1525 $wtpl->setCurrentBlock("navigation_item");
1526 $wtpl->setVariable("NAV_ITEM_URL", $url);
1527 $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1528 $wtpl->parseCurrentBlock();
1529 }
1530
1531 $wtpl->setCurrentBlock("navigation_month_details");
1532 if ($blpg > 0) {
1533 $wtpl->setVariable("NAV_MONTH", $month_name);
1534 $wtpl->setVariable("URL_MONTH", $month_url);
1535 }
1536 $wtpl->parseCurrentBlock();
1537 }
1538 }
1539
1540 if ($blpg === 0) {
1541 $wtpl->setCurrentBlock("option_bl");
1542 foreach ($month_options as $value => $caption) {
1543 $wtpl->setVariable("OPTION_VALUE", $value);
1544 $wtpl->setVariable("OPTION_CAPTION", $caption);
1545 if ($value == $this->month) {
1546 $wtpl->setVariable("OPTION_SEL", ' selected="selected"');
1547 }
1548 $wtpl->parseCurrentBlock();
1549 }
1550
1551 $wtpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this, $a_list_cmd));
1552 }
1553 }
1554 $ilCtrl->setParameter($this, "bmn", $this->month);
1555 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
1556 return $wtpl->get();
1557 }
1558
1562 protected function renderNavigationByKeywords(
1563 string $a_list_cmd = "render",
1564 bool $a_show_inactive = false,
1565 string $a_link_template = "",
1566 int $a_blpg = 0
1567 ): string {
1568 $ilCtrl = $this->ctrl;
1569
1570 $blpg = ($a_blpg > 0)
1571 ? $a_blpg
1572 : $this->blpg;
1573
1574 $keywords = $this->getKeywords($a_show_inactive, $blpg);
1575 if ($keywords) {
1576 $wtpl = new ilTemplate("tpl.blog_list_navigation_keywords.html", true, true, "components/ILIAS/Blog");
1577
1578 $max = max($keywords);
1579
1580 $wtpl->setCurrentBlock("keyword");
1581 foreach ($keywords as $keyword => $counter) {
1582 if (!$a_link_template) {
1583 $ilCtrl->setParameter($this, "kwd", urlencode((string) $keyword)); // #15885
1584 $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1585 $ilCtrl->setParameter($this, "kwd", "");
1586 } else {
1587 $url = $this->buildExportLink($a_link_template, "keyword", (string) $keyword);
1588 }
1589
1590 $wtpl->setVariable("TXT_KEYWORD", $keyword);
1591 $wtpl->setVariable("CLASS_KEYWORD", ilTagging::getRelevanceClass($counter, $max));
1592 $wtpl->setVariable("URL_KEYWORD", $url);
1593 $wtpl->parseCurrentBlock();
1594 }
1595
1596 return $wtpl->get();
1597 }
1598 return "";
1599 }
1600
1601 protected function renderNavigationByAuthors(
1602 array $a_items,
1603 string $a_list_cmd = "render",
1604 bool $a_show_inactive = false
1605 ): string {
1606 $ilCtrl = $this->ctrl;
1607
1608 $authors = array();
1609 foreach ($a_items as $month => $items) {
1610 foreach ($items as $item) {
1611 if (($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp"))) {
1612 if ($item["author"]) {
1613 $authors[] = $item["author"];
1614 }
1615
1616 if (isset($item["editors"])) {
1617 foreach ($item["editors"] as $editor_id) {
1618 if ($editor_id != $item["author"]) {
1619 $authors[] = $editor_id;
1620 }
1621 }
1622 }
1623 }
1624 }
1625 }
1626
1627 $authors = array_unique($authors);
1628
1629 // filter out deleted users
1630 $authors = array_filter($authors, function ($id) {
1631 return ilObject::_lookupType($id) == "usr";
1632 });
1633
1634 if (count($authors) > 1) {
1635 $list = array();
1636 foreach ($authors as $user_id) {
1637 if ($user_id) {
1638 $ilCtrl->setParameter($this, "ath", $user_id);
1639 $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1640 $ilCtrl->setParameter($this, "ath", "");
1641
1643 if (substr($base_name, 0, 1) == "[") {
1645 $sort = $name;
1646 } else {
1648 $user_id,
1649 true,
1650 false,
1651 "",
1652 false,
1653 true,
1654 false
1655 );
1656 $name_arr = ilObjUser::_lookupName($user_id);
1657 $sort = $name_arr["lastname"] . " " . $name_arr["firstname"];
1658 }
1659
1660 $idx = trim(strip_tags($sort)) . "///" . $user_id; // #10934
1661 $list[$idx] = array($name, $url);
1662 }
1663 }
1664 ksort($list);
1665
1666 $wtpl = new ilTemplate("tpl.blog_list_navigation_authors.html", true, true, "components/ILIAS/Blog");
1667
1668 $wtpl->setCurrentBlock("author");
1669 foreach ($list as $author) {
1670 $wtpl->setVariable("TXT_AUTHOR", $author[0]);
1671 $wtpl->setVariable("URL_AUTHOR", $author[1]);
1672 $wtpl->parseCurrentBlock();
1673 }
1674
1675 return $wtpl->get();
1676 }
1677 return "";
1678 }
1679
1684 array $a_items,
1685 bool $single_posting = false
1686 ): void {
1687 $nav_renderer = $this->gui->navigation()->toolbarNavigationRenderer();
1688 $nav_renderer->renderToolbarNavigation(
1689 $this->perm,
1690 $a_items,
1691 $this->blpg,
1692 $single_posting,
1693 $this->month,
1694 $this->user_page
1695 );
1696 }
1697
1701 public function renderNavigation(
1702 string $a_list_cmd = "render",
1703 string $a_posting_cmd = "preview",
1704 ?string $a_link_template = null,
1705 bool $a_show_inactive = false,
1706 int $a_blpg = 0
1707 ): string {
1708 $ilSetting = $this->settings;
1709 $a_items = $this->items;
1710 $blpg = ($a_blpg > 0)
1711 ? $a_blpg
1712 : $this->blpg;
1713
1714 if ($this->blog_settings->getOrder()) {
1715 $order = array_flip($this->blog_settings->getOrder());
1716 } else {
1717 $order = array(
1718 "navigation" => 0
1719 ,"keywords" => 2
1720 ,"authors" => 1
1721 );
1722 }
1723
1724 $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true, "components/ILIAS/Blog");
1725
1726 $blocks = array();
1727
1728 // by date
1729 if (count($a_items)) {
1730 $blocks[$order["navigation"]] = array(
1731 $this->lng->txt("blog_navigation"),
1732 $this->renderNavigationByDate($a_items, $a_list_cmd, $a_posting_cmd, $a_link_template, $a_show_inactive, $a_blpg)
1733 );
1734 }
1735
1736 if ($this->blog_settings->getKeywords()) {
1737 // keywords
1738 $may_edit_keywords = ($blpg > 0 &&
1739 $this->perm->mayEditPosting($blpg) &&
1740 $a_list_cmd !== "preview" &&
1741 $a_list_cmd !== "gethtml" &&
1742 !$a_link_template);
1743 $keywords = $this->renderNavigationByKeywords($a_list_cmd, $a_show_inactive, (string) $a_link_template, $a_blpg);
1744 if ($keywords || $may_edit_keywords) {
1745 if (!$keywords) {
1746 $keywords = $this->lng->txt("blog_no_keywords");
1747 }
1748 $cmd = null;
1749 $blocks[$order["keywords"]] = array(
1750 $this->lng->txt("blog_keywords"),
1751 $keywords,
1752 $cmd
1753 ? array($cmd, $this->lng->txt("blog_edit_keywords"))
1754 : null
1755 );
1756 }
1757 }
1758
1759 // is not part of (html) export
1760 if (!$a_link_template) {
1761 // authors
1762 if ($this->id_type === self::REPOSITORY_NODE_ID &&
1763 $this->blog_settings->getAuthors()) {
1764 $authors = $this->renderNavigationByAuthors($a_items, $a_list_cmd, $a_show_inactive);
1765 if ($authors) {
1766 $blocks[$order["authors"]] = array($this->lng->txt("blog_authors"), $authors);
1767 }
1768 }
1769
1770 // rss
1771 if ($this->blog_settings->getRSS() &&
1772 $ilSetting->get('enable_global_profiles') &&
1773 $a_list_cmd === "preview") {
1774 // #10827
1775 $blog_id = $this->node_id;
1776 if ($this->id_type !== self::WORKSPACE_NODE_ID) {
1777 $blog_id .= "_cll";
1778 }
1779 $url = ILIAS_HTTP_PATH . "/feed.php?blog_id=" . $blog_id .
1780 "&client_id=" . rawurlencode(CLIENT_ID);
1781
1782 $wtpl->setVariable("RSS_BUTTON", ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_RSS, $url));
1783 }
1784 }
1785
1786 if (count($blocks)) {
1787 global $DIC;
1788
1789 $ui_factory = $DIC->ui()->factory();
1790 $ui_renderer = $DIC->ui()->renderer();
1791
1792 ksort($blocks);
1793 foreach ($blocks as $block) {
1794 $title = $block[0];
1795
1796 $content = $block[1];
1797
1798 $secondary_panel = $ui_factory->panel()->secondary()->legacy($title, $ui_factory->legacy()->content($content));
1799
1800 if (isset($block[2]) && is_array($block[2])) {
1801 $link = $ui_factory->button()->shy($block[2][1], $block[2][0]);
1802 $secondary_panel = $secondary_panel->withFooter($link);
1803 }
1804
1805 $wtpl->setCurrentBlock("block_bl");
1806 $wtpl->setVariable("BLOCK", $ui_renderer->render($secondary_panel));
1807 $wtpl->parseCurrentBlock();
1808 }
1809 }
1810
1811 return $wtpl->get();
1812 }
1813
1817 public function getKeywords(
1818 bool $a_show_inactive,
1819 ?int $a_posting_id = null
1820 ): array {
1821 $keywords = array();
1822 if ($a_posting_id) {
1823 foreach (ilBlogPosting::getKeywords($this->obj_id, $a_posting_id) as $keyword) {
1824 if (isset($keywords[$keyword])) {
1825 $keywords[$keyword]++;
1826 } else {
1827 $keywords[$keyword] = 1;
1828 }
1829 }
1830 } else {
1831 foreach ($this->items as $month => $items) {
1832 foreach ($items as $item) {
1833 if ($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp")) {
1834 foreach (ilBlogPosting::getKeywords($this->obj_id, $item["id"]) as $keyword) {
1835 if (isset($keywords[$keyword])) {
1836 $keywords[$keyword]++;
1837 } else {
1838 $keywords[$keyword] = 1;
1839 }
1840 }
1841 }
1842 }
1843 }
1844 }
1845
1846 // #15881
1847 $tmp = array();
1848 foreach ($keywords as $keyword => $counter) {
1849 $tmp[] = array("keyword" => $keyword, "counter" => $counter);
1850 }
1851 $tmp = ilArrayUtil::sortArray($tmp, "keyword", "ASC");
1852
1853 $keywords = array();
1854 foreach ($tmp as $item) {
1855 $keywords[(string) $item["keyword"]] = $item["counter"];
1856 }
1857 return $keywords;
1858 }
1859
1863 public function buildExportFile(
1864 bool $a_include_comments = false,
1865 bool $print_version = false
1866 ): BlogHtmlExport {
1867 $type = "html";
1868 $format = explode("_", $this->blog_request->getFormat());
1869 if (($format[1] ?? "") === "comments" || $a_include_comments) {
1870 $a_include_comments = true;
1871 $type = "html_comments";
1872 }
1873
1874 // create export file
1875 //ilExport::_createExportDirectory($this->object->getId(), $type, "blog");
1876 //$exp_dir = ilExport::_getExportDirectory($this->object->getId(), $type, "blog");
1877
1878 $subdir = $this->object->getType() . "_" . $this->object->getId();
1879 if ($print_version) {
1880 $subdir .= "print";
1881 }
1882
1883 $blog_export = new BlogHtmlExport($this, "", $subdir);
1884 $blog_export->setPrintVersion($print_version);
1885 $blog_export->includeComments($a_include_comments);
1886 $blog_export->exportHTML();
1887 return $blog_export;
1888 }
1889
1890 public function getNotesSubId(): int
1891 {
1892 return $this->blpg;
1893 }
1894
1895 public function disableNotes(bool $a_value = false): void
1896 {
1897 $this->disable_notes = $a_value;
1898 }
1899
1900 protected function addHeaderActionForCommand(
1901 string $a_cmd
1902 ): void {
1903 $ilUser = $this->user;
1904 $ilCtrl = $this->ctrl;
1905 // preview?
1906 if ($a_cmd === "preview" || $a_cmd === "previewFullscreen" || $this->prvm) {
1907 // notification
1908 if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
1909 if (!$this->prvm) {
1910 $ilCtrl->setParameter($this, "prvm", "fsc");
1911 }
1912 $this->insertHeaderAction($this->initHeaderAction(null, null, true));
1913 if (!$this->prvm) {
1914 $ilCtrl->setParameter($this, "prvm", "");
1915 }
1916 }
1917 } else {
1918 $this->addHeaderAction();
1919 }
1920 }
1921
1922 protected function initHeaderAction(
1923 ?string $sub_type = null,
1924 ?int $sub_id = null,
1925 bool $is_preview = false
1926 ): ?ilObjectListGUI {
1927 $ilUser = $this->user;
1928 $ilCtrl = $this->ctrl;
1929 if (!$this->obj_id) {
1930 return null;
1931 }
1932 $sub_type = $sub_id = null;
1933 if ($this->blpg > 0) {
1934 $sub_type = "blp";
1935 $sub_id = $this->blpg;
1936 }
1937
1938 $lg = parent::initHeaderAction($sub_type, $sub_id);
1939 if (!$lg) {
1940 return null;
1941 }
1942 $lg->enableComments(false);
1943 $lg->enableNotes(false);
1944
1945 if ($is_preview) {
1946 if ($this->blpg > 0) {
1947 if (($this->object->getNotesStatus() && !$this->disable_notes)) {
1948 $lg->enableComments(true);
1949 }
1950 $lg->enableNotes(true);
1951 }
1952 $lg->enableTags(false);
1953
1954 if (ilNotification::hasNotification(ilNotification::TYPE_BLOG, $ilUser->getId(), $this->obj_id)) {
1955 $ilCtrl->setParameter($this, "ntf", 1);
1956 $link = $ilCtrl->getLinkTarget($this, "setNotification");
1957 $ilCtrl->setParameter($this, "ntf", "");
1958 if (ilNotification::hasOptOut($this->obj_id)) {
1959 $lg->addCustomCommand($link, "blog_notification_toggle_off");
1960 }
1961
1962 $lg->addHeaderIcon(
1963 "not_icon",
1964 ilUtil::getImagePath("object/notification_on.svg"),
1965 $this->lng->txt("blog_notification_activated")
1966 );
1967 } else {
1968 $ilCtrl->setParameter($this, "ntf", 2);
1969 $link = $ilCtrl->getLinkTarget($this, "setNotification");
1970 $ilCtrl->setParameter($this, "ntf", "");
1971 $lg->addCustomCommand($link, "blog_notification_toggle_on");
1972
1973 $lg->addHeaderIcon(
1974 "not_icon",
1975 ilUtil::getImagePath("object/notification_off.svg"),
1976 $this->lng->txt("blog_notification_deactivated")
1977 );
1978 }
1979
1980 // #11758
1981 if ($this->perm->mayContribute()) {
1982 $ilCtrl->setParameter($this, "prvm", "");
1983
1984 $ilCtrl->setParameter($this, "bmn", "");
1985 $ilCtrl->setParameter($this, "blpg", "");
1986 $link = $ilCtrl->getLinkTarget($this, "");
1987 $ilCtrl->setParameter($this, "blpg", $sub_id);
1988 $ilCtrl->setParameter($this, "bmn", $this->month);
1989 $lg->addCustomCommand($link, "blog_edit"); // #11868
1990
1991 if ($sub_id && $this->perm->mayEditPosting($sub_id)) {
1992 $link = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit");
1993 $lg->addCustomCommand($link, "blog_edit_posting");
1994 }
1995
1996 $ilCtrl->setParameter($this, "prvm", "fsc");
1997 }
1998
1999 $ilCtrl->setParameter($this, "ntf", "");
2000 }
2001
2002 return $lg;
2003 }
2004
2005 protected function setNotification(): void
2006 {
2007 $ilUser = $this->user;
2008 $ilCtrl = $this->ctrl;
2009
2010 switch ($this->ntf) {
2011 case 1:
2012 ilNotification::setNotification(ilNotification::TYPE_BLOG, $ilUser->getId(), $this->obj_id, false);
2013 break;
2014
2015 case 2:
2016 ilNotification::setNotification(ilNotification::TYPE_BLOG, $ilUser->getId(), $this->obj_id, true);
2017 break;
2018 }
2019
2020 $ilCtrl->redirect($this, "preview");
2021 }
2022
2026 public static function lookupSubObjectTitle(
2027 int $a_blog_id,
2028 int $a_posting_id
2029 ): string {
2030 // page might be deleted, so setting halt on errors to false
2031 $post = new ilBlogPosting($a_posting_id);
2032 if ($post->getBlogId() === $a_blog_id) {
2033 return $post->getTitle();
2034 }
2035 return "";
2036 }
2037
2041 protected function filterInactivePostings(): void
2042 {
2043 foreach ($this->items as $month => $postings) {
2044 foreach ($postings as $id => $item) {
2045 if (!ilBlogPosting::_lookupActive($id, "blp")) {
2046 unset($this->items[$month][$id]);
2047 } elseif ($this->blog_settings->getApproval() && !$item["approved"]) {
2048 unset($this->items[$month][$id]);
2049 }
2050 }
2051 if (!count($this->items[$month])) {
2052 unset($this->items[$month]);
2053 }
2054 }
2055
2056 if ($this->items && !isset($this->items[$this->month])) {
2057 $keys = array_keys($this->items);
2058 $this->month = array_shift($keys);
2059 }
2060 }
2061
2062 public function filterItemsByKeyword(
2063 array $a_items,
2064 string $a_keyword
2065 ): array {
2066 $res = [];
2067 foreach ($a_items as $month => $items) {
2068 foreach ($items as $item) {
2069 if (in_array(
2070 $a_keyword,
2071 ilBlogPosting::getKeywords($this->obj_id, $item["id"])
2072 )) {
2073 $res[] = $item;
2074 }
2075 }
2076 }
2077 return $res;
2078 }
2079
2080 protected function addLocatorItems(): void
2081 {
2082 $ilLocator = $this->locator;
2083
2084 if (is_object($this->object)) {
2085 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "preview"), "", $this->node_id);
2086 }
2087 }
2088
2089 public function approve(): void
2090 {
2091 if ($this->perm->canManage() && $this->apid > 0) {
2092 $post = new ilBlogPosting($this->apid);
2093 $post->setApproved(true);
2094 $post->setBlogNodeId($this->node_id, ($this->id_type == self::WORKSPACE_NODE_ID));
2095 $post->update(true, false, true, "new"); // #13434
2096
2097 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
2098 }
2099
2100 $this->ctrl->redirect($this, "render");
2101 }
2102
2103
2104 //
2105 // contributors
2106 //
2107
2108 public function contributors(): void
2109 {
2110 $ilTabs = $this->tabs;
2111 $ilToolbar = $this->toolbar;
2112 $ilCtrl = $this->ctrl;
2113 $lng = $this->lng;
2114 $tpl = $this->tpl;
2115
2116 if (!$this->checkPermissionBool("write")) {
2117 return;
2118 }
2119
2120 $ilTabs->activateTab("contributors");
2121
2122 $local_roles = $this->object->getAllLocalRoles($this->node_id);
2123
2124 // add member
2126 $this,
2127 $ilToolbar,
2128 array(
2129 'auto_complete_name' => $lng->txt('user'),
2130 'submit_name' => $lng->txt('add'),
2131 'add_search' => true,
2132 'add_from_container' => $this->node_id,
2133 'user_type' => $local_roles
2134 ),
2135 true
2136 );
2137
2138 $other_roles = $this->object->getRolesWithContributeOrRedact($this->node_id);
2139 if ($other_roles) {
2140 $this->tpl->setOnScreenMessage('info', sprintf($lng->txt("blog_contribute_other_roles"), implode(", ", $other_roles)));
2141 }
2142
2143 $table = $this->gui->contributor()->contributorTableBuilder(
2144 $this->object->getAllLocalRoles($this->node_id),
2145 $this,
2146 "contributors"
2147 )->getTable();
2148
2149 if ($table->handleCommand()) {
2150 return;
2151 }
2152
2153 $tpl->setContent($table->render());
2154 }
2155
2159 public function addUserFromAutoComplete(): void
2160 {
2161 $lng = $this->lng;
2162
2163 $user_login = $this->blog_request->getUserLogin();
2164 $user_type = $this->blog_request->getUserType();
2165
2166 if (trim($user_login) === '') {
2167 $this->tpl->setOnScreenMessage('failure', $lng->txt('msg_no_search_string'));
2168 $this->contributors();
2169 return;
2170 }
2171 $users = explode(',', $user_login);
2172
2173 $user_ids = array();
2174 foreach ($users as $user) {
2176
2177 if (!$user_id) {
2178 $this->tpl->setOnScreenMessage('failure', $lng->txt('user_not_known'));
2179 $this->contributors();
2180 return;
2181 }
2182
2183 $user_ids[] = (int) $user_id;
2184 }
2185
2186 $this->addContributor($user_ids, $user_type);
2187 }
2188
2192 public function addContributor(
2193 array $a_user_ids = array(),
2194 ?string $a_user_type = null
2195 ): void {
2196 $ilCtrl = $this->ctrl;
2197 $lng = $this->lng;
2198 $rbacreview = $this->rbac_review;
2199 $rbacadmin = $this->rbacadmin;
2200 $a_user_type = (int) $a_user_type;
2201
2202 if (!$this->checkPermissionBool("write")) {
2203 return;
2204 }
2205
2206 if (!count($a_user_ids) || !$a_user_type) {
2207 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"));
2208 $this->contributors();
2209 return;
2210 }
2211
2212 // get contributor role
2213 $local_roles = array_keys($this->object->getAllLocalRoles($this->node_id));
2214 if (!in_array($a_user_type, $local_roles)) {
2215 $this->tpl->setOnScreenMessage('failure', $lng->txt("missing_perm"));
2216 $this->contributors();
2217 return;
2218 }
2219
2220 foreach ($a_user_ids as $user_id) {
2221 $user_id = (int) $user_id;
2222 $a_user_type = (int) $a_user_type;
2223 if (!$rbacreview->isAssigned($user_id, $a_user_type)) {
2224 $rbacadmin->assignUser($a_user_type, $user_id);
2225 }
2226 }
2227
2228 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
2229 $ilCtrl->redirect($this, "contributors");
2230 }
2231
2235 public function confirmRemoveContributor(array $ids = []): void
2236 {
2237 if (empty($ids)) {
2238 $ids = $this->blog_request->getIds();
2239 }
2240 if (count($ids) === 0) {
2241 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"), true);
2242 $this->ctrl->redirect($this, "contributors");
2243 }
2244
2245 $confirm = new ilConfirmationGUI();
2246 $confirm->setHeaderText($this->lng->txt('blog_confirm_delete_contributors'));
2247 $confirm->setFormAction($this->ctrl->getFormAction($this, 'removeContributor'));
2248 $confirm->setConfirm($this->lng->txt('delete'), 'removeContributor');
2249 $confirm->setCancel($this->lng->txt('cancel'), 'contributors');
2250
2251 foreach ($ids as $user_id) {
2252 $confirm->addItem(
2253 'id[]',
2254 (string) $user_id,
2255 $this->profile_gui->getNamePresentation($user_id, false, "", true)
2256 );
2257 }
2258
2259 $this->tpl->setContent($confirm->getHTML());
2260 }
2261
2262 public function removeContributor(): void
2263 {
2264 $ilCtrl = $this->ctrl;
2265 $lng = $this->lng;
2266 $rbacadmin = $this->rbacadmin;
2267
2268 $ids = $this->blog_request->getIds();
2269
2270 if (count($ids) === 0) {
2271 $this->tpl->setOnScreenMessage('failure', $lng->txt("select_one"), true);
2272 $ilCtrl->redirect($this, "contributors");
2273 }
2274
2275 // get contributor role
2276 $local_roles = array_keys($this->object->getAllLocalRoles($this->node_id));
2277 if (!$local_roles) {
2278 $this->tpl->setOnScreenMessage('failure', $lng->txt("missing_perm"));
2279 $this->contributors();
2280 return;
2281 }
2282
2283 foreach ($ids as $user_id) {
2284 foreach ($local_roles as $role_id) {
2285 $rbacadmin->deassignUser($role_id, $user_id);
2286 }
2287 }
2288
2289 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
2290 $this->ctrl->redirect($this, "contributors");
2291 }
2292
2296 public function addContributorContainerAction(array $ids = []): void
2297 {
2298 if (empty($ids)) {
2299 $ids = $this->blog_request->getIds();
2300 }
2301
2302 // This would typically add contributors from a container
2303 // For now, redirecting back to contributors as this seems to be a placeholder action
2304 $this->ctrl->redirect($this, "contributors");
2305 }
2306
2307 public function deactivateAdmin(): void
2308 {
2309 if ($this->checkPermissionBool("write") && $this->apid > 0) {
2310 // ilBlogPostingGUI::deactivatePage()
2311 $post = new ilBlogPosting($this->apid);
2312 $post->setApproved(false);
2313 $post->setActive(false);
2314 $post->update(true, false, false);
2315
2316 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
2317 }
2318
2319 $this->ctrl->redirect($this, "render");
2320 }
2321
2322
2326
2327 public function setContentStyleSheet(
2328 ?ilGlobalTemplateInterface $a_tpl = null
2329 ): void {
2330 $tpl = $this->tpl;
2331
2332 if ($a_tpl) {
2333 $ctpl = $a_tpl;
2334 } else {
2335 $ctpl = $tpl;
2336 }
2337
2338 $this->content_style_gui->addCss(
2339 $ctpl,
2340 $this->object->getRefId(),
2341 $this->object->getId()
2342 );
2343 }
2344
2348 protected function exportWithComments(): void
2349 {
2350 $this->export(true);
2351 }
2352
2356
2357 public function getPrintView(): \ILIAS\Export\PrintProcessGUI
2358 {
2359 $style_sheet_id = $this->content_style_domain->getEffectiveStyleId();
2360
2362 $blog = $this->object;
2363 $provider = new \ILIAS\Blog\BlogPrintViewProviderGUI(
2364 $this->lng,
2365 $this->ctrl,
2366 $blog,
2367 $this->node_id,
2368 $this->access_handler,
2369 $style_sheet_id,
2370 $this->blog_request->getObjIds()
2371 );
2372
2373 return new \ILIAS\Export\PrintProcessGUI(
2374 $provider,
2375 $this->http,
2376 $this->ui,
2377 $this->lng
2378 );
2379 }
2380
2381 public function printViewSelection(): void
2382 {
2383 $view = $this->getPrintView();
2384 $view->sendForm();
2385 }
2386
2387 public function printPostings(): void
2388 {
2389 $print_view = $this->getPrintView();
2390 $print_view->sendPrintView();
2391 }
2392
2393 protected function forwardExport(): void
2394 {
2395 $this->ctrl->redirectByClass(ilExportGUI::class);
2396 }
2397}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
perm( $access_handler, ?int $node_id, int $id_type, int $user_id, int $owner)
const IL_CAL_DATE
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
Class ilBlogPosting GUI class.
static getSnippet(int $a_id, bool $a_truncate=false, int $a_truncate_length=500, string $a_truncate_sign="...", bool $a_include_picture=false, int $a_picture_width=144, int $a_picture_height=144, ?string $a_export_directory=null)
Get first text paragraph of page.
Class ilBlogPosting.
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog.
static lookupBlogId(int $a_posting_id)
static getKeywords(int $a_obj_id, int $a_posting_id)
static _numericMonthToString(int $a_month, bool $a_long=true, ?ilLanguage $lng=null)
numeric month to string
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Base class for ILIAS Exception handling.
Export User Interface Class.
const CMD_LIST_EXPORT_FILES
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
Help GUI class.
Class ilInfoScreenGUI.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Last visited history for repository items.
static hasOptOut(int $obj_id)
Is opt out (disable notification) allowed?
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user.
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user.
@ilCtrl_Calls ilObjBlogGUI: ilBlogPostingGUI, ilWorkspaceAccessGUI @ilCtrl_Calls ilObjBlogGUI: ilInfo...
infoScreen()
this one is called from the info button in the repository
afterSave(ilObject $new_object)
Post (successful) object creation hook.
initHeaderAction(?string $sub_type=null, ?int $sub_id=null, bool $is_preview=false)
ILIAS Style Content GUIService $content_style_gui
executeCommand()
execute command
addUserFromAutoComplete()
Autocomplete submit.
getType()
Functions that must be overwritten.
confirmRemoveContributor(array $ids=[])
Used in ContributorTableBuilder.
static lookupSubObjectTitle(int $a_blog_id, int $a_posting_id)
Get title for blog posting (used in ilNotesGUI)
addHeaderActionForCommand(string $a_cmd)
renderList(array $items, string $a_cmd="preview", string $a_link_template="", bool $a_show_inactive=false, string $a_export_directory="")
Build posting month list.
addLocatorItems()
Functions to be overwritten.
getKeywords(bool $a_show_inactive, ?int $a_posting_id=null)
Get keywords for single posting or complete blog.
renderNavigationByAuthors(array $a_items, string $a_list_cmd="render", bool $a_show_inactive=false)
PermissionManager $perm
ProfileAdapter $profile
addContributor(array $a_user_ids=array(), ?string $a_user_type=null)
Centralized method to add contributors.
setSettingsSubTabs(string $a_active)
buildExportLink(string $a_template, string $a_type, string $a_id)
Build export link.
exportWithComments()
Handle export choice.
ProfileGUI $profile_gui
addContributorContainerAction(array $ids=[])
Used in ContributorTableBuilder.
renderNavigationByDate(array $a_items, string $a_list_cmd="render", string $a_posting_cmd="preview", ?string $a_link_template=null, bool $a_show_inactive=false, int $a_blpg=0)
Build navigation by date block.
ContextServices $tool_context
renderFullScreen(string $a_content, string $a_navigation)
Build fullscreen context.
ILIAS Blog ReadingTime BlogSettingsGUI $reading_time_gui
buildExportFile(bool $a_include_comments=false, bool $print_version=false)
Build export file.
renderNavigation(string $a_list_cmd="render", string $a_posting_cmd="preview", ?string $a_link_template=null, bool $a_show_inactive=false, int $a_blpg=0)
Build navigation blocks.
render()
Render object context.
filterItemsByKeyword(array $a_items, string $a_keyword)
filterInactivePostings()
Filter inactive items from items list.
ILIAS DI UIServices $ui
StandardGUIRequest $blog_request
setTabs()
create tabs (repository/workspace switch)
renderFullscreenHeader(ilGlobalTemplateInterface $a_tpl, int $a_user_id, bool $a_export=false)
ilRbacAdmin $rbacadmin
ReadingTimeManager $reading_time_manager
disableNotes(bool $a_value=false)
InternalGUIService $gui
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
renderToolbarNavigation(array $a_items, bool $single_posting=false)
Toolbar navigation.
Settings $blog_settings
ILIAS Style Content Object ObjectFacade $content_style_domain
buildPostingList(int $a_obj_id)
Gather all blog postings.
preview()
Render fullscreen presentation.
InternalDomainService $domain
export(bool $a_with_comments=false)
Build and deliver export file.
createPosting()
Create new posting.
renderNavigationByKeywords(string $a_list_cmd="render", bool $a_show_inactive=false, string $a_link_template="", int $a_blpg=0)
Build navigation by keywords block.
ILIAS Notes Service $notes
ilNavigationHistory $nav_history
getListItems(bool $a_show_inactive=false)
Filter blog postings by month, keyword or author.
setContentStyleSheet(?ilGlobalTemplateInterface $a_tpl=null)
const NAV_MODE_LIST
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupName(int $a_user_id)
static _lookupId(string|array $a_user_str)
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false)
New implementation of ilObjectGUI.
ilAccessHandler $access
ilGlobalTemplateInterface $tpl
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
setLocator()
set Locator
prepareOutput(bool $show_sub_objects=true)
GUI class for the workflow of copying objects.
addHeaderAction()
Add header action menu.
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
static get(string $a_type, string $a_href="")
Get icon html.
Class ilRbacAdmin Core functions for role based access control.
deassignUser(int $a_rol_id, int $a_usr_id)
Deassigns a user from a role.
assignUser(int $a_rol_id, int $a_usr_id)
Assigns an user to a role.
static fillAutoCompleteToolbar(object $parent_object, ?ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt('user'), auto_complete_size = 15, user_type = array(ilCoursePar...
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateTab(string $a_id)
static getRelevanceClass(int $cnt, int $max)
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const CLIENT_ID
Definition: constants.php:41
const ANONYMOUS_USER_ID
Definition: constants.php:27
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$info
Definition: entry_point.php:21
setDescription(string $a_descr)
Sets description below title in standard template.
loadStandardTemplate()
This loads the standard template "tpl.adm_content.html" and "tpl.statusline.html" the CONTENT and STA...
setRightContent(string $a_html)
Sets content of right column.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
resetHeaderBlock(bool $a_reset_header_action=true)
Reset all header properties: title, icon, description, alerts, action menu.
setContent(string $a_html)
Sets content for standard template.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
$ref_id
Definition: ltiauth.php:66
$service
Definition: ltiresult.php:36
$res
Definition: ltiservices.php:69
$post
Definition: ltitoken.php:46
$provider
Definition: ltitoken.php:80
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
catch(\Exception $e) $req
Definition: xapiproxy.php:91
global $lng
Definition: privfeed.php:31
global $ilSetting
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68
$counter