• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Notes/classes/class.ilNoteGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once ("Services/Notes/classes/class.ilNote.php");
00025 
00033 class ilNoteGUI
00034 {
00035         var $public_deletion_enabled = false;
00036         
00037         
00046         function ilNoteGUI($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_include_subobjects = false)
00047         {
00048                 global $ilCtrl, $lng;
00049 
00050                 $this->rep_obj_id = $a_rep_obj_id;
00051                 $this->obj_id = $a_obj_id;
00052                 $this->obj_type = $a_obj_type;
00053                 $this->inc_sub = $a_include_subobjects;
00054                 
00055                 $this->ctrl =& $ilCtrl;
00056                 $this->lng =& $lng;
00057                 
00058                 $this->add_note_form = false;
00059                 $this->edit_note_form = false;
00060                 $this->private_enabled = false;
00061                 $this->public_enabled = false;
00062                 $this->enable_hiding = true;
00063                 $this->targets_enabled = false;
00064                 $this->multi_selection = false;
00065                 $this->export_html = false;
00066                 $this->print = false;
00067         }
00068         
00072         function &executeCommand()
00073         {
00074                 $cmd = $this->ctrl->getCmd("getNotesHTML");
00075                 $next_class = $this->ctrl->getNextClass($this);
00076 
00077                 switch($next_class)
00078                 {
00079                         default:
00080                                 return $this->$cmd();
00081                                 break;
00082                 }
00083         }
00084         
00088         function enablePrivateNotes($a_enable = true)
00089         {
00090                 $this->private_enabled = $a_enable;
00091         }
00092         
00096         function enablePublicNotes($a_enable = true)
00097         {
00098                 $this->public_enabled =  $a_enable;
00099         }
00100 
00104         function enablePublicNotesDeletion($a_enable = true)
00105         {
00106                 $this->public_deletion_enabled =  $a_enable;
00107         }
00108 
00112         function enableHiding($a_enable = true)
00113         {
00114                 $this->enable_hiding = $a_enable;
00115         }
00116         
00120         function enableTargets($a_enable = true)
00121         {
00122                 $this->targets_enabled = $a_enable;
00123         }
00124 
00128         function enableMultiSelection($a_enable = true)
00129         {
00130                 $this->multi_selection = $a_enable;
00131         }
00132 
00133         /***
00134         * get note lists html code
00135         */
00136         function getNotesHTML()
00137         {
00138                 global $ilUser;
00139 
00140                 $html = "";
00141                 if ($this->private_enabled && ($ilUser->getId() != ANONYMOUS_USER_ID))
00142                 {
00143                         $html.= $this->getNoteListHTML(IL_NOTE_PRIVATE);
00144                 }
00145                 
00146                 if ($this->public_enabled && (!$this->delete_note || $this->public_deletion_enabled))
00147                 {
00148                         $html.= $this->getNoteListHTML(IL_NOTE_PUBLIC);
00149                 }
00150                 
00151                 return $html;
00152         }
00153 
00157         function getNoteListHTML($a_type = IL_NOTE_PRIVATE)
00158         {
00159                 global $lng, $ilCtrl, $ilUser, $ilAccess, $tree, $objDefinition;
00160 
00161                 $suffix = ($a_type == IL_NOTE_PRIVATE)
00162                         ? "private"
00163                         : "public";
00164                 
00165                 if ($this->delete_note || $this->export_html || $this->print)
00166                 {
00167                         if ($_GET["note_id"] != "")
00168                         {
00169                                 $filter = $_GET["note_id"];
00170                         }
00171                         else
00172                         {
00173                                 $filter = $_POST["note"];
00174                         }
00175                 }
00176                 
00177                 $notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id,
00178                         $this->obj_type, $a_type, $this->inc_sub, $filter,
00179                         $ilUser->getPref("notes_pub_all"), $this->public_deletion_enabled);
00180 
00181                 $tpl = new ilTemplate("tpl.notes_list.html", true, true, "Services/Notes");
00182                 
00183                 // show counter if notes are hidden
00184                 $cnt_str = ($ilUser->getPref("notes_".$suffix) == "n"
00185                         && count($notes) > 0)
00186                         ? " (".count($notes).")"
00187                         : "";
00188                 
00189                 if ($this->delete_note)
00190                 {
00191                         $tpl->setVariable("TXT_NOTES", $lng->txt("info_delete_sure"));
00192                 }
00193                 else if ($a_type == IL_NOTE_PRIVATE)
00194                 {
00195                         $tpl->setVariable("TXT_NOTES", $lng->txt("private_notes").$cnt_str);
00196                         $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
00197                 }
00198                 else
00199                 {
00200                         $tpl->setVariable("TXT_NOTES", $lng->txt("public_notes").$cnt_str);
00201                         $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PUBLIC);
00202                 }
00203                 $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
00204                 
00205                 if ($this->export_html || $this->print)
00206                 {
00207                         $tpl->touchBlock("print_style");
00208                 }
00209                 
00210                 // show add new note button
00211                 if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note &&
00212                         !$this->export_html && !$this->print &&
00213                         ($ilUser->getId() != ANONYMOUS_USER_ID))
00214                 {
00215                         if (!$this->inc_sub)    // we cannot offer add button if aggregated notes
00216                         {                                               // are displayed
00217                                 $tpl->setCurrentBlock("add_note_btn");
00218                                 $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add_note"));
00219                                 $tpl->setVariable("LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass("ilnotegui", "addNoteForm").
00220                                         "#note_edit");
00221                                 $tpl->parseCurrentBlock();
00222                         }
00223                 }
00224                 
00225                 // show show/hide button for note list
00226                 if (count($notes) > 0 && $this->enable_hiding && !$this->delete_note
00227                         && !$this->export_html && !$this->print)
00228                 {
00229                         if ($ilUser->getPref("notes_".$suffix) == "n")
00230                         {
00231                                 $tpl->setCurrentBlock("show_notes");
00232                                 $tpl->setVariable("LINK_SHOW_NOTES", $this->ctrl->getLinkTargetByClass("ilnotegui", "showNotes"));
00233                                 $tpl->setVariable("TXT_SHOW_NOTES", $lng->txt("show_".$suffix."_notes"));
00234                                 $tpl->parseCurrentBlock();
00235                         }
00236                         else
00237                         {
00238                                 // never individually hide for anonymous users
00239                                 if (($ilUser->getId() != ANONYMOUS_USER_ID))
00240                                 {
00241                                         $tpl->setCurrentBlock("hide_notes");
00242                                         $tpl->setVariable("LINK_HIDE_NOTES", $this->ctrl->getLinkTargetByClass("ilnotegui", "hideNotes"));
00243                                         $tpl->setVariable("TXT_HIDE_NOTES", $lng->txt("hide_".$suffix."_notes"));
00244                                         $tpl->parseCurrentBlock();
00245                                         
00246                                         // show all public notes / my notes only switch
00247                                         if ($a_type == IL_NOTE_PUBLIC)
00248                                         {
00249                                                 if ($ilUser->getPref("notes_pub_all") == "n")
00250                                                 {
00251                                                         $tpl->setCurrentBlock("all_pub_notes");
00252                                                         $tpl->setVariable("LINK_ALL_PUB_NOTES", $this->ctrl->getLinkTargetByClass("ilnotegui", "showAllPublicNotes"));
00253                                                         $tpl->setVariable("TXT_ALL_PUB_NOTES", $lng->txt("note_all_pub_notes"));
00254                                                         $tpl->parseCurrentBlock();
00255                                                 }
00256                                                 else
00257                                                 {
00258                                                         $tpl->setCurrentBlock("my_pub_notes");
00259                                                         $tpl->setVariable("LINK_MY_PUB_NOTES", $this->ctrl->getLinkTargetByClass("ilnotegui", "showMyPublicNotes"));
00260                                                         $tpl->setVariable("TXT_MY_PUB_NOTES", $lng->txt("note_my_pub_notes"));
00261                                                         $tpl->parseCurrentBlock();
00262                                                 }
00263                                         }
00264                                 }
00265                         }
00266                 }
00267                 
00268                 // show add new note text area
00269                 if ($this->add_note_form && $a_type == $_GET["note_type"])
00270                 {
00271                         $tpl->setCurrentBlock("edit_note");
00272                         $tpl->setVariable("TXT_SUBJECT", $lng->txt("subject"));
00273                         $tpl->setVariable("TXT_NOTE", $lng->txt("note"));
00274                         $tpl->setVariable("NOTE_SUBJECT", "");
00275                         $tpl->setVariable("SUB_NOTE", "sub_note");
00276                         $tpl->setVariable("TA_NOTE", "note");
00277                         $tpl->setVariable("NOTE_CONTENT", "");
00278                         $tpl->setVariable("BTN_ADD_NOTE", "addNote");
00279                         $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add"));
00280                         $tpl->setVariable("BTN_CANCEL_ADD_NOTE", "cancelAddNote");
00281                         $tpl->setVariable("TXT_CANCEL_ADD_NOTE", $lng->txt("cancel"));
00282                         $tpl->setVariable("VAL_LABEL_NONE", IL_NOTE_UNLABELED);
00283                         $tpl->setVariable("TXT_LABEL_NONE", $lng->txt("unlabeled"));
00284                         $tpl->setVariable("VAL_LABEL_QUESTION", IL_NOTE_QUESTION);
00285                         $tpl->setVariable("TXT_LABEL_QUESTION", $lng->txt("question"));
00286                         $tpl->setVariable("VAL_LABEL_IMPORTANT", IL_NOTE_IMPORTANT);
00287                         $tpl->setVariable("TXT_LABEL_IMPORTANT", $lng->txt("important"));
00288                         $tpl->setVariable("VAL_LABEL_PRO", IL_NOTE_PRO);
00289                         $tpl->setVariable("TXT_LABEL_PRO", $lng->txt("pro"));
00290                         $tpl->setVariable("VAL_LABEL_CONTRA", IL_NOTE_CONTRA);
00291                         $tpl->setVariable("TXT_LABEL_CONTRA", $lng->txt("contra"));
00292                         $tpl->parseCurrentBlock();
00293                         $tpl->setCurrentBlock("note_row");
00294                         $tpl->parseCurrentBlock();
00295                 }
00296 
00297                 // list all notes
00298                 if ($ilUser->getPref("notes_".$suffix) != "n" || !$this->enable_hiding)
00299                 {
00300                         foreach($notes as $note)
00301                         {
00302                                 if ($this->edit_note_form && ($note->getId() == $_GET["note_id"])
00303                                         && $a_type == $_GET["note_type"])
00304                                 {
00305                                         $tpl->setCurrentBlock("edit_note_form");
00306                                         $tpl->setVariable("TXT_SUBJECT", $lng->txt("subject"));
00307                                         $tpl->setVariable("TXT_NOTE", $lng->txt("note"));
00308                                         $tpl->setVariable("NOTE_SUBJECT",
00309                                                 ilUtil::prepareFormOutput($note->getSubject()));
00310                                         $tpl->setVariable("SUB_NOTE", "sub_note");
00311                                         $tpl->setVariable("TA_NOTE", "note");
00312                                         $tpl->setVariable("NOTE_CONTENT",
00313                                                 ilUtil::prepareFormOutput($note->getText()));
00314                                         $tpl->setVariable("BTN_ADD_NOTE", "updateNote");
00315                                         $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("save"));
00316                                         $tpl->setVariable("BTN_CANCEL_ADD_NOTE", "cancelUpdateNote");
00317                                         $tpl->setVariable("TXT_CANCEL_ADD_NOTE", $lng->txt("cancel"));
00318                                         $tpl->setVariable("VAL_LABEL_NONE", IL_NOTE_UNLABELED);
00319                                         $tpl->setVariable("TXT_LABEL_NONE", $lng->txt("unlabeled"));
00320                                         $tpl->setVariable("VAL_LABEL_QUESTION", IL_NOTE_QUESTION);
00321                                         $tpl->setVariable("TXT_LABEL_QUESTION", $lng->txt("question"));
00322                                         $tpl->setVariable("VAL_LABEL_IMPORTANT", IL_NOTE_IMPORTANT);
00323                                         $tpl->setVariable("TXT_LABEL_IMPORTANT", $lng->txt("important"));
00324                                         $tpl->setVariable("VAL_LABEL_PRO", IL_NOTE_PRO);
00325                                         $tpl->setVariable("TXT_LABEL_PRO", $lng->txt("pro"));
00326                                         $tpl->setVariable("VAL_LABEL_CONTRA", IL_NOTE_CONTRA);
00327                                         $tpl->setVariable("TXT_LABEL_CONTRA", $lng->txt("contra"));
00328                                         $tpl->setVariable("VAL_NOTE_ID", $_GET["note_id"]);
00329                                         switch($note->getLabel())
00330                                         {
00331                                                 case IL_NOTE_UNLABELED:
00332                                                         $tpl->setVariable("SEL_NONE", 'selected="selected"');
00333                                                         break;
00334                                                         
00335                                                 case IL_NOTE_IMPORTANT:
00336                                                         $tpl->setVariable("SEL_IMPORTANT", 'selected="selected"');
00337                                                         break;
00338                                                         
00339                                                 case IL_NOTE_QUESTION:
00340                                                         $tpl->setVariable("SEL_QUESTION", 'selected="selected"');
00341                                                         break;
00342                                                         
00343                                                 case IL_NOTE_PRO:
00344                                                         $tpl->setVariable("SEL_PRO", 'selected="selected"');
00345                                                         break;
00346                                                         
00347                                                 case IL_NOTE_CONTRA:
00348                                                         $tpl->setVariable("SEL_CONTRA", 'selected="selected"');
00349                                                         break;
00350                                         }
00351                                         $tpl->parseCurrentBlock();
00352                                 }
00353                                 else
00354                                 {
00355                                         $cnt_col = 2;
00356                                         
00357                                         // delete note stuff for all private notes
00358                                         if (($note->getAuthor() == $ilUser->getId() ||
00359                                                 $this->public_deletion_enabled)
00360                                                 && ($ilUser->getId() != ANONYMOUS_USER_ID))
00361                                         {
00362                                                 // only private notes can be deleted by the user
00363                                                 // public notes can be deleted if flag set (outside permission checking)
00364                                                 if (($a_type == IL_NOTE_PRIVATE || $this->public_deletion_enabled) 
00365                                                         && !$this->delete_note
00366                                                         && !$this->export_html && !$this->print)
00367                                                 {
00368                                                         $tpl->setCurrentBlock("delete_note");
00369                                                         $tpl->setVariable("TXT_DELETE_NOTE", $lng->txt("delete"));
00370                                                         $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
00371                                                         $tpl->setVariable("LINK_DELETE_NOTE",
00372                                                                 $ilCtrl->getLinkTargetByClass("ilnotegui", "deleteNote")
00373                                                                 ."#note_".$note->getId());
00374                                                         $tpl->parseCurrentBlock();
00375                                                 }
00376                                         }
00377                                         
00378                                         // edit note stuff for all private notes
00379                                         if ($note->getAuthor() == $ilUser->getId()
00380                                                 && ($ilUser->getId() != ANONYMOUS_USER_ID))
00381                                         {
00382                                                 // checkboxes in multiselection mode
00383                                                 if ($this->multi_selection && !$this->delete_note)
00384                                                 {
00385                                                         $tpl->setCurrentBlock("checkbox_col");
00386                                                         $tpl->setVariable("CHK_NOTE", "note[]");
00387                                                         $tpl->setVariable("CHK_NOTE_ID", $note->getId());
00388                                                         $tpl->parseCurrentBlock();
00389                                                         $cnt_col = 1;
00390                                                 }
00391 
00392                                                 if (!$this->delete_note && !$this->export_html && !$this->print)
00393                                                 {
00394                                                         $tpl->setCurrentBlock("edit_note");
00395                                                         $tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
00396                                                         $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
00397                                                         $tpl->setVariable("LINK_EDIT_NOTE",
00398                                                                 $ilCtrl->getLinkTargetByClass("ilnotegui", "editNoteForm")
00399                                                                 ."#note_edit");
00400                                                         $tpl->parseCurrentBlock();
00401                                                 }
00402                                         }
00403                                         
00404                                         $tpl->setVariable("CNT_COL", $cnt_col);
00405                                         
00406                                         // output author account
00407                                         if ($a_type == IL_NOTE_PUBLIC)
00408                                         {
00409                                                 $tpl->setCurrentBlock("author");
00410                                                 $tpl->setVariable("VAL_AUTHOR", ilObjUser::_lookupLogin($note->getAuthor()));
00411                                                 $tpl->parseCurrentBlock();
00412                                         }
00413                                         
00414                                         // last edited
00415                                         if ($note->getUpdateDate() != "0000-00-00 00:00:00")
00416                                         {
00417                                                 $tpl->setCurrentBlock("last_edit");
00418                                                 $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
00419                                                 $tpl->setVariable("DATE_LAST_EDIT", $note->getUpdateDate());
00420                                                 $tpl->parseCurrentBlock();
00421                                         }
00422                                         
00423                                         // hidden note ids for deletion
00424                                         if ($this->delete_note)
00425                                         {
00426                                                 $tpl->setCurrentBlock("delete_ids");
00427                                                 $tpl->setVariable("HID_NOTE", "note[]");
00428                                                 $tpl->setVariable("HID_NOTE_ID", $note->getId());
00429                                                 $tpl->parseCurrentBlock();                                              
00430                                         }
00431                                         $target = $note->getObject();
00432                                         
00433                                         // target objects                                                       
00434                                         $this->showTargets($tpl, $this->rep_obj_id, $note->getId(),
00435                                                 $target["obj_type"], $target["obj_id"]);
00436                                         
00437                                         $rowclass = ($rowclass != "tblrow1")
00438                                                 ? "tblrow1"
00439                                                 : "tblrow2";
00440                                         if (!$this->export_html && !$this->print)
00441                                         {
00442                                                 $tpl->setCurrentBlock("note_img");
00443                                                 switch ($note->getLabel())
00444                                                 {
00445                                                         case IL_NOTE_UNLABELED:
00446                                                                 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_unlabeled.gif"));
00447                                                                 $tpl->setVariable("ALT_NOTE", $lng->txt("note"));
00448                                                                 break;
00449                                                                 
00450                                                         case IL_NOTE_IMPORTANT:
00451                                                                 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_important.gif"));
00452                                                                 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("important"));
00453                                                                 break;
00454                                                                 
00455                                                         case IL_NOTE_QUESTION:
00456                                                                 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_question.gif"));
00457                                                                 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("question"));
00458                                                                 break;
00459                                                                 
00460                                                         case IL_NOTE_PRO:
00461                                                                 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_pro.gif"));
00462                                                                 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("pro"));
00463                                                                 break;
00464                                                                 
00465                                                         case IL_NOTE_CONTRA:
00466                                                                 $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_contra.gif"));
00467                                                                 $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("contra"));
00468                                                                 break;
00469                                                 }
00470                                                 $tpl->parseCurrentBlock();
00471                                         }
00472                                         else
00473                                         {
00474                                                 switch ($note->getLabel())
00475                                                 {
00476                                                         case IL_NOTE_UNLABELED:
00477                                                                 $tpl->setVariable("EXP_ICON", "[&nbsp;]");
00478                                                                 break;
00479                                                                 
00480                                                         case IL_NOTE_IMPORTANT:
00481                                                                 $tpl->setVariable("EXP_ICON", "[!]");
00482                                                                 break;
00483                                                                 
00484                                                         case IL_NOTE_QUESTION:
00485                                                                 $tpl->setVariable("EXP_ICON", "[?]");
00486                                                                 break;
00487 
00488                                                         case IL_NOTE_PRO:
00489                                                                 $tpl->setVariable("EXP_ICON", "[+]");
00490                                                                 break;
00491                                                                 
00492                                                         case IL_NOTE_CONTRA:
00493                                                                 $tpl->setVariable("EXP_ICON", "[-]");
00494                                                                 break;
00495                                                 }
00496                                         }
00497                                         $tpl->setCurrentBlock("note");
00498                                         $tpl->setVariable("ROWCLASS", $rowclass);
00499                                         $tpl->setVariable("TXT_DATE", $lng->txt("date"));
00500                                         $tpl->setVariable("TXT_CREATED", $lng->txt("create_date"));
00501                                         $tpl->setVariable("VAL_DATE", $note->getCreationDate());
00502                                         $tpl->setVariable("NOTE_TEXT", nl2br($note->getText()));
00503                                         $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
00504                                         $tpl->setVariable("NOTE_ID", $note->getId());
00505                                         $tpl->parseCurrentBlock();
00506                                 }
00507                                 $tpl->setCurrentBlock("note_row");
00508                                 $tpl->parseCurrentBlock();
00509                         }
00510                         
00511                         // multiple items commands
00512                         if ($this->multi_selection && !$this->delete_note)
00513                         {
00514                                 $tpl->setCurrentBlock("multiple_commands");
00515                                 $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
00516                                 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00517                                 $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
00518                                 $tpl->setVariable("TXT_DELETE_NOTES", $this->lng->txt("delete"));
00519                                 $tpl->setVariable("TXT_PRINT_NOTES", $this->lng->txt("print"));
00520                                 $tpl->setVariable("TXT_EXPORT_NOTES", $this->lng->txt("exp_html"));
00521                                 $tpl->parseCurrentBlock();
00522                         }
00523 
00524                         // delete / cancel row
00525                         if ($this->delete_note)
00526                         {
00527                                 $tpl->setCurrentBlock("delete_cancel");
00528                                 $tpl->setVariable("TXT_DEL_NOTES", $this->lng->txt("delete"));
00529                                 $tpl->setVariable("TXT_CANCEL_DEL_NOTES", $this->lng->txt("cancel"));
00530                                 $tpl->parseCurrentBlock();
00531                         }
00532                         
00533                         // print
00534                         if ($this->print)
00535                         {
00536                                 $tpl->touchBlock("print_js");
00537                                 $tpl->setCurrentBlock("print_back");
00538                                 $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTarget($this, "showNotes"));
00539                                 $tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
00540                                 $tpl->parseCurrentBlock();
00541                         }
00542                 }
00543                 
00544                 if ($this->delete_note && count($notes) == 0)
00545                 {
00546                         return "";
00547                 }
00548                 else
00549                 {
00550                         return $tpl->get();
00551                 }
00552         }
00553         
00557         function showTargets(&$tpl, $a_rep_obj_id, $a_note_id, $a_obj_type, $a_obj_id)
00558         {
00559                 global $tree, $ilAccess, $objDefinition;
00560 
00561                 if ($this->targets_enabled)
00562                 {
00563                         if ($a_rep_obj_id > 0)
00564                         {
00565                                 // get all visible references of target object
00566                                 $ref_ids = ilObject::_getAllReferences($a_rep_obj_id);
00567                                 $vis_ref_ids = array();
00568                                 foreach($ref_ids as $ref_id)
00569                                 {
00570                                         if ($ilAccess->checkAccess("visible", "", $ref_id))
00571                                         {
00572                                                 $vis_ref_ids[] = $ref_id;
00573                                         }
00574                                 }
00575                         
00576                                 // output links to targets
00577                                 if (count($vis_ref_ids) > 0)
00578                                 {
00579                                         foreach($vis_ref_ids as $vis_ref_id)
00580                                         {
00581                                                 $type = ilObject::_lookupType($vis_ref_id, true);
00582                                                 
00583                                                 if ($a_obj_type != "pg")
00584                                                 {
00585                                                         if (!is_object($this->item_list_gui[$type]))
00586                                                         {
00587                                                                 $class = $objDefinition->getClassName($type);
00588                                                                 $location = $objDefinition->getLocation($type);
00589                                                                 $full_class = "ilObj".$class."ListGUI";
00590                                                                 include_once($location."/class.".$full_class.".php");
00591                                                                 $this->item_list_gui[$type] = new $full_class();
00592                                                         }
00593                                                         $title = ilObject::_lookupTitle($a_rep_obj_id);
00594                                                         $this->item_list_gui[$type]->initItem($vis_ref_id, $a_rep_obj_id, $title);
00595                                                         $link = $this->item_list_gui[$type]->getCommandLink("infoScreen");
00596                                                         
00597                                                         // workaround, because # anchor can't be passed through frameset
00598                                                         $link = ilUtil::appendUrlParameterString($link, "anchor=note_".$a_note_id);
00599                                                         
00600                                                         $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link)."#note_".$a_note_id;
00601                                                 }
00602                                                 else
00603                                                 {
00604                                                         $title = ilObject::_lookupTitle($a_rep_obj_id);
00605                                                         $link = "goto.php?target=pg_".$a_obj_id."_".$vis_ref_id;
00606                                                 }
00607                                                 
00608                                                 $par_id = $tree->getParentId($vis_ref_id);
00609                                                 if ($this->export_html || $this->print)
00610                                                 {
00611                                                         $tpl->setCurrentBlock("exp_target_object");
00612                                                 }
00613                                                 else
00614                                                 {
00615                                                         $tpl->setCurrentBlock("target_object");
00616                                                         $tpl->setVariable("LINK_TARGET", $link);
00617                                                 }
00618                                                 $tpl->setVariable("TXT_CONTAINER",
00619                                                         ilObject::_lookupTitle(
00620                                                         ilObject::_lookupObjId($par_id)));
00621                                                 $tpl->setVariable("TXT_TARGET",
00622                                                         $title);
00623                                                 $tpl->parseCurrentBlock();
00624                                         }
00625                                         $tpl->touchBlock("target_objects");
00626                                 }
00627                         }
00628                 }
00629         }
00630 
00631         
00636         function getPDOverviewNoteListHTML()
00637         {
00638                 global $lng, $ilUser, $ilCtrl;
00639                 
00640                 //$notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id, $this->obj_type, $a_type);
00641                 
00642                 $tpl = new ilTemplate("tpl.pd_notes_overview.html", true, true, "Services/Notes");
00643                 $tpl->setVariable("TXT_NOTES", $lng->txt("notes"));
00644                 $showdetails = $ilUser->getPref('show_pd_notes_details') == 'y';
00645                 // add details link
00646                 if ($showdetails)
00647                 {
00648                         $tpl->setCurrentBlock("hide_details");
00649                         $tpl->setVariable("LINK_HIDE_DETAILS",
00650                                 $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui",
00651                                         "hidePDNotesDetails"));
00652                         $tpl->setVariable("TXT_HIDE_DETAILS",
00653                                 $this->lng->txt("hide_details"));
00654                         $tpl->parseCurrentBlock();
00655                 }
00656                 else
00657                 {
00658                         $tpl->setCurrentBlock("show_details");
00659                         $tpl->setVariable("LINK_SHOW_DETAILS",
00660                                 $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui",
00661                                         "showPDNotesDetails"));
00662                         $tpl->setVariable("TXT_SHOW_DETAILS",
00663                                 $this->lng->txt("show_details"));
00664                         $tpl->parseCurrentBlock();
00665                 }
00666 
00667                 // get last ten notes
00668                 include_once("Services/Notes/classes/class.ilNote.php");
00669                 $notes = ilNote::_getLastNotesOfUser();
00670 
00671                 $output = false;
00672                 foreach($notes as $note)
00673                 {
00674                         $output = true;
00675 
00676                         $rowclass = ($rowclass != "tblrow1")
00677                                 ? "tblrow1"
00678                                 : "tblrow2";
00679                         $tpl->setCurrentBlock("note");
00680                         $tpl->setVariable("ROWCLASS", $rowclass);
00681                         $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
00682                         switch ($note->getLabel())
00683                         {
00684                                 case IL_NOTE_UNLABELED:
00685                                         $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_unlabeled.gif"));
00686                                         $tpl->setVariable("ALT_NOTE", $lng->txt("note"));
00687                                         break;
00688                                         
00689                                 case IL_NOTE_IMPORTANT:
00690                                         $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_important.gif"));
00691                                         $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("important"));
00692                                         break;
00693                                         
00694                                 case IL_NOTE_QUESTION:
00695                                         $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_question.gif"));
00696                                         $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("question"));
00697                                         break;
00698                                         
00699                                 case IL_NOTE_PRO:
00700                                         $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_pro.gif"));
00701                                         $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("pro"));
00702                                         break;
00703                                         
00704                                 case IL_NOTE_CONTRA:
00705                                         $tpl->setVariable("IMG_NOTE", ilUtil::getImagePath("note_contra.gif"));
00706                                         $tpl->setVariable("ALT_NOTE", $lng->txt("note").", ".$lng->txt("contra"));
00707                                         break;
00708                         }
00709 
00710                         // details
00711                         $target = $note->getObject();
00712                         if ($showdetails)
00713                         {
00714                                 $tpl->setVariable("NOTE_TEXT",
00715                                         ilUtil::shortenText($note->getText(), 150, true, true));
00716                                 $tpl->setVariable("TXT_CREATED", $lng->txt("create_date"));
00717                                 $tpl->setVariable("VAL_DATE", substr($note->getCreationDate(),0,10));
00718                                 
00719                                 // target objects
00720                                 $this->showTargets($tpl, $target["rep_obj_id"], $note->getId(),
00721                                         $target["obj_type"], $target["obj_id"]);
00722                         }
00723                         
00724                         // edit button
00725                         $tpl->setCurrentBlock("edit_note");
00726                         $tpl->setVariable("TXT_EDIT_NOTE", $this->lng->txt("edit"));
00727                         $this->ctrl->setParameterByClass("ilnotegui", "rel_obj", $target["rep_obj_id"]);
00728                         $this->ctrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
00729                         $this->ctrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
00730                         $tpl->setVariable("LINK_EDIT_NOTE",
00731                                 $this->ctrl->getLinkTargetByClass(array("ilpdnotesgui", "ilnotegui"), "editNoteForm")
00732                                 ."#note_edit");
00733                         $tpl->parseCurrentBlock();
00734                         
00735                         $tpl->parseCurrentBlock();
00736                         $tpl->setCurrentBlock("note_row");
00737                         $tpl->parseCurrentBlock();
00738                 }
00739                 
00740                 if ($output)
00741                 {
00742                         return $tpl->get();
00743                 }
00744                 else
00745                 {
00746                         return "";
00747                 }
00748         }
00749         
00753         function addNoteForm()
00754         {
00755                 global $ilUser;
00756                 
00757                 $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
00758                         ? "private"
00759                         : "public";
00760                 $ilUser->setPref("notes_".$suffix, "y");
00761 
00762                 $this->add_note_form = true;
00763                 return $this->getNotesHTML();
00764         }
00765         
00769         function cancelAddNote()
00770         {
00771                 return $this->getNotesHTML();
00772         }
00773         
00777         function cancelUpdateNote()
00778         {
00779                 return $this->getNotesHTML();
00780         }
00781         
00785         function addNote()
00786         {
00787                 global $ilUser;
00788 
00789                 if($_POST["note"] != "" || $_POST["sub_note"] != "")
00790                 {
00791                         $note = new ilNote();
00792                         $note->setObject($this->obj_type, $this->rep_obj_id, $this->obj_id);                    
00793                         $note->setType($_GET["note_type"]);
00794                         $note->setAuthor($ilUser->getId());
00795                         $note->setText(ilUtil::stripSlashes($_POST["note"]));
00796                         $note->setSubject(ilUtil::stripSlashes($_POST["sub_note"]));
00797                         $note->setLabel($_POST["note_label"]);
00798                         $note->create();
00799                 }
00800                 
00801                 return $this->getNotesHTML();
00802         }
00803 
00807         function updateNote()
00808         {
00809                 global $ilUser;
00810 
00811                 $note = new ilNote($_POST["note_id"]);
00812                 //$note->setObject($this->obj_type, $this->rep_obj_id, $this->obj_id);
00813                 //$note->setType(IL_NOTE_PRIVATE);
00814                 //$note->setAuthor($ilUser->getId());
00815                 $note->setText(ilUtil::stripSlashes($_POST["note"]));
00816                 $note->setSubject(ilUtil::stripSlashes($_POST["sub_note"]));
00817                 $note->setLabel($_POST["note_label"]);
00818                 $note->update();
00819                 
00820                 return $this->getNotesHTML();
00821         }
00822 
00826         function editNoteForm()
00827         {
00828                 $this->edit_note_form = true;
00829                 return $this->getNotesHTML();
00830         }
00831 
00835         function deleteNote()
00836         {
00837                 $this->delete_note = true;
00838                 return $this->getNotesHTML();
00839         }
00840         
00844         function deleteNotes()
00845         {
00846                 global $lng;
00847                 
00848                 if (!$_POST["note"])
00849                 {
00850                         sendinfo($lng->txt("no_checkbox"));
00851                 }
00852                 else
00853                 {
00854                         $this->delete_note = true;
00855                 }
00856                 return $this->getNotesHTML();
00857         }
00858 
00862         function cancelDelete()
00863         {
00864                 return $this->getNotesHTML();
00865         }
00866         
00870         function confirmDelete()
00871         {
00872                 foreach($_POST["note"] as $id)
00873                 {
00874                         $note = new ilNote($id);
00875                         $note->delete();
00876                 }
00877                 return $this->getNotesHTML();
00878         }
00879 
00883         function exportNotesHTML()
00884         {
00885                 $tpl = new ilTemplate("tpl.main.html", true, true);
00886 
00887                 $this->export_html = true;
00888                 $this->multi_selection = false;
00889                 $tpl->setVariable("CONTENT", $this->getNotesHTML());
00890                 ilUtil::deliverData($tpl->get(), "notes.html");
00891         }
00892         
00896         function printNotes()
00897         {
00898                 $tpl = new ilTemplate("tpl.main.html", true, true);
00899 
00900                 $this->print = true;
00901                 $this->multi_selection = false;
00902                 $tpl->setVariable("CONTENT", $this->getNotesHTML());
00903                 echo $tpl->get(); exit;
00904         }
00905 
00909         function showNotes()
00910         {
00911                 global $ilUser;
00912 
00913                 $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
00914                         ? "private"
00915                         : "public";
00916                 $ilUser->writePref("notes_".$suffix, "y");
00917 
00918                 return $this->getNotesHTML();
00919         }
00920         
00924         function hideNotes()
00925         {
00926                 global $ilUser;
00927 
00928                 $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
00929                         ? "private"
00930                         : "public";
00931                 $ilUser->writePref("notes_".$suffix, "n");
00932 
00933                 return $this->getNotesHTML();
00934         }
00935 
00939         function showAllPublicNotes()
00940         {
00941                 global $ilUser;
00942                 
00943                 $ilUser->writePref("notes_pub_all", "y");
00944                 
00945                 return $this->getNotesHTML();
00946         }
00947 
00951         function showMyPublicNotes()
00952         {
00953                 global $ilUser;
00954                 
00955                 $ilUser->writePref("notes_pub_all", "n");
00956                 
00957                 return $this->getNotesHTML();
00958         }
00959 }
00960 ?>

Generated on Fri Dec 13 2013 11:57:59 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1