ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPDNotesGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23 */
24 
37 {
38 
44  var $ilias;
45  var $tpl;
46  var $lng;
47 
48  const PUBLIC_COMMENTS = "publiccomments";
49  const PRIVATE_NOTES = "privatenotes";
50 
56  function ilPDNotesGUI()
57  {
58  global $ilias, $tpl, $lng, $ilCtrl;
59 
60  // initiate variables
61  $this->ilias =& $ilias;
62  $this->tpl =& $tpl;
63  $this->lng =& $lng;
64  $this->ctrl =& $ilCtrl;
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.gif"),
103  // $this->lng->txt("personal_desktop"));
104  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
105  "");
106  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
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  $first = true;
128  foreach ($rel_objs as $r)
129  {
130  if ($first) // take first one as default
131  {
132  $this->current_rel_obj = $r["rep_obj_id"];
133  }
134  if ($r["rep_obj_id"] == $ilUser->getPref("pd_notes_rel_obj".$this->getMode()))
135  {
136  $this->current_rel_obj = $r["rep_obj_id"];
137  }
138  $first = false;
139  }
140  if ($this->current_rel_obj > 0)
141  {
142  $notes_gui = new ilNoteGUI($this->current_rel_obj, 0,
143  ilObject::_lookupType($this->current_rel_obj),true);
144  }
145  else
146  {
147  $notes_gui = new ilNoteGUI(0, $ilUser->getId(), "pd");
148  }
149 
150  if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
151  {
152  $notes_gui->enablePrivateNotes(true);
153  $notes_gui->enablePublicNotes(false);
154  }
155  else
156  {
157  $notes_gui->enablePrivateNotes(false);
158  $notes_gui->enablePublicNotes(true);
159  }
160  $notes_gui->enableHiding(false);
161  $notes_gui->enableTargets(true);
162  $notes_gui->enableMultiSelection(true);
163  $notes_gui->enableAnchorJump(false);
164 
165  $next_class = $this->ctrl->getNextClass($this);
166 
167  if ($next_class == "ilnotegui")
168  {
169  $html = $this->ctrl->forwardCommand($notes_gui);
170  }
171  else
172  {
173  $html = $notes_gui->getNotesHTML();
174  }
175 
176  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.pd_notes.html", "Services/Notes");
177 
178  if (count($rel_objs) > 1 ||
179  ($rel_objs[0]["rep_obj_id"] > 0))
180  {
181  // prepend personal dektop, if first object
182  if ($rel_objs[0]["rep_obj_id"] > 0 && $this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
183  {
184  $rel_objs = array_merge(array(0), $rel_objs);
185  }
186 
187  foreach($rel_objs as $obj)
188  {
189  $this->tpl->setCurrentBlock("related_option");
190  $this->tpl->setVariable("VAL_RELATED",
191  $obj["rep_obj_id"]);
192 //echo "-".$obj["rep_obj_id"]."-".$obj["obj_type"]."-";
193  if ($obj["rep_obj_id"] > 0)
194  {
195  $type = ilObject::_lookupType($obj["rep_obj_id"]);
196  $type_str = (in_array($type, array("lm", "htlm", "sahs", "dbk")))
197  ? $lng->txt("learning_resource")
198  : $lng->txt("obj_".$type);
199  $this->tpl->setVariable("TXT_RELATED", $type_str.": ".
200  ilObject::_lookupTitle($obj["rep_obj_id"]));
201  }
202  else
203  {
204  $this->tpl->setVariable("TXT_RELATED",
205  $lng->txt("personal_desktop"));
206  }
207  if ($obj["rep_obj_id"] == $this->current_rel_obj)
208  {
209  $this->tpl->setVariable("SEL", 'selected="selected"');
210  }
211  $this->tpl->parseCurrentBlock();
212  }
213 
214  $this->tpl->setCurrentBlock("related_selection");
215  $this->tpl->setVariable("TXT_CHANGE", $lng->txt("change"));
216  $this->tpl->setVariable("TXT_RELATED_TO", $lng->txt("related_to"));
217  $this->tpl->setVariable("TXT_FILTER", $lng->txt("filter"));
218  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
219  $this->tpl->parseCurrentBlock();
220  }
221 
222  $this->tpl->setCurrentBlock("adm_content");
223  // output notes
224  $this->tpl->setVariable("NOTES", $html);
225  $this->tpl->parseCurrentBlock();
226 
227  }
228 
233  {
234  global $ilUser;
235 
236  $ilUser->writePref("pd_notes_rel_obj".$this->getMode(), $_POST["rel_obj"]);
237  $this->ctrl->redirect($this);
238  }
239 
240  // scorm2004-start
244  function setTabs()
245  {
246  global $ilTabs, $ilUser, $ilCtrl;
247 
248  $ilTabs->addSubTabTarget("private_notes",
249  $ilCtrl->getLinkTarget($this, "showPrivateNotes"), "", "", "",
250  ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES));
251  $ilTabs->addSubTabTarget("notes_public_comments",
252  $ilCtrl->getLinkTarget($this, "showPublicComments"), "", "", "",
253  ($this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS));
254  }
255 
259  function showPrivateNotes()
260  {
261  global $ilUser, $ilCtrl;
262 
263  $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PRIVATE_NOTES);
264  $ilCtrl->redirect($this, "");
265  }
266 
271  {
272  global $ilUser, $ilCtrl;
273 
274  $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PUBLIC_COMMENTS);
275  $ilCtrl->redirect($this, "");
276  }
277 
281  function getMode()
282  {
283  global $ilUser;
284 
285  if ($ilUser->getPref("pd_notes_mode") == ilPDNotesGUI::PUBLIC_COMMENTS)
286  {
288  }
289  else
290  {
292  }
293  }
294 }
295 ?>