00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once ("Services/Notes/classes/class.ilNote.php");
00025
00026
00036 class ilNoteGUI
00037 {
00038 var $public_deletion_enabled = false;
00039
00040
00049 function ilNoteGUI($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_include_subobjects = false)
00050 {
00051 global $ilCtrl, $lng;
00052
00053 $this->rep_obj_id = $a_rep_obj_id;
00054 $this->obj_id = $a_obj_id;
00055 $this->obj_type = $a_obj_type;
00056 $this->inc_sub = $a_include_subobjects;
00057
00058 $this->ctrl =& $ilCtrl;
00059 $this->lng =& $lng;
00060
00061 $this->add_note_form = false;
00062 $this->edit_note_form = false;
00063 $this->private_enabled = false;
00064 $this->public_enabled = false;
00065 $this->enable_hiding = true;
00066 $this->targets_enabled = false;
00067 $this->multi_selection = false;
00068 $this->export_html = false;
00069 $this->print = false;
00070 }
00071
00075 function &executeCommand()
00076 {
00077 $cmd = $this->ctrl->getCmd("getNotesHTML");
00078 $next_class = $this->ctrl->getNextClass($this);
00079
00080 switch($next_class)
00081 {
00082 default:
00083 return $this->$cmd();
00084 break;
00085 }
00086 }
00087
00091 function enablePrivateNotes($a_enable = true)
00092 {
00093 $this->private_enabled = $a_enable;
00094 }
00095
00099 function enablePublicNotes($a_enable = true)
00100 {
00101 $this->public_enabled = $a_enable;
00102 }
00103
00107 function enablePublicNotesDeletion($a_enable = true)
00108 {
00109 $this->public_deletion_enabled = $a_enable;
00110 }
00111
00115 function enableHiding($a_enable = true)
00116 {
00117 $this->enable_hiding = $a_enable;
00118 }
00119
00123 function enableTargets($a_enable = true)
00124 {
00125 $this->targets_enabled = $a_enable;
00126 }
00127
00131 function enableMultiSelection($a_enable = true)
00132 {
00133 $this->multi_selection = $a_enable;
00134 }
00135
00136
00137
00138
00139 function getNotesHTML()
00140 {
00141 global $ilUser;
00142
00143 $html = "";
00144 if ($this->private_enabled && ($ilUser->getId() != ANONYMOUS_USER_ID))
00145 {
00146 $html.= $this->getNoteListHTML(IL_NOTE_PRIVATE);
00147 }
00148
00149 if ($this->public_enabled && (!$this->delete_note || $this->public_deletion_enabled))
00150 {
00151 $html.= $this->getNoteListHTML(IL_NOTE_PUBLIC);
00152 }
00153
00154 return $html;
00155 }
00156
00160 function getNoteListHTML($a_type = IL_NOTE_PRIVATE)
00161 {
00162 global $lng, $ilCtrl, $ilUser, $ilAccess, $tree, $objDefinition;
00163
00164 $suffix = ($a_type == IL_NOTE_PRIVATE)
00165 ? "private"
00166 : "public";
00167
00168 if ($this->delete_note || $this->export_html || $this->print)
00169 {
00170 if ($_GET["note_id"] != "")
00171 {
00172 $filter = $_GET["note_id"];
00173 }
00174 else
00175 {
00176 $filter = $_POST["note"];
00177 }
00178 }
00179
00180 $notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id,
00181 $this->obj_type, $a_type, $this->inc_sub, $filter,
00182 $ilUser->getPref("notes_pub_all"), $this->public_deletion_enabled);
00183
00184 $all_notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id,
00185 $this->obj_type, $a_type, $this->inc_sub, $filter,
00186 "", $this->public_deletion_enabled);
00187
00188 $tpl = new ilTemplate("tpl.notes_list.html", true, true, "Services/Notes");
00189
00190
00191 $cnt_str = (count($all_notes) > 0)
00192 ? " (".count($all_notes).")"
00193 : "";
00194
00195 if ($this->delete_note)
00196 {
00197 $tpl->setVariable("TXT_NOTES", $lng->txt("info_delete_sure"));
00198 }
00199 else if ($a_type == IL_NOTE_PRIVATE)
00200 {
00201 $tpl->setVariable("TXT_NOTES", $lng->txt("private_notes").$cnt_str);
00202 $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
00203 }
00204 else
00205 {
00206 $tpl->setVariable("TXT_NOTES", $lng->txt("public_notes").$cnt_str);
00207 $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PUBLIC);
00208 }
00209 $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
00210
00211 if ($this->export_html || $this->print)
00212 {
00213 $tpl->touchBlock("print_style");
00214 }
00215
00216
00217 if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note &&
00218 !$this->export_html && !$this->print &&
00219 ($ilUser->getId() != ANONYMOUS_USER_ID))
00220 {
00221 if (!$this->inc_sub)
00222 {
00223 $tpl->setCurrentBlock("add_note_btn");
00224 $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add_note"));
00225 $tpl->setVariable("LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass("ilnotegui", "addNoteForm").
00226 "#note_edit");
00227 $tpl->parseCurrentBlock();
00228 }
00229 }
00230
00231
00232 if (count($all_notes) > 0 && $this->enable_hiding && !$this->delete_note
00233 && !$this->export_html && !$this->print)
00234 {
00235 if ($ilUser->getPref("notes_".$suffix) == "n")
00236 {
00237 $tpl->setCurrentBlock("show_notes");
00238 $tpl->setVariable("LINK_SHOW_NOTES", $this->ctrl->getLinkTargetByClass("ilnotegui", "showNotes"));
00239 $tpl->setVariable("TXT_SHOW_NOTES", $lng->txt("show_".$suffix."_notes"));
00240 $tpl->parseCurrentBlock();
00241 }
00242 else
00243 {
00244
00245 if (($ilUser->getId() != ANONYMOUS_USER_ID))
00246 {
00247 $tpl->setCurrentBlock("hide_notes");
00248 $tpl->setVariable("LINK_HIDE_NOTES", $this->ctrl->getLinkTargetByClass("ilnotegui", "hideNotes"));
00249 $tpl->setVariable("TXT_HIDE_NOTES", $lng->txt("hide_".$suffix."_notes"));
00250 $tpl->parseCurrentBlock();
00251
00252
00253 if ($a_type == IL_NOTE_PUBLIC)
00254 {
00255 if ($ilUser->getPref("notes_pub_all") == "n")
00256 {
00257 $tpl->setCurrentBlock("all_pub_notes");
00258 $tpl->setVariable("LINK_ALL_PUB_NOTES", $this->ctrl->getLinkTargetByClass("ilnotegui", "showAllPublicNotes"));
00259 $tpl->setVariable("TXT_ALL_PUB_NOTES", $lng->txt("note_all_pub_notes"));
00260 $tpl->parseCurrentBlock();
00261 }
00262 else
00263 {
00264 $tpl->setCurrentBlock("my_pub_notes");
00265 $tpl->setVariable("LINK_MY_PUB_NOTES", $this->ctrl->getLinkTargetByClass("ilnotegui", "showMyPublicNotes"));
00266 $tpl->setVariable("TXT_MY_PUB_NOTES", $lng->txt("note_my_pub_notes"));
00267 $tpl->parseCurrentBlock();
00268 }
00269 }
00270 }
00271 }
00272 }
00273
00274
00275 if ($this->add_note_form && $a_type == $_GET["note_type"])
00276 {
00277 $tpl->setCurrentBlock("edit_note");
00278 $tpl->setVariable("TXT_SUBJECT", $lng->txt("subject"));
00279 $tpl->setVariable("TXT_NOTE", $lng->txt("note"));
00280 $tpl->setVariable("NOTE_SUBJECT", "");
00281 $tpl->setVariable("SUB_NOTE", "sub_note");
00282 $tpl->setVariable("TA_NOTE", "note");
00283 $tpl->setVariable("NOTE_CONTENT", "");
00284 $tpl->setVariable("BTN_ADD_NOTE", "addNote");
00285 $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add"));
00286 $tpl->setVariable("BTN_CANCEL_ADD_NOTE", "cancelAddNote");
00287 $tpl->setVariable("TXT_CANCEL_ADD_NOTE", $lng->txt("cancel"));
00288 $tpl->setVariable("VAL_LABEL_NONE", IL_NOTE_UNLABELED);
00289 $tpl->setVariable("TXT_LABEL_NONE", $lng->txt("unlabeled"));
00290 $tpl->setVariable("VAL_LABEL_QUESTION", IL_NOTE_QUESTION);
00291 $tpl->setVariable("TXT_LABEL_QUESTION", $lng->txt("question"));
00292 $tpl->setVariable("VAL_LABEL_IMPORTANT", IL_NOTE_IMPORTANT);
00293 $tpl->setVariable("TXT_LABEL_IMPORTANT", $lng->txt("important"));
00294 $tpl->setVariable("VAL_LABEL_PRO", IL_NOTE_PRO);
00295 $tpl->setVariable("TXT_LABEL_PRO", $lng->txt("pro"));
00296 $tpl->setVariable("VAL_LABEL_CONTRA", IL_NOTE_CONTRA);
00297 $tpl->setVariable("TXT_LABEL_CONTRA", $lng->txt("contra"));
00298 $tpl->parseCurrentBlock();
00299 $tpl->setCurrentBlock("note_row");
00300 $tpl->parseCurrentBlock();
00301 }
00302
00303
00304 if ($ilUser->getPref("notes_".$suffix) != "n" || !$this->enable_hiding)
00305 {
00306 foreach($notes as $note)
00307 {
00308 if ($this->edit_note_form && ($note->getId() == $_GET["note_id"])
00309 && $a_type == $_GET["note_type"])
00310 {
00311 $tpl->setCurrentBlock("edit_note_form");
00312 $tpl->setVariable("TXT_SUBJECT", $lng->txt("subject"));
00313 $tpl->setVariable("TXT_NOTE", $lng->txt("note"));
00314 $tpl->setVariable("NOTE_SUBJECT",
00315 ilUtil::prepareFormOutput($note->getSubject()));
00316 $tpl->setVariable("SUB_NOTE", "sub_note");
00317 $tpl->setVariable("TA_NOTE", "note");
00318 $tpl->setVariable("NOTE_CONTENT",
00319 ilUtil::prepareFormOutput($note->getText()));
00320 $tpl->setVariable("BTN_ADD_NOTE", "updateNote");
00321 $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("save"));
00322 $tpl->setVariable("BTN_CANCEL_ADD_NOTE", "cancelUpdateNote");
00323 $tpl->setVariable("TXT_CANCEL_ADD_NOTE", $lng->txt("cancel"));
00324 $tpl->setVariable("VAL_LABEL_NONE", IL_NOTE_UNLABELED);
00325 $tpl->setVariable("TXT_LABEL_NONE", $lng->txt("unlabeled"));
00326 $tpl->setVariable("VAL_LABEL_QUESTION", IL_NOTE_QUESTION);
00327 $tpl->setVariable("TXT_LABEL_QUESTION", $lng->txt("question"));
00328 $tpl->setVariable("VAL_LABEL_IMPORTANT", IL_NOTE_IMPORTANT);
00329 $tpl->setVariable("TXT_LABEL_IMPORTANT", $lng->txt("important"));
00330 $tpl->setVariable("VAL_LABEL_PRO", IL_NOTE_PRO);
00331 $tpl->setVariable("TXT_LABEL_PRO", $lng->txt("pro"));
00332 $tpl->setVariable("VAL_LABEL_CONTRA", IL_NOTE_CONTRA);
00333 $tpl->setVariable("TXT_LABEL_CONTRA", $lng->txt("contra"));
00334 $tpl->setVariable("VAL_NOTE_ID", $_GET["note_id"]);
00335 switch($note->getLabel())
00336 {
00337 case IL_NOTE_UNLABELED:
00338 $tpl->setVariable("SEL_NONE", 'selected="selected"');
00339 break;
00340
00341 case IL_NOTE_IMPORTANT:
00342 $tpl->setVariable("SEL_IMPORTANT", 'selected="selected"');
00343 break;
00344
00345 case IL_NOTE_QUESTION:
00346 $tpl->setVariable("SEL_QUESTION", 'selected="selected"');
00347 break;
00348
00349 case IL_NOTE_PRO:
00350 $tpl->setVariable("SEL_PRO", 'selected="selected"');
00351 break;
00352
00353 case IL_NOTE_CONTRA:
00354 $tpl->setVariable("SEL_CONTRA", 'selected="selected"');
00355 break;
00356 }
00357 $tpl->parseCurrentBlock();
00358 }
00359 else
00360 {
00361 $cnt_col = 2;
00362
00363
00364 if (($note->getAuthor() == $ilUser->getId() ||
00365 $this->public_deletion_enabled)
00366 && ($ilUser->getId() != ANONYMOUS_USER_ID))
00367 {
00368
00369
00370 if (($a_type == IL_NOTE_PRIVATE || $this->public_deletion_enabled)
00371 && !$this->delete_note
00372 && !$this->export_html && !$this->print)
00373 {
00374 $tpl->setCurrentBlock("delete_note");
00375 $tpl->setVariable("TXT_DELETE_NOTE", $lng->txt("delete"));
00376 $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
00377 $tpl->setVariable("LINK_DELETE_NOTE",
00378 $ilCtrl->getLinkTargetByClass("ilnotegui", "deleteNote")
00379 ."#note_".$note->getId());
00380 $tpl->parseCurrentBlock();
00381 }
00382 }
00383
00384
00385 if ($note->getAuthor() == $ilUser->getId()
00386 && ($ilUser->getId() != ANONYMOUS_USER_ID))
00387 {
00388
00389 if ($this->multi_selection && !$this->delete_note)
00390 {
00391 $tpl->setCurrentBlock("checkbox_col");
00392 $tpl->setVariable("CHK_NOTE", "note[]");
00393 $tpl->setVariable("CHK_NOTE_ID", $note->getId());
00394 $tpl->parseCurrentBlock();
00395 $cnt_col = 1;
00396 }
00397
00398 if (!$this->delete_note && !$this->export_html && !$this->print)
00399 {
00400 $tpl->setCurrentBlock("edit_note");
00401 $tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
00402 $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
00403 $tpl->setVariable("LINK_EDIT_NOTE",
00404 $ilCtrl->getLinkTargetByClass("ilnotegui", "editNoteForm")
00405 ."#note_edit");
00406 $tpl->parseCurrentBlock();
00407 }
00408 }
00409
00410 $tpl->setVariable("CNT_COL", $cnt_col);
00411
00412
00413 if ($a_type == IL_NOTE_PUBLIC)
00414 {
00415 $tpl->setCurrentBlock("author");
00416 $tpl->setVariable("VAL_AUTHOR", ilObjUser::_lookupLogin($note->getAuthor()));
00417 $tpl->parseCurrentBlock();
00418 }
00419
00420
00421 if ($note->getUpdateDate() != "0000-00-00 00:00:00")
00422 {
00423 $tpl->setCurrentBlock("last_edit");
00424 $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
00425 $tpl->setVariable("DATE_LAST_EDIT", $note->getUpdateDate());
00426 $tpl->parseCurrentBlock();
00427 }
00428
00429
00430 if ($this->delete_note)
00431 {
00432 $tpl->setCurrentBlock("delete_ids");
00433 $tpl->setVariable("HID_NOTE", "note[]");
00434 $tpl->setVariable("HID_NOTE_ID", $note->getId());
00435 $tpl->parseCurrentBlock();
00436 }
00437 $target = $note->getObject();
00438
00439
00440 $this->showTargets($tpl, $this->rep_obj_id, $note->getId(),
00441 $target["obj_type"], $target["obj_id"]);
00442
00443 $rowclass = ($rowclass != "tblrow1")
00444 ? "tblrow1"
00445 : "tblrow2";
00446 if (!$this->export_html && !$this->print)
00447 {
00448 $tpl->setCurrentBlock("note_img");
00449 switch ($note->getLabel())
00450 {
00451 case IL_NOTE_UNLABELED:
00452 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_unlabeled.gif"));
00453 $tpl->setVariable("ALT_NOTE", $lng->txt("note"));
00454 break;
00455
00456 case IL_NOTE_IMPORTANT:
00457 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_important.gif"));
00458 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("important"));
00459 break;
00460
00461 case IL_NOTE_QUESTION:
00462 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_question.gif"));
00463 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("question"));
00464 break;
00465
00466 case IL_NOTE_PRO:
00467 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_pro.gif"));
00468 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("pro"));
00469 break;
00470
00471 case IL_NOTE_CONTRA:
00472 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_contra.gif"));
00473 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("contra"));
00474 break;
00475 }
00476 $tpl->parseCurrentBlock();
00477 }
00478 else
00479 {
00480 switch ($note->getLabel())
00481 {
00482 case IL_NOTE_UNLABELED:
00483 $tpl->setVariable("EXP_ICON", "[ ]");
00484 break;
00485
00486 case IL_NOTE_IMPORTANT:
00487 $tpl->setVariable("EXP_ICON", "[!]");
00488 break;
00489
00490 case IL_NOTE_QUESTION:
00491 $tpl->setVariable("EXP_ICON", "[?]");
00492 break;
00493
00494 case IL_NOTE_PRO:
00495 $tpl->setVariable("EXP_ICON", "[+]");
00496 break;
00497
00498 case IL_NOTE_CONTRA:
00499 $tpl->setVariable("EXP_ICON", "[-]");
00500 break;
00501 }
00502 }
00503 $tpl->setCurrentBlock("note");
00504 $tpl->setVariable("ROWCLASS", $rowclass);
00505 $tpl->setVariable("TXT_DATE", $lng->txt("date"));
00506 $tpl->setVariable("TXT_CREATED", $lng->txt("create_date"));
00507 $tpl->setVariable("VAL_DATE", $note->getCreationDate());
00508 $tpl->setVariable("NOTE_TEXT", nl2br($note->getText()));
00509 $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
00510 $tpl->setVariable("NOTE_ID", $note->getId());
00511 $tpl->parseCurrentBlock();
00512 }
00513 $tpl->setCurrentBlock("note_row");
00514 $tpl->parseCurrentBlock();
00515 }
00516
00517
00518 if ($this->multi_selection && !$this->delete_note)
00519 {
00520 $tpl->setCurrentBlock("multiple_commands");
00521 $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
00522 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00523 $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
00524 $tpl->setVariable("TXT_DELETE_NOTES", $this->lng->txt("delete"));
00525 $tpl->setVariable("TXT_PRINT_NOTES", $this->lng->txt("print"));
00526 $tpl->setVariable("TXT_EXPORT_NOTES", $this->lng->txt("exp_html"));
00527 $tpl->parseCurrentBlock();
00528 }
00529
00530
00531 if ($this->delete_note)
00532 {
00533 $tpl->setCurrentBlock("delete_cancel");
00534 $tpl->setVariable("TXT_DEL_NOTES", $this->lng->txt("delete"));
00535 $tpl->setVariable("TXT_CANCEL_DEL_NOTES", $this->lng->txt("cancel"));
00536 $tpl->parseCurrentBlock();
00537 }
00538
00539
00540 if ($this->print)
00541 {
00542 $tpl->touchBlock("print_js");
00543 $tpl->setCurrentBlock("print_back");
00544 $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTarget($this, "showNotes"));
00545 $tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
00546 $tpl->parseCurrentBlock();
00547 }
00548 }
00549
00550 if ($this->delete_note && count($notes) == 0)
00551 {
00552 return "";
00553 }
00554 else
00555 {
00556 return $tpl->get();
00557 }
00558 }
00559
00563 function showTargets(&$tpl, $a_rep_obj_id, $a_note_id, $a_obj_type, $a_obj_id)
00564 {
00565 global $tree, $ilAccess, $objDefinition;
00566
00567 if ($this->targets_enabled)
00568 {
00569 if ($a_rep_obj_id > 0)
00570 {
00571
00572 $ref_ids = ilObject::_getAllReferences($a_rep_obj_id);
00573 $vis_ref_ids = array();
00574 foreach($ref_ids as $ref_id)
00575 {
00576 if ($ilAccess->checkAccess("visible", "", $ref_id))
00577 {
00578 $vis_ref_ids[] = $ref_id;
00579 }
00580 }
00581
00582
00583 if (count($vis_ref_ids) > 0)
00584 {
00585 foreach($vis_ref_ids as $vis_ref_id)
00586 {
00587 $type = ilObject::_lookupType($vis_ref_id, true);
00588
00589 if ($a_obj_type != "pg")
00590 {
00591 if (!is_object($this->item_list_gui[$type]))
00592 {
00593 $class = $objDefinition->getClassName($type);
00594 $location = $objDefinition->getLocation($type);
00595 $full_class = "ilObj".$class."ListGUI";
00596 include_once($location."/class.".$full_class.".php");
00597 $this->item_list_gui[$type] = new $full_class();
00598 }
00599 $title = ilObject::_lookupTitle($a_rep_obj_id);
00600 $this->item_list_gui[$type]->initItem($vis_ref_id, $a_rep_obj_id, $title);
00601 $link = $this->item_list_gui[$type]->getCommandLink("infoScreen");
00602
00603
00604 $link = ilUtil::appendUrlParameterString($link, "anchor=note_".$a_note_id);
00605
00606 $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link)."#note_".$a_note_id;
00607 }
00608 else
00609 {
00610 $title = ilObject::_lookupTitle($a_rep_obj_id);
00611 $link = "goto.php?target=pg_".$a_obj_id."_".$vis_ref_id;
00612 }
00613
00614 $par_id = $tree->getParentId($vis_ref_id);
00615 if ($this->export_html || $this->print)
00616 {
00617 $tpl->setCurrentBlock("exp_target_object");
00618 }
00619 else
00620 {
00621 $tpl->setCurrentBlock("target_object");
00622 $tpl->setVariable("LINK_TARGET", $link);
00623 }
00624 $tpl->setVariable("TXT_CONTAINER",
00625 ilObject::_lookupTitle(
00626 ilObject::_lookupObjId($par_id)));
00627 $tpl->setVariable("TXT_TARGET",
00628 $title);
00629 $tpl->parseCurrentBlock();
00630 }
00631 $tpl->touchBlock("target_objects");
00632 }
00633 }
00634 }
00635 }
00636
00637
00642 function getPDOverviewNoteListHTML()
00643 {
00644 global $lng, $ilUser, $ilCtrl;
00645
00646
00647
00648 $tpl = new ilTemplate("tpl.pd_notes_overview.html", true, true, "Services/Notes");
00649 $tpl->setVariable("TXT_NOTES", $lng->txt("notes"));
00650 $showdetails = $ilUser->getPref('show_pd_notes_details') == 'y';
00651
00652 if ($showdetails)
00653 {
00654 $tpl->setCurrentBlock("hide_details");
00655 $tpl->setVariable("LINK_HIDE_DETAILS",
00656 $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui",
00657 "hidePDNotesDetails"));
00658 $tpl->setVariable("TXT_HIDE_DETAILS",
00659 $this->lng->txt("hide_details"));
00660 $tpl->parseCurrentBlock();
00661 }
00662 else
00663 {
00664 $tpl->setCurrentBlock("show_details");
00665 $tpl->setVariable("LINK_SHOW_DETAILS",
00666 $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui",
00667 "showPDNotesDetails"));
00668 $tpl->setVariable("TXT_SHOW_DETAILS",
00669 $this->lng->txt("show_details"));
00670 $tpl->parseCurrentBlock();
00671 }
00672
00673
00674 include_once("Services/Notes/classes/class.ilNote.php");
00675 $notes = ilNote::_getLastNotesOfUser();
00676
00677 $output = false;
00678 foreach($notes as $note)
00679 {
00680 $output = true;
00681
00682 $rowclass = ($rowclass != "tblrow1")
00683 ? "tblrow1"
00684 : "tblrow2";
00685 $tpl->setCurrentBlock("note");
00686 $tpl->setVariable("ROWCLASS", $rowclass);
00687 $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
00688 switch ($note->getLabel())
00689 {
00690 case IL_NOTE_UNLABELED:
00691 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_unlabeled.gif"));
00692 $tpl->setVariable("ALT_NOTE", $lng->txt("note"));
00693 break;
00694
00695 case IL_NOTE_IMPORTANT:
00696 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_important.gif"));
00697 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("important"));
00698 break;
00699
00700 case IL_NOTE_QUESTION:
00701 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_question.gif"));
00702 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("question"));
00703 break;
00704
00705 case IL_NOTE_PRO:
00706 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_pro.gif"));
00707 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("pro"));
00708 break;
00709
00710 case IL_NOTE_CONTRA:
00711 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_contra.gif"));
00712 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("contra"));
00713 break;
00714 }
00715
00716
00717 $target = $note->getObject();
00718 if ($showdetails)
00719 {
00720 $tpl->setCurrentBlock("details");
00721 $tpl->setVariable("NOTE_TEXT",
00722 ilUtil::shortenText($note->getText(), 150, true, true));
00723
00724 $tpl->setVariable("VAL_DATE", substr($note->getCreationDate(),0,10));
00725 $tpl->parseCurrentBlock();
00726
00727
00728 $this->showTargets($tpl, $target["rep_obj_id"], $note->getId(),
00729 $target["obj_type"], $target["obj_id"]);
00730 }
00731
00732
00733 $tpl->setCurrentBlock("edit_note");
00734 $tpl->setVariable("TXT_EDIT_NOTE", $this->lng->txt("edit"));
00735 $this->ctrl->setParameterByClass("ilnotegui", "rel_obj", $target["rep_obj_id"]);
00736 $this->ctrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
00737 $this->ctrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
00738 $tpl->setVariable("LINK_EDIT_NOTE",
00739 $this->ctrl->getLinkTargetByClass(array("ilpdnotesgui", "ilnotegui"), "editNoteForm")
00740 ."#note_edit");
00741 $tpl->parseCurrentBlock();
00742
00743 $tpl->parseCurrentBlock();
00744 $tpl->setCurrentBlock("note_row");
00745 $tpl->parseCurrentBlock();
00746 }
00747
00748 if ($output)
00749 {
00750 return $tpl->get();
00751 }
00752 else
00753 {
00754 return "";
00755 }
00756 }
00757
00761 function addNoteForm()
00762 {
00763 global $ilUser;
00764
00765 $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
00766 ? "private"
00767 : "public";
00768 $ilUser->setPref("notes_".$suffix, "y");
00769
00770 $this->add_note_form = true;
00771 return $this->getNotesHTML();
00772 }
00773
00777 function cancelAddNote()
00778 {
00779 return $this->getNotesHTML();
00780 }
00781
00785 function cancelUpdateNote()
00786 {
00787 return $this->getNotesHTML();
00788 }
00789
00793 function addNote()
00794 {
00795 global $ilUser;
00796
00797 if($_POST["note"] != "" || $_POST["sub_note"] != "")
00798 {
00799 $note = new ilNote();
00800 $note->setObject($this->obj_type, $this->rep_obj_id, $this->obj_id);
00801 $note->setType($_GET["note_type"]);
00802 $note->setAuthor($ilUser->getId());
00803 $note->setText(ilUtil::stripSlashes($_POST["note"]));
00804 $note->setSubject(ilUtil::stripSlashes($_POST["sub_note"]));
00805 $note->setLabel($_POST["note_label"]);
00806 $note->create();
00807 }
00808
00809 return $this->getNotesHTML();
00810 }
00811
00815 function updateNote()
00816 {
00817 global $ilUser;
00818
00819 $note = new ilNote($_POST["note_id"]);
00820
00821
00822
00823 $note->setText(ilUtil::stripSlashes($_POST["note"]));
00824 $note->setSubject(ilUtil::stripSlashes($_POST["sub_note"]));
00825 $note->setLabel($_POST["note_label"]);
00826 $note->update();
00827
00828 return $this->getNotesHTML();
00829 }
00830
00834 function editNoteForm()
00835 {
00836 $this->edit_note_form = true;
00837 return $this->getNotesHTML();
00838 }
00839
00843 function deleteNote()
00844 {
00845 $this->delete_note = true;
00846 return $this->getNotesHTML();
00847 }
00848
00852 function deleteNotes()
00853 {
00854 global $lng;
00855
00856 if (!$_POST["note"])
00857 {
00858 sendinfo($lng->txt("no_checkbox"));
00859 }
00860 else
00861 {
00862 $this->delete_note = true;
00863 }
00864 return $this->getNotesHTML();
00865 }
00866
00870 function cancelDelete()
00871 {
00872 return $this->getNotesHTML();
00873 }
00874
00878 function confirmDelete()
00879 {
00880 foreach($_POST["note"] as $id)
00881 {
00882 $note = new ilNote($id);
00883 $note->delete();
00884 }
00885 return $this->getNotesHTML();
00886 }
00887
00891 function exportNotesHTML()
00892 {
00893 $tpl = new ilTemplate("tpl.main.html", true, true);
00894
00895 $this->export_html = true;
00896 $this->multi_selection = false;
00897 $tpl->setVariable("CONTENT", $this->getNotesHTML());
00898 ilUtil::deliverData($tpl->get(), "notes.html");
00899 }
00900
00904 function printNotes()
00905 {
00906 $tpl = new ilTemplate("tpl.main.html", true, true);
00907
00908 $this->print = true;
00909 $this->multi_selection = false;
00910 $tpl->setVariable("CONTENT", $this->getNotesHTML());
00911 echo $tpl->get(); exit;
00912 }
00913
00917 function showNotes()
00918 {
00919 global $ilUser;
00920
00921 $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
00922 ? "private"
00923 : "public";
00924 $ilUser->writePref("notes_".$suffix, "y");
00925
00926 return $this->getNotesHTML();
00927 }
00928
00932 function hideNotes()
00933 {
00934 global $ilUser;
00935
00936 $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
00937 ? "private"
00938 : "public";
00939 $ilUser->writePref("notes_".$suffix, "n");
00940
00941 return $this->getNotesHTML();
00942 }
00943
00947 function showAllPublicNotes()
00948 {
00949 global $ilUser;
00950
00951 $ilUser->writePref("notes_pub_all", "y");
00952
00953 return $this->getNotesHTML();
00954 }
00955
00959 function showMyPublicNotes()
00960 {
00961 global $ilUser;
00962
00963 $ilUser->writePref("notes_pub_all", "n");
00964
00965 return $this->getNotesHTML();
00966 }
00967 }
00968 ?>