/**
  * inititialize new item
  * Course reference inits the course item
  *
  * @param	int			$a_ref_id		reference id
  * @param	int			$a_obj_id		object id
  * @param	string		$a_title		title
  * @param	string		$a_description	description
  */
 function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "")
 {
     global $ilBench, $ilAccess, $tree;
     $this->reference_ref_id = $a_ref_id;
     $this->reference_obj_id = $a_obj_id;
     include_once './Services/ContainerReference/classes/class.ilContainerReference.php';
     $target_obj_id = ilContainerReference::_lookupTargetId($a_obj_id);
     $target_ref_ids = ilObject::_getAllReferences($target_obj_id);
     $target_ref_id = current($target_ref_ids);
     $target_title = ilContainerReference::_lookupTitle($a_obj_id);
     $target_description = ilObject::_lookupDescription($target_obj_id);
     $this->deleted = $tree->isDeleted($target_ref_id);
     $ilBench->start("ilObjCourseListGUI", "1000_checkAllConditions");
     $this->conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($target_ref_id, $target_obj_id);
     $ilBench->stop("ilObjCourseListGUI", "1000_checkAllConditions");
     parent::initItem($target_ref_id, $target_obj_id, $target_title, $target_description);
     // general commands array
     include_once './Modules/CourseReference/classes/class.ilObjCourseReferenceAccess.php';
     $this->commands = ilObjCourseReferenceAccess::_getCommands($this->reference_ref_id);
     if ($ilAccess->checkAccess('write', '', $this->reference_ref_id) or $this->deleted) {
         $this->info_screen_enabled = false;
     } else {
         $this->info_screen_enabled = true;
     }
 }
