ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPDNotesGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 include_once("Services/Notes/classes/class.ilNote.php");
7 
18 {
19 
25  var $ilias;
26  var $tpl;
27  var $lng;
28 
29  const PUBLIC_COMMENTS = "publiccomments";
30  const PRIVATE_NOTES = "privatenotes";
31 
37  function ilPDNotesGUI()
38  {
39  global $ilias, $tpl, $lng, $ilCtrl, $ilUser, $ilTabs, $ilHelp;
40 
41  $ilHelp->setScreenIdComponent("note");
42 
43  // initiate variables
44  $this->ilias =& $ilias;
45  $this->tpl =& $tpl;
46  $this->lng =& $lng;
47  $this->ctrl =& $ilCtrl;
48 
49  // link from ilPDNotesBlockGUI
50  if($_GET["rel_obj"])
51  {
52  $mode = ($_GET["note_type"] == IL_NOTE_PRIVATE) ? self::PRIVATE_NOTES : self::PUBLIC_COMMENTS;
53  $ilUser->writePref("pd_notes_mode", $mode);
54  $ilUser->writePref("pd_notes_rel_obj".$mode, $_GET["rel_obj"]);
55  }
56  // edit link
57  else if($_REQUEST["note_id"])
58  {
59  $note = new ilNote($_REQUEST["note_id"]);
60  $mode = ($note->getType() == IL_NOTE_PRIVATE) ? self::PRIVATE_NOTES : self::PUBLIC_COMMENTS;
61  $obj = $note->getObject();
62  $ilUser->writePref("pd_notes_mode", $mode);
63  $ilUser->writePref("pd_notes_rel_obj".$mode, $obj["rep_obj_id"]);
64  }
65  }
66 
70  function &executeCommand()
71  {
72  $next_class = $this->ctrl->getNextClass();
73 
74  switch($next_class)
75  {
76  case "ilnotegui":
77  // scorm2004-start
78  $this->setTabs();
79  // scorm2004-end
80  $this->displayHeader();
81  $this->view(); // forwardCommand is invoked in view() method
82  break;
83 
84  default:
85  // scorm2004-start
86  $this->setTabs();
87  // scorm2004-end
88  $cmd = $this->ctrl->getCmd("view");
89  $this->displayHeader();
90  $this->$cmd();
91  break;
92  }
93  $this->tpl->show(true);
94  return true;
95  }
96 
100  function displayHeader()
101  {
102  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"),
103  // $this->lng->txt("personal_desktop"));
104 // $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"),
105 // "");
106  $this->tpl->setTitle($this->lng->txt("notes"));
107 
108  // catch feedback message
109  // display infopanel if something happened
111 
112  }
113 
114  /*
115  * display notes
116  */
117  function view()
118  {
119  global $ilUser, $lng;
120 
121  //$this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.table.html")
122  include_once("Services/Notes/classes/class.ilNoteGUI.php");
123 
124  // output related item selection (if more than one)
125  include_once("Services/Notes/classes/class.ilNote.php");
126  $rel_objs = ilNote::_getRelatedObjectsOfUser($this->getMode());
127 //var_dump($rel_objs);
128  // prepend personal dektop, if first object
129 // if ($rel_objs[0]["rep_obj_id"] > 0 && $this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
130  if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
131  {
132 
133  $rel_objs = array_merge(array(0), $rel_objs);
134  }
135 
136  // #9410
137  if(!$rel_objs && $this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS)
138  {
139  $lng->loadLanguageModule("notes");
140  ilUtil::sendInfo($lng->txt("msg_no_search_result"));
141  return;
142  }
143 
144  $first = true;
145  foreach ($rel_objs as $r)
146  {
147  if ($first) // take first one as default
148  {
149  $this->current_rel_obj = $r["rep_obj_id"];
150  }
151  if ($r["rep_obj_id"] == $ilUser->getPref("pd_notes_rel_obj".$this->getMode()))
152  {
153  $this->current_rel_obj = $r["rep_obj_id"];
154  }
155  $first = false;
156  }
157  if ($this->current_rel_obj > 0)
158  {
159  $notes_gui = new ilNoteGUI($this->current_rel_obj, 0,
160  ilObject::_lookupType($this->current_rel_obj),true);
161  }
162  else
163  {
164  $notes_gui = new ilNoteGUI(0, $ilUser->getId(), "pd");
165  }
166 
167  if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
168  {
169  $notes_gui->enablePrivateNotes(true);
170  $notes_gui->enablePublicNotes(false);
171  }
172  else
173  {
174  $notes_gui->enablePrivateNotes(false);
175  $notes_gui->enablePublicNotes(true);
176  }
177  $notes_gui->enableHiding(false);
178  $notes_gui->enableTargets(true);
179  $notes_gui->enableMultiSelection(true);
180  $notes_gui->enableAnchorJump(false);
181 
182  $next_class = $this->ctrl->getNextClass($this);
183 
184  if ($next_class == "ilnotegui")
185  {
186  $html = $this->ctrl->forwardCommand($notes_gui);
187  }
188  else
189  {
190  $html = $notes_gui->getNotesHTML();
191  }
192 
193  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pd_notes.html", "Services/Notes");
194 
195  if (count($rel_objs) > 1 ||
196  ($rel_objs[0]["rep_obj_id"] > 0))
197  {
198  foreach($rel_objs as $obj)
199  {
200  $this->tpl->setCurrentBlock("related_option");
201  $this->tpl->setVariable("VAL_RELATED",
202  $obj["rep_obj_id"]);
203 //echo "-".$obj["rep_obj_id"]."-".$obj["obj_type"]."-";
204  if ($obj["rep_obj_id"] > 0)
205  {
206  $type = ilObject::_lookupType($obj["rep_obj_id"]);
207  $type_str = (in_array($type, array("lm", "htlm", "sahs", "dbk")))
208  ? $lng->txt("learning_resource")
209  : $lng->txt("obj_".$type);
210  $this->tpl->setVariable("TXT_RELATED", $type_str.": ".
211  ilObject::_lookupTitle($obj["rep_obj_id"]));
212  }
213  else
214  {
215  $this->tpl->setVariable("TXT_RELATED",
216  $lng->txt("personal_desktop"));
217  }
218  if ($obj["rep_obj_id"] == $this->current_rel_obj)
219  {
220  $this->tpl->setVariable("SEL", 'selected="selected"');
221  }
222  $this->tpl->parseCurrentBlock();
223  }
224 
225  $this->tpl->setCurrentBlock("related_selection");
226  $this->tpl->setVariable("TXT_CHANGE", $lng->txt("change"));
227  $this->tpl->setVariable("TXT_RELATED_TO", $lng->txt("related_to"));
228  $this->tpl->setVariable("TXT_FILTER", $lng->txt("filter"));
229  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
230  $this->tpl->parseCurrentBlock();
231  }
232 
233  $this->tpl->setCurrentBlock("adm_content");
234  // output notes
235  $this->tpl->setVariable("NOTES", $html);
236  $this->tpl->parseCurrentBlock();
237 
238  }
239 
244  {
245  global $ilUser;
246 
247  $ilUser->writePref("pd_notes_rel_obj".$this->getMode(), $_POST["rel_obj"]);
248  $this->ctrl->redirect($this);
249  }
250 
251  // scorm2004-start
255  function setTabs()
256  {
257  global $ilTabs, $ilSetting, $ilCtrl;
258 
259  $ilTabs->addTarget("private_notes",
260  $ilCtrl->getLinkTarget($this, "showPrivateNotes"), "", "", "",
261  ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES));
262  if(!$ilSetting->get("disable_comments"))
263  {
264  $ilTabs->addTarget("notes_public_comments",
265  $ilCtrl->getLinkTarget($this, "showPublicComments"), "", "", "",
266  ($this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS));
267  }
268  }
269 
273  function showPrivateNotes()
274  {
275  global $ilUser, $ilCtrl;
276 
277  $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PRIVATE_NOTES);
278  $ilCtrl->redirect($this, "");
279  }
280 
285  {
286  global $ilUser, $ilCtrl, $ilSetting;
287 
288  if($ilSetting->get("disable_comments"))
289  {
290  $ilCtrl->redirect($this, "showPrivateNotes");
291  }
292 
293  $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PUBLIC_COMMENTS);
294  $ilCtrl->redirect($this, "");
295  }
296 
300  function getMode()
301  {
302  global $ilUser, $ilSetting;
303 
304  if ($ilUser->getPref("pd_notes_mode") == ilPDNotesGUI::PUBLIC_COMMENTS &&
305  !$ilSetting->get("disable_comments"))
306  {
308  }
309  else
310  {
312  }
313  }
314 }
315 ?>