ILIAS  release_8 Revision v8.23
ilPDNotesGUI Class Reference

Private Notes on PD. More...

+ Collaboration diagram for ilPDNotesGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 displayHeader ()
 
 view ()
 
 changeRelatedObject ()
 
 showPrivateNotes ()
 
 showPublicComments ()
 
 printSelection ()
 

Data Fields

ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 

Protected Member Functions

 readFilter ()
 
 getRelatedObjects ()
 
 setSortation ()
 
 getFilter ()
 
 setToolbar ()
 

Protected Attributes

int $note_type
 
string $search_text = ""
 
ILIAS Notes FilterAdapterGUI $filter = null
 
ILIAS Notes InternalGUIService $gui
 
ILIAS DI UIServices $ui
 
NotesManager $notes_manager
 
int $current_rel_obj = null
 
StandardGUIRequest $request
 
ilCtrl $ctrl
 
ilObjUser $user
 
ilTabsGUI $tabs
 
ilHelpGUI $help
 
ilSetting $settings
 
ilAccessHandler $access
 
ilToolbarGUI $toolbar
 
array $related_objects = null
 

Detailed Description

Private Notes on PD.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de ilPDNotesGUI: ilNoteGUI

Definition at line 28 of file class.ilPDNotesGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPDNotesGUI::__construct ( )

Definition at line 51 of file class.ilPDNotesGUI.php.

