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

classes/class.ilBookmarkAdministrationGUI.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004         +-----------------------------------------------------------------------------+
00005         | ILIAS open source                                                           |
00006         +-----------------------------------------------------------------------------+
00007         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00008         |                                                                             |
00009         | This program is free software; you can redistribute it and/or               |
00010         | modify it under the terms of the GNU General Public License                 |
00011         | as published by the Free Software Foundation; either version 2              |
00012         | of the License, or (at your option) any later version.                      |
00013         |                                                                             |
00014         | This program is distributed in the hope that it will be useful,             |
00015         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017         | GNU General Public License for more details.                                |
00018         |                                                                             |
00019         | You should have received a copy of the GNU General Public License           |
00020         | along with this program; if not, write to the Free Software                 |
00021         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00022         +-----------------------------------------------------------------------------+
00023 */
00024 
00036 require_once ("classes/class.ilBookmarkExplorer.php");
00037 require_once ("classes/class.ilBookmarkFolder.php");
00038 require_once ("classes/class.ilBookmark.php");
00039 require_once ("classes/class.ilTableGUI.php");
00040 
00041 class ilBookmarkAdministrationGUI
00042 {
00048         var $user_id;
00049 
00055         var $ilias;
00056         var $tpl;
00057         var $lng;
00058 
00059         var $tree;
00060         var $id;
00061         var $data;
00062 
00068         function ilBookmarkAdministrationGUI($bmf_id = 0)
00069         {
00070                 global $ilias, $tpl, $lng;
00071 
00072                 // if no bookmark folder id is given, take dummy root node id (that is 1)
00073                 if (empty($bmf_id))
00074                 {
00075                         $bmf_id = 1;
00076                 }
00077 
00078                 // initiate variables
00079                 $this->ilias =& $ilias;
00080                 $this->tpl =& $tpl;
00081                 $this->lng =& $lng;
00082                 $this->user_id = $_SESSION["AccountId"];
00083                 $this->id = $bmf_id;
00084 
00085                 $this->tree = new ilTree($_SESSION["AccountId"]);
00086                 $this->tree->setTableNames('bookmark_tree','bookmark_data');
00087                 $this->root_id = $this->tree->readRootId();
00088 
00089         }
00090 
00091 
00097         function frameset()
00098         {
00099                 $this->tpl = new ilTemplate("tpl.bookmark_frameset.html", false, false);
00100         }
00101 
00105         function explorer()
00106         {
00107                 //$this->tpl = new ilTemplate("tpl.explorer.html", false, false);
00108                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00109 
00110                 $exp = new ilBookmarkExplorer("usr_bookmarks.php",$_SESSION["AccountId"]);
00111                 $exp->setTargetGet("bmf_id");
00112 
00113                 if ($_GET["mexpand"] == "")
00114                 {
00115                         $mtree = new ilTree($_SESSION["AccountId"]);
00116                         $mtree->setTableNames('bookmark_tree','bookmark_data');
00117                         $expanded = $mtree->readRootId();
00118                 }
00119                 else
00120                 {
00121                         $expanded = $_GET["mexpand"];
00122                 }
00123 
00124                 $exp->setExpand($expanded);
00125 
00126                 // build html-output
00127                 $exp->setOutput(0);
00128                 $output = $exp->getOutput();
00129 
00130                 $this->tpl->setCurrentBlock("content");
00131                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("bookmarks"));
00132                 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
00133                 $this->tpl->setVariable("EXPLORER",$output);
00134                 $this->tpl->setVariable("ACTION", "usr_bookmarks.php?cmd=explorer&mexpand=".$_GET["mexpand"]);
00135                 $this->tpl->parseCurrentBlock();
00136         }
00137 
00138 
00142         function main_header()
00143         {
00144                 global $lng, $tpl;
00145 
00146                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.bookmarks.html");
00147 
00148                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00149 
00150                 // output tabs
00151                 //$this->setTabs();
00152 
00153                 // output locator
00154                 $this->displayLocator();
00155 
00156                 // output message
00157                 if($this->message)
00158                 {
00159                         sendInfo($this->message);
00160                 }
00161 
00162                 // display infopanel if something happened
00163                 infoPanel();
00164 
00165                 $this->tpl->setVariable("HEADER",  $this->lng->txt("personal_desktop"));
00166 
00167                 //$this->tpl->addBlockFile("OBJECTS", "objects", "tpl.table.html");
00168                 //$this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00169 
00170                 // display tabs
00171                 include "./include/inc.personaldesktop_buttons.php";
00172 
00173         }
00174 
00175 
00176         /*
00177         * display content of bookmark folder
00178         */
00179         function view($a_output_header = true)
00180         {
00181                 global $tree, $rbacsystem;
00182                 
00183                 include_once("classes/class.ilFrameTargetInfo.php");
00184 
00185                 $mtree = new ilTree($_SESSION["AccountId"]);
00186                 $mtree->setTableNames('bookmark_tree','bookmark_data');
00187 
00188                 if ($a_output_header)
00189                 {
00190                         $this->main_header();
00191                 }
00192                 $this->tpl->addBlockFile("OBJECTS", "objects", "tpl.table.html");
00193 
00194                 $this->tpl->setVariable("FORMACTION", "usr_bookmarks.php?bmf_id=".$this->id."&cmd=post");
00195 
00196                 $objects = ilBookmarkFolder::getObjects($this->id);
00197                 
00198                 $this->tpl->setCurrentBlock("objects");
00199                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.bookmark_row.html");
00200                 $cnt = 0;
00201                 
00202                 // return to parent folder
00203                 if ($this->id != $mtree->readRootId() || $this->id =="")
00204                 {                       
00205                         $this->tpl->setCurrentBlock("tbl_content");
00206                         
00207                         // color changing
00208                         $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
00209 
00210                         $this->tpl->setVariable("CHECKBOX", "&nbsp;");
00211                         $this->tpl->setVariable("ROWCOL", $css_row);
00212 
00213                         $val = ilUtil::getImagePath("icon_cat.gif");
00214                         $this->tpl->setVariable("IMG", $val);
00215                         
00216                         // title
00217                         $link = "usr_bookmarks.php?bmf_id=".$mtree->getParentId($this->id);
00218                         $this->tpl->setVariable("TXT_TITLE", "..");
00219                         $this->tpl->setVariable("LINK_TARGET", $link);
00220                         $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("MainContent"));
00221 
00222                         $this->tpl->parseCurrentBlock();
00223                 }
00224 
00225                 foreach ($objects as $key => $object)
00226                 {
00227                         // type icon
00228                         $link = ($object["type"] == "bmf") ?
00229                                 "usr_bookmarks.php?cmd=editForm&type=bmf&obj_id=".$object["obj_id"]."&bmf_id=".$this->id :
00230                                 "usr_bookmarks.php?cmd=editForm&type=bm&obj_id=".$object["obj_id"]."&bmf_id=".$this->id;
00231 
00232                         
00233                         $this->tpl->setCurrentBlock("tbl_content");
00234                         
00235                         // edit link
00236                         $this->tpl->setCurrentBlock("edit");
00237                         $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00238                         $this->tpl->setVariable("LINK_EDIT", $link);
00239                         $this->tpl->parseCurrentBlock();
00240                         $this->tpl->setCurrentBlock("tbl_content");
00241 
00242 
00243                         // color changing
00244                         $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
00245 
00246                         // surpress checkbox for particular object types
00247                         //$this->tpl->setVariable("CHECKBOX_ID", $object["type"].":".$object["obj_id"]);
00248                         $this->tpl->setVariable("CHECKBOX",ilUtil::formCheckBox("", "id[]", $object["type"].":".$object["obj_id"]));
00249                         $this->tpl->setVariable("ROWCOL", $css_row);
00250 
00251                         $img_type = ($object["type"] == "bmf") ? "cat" : $object["type"];
00252                         $val = ilUtil::getImagePath("icon_".$img_type.".gif");
00253                         $this->tpl->setVariable("IMG", $val);
00254                         
00255                         // title
00256                         $link = ($object["type"] == "bmf") ?
00257                                 "usr_bookmarks.php?bmf_id=".$object["obj_id"] :
00258                                 $object["target"];
00259                         $this->tpl->setVariable("TXT_TITLE", $object["title"]);
00260                         $this->tpl->setVariable("LINK_TARGET", $link);
00261                         
00262                         if ($object["type"] == "bmf")
00263                         {
00264                                 $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("MainContent"));
00265                         }
00266                         else
00267                         {
00268                                 $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("ExternalContent"));
00269                         }
00270 
00271                         // target
00272                         $this->tpl->setVariable("TXT_TARGET", $object["target"]);
00273 
00274                         $this->tpl->parseCurrentBlock();
00275                 }
00276 
00277                 $tbl = new ilTableGUI();
00278 
00279                 if (!empty($this->id) && $this->id != 1)
00280                 {
00281                         $BookmarkFolder = new ilBookmarkFolder($this->id);
00282                         $addstr = " ".$this->lng->txt("in")." ".$BookmarkFolder->getTitle();
00283                 }
00284                 else
00285                 {
00286                         $addstr = "";
00287                 }
00288 
00289                 // title & header columns
00290                 $tbl->setTitle($this->lng->txt("bookmarks").$addstr,
00291                         "icon_bm_b.gif", $this->lng->txt("bookmarks"));
00292                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00293                 $tbl->setHeaderNames(array("", $this->lng->txt("type"), $this->lng->txt("title"),
00294                         $this->lng->txt("bookmark_target")));
00295                 $tbl->setHeaderVars(array("", "type", "title", "target"),
00296                         array("bmf_id" => $this->id));
00297                 $tbl->setColumnWidth(array("1%", "1%", "49%", "49%"));
00298 
00299                 //$tbl->setOrderColumn($_GET["sort_by"]);
00300                 //$tbl->setOrderDirection($_GET["sort_order"]);
00301                 $tbl->setLimit($limit);
00302                 $tbl->setOffset($offset);
00303                 $tbl->setMaxCount($maxcount);
00304 
00305                 // footer
00306                 $tbl->setFooter("tblfooter", $this->lng->txt("previous"),$this->lng->txt("next"));
00307                 //$tbl->disable("content");
00308                 $tbl->disable("footer");
00309 
00310                 // render table
00311                 $tbl->render();
00312 
00313 
00314                 // SHOW POSSIBLE SUB OBJECTS
00315                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00316                 $this->tpl->setVariable("NUM_COLS", 4);
00317                 $this->showPossibleSubObjects();
00318 
00319                 $this->tpl->parseCurrentBlock();
00320         }
00321 
00325         function add_cell($val, $link = "")
00326         {
00327                 if (!empty($link))
00328                 {
00329                         $this->tpl->setCurrentBlock("begin_link");
00330                         $this->tpl->setVariable("LINK_TARGET", $link);
00331                         $this->tpl->parseCurrentBlock();
00332                         $this->tpl->touchBlock("end_link");
00333                 }
00334 
00335                 $this->tpl->setCurrentBlock("text");
00336                 $this->tpl->setVariable("TEXT_CONTENT", $val);
00337                 $this->tpl->parseCurrentBlock();
00338                 $this->tpl->setCurrentBlock("table_cell");
00339                 $this->tpl->parseCurrentBlock();
00340         }
00341 
00345         function displayLocator()
00346         {
00347                 global $lng;
00348 
00349                 if (empty($this->id))
00350                 {
00351                         return;
00352                 }
00353 
00354                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00355 
00356                 $path = $this->tree->getPathFull($this->id);
00357 
00358                 $modifier = 1;
00359 
00360                 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
00361                 $this->tpl->touchBlock("locator_separator");
00362                 $this->tpl->setCurrentBlock("locator_item");
00363                 $this->tpl->setVariable("ITEM", $this->lng->txt("personal_desktop"));
00364                 $this->tpl->setVariable("LINK_ITEM", "usr_personaldesktop.php");
00365                 $this->tpl->setVariable("LINK_TARGET","target=\"bottom\"");
00366                 $this->tpl->parseCurrentBlock();
00367 
00368                 foreach ($path as $key => $row)
00369                 {
00370                         if ($key < count($path)-$modifier)
00371                         {
00372                                 $this->tpl->touchBlock("locator_separator");
00373                         }
00374 
00375                         $this->tpl->setCurrentBlock("locator_item");
00376                         $title = ($row["child"] == 1) ?
00377                                 $lng->txt("bookmarks_of")." ".$this->ilias->account->getFullname() :
00378                                 $row["title"];
00379                         $this->tpl->setVariable("ITEM", $title);
00380                         // TODO: SCRIPT NAME HAS TO BE VARIABLE!!!
00381                         $this->tpl->setVariable("LINK_ITEM", "usr_bookmarks.php?bmf_id=".$row["child"]);
00382                         $this->tpl->parseCurrentBlock();
00383                 }
00384 
00385                 $this->tpl->setCurrentBlock("locator");
00386 
00387                 $this->tpl->parseCurrentBlock();
00388         }
00389 
00390 
00394         function newFormBookmarkFolder()
00395         {
00396                 global $tpl, $lng;
00397 
00398                 $this->main_header();
00399 
00400                 $tpl->addBlockFile("OBJECTS", "objects", "tpl.bookmark_newfolder.html");
00401                 $tpl->setVariable("TITLE", $this->get_last("title", ""));
00402                 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00403                 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00404                 $tpl->setVariable("TXT_FOLDER_NEW", $lng->txt("bookmark_folder_new"));
00405                 $tpl->setVariable("FORMACTION", "usr_bookmarks.php?bmf_id=".$this->id."&cmd=createBookmarkFolder");
00406         }
00407 
00408 
00412         function editFormBookmarkFolder()
00413         {
00414                 global $tpl, $lng;
00415 
00416                 $this->main_header();
00417 
00418                 $tpl->addBlockFile("OBJECTS", "objects", "tpl.bookmark_newfolder.html");
00419 
00420                 $bmf = new ilBookmarkFolder($_GET["obj_id"]);
00421 
00422                 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00423                 $tpl->setVariable("TITLE", $this->get_last("title", $bmf->getTitle()));
00424                 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00425                 $tpl->setVariable("TXT_FOLDER_NEW", $lng->txt("bookmark_folder_edit"));
00426                 $tpl->setVariable("FORMACTION", "usr_bookmarks.php?obj_id=".$_GET["obj_id"].
00427                         "&bmf_id=".$this->id."&cmd=updateBookmarkFolder");
00428         }
00429 
00430 
00434         function newFormBookmark()
00435         {
00436                 global $tpl, $lng;
00437 
00438                 $this->main_header();
00439 
00440                 $tpl->addBlockFile("OBJECTS", "objects", "tpl.bookmark_new.html");
00441                 $tpl->setVariable("TXT_BOOKMARK_NEW", $lng->txt("bookmark_new"));
00442                 $tpl->setVariable("TXT_TARGET", $lng->txt("bookmark_target"));
00443                 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00444 
00445                 $tpl->setVariable("TITLE", $this->get_last("title", ""));
00446                 $tpl->setVariable("TARGET", $this->get_last("target", "http://"));
00447 
00448                 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00449 
00450                 $tpl->setVariable("FORMACTION", "usr_bookmarks.php?bmf_id=".$this->id."&cmd=createBookmark");
00451                 $tpl->parseCurrentBlock();
00452         }
00453 
00454 
00458         function get_last($a_var, $a_value)
00459         {
00460                 return  (!empty($_SESSION["message"])) ?
00461                                 ($_SESSION["error_post_vars"][$a_var]) :
00462                                 $a_value;
00463         }
00464 
00468         function editFormBookmark()
00469         {
00470                 global $tpl, $lng;
00471 
00472                 $this->main_header();
00473 
00474                 $tpl->addBlockFile("OBJECTS", "objects", "tpl.bookmark_new.html");
00475 
00476                 $tpl->setVariable("TXT_BOOKMARK_NEW", $lng->txt("bookmark_edit"));
00477                 $tpl->setVariable("TXT_TARGET", $lng->txt("bookmark_target"));
00478                 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00479 
00480                 $Bookmark = new ilBookmark($_GET["obj_id"]);
00481                 $tpl->setVariable("TITLE", $this->get_last("title", $Bookmark->getTitle()));
00482                 $tpl->setVariable("TARGET", $this->get_last("target", $Bookmark->getTarget()));
00483 
00484                 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00485 
00486                 $tpl->setVariable("FORMACTION", "usr_bookmarks.php?obj_id=".$_GET["obj_id"].
00487                         "&bmf_id=".$this->id."&cmd=updateBookmark");
00488                 $tpl->parseCurrentBlock();
00489         }
00490 
00491 
00495         function createBookmarkFolder()
00496         {
00497                 // check title
00498                 if (empty($_POST["title"]))
00499                 {
00500                         //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
00501                         sendInfo($this->lng->txt("please_enter_title"), true);
00502                         ilUtil::redirect("usr_bookmarks.php?bmf_id=".$this->id."&cmd=newForm&type=bmf");
00503                 }
00504 
00505                 // create bookmark folder
00506                 $bmf = new ilBookmarkFolder();
00507                 $bmf->setTitle($_POST["title"]);
00508                 $bmf->setParent($this->id);
00509 
00510                 $bmf->create();
00511 
00512                 $this->view();
00513         }
00514 
00515 
00519         function updateBookmarkFolder()
00520         {
00521                 // check title
00522                 if (empty($_POST["title"]))
00523                 {
00524                         $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
00525                 }
00526 
00527                 // update bookmark folder
00528                 $bmf = new ilBookmarkFolder($_GET["obj_id"]);
00529                 $bmf->setTitle($_POST["title"]);
00530                 $bmf->update();
00531 
00532                 $this->view();
00533         }
00534 
00535 
00539         function createBookmark()
00540         {
00541                 // check title and target
00542                 if (empty($_POST["title"]))
00543                 {
00544                         //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
00545                         sendInfo($this->lng->txt("please_enter_title"), true);
00546                         ilUtil::redirect("usr_bookmarks.php?bmf_id=".$this->id."&cmd=newForm&type=bm");
00547                 }
00548                 if (empty($_POST["target"]))
00549                 {
00550                         //$this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
00551                         sendInfo($this->lng->txt("please_enter_target"), true);
00552                         ilUtil::redirect("usr_bookmarks.php?bmf_id=".$this->id."&cmd=newForm&type=bm");
00553                 }
00554 
00555                 // create bookmark
00556                 $bm = new ilBookmark();
00557                 $bm->setTitle($_POST["title"]);
00558                 $bm->setTarget($_POST["target"]);
00559                 $bm->setParent($this->id);
00560                 $bm->create();
00561 
00562                 $this->view();
00563         }
00564 
00568         function updateBookmark()
00569         {
00570                 // check title and target
00571                 if (empty($_POST["title"]))
00572                 {
00573                         $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
00574                 }
00575                 if (empty($_POST["target"]))
00576                 {
00577                         $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
00578                 }
00579 
00580                 // update bookmark
00581                 $bm = new ilBookmark($_GET["obj_id"]);
00582                 $bm->setTitle($_POST["title"]);
00583                 $bm->setTarget($_POST["target"]);
00584                 $bm->update();
00585 
00586                 $this->view();
00587         }
00588 
00592         function delete()
00593         {
00594 
00595                 $this->main_header();
00596 
00597                 if (!isset($_POST["id"]))
00598                 {
00599                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00600                 }
00601 
00602                 $this->tpl->addBlockFile("OBJECTS", "objects", "tpl.obj_confirm.html");
00603 
00604                 sendInfo($this->lng->txt("info_delete_sure"));
00605                 $this->tpl->setVariable("FORMACTION", "usr_bookmarks.php?bmf_id=".$this->id."&cmd=post");
00606 
00607                 // output table header
00608                 $cols = array("type", "title", "bookmark_target");
00609                 foreach ($cols as $key)
00610                 {
00611                         $this->tpl->setCurrentBlock("table_header");
00612                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
00613                         $this->tpl->parseCurrentBlock();
00614                 }
00615 
00616                 $_SESSION["saved_post"] = $_POST["id"];
00617 
00618                 foreach($_POST["id"] as $id)
00619                 {
00620                         list($type, $obj_id) = explode(":", $id);
00621                         switch($type)
00622                         {
00623                                 case "bmf":
00624                                         $BookmarkFolder = new ilBookmarkFolder($obj_id);
00625                                         $title = $BookmarkFolder->getTitle();
00626                                         $target = "&nbsp;";
00627                                         unset($BookmarkFolder);
00628                                         break;
00629 
00630                                 case "bm":
00631                                         $Bookmark = new ilBookmark($obj_id);
00632                                         $title = $Bookmark->getTitle();
00633                                         $target = $Bookmark->getTarget();
00634                                         unset($Bookmark);
00635                                         break;
00636                         }
00637 
00638                         // output type icon
00639                         $this->tpl->setCurrentBlock("table_cell");
00640                         $img_type = ($type == "bmf") ? "cat" : $type;
00641                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($img_type, $this->tpl->tplPath));
00642                         $this->tpl->parseCurrentBlock();
00643 
00644                         // output title
00645                         $this->tpl->setCurrentBlock("table_cell");
00646                         $this->tpl->setVariable("TEXT_CONTENT", $title);
00647                         $this->tpl->parseCurrentBlock();
00648 
00649                         // output target
00650                         $this->tpl->setCurrentBlock("table_cell");
00651                         $this->tpl->setVariable("TEXT_CONTENT", $target);
00652                         $this->tpl->parseCurrentBlock();
00653 
00654                         // output table row
00655                         $this->tpl->setCurrentBlock("table_row");
00656                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00657                         $this->tpl->parseCurrentBlock();
00658                 }
00659 
00660                 // cancel and confirm button
00661                 $buttons = array( "cancel"  => $this->lng->txt("cancel"),
00662                         "confirm"  => $this->lng->txt("confirm"));
00663 
00664                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00665                 foreach($buttons as $name => $value)
00666                 {
00667                         $this->tpl->setCurrentBlock("operation_btn");
00668                         $this->tpl->setVariable("BTN_NAME",$name);
00669                         $this->tpl->setVariable("BTN_VALUE",$value);
00670                         $this->tpl->parseCurrentBlock();
00671                 }
00672 
00673         }
00674 
00678         function cancel()
00679         {
00680                 session_unregister("saved_post");
00681                 $this->view();
00682         }
00683 
00687         function confirm()
00688         {
00689                 global $tree, $rbacsystem, $rbacadmin, $objDefinition;
00690 
00691                 // AT LEAST ONE OBJECT HAS TO BE CHOSEN.
00692                 if (!isset($_SESSION["saved_post"]))
00693                 {
00694                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00695                 }
00696 
00697                 // FOR ALL SELECTED OBJECTS
00698                 foreach ($_SESSION["saved_post"] as $id)
00699                 {
00700                         list($type, $id) = explode(":", $id);
00701 
00702                         // get node data and subtree nodes
00703                         $node_data = $this->tree->getNodeData($id);
00704                         $subtree_nodes = $this->tree->getSubTree($node_data);
00705 
00706                         // delete tree
00707                         $this->tree->deleteTree($node_data);
00708 
00709                         // delete objects of subtree nodes
00710                         foreach ($subtree_nodes as $node)
00711                         {
00712                                 switch ($node["type"])
00713                                 {
00714                                         case "bmf":
00715                                                 $BookmarkFolder = new ilBookmarkFolder($node["obj_id"]);
00716                                                 $BookmarkFolder->delete();
00717                                                 break;
00718 
00719                                         case "bm":
00720                                                 $Bookmark = new ilBookmark($node["obj_id"]);
00721                                                 $Bookmark->delete();
00722                                                 break;
00723                                 }
00724                         }
00725                 }
00726 
00727                 $this->main_header();
00728 
00729                 // Feedback
00730                 sendInfo($this->lng->txt("info_deleted"),true);
00731 
00732                 $this->view(false);
00733         }
00734 
00735 
00736 
00740         function showActions()
00741         {
00742                 global $objDefinition;
00743 
00744                 $notoperations = array();
00745                 // NO PASTE AND CLEAR IF CLIPBOARD IS EMPTY
00746                 if (empty($_SESSION["clipboard"]))
00747                 {
00748                         $notoperations[] = "paste";
00749                         $notoperations[] = "clear";
00750                 }
00751                 // CUT COPY PASTE LINK DELETE IS NOT POSSIBLE IF CLIPBOARD IS FILLED
00752                 if ($_SESSION["clipboard"])
00753                 {
00754                         $notoperations[] = "cut";
00755                         $notoperations[] = "copy";
00756                         $notoperations[] = "link";
00757                 }
00758 
00759                 $operations = array();
00760 
00761                 $d = $objDefinition->getActions("bmf");
00762 
00763                 foreach ($d as $row)
00764                 {
00765                         if (!in_array($row["name"], $notoperations))
00766                         {
00767                                 $operations[] = $row;
00768                         }
00769                 }
00770 
00771                 if (count($operations)>0)
00772                 {
00773                         foreach ($operations as $val)
00774                         {
00775                                 $this->tpl->setCurrentBlock("operation_btn");
00776                                 $this->tpl->setVariable("BTN_NAME", $val["lng"]);
00777                                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
00778                                 $this->tpl->parseCurrentBlock();
00779                         }
00780 
00781                         $this->tpl->setCurrentBlock("operation");
00782                         $this->tpl->parseCurrentBlock();
00783                 }
00784         }
00785 
00789         function showPossibleSubObjects()
00790         {
00791                 global $objDefinition;
00792 
00793                 $d = $objDefinition->getCreatableSubObjects("bmf");
00794 
00795                 if (count($d) > 0)
00796                 {
00797                         foreach ($d as $row)
00798                         {
00799                             $count = 0;
00800                                 if ($row["max"] > 0)
00801                                 {
00802                                         //how many elements are present?
00803                                         for ($i=0; $i<count($this->data["ctrl"]); $i++)
00804                                         {
00805                                                 if ($this->data["ctrl"][$i]["type"] == $row["name"])
00806                                                 {
00807                                                     $count++;
00808                                                 }
00809                                         }
00810                                 }
00811                                 if ($row["max"] == "" || $count < $row["max"])
00812                                 {
00813                                         $subobj[] = $row["name"];
00814                                 }
00815                         }
00816                 }
00817 
00818                 if (is_array($subobj))
00819                 {
00820                         //build form
00821                         $opts = ilUtil::formSelect(12,"type",$subobj);
00822 
00823                         $this->tpl->setCurrentBlock("add_object");
00824                         $this->tpl->setVariable("COLUMN_COUNTS", 7);
00825                         $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
00826                         $this->tpl->setVariable("BTN_NAME", "newForm");
00827                         $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00828                         $this->tpl->parseCurrentBlock();
00829                 }
00830 
00831                 $this->tpl->setVariable("TPLPATH",$this->tpl->tplPath);
00832 
00833                 $this->tpl->setCurrentBlock("tbl_action_select");
00834                 //$this->tpl->setVariable("SELECT_ACTION",ilUtil::formSelect("","action_type",$actions,false,true));
00835                 $this->tpl->setVariable("BTN_NAME","delete");
00836                 $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
00837                 $this->tpl->parseCurrentBlock();
00838 
00839         }
00840 }
00841 ?>

Generated on Fri Dec 13 2013 09:06:33 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1