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