References $context, $DIC, $ilUser, $lng, $tpl, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), readFilter(), ILIAS\Repository\settings(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

52  {
53  global $DIC;
54 
55  $this->user = $DIC->user();
56  $this->tabs = $DIC->tabs();
57  $this->help = $DIC["ilHelp"];
58  $this->settings = $DIC->settings();
59  $this->access = $DIC->access();
60  $this->toolbar = $DIC->toolbar();
61  $tpl = $DIC["tpl"];
62  $lng = $DIC->language();
63  $ilCtrl = $DIC->ctrl();
64  $ilUser = $DIC->user();
65  $ilHelp = $DIC["ilHelp"];
66  $this->ui = $DIC->ui();
67 
68  $this->request = $DIC->notes()
69  ->internal()
70  ->gui()
71  ->standardRequest();
72 
73  $ilHelp->setScreenIdComponent("note");
74 
75  $lng->loadLanguageModule("notes");
76 
77  // initiate variables
78  $this->tpl = $tpl;
79  $this->lng = $lng;
80  $this->ctrl = $ilCtrl;
81 
82  $this->notes_manager = $DIC->notes()->internal()->domain()->notes();
83  $this->gui = $DIC->notes()->internal()->gui();
84 
85  // link from ilPDNotesBlockGUI
86  $rel_obj = $this->request->getRelatedObjId();
87  $this->note_type = ($this->request->getNoteType() === Note::PRIVATE || $ilCtrl->getCmd() === "getNotesHTML")
88  ? Note::PRIVATE
89  : Note::PUBLIC;
90  if ($ilCtrl->getCmd() === "getCommentsHTML") {
91  $this->note_type = Note::PUBLIC;
92  }
93  $this->ctrl->setParameter($this, "note_type", $this->note_type);
94  if ($rel_obj > 0) {
95  $ilUser->writePref("pd_notes_rel_obj" . $this->note_type, (string) $rel_obj);
96  }
97  // edit link
98  elseif ($this->request->getNoteId() > 0) {
99  $note = $this->notes_manager->getById($this->request->getNoteId());
100  $context = $note->getContext();
101  $ilUser->writePref("pd_notes_rel_obj" . $this->note_type, $context->getObjId());
102  }
103  $this->readFilter();
104  $ajax_url = $this->ctrl->getLinkTargetByClass(
105  ["ildashboardgui", "ilpdnotesgui", "ilnotegui"],
106  "",
107  "",
108  true,
109  false
110  );
111  $this->gui->initJavascript($ajax_url);
112  }
$context
Definition: webdav.php:29
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: feed.php:28
ilGlobalTemplateInterface $tpl
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

Member Function Documentation

◆ changeRelatedObject()

ilPDNotesGUI::changeRelatedObject ( )

Definition at line 267 of file class.ilPDNotesGUI.php.

References $ilUser, $user, and ILIAS\Repository\ctrl().

267  : void
268  {
270 
271  $ilUser->writePref(
272  "pd_notes_rel_obj" . $this->note_type,
273  (string) $this->request->getRelatedObjId()
274  );
275  $this->ctrl->redirect($this);
276  }
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ displayHeader()

ilPDNotesGUI::displayHeader ( )

Definition at line 143 of file class.ilPDNotesGUI.php.

References $ilSetting, $settings, ilUtil\getImagePath(), and ILIAS\Repository\lng().

Referenced by executeCommand().

143  : void
144  {
146 
147  $t = $this->lng->txt("notes");
148  if (!$ilSetting->get("disable_notes") && !$ilSetting->get("disable_comments")) {
149  $t = $this->lng->txt("notes_and_comments");
150  }
151  if ($ilSetting->get("disable_notes")) {
152  $t = $this->lng->txt("notes_comments");
153  }
154 
155  if ($this->note_type === Note::PRIVATE) {
156  $t = $this->lng->txt("private_notes");
157  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_nots.svg"));
158  } else {
159  $t = $this->lng->txt("notes_public_comments");
160  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_coms.svg"));
161  }
162 
163  $this->tpl->setTitle($t);
164  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $ilSetting
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPDNotesGUI::executeCommand ( )

Definition at line 125 of file class.ilPDNotesGUI.php.

References ILIAS\Repository\ctrl(), displayHeader(), and view().

125  : void
126  {
127  $next_class = $this->ctrl->getNextClass();
128  switch ($next_class) {
129  case "ilnotegui":
130  $this->displayHeader();
131  $this->view(); // forwardCommand is invoked in view() method
132  break;
133 
134  default:
135  $cmd = $this->ctrl->getCmd("view");
136  $this->displayHeader();
137  $this->$cmd();
138  break;
139  }
140  $this->tpl->printToStdout(true);
141  }
+ Here is the call graph for this function:

◆ getFilter()

ilPDNotesGUI::getFilter ( )
protected

Definition at line 305 of file class.ilPDNotesGUI.php.

References $filter, $gui, $lng, ilObject\_lookupTitle(), ILIAS\UI\examples\Symbol\Glyph\Filter\filter(), getRelatedObjects(), ILIAS\Repository\lng(), and ilLanguage\txt().

Referenced by readFilter(), and view().

306  {
307  $gui = $this->gui;
308  $lng = $this->lng;
309  if (is_null($this->filter)) {
310  $options = [];
311 
312  if ($this->note_type === Note::PRIVATE) {
313  $options[-1] = $this->lng->txt("note_without_object");
314  }
315 
316  foreach ($this->getRelatedObjects() as $k) {
317  $options[$k] = ilObject::_lookupTitle($k);
318  }
319  $this->filter = $gui->filter(
320  "notes_filter_" . $this->note_type,
321  self::class,
322  "view",
323  false,
324  false
325  )
326  ->text("text", $lng->txt("notes_text"))
327  ->select("object", $lng->txt("notes_origin"), $options);
328  }
329  return $this->filter;
330  }
ILIAS Notes FilterAdapterGUI $filter
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...
static _lookupTitle(int $obj_id)
ILIAS Notes InternalGUIService $gui
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRelatedObjects()

ilPDNotesGUI::getRelatedObjects ( )
protected

Definition at line 166 of file class.ilPDNotesGUI.php.

References $related_objects.

Referenced by getFilter(), and view().

166  : array
167  {
168  if (is_null($this->related_objects)) {
169  $this->related_objects = $this->notes_manager->getRelatedObjectsOfUser(
170  $this->note_type
171  );
172  }
173  return $this->related_objects;
174  }
+ Here is the caller graph for this function:

◆ printSelection()

ilPDNotesGUI::printSelection ( )
Exceptions

Definition at line 369 of file class.ilPDNotesGUI.php.

369  : void
370  {
371  $pv = $this->gui->print();
372  $pv->sendForm();
373  }

◆ readFilter()

ilPDNotesGUI::readFilter ( )
protected

Definition at line 114 of file class.ilPDNotesGUI.php.

References $data, getFilter(), and ILIAS\Repository\int().

Referenced by __construct().

114  : void
115  {
116  $data = $this->getFilter()->getData();
117  if (!isset($data["object"]) || $data["object"] === "") {
118  $this->current_rel_obj = null;
119  } else {
120  $this->current_rel_obj = (int) $data["object"];
121  }
122  $this->search_text = $data["text"] ?? "";
123  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSortation()

ilPDNotesGUI::setSortation ( )
protected

Definition at line 299 of file class.ilPDNotesGUI.php.

References view().

299  : void
300  {
301  $this->notes_manager->setSortAscending($this->gui->standardRequest()->getSortation() === "asc");
302  $this->view();
303  }
+ Here is the call graph for this function:

◆ setToolbar()

ilPDNotesGUI::setToolbar ( )
protected

Definition at line 332 of file class.ilPDNotesGUI.php.

References Vendor\Package\$b, $c, $ctrl, ilCtrl\getLinkTarget(), ilCtrl\getLinkTargetByClass(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), and ILIAS\Repository\ui().

Referenced by view().

332  : void
333  {
334  $ctrl = $this->ctrl;
335 
336  // sortation
337  $c = $this->lng->txt("create_date") . ", ";
338  $options = [
339  'desc' => $c . $this->lng->txt("sorting_desc"),
340  'asc' => $c . $this->lng->txt("sorting_asc")
341  ];
342  $select_option = ($this->notes_manager->getSortAscending())
343  ? 'asc'
344  : 'desc';
345  $s = $this->ui->factory()->viewControl()->sortation($options)
346  ->withTargetURL($ctrl->getLinkTarget($this, "setSortation"), 'sortation')
347  ->withLabel($options[$select_option]);
348  $this->toolbar->addComponent($s);
349 
350  // print selection
351  $pv = $this->gui->print();
352  $modal_elements = $pv->getModalElements(
353  $ctrl->getLinkTarget($this, "printSelection")
354  );
355  $this->toolbar->addComponent($modal_elements->button);
356  $this->toolbar->addComponent($modal_elements->modal);
357 
358  // export html
359  $b = $this->ui->factory()->button()->standard(
360  $this->lng->txt("notes_html_export"),
361  $ctrl->getLinkTargetByClass("ilNoteGUI", "exportNotesHTML")
362  );
363  $this->toolbar->addComponent($b);
364  }
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
$c
Definition: cli.php:38
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showPrivateNotes()

ilPDNotesGUI::showPrivateNotes ( )

Definition at line 278 of file class.ilPDNotesGUI.php.

References $ctrl, $ilUser, $user, and ilCtrl\redirectByClass().

278  : void
279  {
281  $ilCtrl = $this->ctrl;
282 
283  $ilCtrl->redirectByClass(ilNoteGUI::class, "getNotesHTML");
284  }
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ showPublicComments()

ilPDNotesGUI::showPublicComments ( )

Definition at line 286 of file class.ilPDNotesGUI.php.

References $ctrl, $ilSetting, $ilUser, $settings, and $user.

286  : void
287  {
289  $ilCtrl = $this->ctrl;
291 
292  if ($ilSetting->get("disable_comments")) {
293  $ilCtrl->redirect($this, "showPrivateNotes");
294  }
295 
296  $ilCtrl->redirectByClass(ilNoteGUI::class, "getCommentsHTML");
297  }
global $ilSetting
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:34

◆ view()

ilPDNotesGUI::view ( )

Definition at line 176 of file class.ilPDNotesGUI.php.

References $access, $ilSetting, $ilUser, $lng, $ref_id, $search_text, $settings, $toolbar, $user, ilObject\_getAllReferences(), ilObject\_lookupType(), ILIAS\Repository\ctrl(), ilNoteGUI\enablePrivateNotes(), getFilter(), getRelatedObjects(), ilLanguage\loadLanguageModule(), setToolbar(), and ilLanguage\txt().

Referenced by executeCommand(), and setSortation().

176  : void
177  {
179  $lng = $this->lng;
181  $ilAccess = $this->access;
182  $ilToolbar = $this->toolbar;
183 
184  $rel_objs = $this->getRelatedObjects();
185  $this->setToolbar();
186 
187  if ($this->note_type === Note::PRIVATE) {
188  $rel_objs = array_merge(
189  [0],
190  $rel_objs
191  );
192  }
193 
194  // #9410
195  if (count($rel_objs) === 0 && $this->note_type === Note::PUBLIC) {
196  $lng->loadLanguageModule("notes");
197  $this->tpl->setOnScreenMessage('info', $lng->txt("msg_no_search_result"));
198  return;
199  }
200  if ($this->current_rel_obj === null) {
201  $notes_gui = new ilNoteGUI(
202  $rel_objs,
203  0,
204  "",
205  true,
206  0,
207  false,
208  $this->search_text
209  );
210  } elseif ($this->current_rel_obj > 0) {
211  $notes_gui = new ilNoteGUI(
212  $this->current_rel_obj,
213  0,
214  \ilObject::_lookupType($this->current_rel_obj),
215  true,
216  0,
217  false,
218  $this->search_text
219  );
220  } else {
221  $notes_gui = new ilNoteGUI(
222  0,
223  $ilUser->getId(),
224  "pd",
225  false,
226  0,
227  false,
229  );
230  }
231  //$notes_gui->setHideNewForm(true);
232 
233  if ($this->note_type === Note::PRIVATE) {
234  $notes_gui->enablePrivateNotes(true);
235  $notes_gui->enablePublicNotes(false);
236  } else {
237  $notes_gui->enablePrivateNotes(false);
238  $notes_gui->enablePublicNotes(true);
239  // #13707
240  if ($this->current_rel_obj > 0 &&
241  $ilSetting->get("comments_del_tutor", '1')) {
242  foreach (\ilObject::_getAllReferences($this->current_rel_obj) as $ref_id) {
243  if ($ilAccess->checkAccess("write", "", $ref_id)) {
244  $notes_gui->enablePublicNotesDeletion(true);
245  break;
246  }
247  }
248  }
249  }
250  $notes_gui->enableTargets(true);
251 
252  $next_class = $this->ctrl->getNextClass($this);
253 
254  if ($next_class === "ilnotegui") {
255  $html = $this->ctrl->forwardCommand($notes_gui);
256  } elseif ($this->note_type === Note::PRIVATE) {
257  $html = $notes_gui->getNotesHTML();
258  } else {
259  $html = $notes_gui->getCommentsHTML();
260  }
261 
262  $filter_html = $this->getFilter()->render();
263 
264  $this->tpl->setContent($filter_html . $html);
265  }
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...
static _getAllReferences(int $id)
get all reference ids for object ID
enablePrivateNotes(bool $a_enable=true)
loadLanguageModule(string $a_module)
Load language module.
Notes GUI class.
$ref_id
Definition: ltiauth.php:67
ilToolbarGUI $toolbar
global $ilSetting
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:34
static _lookupType(int $id, bool $reference=false)
ilAccessHandler $access
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilPDNotesGUI::$access
protected

Definition at line 45 of file class.ilPDNotesGUI.php.

Referenced by view().

◆ $ctrl

ilCtrl ilPDNotesGUI::$ctrl
protected

Definition at line 40 of file class.ilPDNotesGUI.php.

Referenced by setToolbar(), showPrivateNotes(), and showPublicComments().

◆ $current_rel_obj

int ilPDNotesGUI::$current_rel_obj = null
protected

Definition at line 37 of file class.ilPDNotesGUI.php.

◆ $filter

ILIAS Notes FilterAdapterGUI ilPDNotesGUI::$filter = null
protected

Definition at line 32 of file class.ilPDNotesGUI.php.

Referenced by getFilter().

◆ $gui

ILIAS Notes InternalGUIService ilPDNotesGUI::$gui
protected

Definition at line 33 of file class.ilPDNotesGUI.php.

Referenced by getFilter().

◆ $help

ilHelpGUI ilPDNotesGUI::$help
protected

Definition at line 43 of file class.ilPDNotesGUI.php.

◆ $lng

ilLanguage ilPDNotesGUI::$lng

Definition at line 48 of file class.ilPDNotesGUI.php.

Referenced by __construct(), getFilter(), and view().

◆ $note_type

int ilPDNotesGUI::$note_type
protected

Definition at line 30 of file class.ilPDNotesGUI.php.

◆ $notes_manager

NotesManager ilPDNotesGUI::$notes_manager
protected

Definition at line 35 of file class.ilPDNotesGUI.php.

◆ $related_objects

array ilPDNotesGUI::$related_objects = null
protected

Definition at line 49 of file class.ilPDNotesGUI.php.

Referenced by getRelatedObjects().

◆ $request

StandardGUIRequest ilPDNotesGUI::$request
protected

Definition at line 38 of file class.ilPDNotesGUI.php.

◆ $search_text

string ilPDNotesGUI::$search_text = ""
protected

Definition at line 31 of file class.ilPDNotesGUI.php.

Referenced by view().

◆ $settings

ilSetting ilPDNotesGUI::$settings
protected

Definition at line 44 of file class.ilPDNotesGUI.php.

Referenced by displayHeader(), showPublicComments(), and view().

◆ $tabs

ilTabsGUI ilPDNotesGUI::$tabs
protected

Definition at line 42 of file class.ilPDNotesGUI.php.

◆ $toolbar

ilToolbarGUI ilPDNotesGUI::$toolbar
protected

Definition at line 46 of file class.ilPDNotesGUI.php.

Referenced by view().

◆ $tpl

ilGlobalTemplateInterface ilPDNotesGUI::$tpl

Definition at line 47 of file class.ilPDNotesGUI.php.

Referenced by __construct().

◆ $ui

ILIAS DI UIServices ilPDNotesGUI::$ui
protected

Definition at line 34 of file class.ilPDNotesGUI.php.

◆ $user

ilObjUser ilPDNotesGUI::$user
protected

The documentation for this class was generated from the following file: