ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
PresentationHeaderGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Blog\Navigation;
22
29
39{
40 protected \ilObjUser $user;
41
42 public function __construct(
43 protected InternalDomainService $domain,
44 protected InternalGUIService $gui,
45 protected \ilObjBlog $blog,
46 protected PermissionManager $perm,
47 ) {
48 $this->user = $this->domain->user();
49 }
50
51 public function addHeaderAction(
52 ?\ilObjectListGUI $list_gui
53 ): void {
54 $user = $this->domain->user();
55
56 // notification
57 if ($user->getId() !== ANONYMOUS_USER_ID) {
58 $this->insertHeaderAction($list_gui);
59 }
60 }
61
62 public function get(
64 int $posting_id = 0
65 ): ?ilObjectListGUI {
66 $ctrl = $this->gui->ctrl();
67 $lng = $this->domain->lng();
68 if ($posting_id > 0) {
69 if ($this->blog->getNotesStatus()) {
70 $lg->enableComments(true);
71 }
72 $lg->enableNotes(true);
73 }
74 $lg->enableTags(false);
75
78 $this->user->getId(),
79 $this->blog->getId()
80 )
81 ) {
82 $ctrl->setParameterByClass(
83 PresentationGUI::class,
84 "ntf",
85 "1"
86 );
87 $link = $ctrl->getLinkTargetByClass(
88 PresentationGUI::class,
89 "setNotification"
90 );
91 $ctrl->setParameter($this, "ntf", "");
92 if (\ilNotification::hasOptOut($this->blog->getId())) {
93 $lg->addCustomCommand($link, "blog_notification_toggle_off");
94 }
95
96 $lg->addHeaderIcon(
97 "not_icon",
98 \ilUtil::getImagePath("object/notification_on.svg"),
99 $lng->txt("blog_notification_activated")
100 );
101 } else {
102 $ctrl->setParameterByClass(PresentationGUI::class, "ntf", 2);
103 $link = $ctrl->getLinkTargetByClass(PresentationGUI::class, "setNotification");
104 $ctrl->setParameterByClass(PresentationGUI::class, "ntf", "");
105 $lg->addCustomCommand($link, "blog_notification_toggle_on");
106
107 $lg->addHeaderIcon(
108 "not_icon",
109 \ilUtil::getImagePath("object/notification_off.svg"),
110 $lng->txt("blog_notification_deactivated")
111 );
112 }
113
114 // #11758
115 if ($this->perm->mayContribute()) {
116 $edit_path = [
117 \ilObjBlogGUI::class,
118 EditingGUI::class
119 ];
120 $ctrl->setParameterByClass(EditingGUI::class, "bmn", "");
121 $ctrl->setParameterByClass(EditingGUI::class, "blpg", "");
122 $link = $ctrl->getLinkTargetByClass($edit_path, "");
123 $lg->addCustomCommand($link, "blog_edit"); // #11868
124
125 $posting_path = [
126 \ilObjBlogGUI::class,
127 EditingGUI::class,
128 \ilBlogPostingGUI::class,
129 ];
130 $ctrl->setParameterByClass(\ilObjBlogGUI::class, "blpg", $posting_id);
131
132 if ($posting_id && $this->perm->mayEditPosting($posting_id)) {
133 $link = $ctrl->getLinkTargetByClass(\ilBlogPostingGUI::class, "edit");
134 $lg->addCustomCommand($link, "blog_edit_posting");
135 }
136 }
137
138 $ctrl->setParameterByClass(PresentationGUI::class, "ntf", "");
139
140 return $lg;
141 }
142}
@ilCtrl_Calls ILIAS\Blog\Editing\EditingGUI: ilRepositorySearchGUI, ilBlogPostingGUI
Definition: EditingGUI.php:37
alles nur in presentation aufrufen! (rest macht nur ) ilObjBlogGUI->addHeaderActionForCommand (called...
__construct(protected InternalDomainService $domain, protected InternalGUIService $gui, protected \ilObjBlog $blog, protected PermissionManager $perm,)
@ilCtrl_Calls ILIAS\Blog\Presentation\PresentationGUI: ilBlogPostingGUI
static hasOptOut(int $obj_id)
Is opt out (disable notification) allowed?
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user.
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 ANONYMOUS_USER_ID
Definition: constants.php:27
global $lng
Definition: privfeed.php:26