Beispiel #2
0
 /**
  * get notes/comments list as html code
  */
 function getNoteListHTML($a_type = IL_NOTE_PRIVATE, $a_init_form = true)
 {
     global $lng, $ilCtrl, $ilUser;
     include_once "./Services/User/classes/class.ilUserUtil.php";
     $suffix = $a_type == IL_NOTE_PRIVATE ? "private" : "public";
     /* user settings are deprecated
     		$user_setting_notes_public_all = $ilUser->getPref("notes_pub_all");
     		$user_setting_notes_by_type = $ilUser->getPref("notes_".$suffix);		 
     		*/
     $user_setting_notes_public_all = "y";
     $user_setting_notes_by_type = "y";
     if ($this->delete_note || $this->export_html || $this->print) {
         if ($_GET["note_id"] != "") {
             $filter = $_GET["note_id"];
         } else {
             $filter = $_POST["note"];
         }
     }
     $notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id, $this->obj_type, $a_type, $this->inc_sub, $filter, $user_setting_notes_public_all, $this->repository_mode, (bool) $_SESSION["comments_sort_asc"]);
     $all_notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id, $this->obj_type, $a_type, $this->inc_sub, $filter, "", $this->repository_mode);
     $tpl = new ilTemplate("tpl.notes_list.html", true, true, "Services/Notes");
     if ($this->ajax) {
         include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
         $tpl->setCurrentBlock("close_img");
         $tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
         $tpl->parseCurrentBlock();
     }
     // show counter if notes are hidden
     $cnt_str = count($all_notes) > 0 ? " (" . count($all_notes) . ")" : "";
     // title
     if ($this->ajax) {
         switch ($this->obj_type) {
             case "catr":
             case "crsr":
                 include_once "Services/ContainerReference/classes/class.ilContainerReference.php";
                 $title = ilContainerReference::_lookupTitle($this->rep_obj_id);
                 break;
             default:
                 $title = ilObject::_lookupTitle($this->rep_obj_id);
                 break;
         }
         $img = ilUtil::img(ilObject::_getIcon($this->rep_obj_id, "tiny"));
         // add sub-object if given
         if ($this->obj_id) {
             $sub_title = $this->getSubObjectTitle($this->rep_obj_id, $this->obj_id);
             if ($sub_title) {
                 $title .= " - " . $sub_title;
             }
         }
         $tpl->setCurrentBlock("title");
         $tpl->setVariable("TITLE", $img . " " . $title);
         $tpl->parseCurrentBlock();
     }
     if ($this->delete_note) {
         $cnt_str = "";
     }
     if ($a_type == IL_NOTE_PRIVATE) {
         $tpl->setVariable("TXT_NOTES", $lng->txt("private_notes") . $cnt_str);
         $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
     } else {
         $tpl->setVariable("TXT_NOTES", $lng->txt("notes_public_comments") . $cnt_str);
         $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PUBLIC);
     }
     $anch = $this->anchor_jump ? "notes_top" : "";
     $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this, "getNotesHTML", $anch));
     if ($this->ajax) {
         $os = "onsubmit = \"ilNotes.cmdAjaxForm(event, '" . $ilCtrl->getFormActionByClass("ilnotegui", "", "", true) . "'); return false;\"";
         $tpl->setVariable("ON_SUBMIT_FORM", $os);
         $tpl->setVariable("FORM_ID", "Ajax");
     }
     if ($this->export_html || $this->print) {
         $tpl->touchBlock("print_style");
     }
     // show add new note button
     if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note && !$this->export_html && !$this->print && $ilUser->getId() != ANONYMOUS_USER_ID) {
         if (!$this->inc_sub) {
             // are displayed
             if ($this->rep_obj_id > 0 || $a_type != IL_NOTE_PUBLIC) {
                 $tpl->setCurrentBlock("add_note_btn");
                 if ($a_type == IL_NOTE_PUBLIC) {
                     $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("notes_add_comment"));
                 } else {
                     $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add_note"));
                 }
                 $tpl->setVariable("LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass("ilnotegui", "addNoteForm") . "#note_edit");
                 $tpl->parseCurrentBlock();
             }
         }
     }
     // show show/hide button for note list
     if (count($all_notes) > 0 && $this->enable_hiding && !$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) {
         if ($user_setting_notes_by_type == "n") {
             if ($a_type == IL_NOTE_PUBLIC) {
                 $txt = $lng->txt("notes_show_comments");
             } else {
                 $txt = $lng->txt("show_" . $suffix . "_notes");
             }
             $this->renderLink($tpl, "show_notes", $txt, "showNotes", "notes_top");
         } else {
             // never individually hide for anonymous users
             if ($ilUser->getId() != ANONYMOUS_USER_ID) {
                 if ($a_type == IL_NOTE_PUBLIC) {
                     $txt = $lng->txt("notes_hide_comments");
                 } else {
                     $txt = $lng->txt("hide_" . $suffix . "_notes");
                 }
                 $this->renderLink($tpl, "hide_notes", $txt, "hideNotes", "notes_top");
                 // show all public notes / my notes only switch
                 if ($a_type == IL_NOTE_PUBLIC) {
                     if ($user_setting_notes_public_all == "n") {
                         $this->renderLink($tpl, "all_pub_notes", $lng->txt("notes_all_comments"), "showAllPublicNotes", "notes_top");
                     } else {
                         $this->renderLink($tpl, "my_pub_notes", $lng->txt("notes_my_comments"), "showMyPublicNotes", "notes_top");
                     }
                 }
             }
         }
     }
     // show add new note text area
     if (!$this->edit_note_form && $user_setting_notes_by_type != "n" && !$this->delete_note && $ilUser->getId() != ANONYMOUS_USER_ID) {
         if ($a_init_form) {
             $this->initNoteForm("create", $a_type);
         }
         $tpl->setCurrentBlock("edit_note_form");
         //			$tpl->setVariable("EDIT_FORM", $this->form->getHTML());
         $tpl->setVariable("EDIT_FORM", $this->form_tpl->get());
         $tpl->parseCurrentBlock();
         $tpl->parseCurrentBlock();
         $tpl->setCurrentBlock("note_row");
         $tpl->parseCurrentBlock();
     }
     // list all notes
     if ($user_setting_notes_by_type != "n" || !$this->enable_hiding) {
         $reldates = ilDatePresentation::useRelativeDates();
         ilDatePresentation::setUseRelativeDates(false);
         if (sizeof($notes)) {
             if ((int) $_SESSION["comments_sort_asc"] == 1) {
                 $sort_txt = $lng->txt("notes_sort_desc");
                 $sort_cmd = "listSortDesc";
             } else {
                 $sort_txt = $lng->txt("notes_sort_asc");
                 $sort_cmd = "listSortAsc";
             }
             $this->renderLink($tpl, "sort_list", $sort_txt, $sort_cmd, $anch);
         }
         $notes_given = false;
         foreach ($notes as $note) {
             if ($this->edit_note_form && $note->getId() == $_GET["note_id"] && $a_type == $_GET["note_type"]) {
                 if ($a_init_form) {
                     $this->initNoteForm("edit", $a_type, $note);
                 }
                 $tpl->setCurrentBlock("edit_note_form");
                 //					$tpl->setVariable("EDIT_FORM", $this->form->getHTML());
                 $tpl->setVariable("EDIT_FORM", $this->form_tpl->get());
                 $tpl->parseCurrentBlock();
             } else {
                 $cnt_col = 2;
                 // delete note stuff for all private notes
                 if ($this->checkDeletion($note) && !$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) {
                     $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
                     $this->renderLink($tpl, "delete_note", $lng->txt("delete"), "deleteNote", "note_" . $note->getId());
                 }
                 // checkboxes in multiselection mode
                 if ($this->multi_selection && !$this->delete_note) {
                     $tpl->setCurrentBlock("checkbox_col");
                     $tpl->setVariable("CHK_NOTE", "note[]");
                     $tpl->setVariable("CHK_NOTE_ID", $note->getId());
                     $tpl->parseCurrentBlock();
                     $cnt_col = 1;
                 }
                 // edit note stuff for all private notes
                 if ($this->checkEdit($note)) {
                     if (!$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) {
                         $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
                         $this->renderLink($tpl, "edit_note", $lng->txt("edit"), "editNoteForm", "note_edit");
                     }
                 }
                 $tpl->setVariable("CNT_COL", $cnt_col);
                 // output author account
                 if ($a_type == IL_NOTE_PUBLIC && ilObject::_exists($note->getAuthor())) {
                     //$tpl->setCurrentBlock("author");
                     //$tpl->setVariable("VAL_AUTHOR", ilObjUser::_lookupLogin($note->getAuthor()));
                     //$tpl->parseCurrentBlock();
                     $tpl->setCurrentBlock("user_img");
                     $tpl->setVariable("USR_IMG", ilObjUser::_getPersonalPicturePath($note->getAuthor(), "xxsmall"));
                     $tpl->setVariable("USR_ALT", $lng->txt("user_image") . ": " . ilObjUser::_lookupLogin($note->getAuthor()));
                     $tpl->parseCurrentBlock();
                     $tpl->setVariable("TXT_USR", ilUserUtil::getNamePresentation($note->getAuthor(), false, false) . " - ");
                 }
                 // last edited
                 if ($note->getUpdateDate() != null) {
                     $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
                     $tpl->setVariable("DATE_LAST_EDIT", ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME)));
                 } else {
                     $tpl->setVariable("VAL_DATE", ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME)));
                 }
                 // hidden note ids for deletion
                 if ($this->delete_note) {
                     $tpl->setCurrentBlock("delete_ids");
                     $tpl->setVariable("HID_NOTE", "note[]");
                     $tpl->setVariable("HID_NOTE_ID", $note->getId());
                     $tpl->parseCurrentBlock();
                 }
                 $target = $note->getObject();
                 // target objects
                 $this->showTargets($tpl, $this->rep_obj_id, $note->getId(), $target["obj_type"], $target["obj_id"]);
                 $rowclass = $rowclass != "tblrow1" ? "tblrow1" : "tblrow2";
                 if (!$this->export_html && !$this->print) {
                     $tpl->setCurrentBlock("note_img");
                     if ($a_type == IL_NOTE_PUBLIC) {
                         $tpl->setVariable("IMG_NOTE", $this->comment_img[$note->getLabel()]["img"]);
                         $tpl->setVariable("ALT_NOTE", $this->comment_img[$note->getLabel()]["alt"]);
                     } else {
                         $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]);
                         $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]);
                     }
                     $tpl->parseCurrentBlock();
                 } else {
                     switch ($note->getLabel()) {
                         case IL_NOTE_UNLABELED:
                             $tpl->setVariable("EXP_ICON", "[ ]");
                             break;
                         case IL_NOTE_IMPORTANT:
                             $tpl->setVariable("EXP_ICON", "[!]");
                             break;
                         case IL_NOTE_QUESTION:
                             $tpl->setVariable("EXP_ICON", "[?]");
                             break;
                         case IL_NOTE_PRO:
                             $tpl->setVariable("EXP_ICON", "[+]");
                             break;
                         case IL_NOTE_CONTRA:
                             $tpl->setVariable("EXP_ICON", "[-]");
                             break;
                     }
                 }
                 $tpl->setCurrentBlock("note");
                 $tpl->setVariable("ROWCLASS", $rowclass);
                 $text = trim($note->getText()) != "" ? nl2br($note->getText()) : "<p class='subtitle'>" . $lng->txt("note_content_removed") . "</p>";
                 $tpl->setVariable("NOTE_TEXT", $text);
                 $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
                 $tpl->setVariable("NOTE_ID", $note->getId());
                 $tpl->setVariable("CLASS", $a_type == IL_NOTE_PUBLIC ? "ilComment" : "ilNote");
                 $tpl->parseCurrentBlock();
             }
             $tpl->setCurrentBlock("note_row");
             $tpl->parseCurrentBlock();
             $notes_given = true;
         }
         if (!$notes_given) {
             $tpl->setCurrentBlock("no_notes");
             if ($a_type == IL_NOTE_PUBLIC) {
                 $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_comments"));
             }
             /*				else
             				{
             					$tpl->setVariable("NO_NOTES", $lng->txt("notes_no_notes"));
             				}*/
             $tpl->parseCurrentBlock();
         }
         ilDatePresentation::setUseRelativeDates($reldates);
         // multiple items commands
         if ($this->multi_selection && !$this->delete_note && !$this->edit_note_form && count($notes) > 0) {
             if ($a_type == IL_NOTE_PRIVATE) {
                 $tpl->setCurrentBlock("delete_cmd");
                 $tpl->setVariable("TXT_DELETE_NOTES", $this->lng->txt("delete"));
                 $tpl->parseCurrentBlock();
             }
             $tpl->setCurrentBlock("multiple_commands");
             $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
             $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
             $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
             $tpl->setVariable("TXT_PRINT_NOTES", $this->lng->txt("print"));
             $tpl->setVariable("TXT_EXPORT_NOTES", $this->lng->txt("exp_html"));
             $tpl->parseCurrentBlock();
         }
         // delete / cancel row
         if ($this->delete_note) {
             $tpl->setCurrentBlock("delete_cancel");
             $tpl->setVariable("TXT_DEL_NOTES", $this->lng->txt("delete"));
             $tpl->setVariable("TXT_CANCEL_DEL_NOTES", $this->lng->txt("cancel"));
             $tpl->parseCurrentBlock();
         }
         // print
         if ($this->print) {
             $tpl->touchBlock("print_js");
             $tpl->setCurrentBlock("print_back");
             $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTarget($this, "showNotes"));
             $tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
             $tpl->parseCurrentBlock();
         }
     }
     // message
     switch ($_GET["note_mess"] != "" ? $_GET["note_mess"] : $this->note_mess) {
         case "mod":
             $mtype = "success";
             $mtxt = $lng->txt("msg_obj_modified");
             break;
         case "ntsdel":
             $mtype = "success";
             $mtxt = $a_type == IL_NOTE_PRIVATE ? $lng->txt("notes_notes_deleted") : $lng->txt("notes_comments_deleted");
             break;
         case "ntdel":
             $mtype = "success";
             $mtxt = $a_type == IL_NOTE_PRIVATE ? $lng->txt("notes_note_deleted") : $lng->txt("notes_comment_deleted");
             break;
         case "frmfld":
             $mtype = "failure";
             $mtxt = $lng->txt("form_input_not_valid");
             break;
         case "qdel":
             $mtype = "question";
             $mtxt = $lng->txt("info_delete_sure");
             break;
         case "noc":
             $mtype = "failure";
             $mtxt = $lng->txt("no_checkbox");
             break;
     }
     if ($mtxt != "") {
         $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype));
     } else {
         $tpl->setVariable("MESS", "");
     }
     if ($this->delete_note && count($notes) == 0) {
         return "";
     } else {
         return $tpl->get();
     }
 }