• 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,$ilias;
00145 
00146                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00147                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00148 
00149                 // output locator
00150                 $this->displayLocator();
00151 
00152                 // output message
00153                 if($this->message)
00154                 {
00155                         sendInfo($this->message);
00156                 }
00157 
00158                 // display infopanel if something happened
00159                 infoPanel();
00160 
00161                 $this->tpl->setVariable("HEADER",  $this->lng->txt("personal_desktop"));
00162 
00163                 // display tabs
00164                 include "./include/inc.personaldesktop_buttons.php";
00165 
00166         }
00167 
00168 
00169         /*
00170         * display content of bookmark folder
00171         */
00172         function view($a_output_header = true)
00173         {
00174                 global $tree, $rbacsystem;
00175                 
00176                 include_once("classes/class.ilFrameTargetInfo.php");
00177 
00178                 $mtree = new ilTree($_SESSION["AccountId"]);
00179                 $mtree->setTableNames('bookmark_tree','bookmark_data');
00180 
00181                 if ($a_output_header)
00182                 {
00183                         $this->main_header();
00184                 }
00185                 $this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.table.html");
00186 
00187                 $this->tpl->setVariable("FORMACTION", "usr_bookmarks.php?bmf_id=".$this->id."&cmd=post");
00188 
00189                 $objects = ilBookmarkFolder::getObjects($this->id);
00190                 
00191                 $this->tpl->setCurrentBlock("objects");
00192                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.bookmark_row.html");
00193                 $cnt = 0;
00194                 
00195                 // return to parent folder
00196                 if ($this->id != $mtree->readRootId() || $this->id =="")
00197                 {                       
00198                         $this->tpl->setCurrentBlock("tbl_content");
00199                         
00200                         // color changing
00201                         $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
00202 
00203                         $this->tpl->setVariable("CHECKBOX", "&nbsp;");
00204                         $this->tpl->setVariable("ROWCOL", $css_row);
00205 
00206                         $val = ilUtil::getImagePath("icon_cat.gif");
00207                         $this->tpl->setVariable("IMG", $val);
00208                         
00209                         // title
00210                         $link = "usr_bookmarks.php?bmf_id=".$mtree->getParentId($this->id);
00211                         $this->tpl->setVariable("TXT_TITLE", "..");
00212                         $this->tpl->setVariable("LINK_TARGET", $link);
00213                         $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("MainContent"));
00214 
00215                         $this->tpl->parseCurrentBlock();
00216                 }
00217 
00218                 foreach ($objects as $key => $object)
00219                 {
00220                         // type icon
00221                         $link = ($object["type"] == "bmf") ?
00222                                 "usr_bookmarks.php?cmd=editForm&type=bmf&obj_id=".$object["obj_id"]."&bmf_id=".$this->id :
00223                                 "usr_bookmarks.php?cmd=editForm&type=bm&obj_id=".$object["obj_id"]."&bmf_id=".$this->id;
00224 
00225                         
00226                         $this->tpl->setCurrentBlock("tbl_content");
00227                         
00228                         // edit link
00229                         $this->tpl->setCurrentBlock("edit");
00230                         $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00231                         $this->tpl->setVariable("LINK_EDIT", $link);
00232                         $this->tpl->parseCurrentBlock();
00233                         $this->tpl->setCurrentBlock("tbl_content");
00234 
00235 
00236                         // color changing
00237                         $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
00238 
00239                         // surpress checkbox for particular object types
00240                         //$this->tpl->setVariable("CHECKBOX_ID", $object["type"].":".$object["obj_id"]);
00241                         $this->tpl->setVariable("CHECKBOX",ilUtil::formCheckBox("", "id[]", $object["type"].":".$object["obj_id"]));
00242                         $this->tpl->setVariable("ROWCOL", $css_row);
00243 
00244                         $img_type = ($object["type"] == "bmf") ? "cat" : $object["type"];
00245                         $val = ilUtil::getImagePath("icon_".$img_type.".gif");
00246                         $this->tpl->setVariable("IMG", $val);
00247                         
00248                         // title
00249                         $link = ($object["type"] == "bmf") ?
00250                                 "usr_bookmarks.php?bmf_id=".$object["obj_id"] :
00251                                 $object["target"];
00252                         $this->tpl->setVariable("TXT_TITLE", $object["title"]);
00253                         $this->tpl->setVariable("LINK_TARGET", $link);
00254                         
00255                         if ($object["type"] == "bmf")
00256                         {
00257                                 $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("MainContent"));
00258                         }
00259                         else
00260                         {
00261                                 $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("ExternalContent"));
00262                         }
00263 
00264                         // target
00265                         $this->tpl->setVariable("TXT_TARGET", $object["target"]);
00266 
00267                         $this->tpl->parseCurrentBlock();
00268                 }
00269 
00270                 $tbl = new ilTableGUI();
00271 
00272                 if (!empty($this->id) && $this->id != 1)
00273                 {
00274                         $BookmarkFolder = new ilBookmarkFolder($this->id);
00275                         $addstr = " ".$this->lng->txt("in")." ".$BookmarkFolder->getTitle();
00276                 }
00277                 else
00278                 {
00279                         $addstr = "";
00280                 }
00281 
00282                 // title & header columns
00283                 $tbl->setTitle($this->lng->txt("bookmarks").$addstr,
00284                         "icon_bm.gif", $this->lng->txt("bookmarks"));
00285                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00286                 $tbl->setHeaderNames(array("", $this->lng->txt("type"), $this->lng->txt("title"),
00287                         $this->lng->txt("bookmark_target"), ""));
00288                 $tbl->setHeaderVars(array("", "type", "title", "target", "commands"),
00289                         array("bmf_id" => $this->id));
00290                 $tbl->setColumnWidth(array("1", "1", "", "", ""));
00291 
00292                 //$tbl->setOrderColumn($_GET["sort_by"]);
00293                 //$tbl->setOrderDirection($_GET["sort_order"]);
00294                 $tbl->setLimit($limit);
00295                 $tbl->setOffset($offset);
00296                 $tbl->setMaxCount($maxcount);
00297 
00298                 // footer
00299                 $tbl->setFooter("tblfooter", $this->lng->txt("previous"),$this->lng->txt("next"));
00300                 //$tbl->disable("content");
00301                 $tbl->disable("footer");
00302                 $tbl->disable("header");
00303 
00304                 // render table
00305                 $tbl->render();
00306 
00307 
00308                 // SHOW POSSIBLE SUB OBJECTS
00309                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00310                 $this->tpl->setVariable("NUM_COLS", 5);
00311                 $this->showPossibleSubObjects();
00312 
00313                 $this->tpl->parseCurrentBlock();
00314         }
00315 
00319         function add_cell($val, $link = "")
00320         {
00321                 if (!empty($link))
00322                 {
00323                         $this->tpl->setCurrentBlock("begin_link");
00324                         $this->tpl->setVariable("LINK_TARGET", $link);
00325                         $this->tpl->parseCurrentBlock();
00326                         $this->tpl->touchBlock("end_link");
00327                 }
00328 
00329                 $this->tpl->setCurrentBlock("text");
00330                 $this->tpl->setVariable("TEXT_CONTENT", $val);
00331                 $this->tpl->parseCurrentBlock();
00332                 $this->tpl->setCurrentBlock("table_cell");
00333                 $this->tpl->parseCurrentBlock();
00334         }
00335 
00339         function displayLocator()
00340         {
00341                 global $lng;
00342 
00343                 if (empty($this->id))
00344                 {
00345                         return;
00346                 }
00347 
00348                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00349 
00350                 $path = $this->tree->getPathFull($this->id);
00351 
00352                 $modifier = 1;
00353 
00354                 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
00355                 $this->tpl->touchBlock("locator_separator");
00356                 $this->tpl->setCurrentBlock("locator_item");
00357                 $this->tpl->setVariable("ITEM", $this->lng->txt("personal_desktop"));
00358                 $this->tpl->setVariable("LINK_ITEM", "usr_personaldesktop.php");
00359                 $this->tpl->setVariable("LINK_TARGET","target=\"bottom\"");
00360                 $this->tpl->parseCurrentBlock();
00361 
00362                 foreach ($path as $key => $row)
00363                 {
00364                         if ($key < count($path)-$modifier)
00365                         {
00366                                 $this->tpl->touchBlock("locator_separator");
00367                         }
00368 
00369                         $this->tpl->setCurrentBlock("locator_item");
00370                         $title = ($row["child"] == 1) ?
00371                                 $lng->txt("bookmarks") :
00372                                 $row["title"];
00373                         $this->tpl->setVariable("ITEM", $title);
00374                         // TODO: SCRIPT NAME HAS TO BE VARIABLE!!!
00375                         $this->tpl->setVariable("LINK_ITEM", "usr_bookmarks.php?bmf_id=".$row["child"]);
00376                         $this->tpl->parseCurrentBlock();
00377                 }
00378 
00379                 $this->tpl->setCurrentBlock("locator");
00380 
00381                 $this->tpl->parseCurrentBlock();
00382         }
00383 
00384 
00388         function newFormBookmarkFolder()
00389         {
00390                 global $tpl, $lng;
00391 
00392                 $this->main_header();
00393 
00394                 $tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.bookmark_newfolder.html");
00395                 $tpl->setVariable("TITLE", $this->get_last("title", ""));
00396                 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00397                 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00398                 $tpl->setVariable("TXT_FOLDER_NEW", $lng->txt("bookmark_folder_new"));
00399                 $tpl->setVariable("FORMACTION", "usr_bookmarks.php?bmf_id=".$this->id."&cmd=createBookmarkFolder");
00400         }
00401 
00402 
00406         function editFormBookmarkFolder()
00407         {
00408                 global $tpl, $lng;
00409 
00410                 $this->main_header();
00411 
00412                 $tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.bookmark_newfolder.html");
00413 
00414                 $bmf = new ilBookmarkFolder($_GET["obj_id"]);
00415 
00416                 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00417                 $tpl->setVariable("TITLE", $this->get_last("title", $bmf->getTitle()));
00418                 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00419                 $tpl->setVariable("TXT_FOLDER_NEW", $lng->txt("bookmark_folder_edit"));
00420                 $tpl->setVariable("FORMACTION", "usr_bookmarks.php?obj_id=".$_GET["obj_id"].
00421                         "&bmf_id=".$this->id."&cmd=updateBookmarkFolder");
00422         }
00423 
00424 
00428         function newFormBookmark()
00429         {
00430                 global $tpl, $lng;
00431 
00432                 $this->main_header();
00433 
00434                 $tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.bookmark_new.html");
00435                 $tpl->setVariable("TXT_BOOKMARK_NEW", $lng->txt("bookmark_new"));
00436                 $tpl->setVariable("TXT_TARGET", $lng->txt("bookmark_target"));
00437                 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00438 
00439                 $tpl->setVariable("TITLE", $this->get_last("title", ""));
00440                 $tpl->setVariable("TARGET", $this->get_last("target", "http://"));
00441 
00442                 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00443 
00444                 $tpl->setVariable("FORMACTION", "usr_bookmarks.php?bmf_id=".$this->id."&cmd=createBookmark");
00445                 $tpl->parseCurrentBlock();
00446         }
00447 
00448 
00452         function get_last($a_var, $a_value)
00453         {
00454                 return  (!empty($_SESSION["message"])) ?
00455                                 ($_SESSION["error_post_vars"][$a_var]) :
00456                                 $a_value;
00457         }
00458 
00462         function editFormBookmark()
00463         {
00464                 global $tpl, $lng;
00465 
00466                 $this->main_header();
00467 
00468                 $tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.bookmark_new.html");
00469 
00470                 $tpl->setVariable("TXT_BOOKMARK_NEW", $lng->txt("bookmark_edit"));
00471                 $tpl->setVariable("TXT_TARGET", $lng->txt("bookmark_target"));
00472                 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00473 
00474                 $Bookmark = new ilBookmark($_GET["obj_id"]);
00475                 $tpl->setVariable("TITLE", $this->get_last("title", $Bookmark->getTitle()));
00476                 $tpl->setVariable("TARGET", $this->get_last("target", $Bookmark->getTarget()));
00477 
00478                 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00479 
00480                 $tpl->setVariable("FORMACTION", "usr_bookmarks.php?obj_id=".$_GET["obj_id"].
00481                         "&bmf_id=".$this->id."&cmd=updateBookmark");
00482                 $tpl->parseCurrentBlock();
00483         }
00484 
00485 
00489         function createBookmarkFolder()
00490         {
00491                 // check title
00492                 if (empty($_POST["title"]))
00493                 {
00494                         //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
00495                         sendInfo($this->lng->txt("please_enter_title"), true);
00496                         ilUtil::redirect("usr_bookmarks.php?bmf_id=".$this->id."&cmd=newForm&type=bmf");
00497                 }
00498 
00499                 // create bookmark folder
00500                 $bmf = new ilBookmarkFolder();
00501                 $bmf->setTitle($_POST["title"]);
00502                 $bmf->setParent($this->id);
00503 
00504                 $bmf->create();
00505 
00506                 $this->view();
00507         }
00508 
00509 
00513         function updateBookmarkFolder()
00514         {
00515                 // check title
00516                 if (empty($_POST["title"]))
00517                 {
00518                         $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
00519                 }
00520 
00521                 // update bookmark folder
00522                 $bmf = new ilBookmarkFolder($_GET["obj_id"]);
00523                 $bmf->setTitle($_POST["title"]);
00524                 $bmf->update();
00525 
00526                 $this->view();
00527         }
00528 
00529 
00533         function createBookmark()
00534         {
00535                 // check title and target
00536                 if (empty($_POST["title"]))
00537                 {
00538                         //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
00539                         sendInfo($this->lng->txt("please_enter_title"), true);
00540                         ilUtil::redirect("usr_bookmarks.php?bmf_id=".$this->id."&cmd=newForm&type=bm");
00541                 }
00542                 if (empty($_POST["target"]))
00543                 {
00544                         //$this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
00545                         sendInfo($this->lng->txt("please_enter_target"), true);
00546                         ilUtil::redirect("usr_bookmarks.php?bmf_id=".$this->id."&cmd=newForm&type=bm");
00547                 }
00548 
00549                 // create bookmark
00550                 $bm = new ilBookmark();
00551                 $bm->setTitle($_POST["title"]);
00552                 $bm->setTarget($_POST["target"]);
00553                 $bm->setParent($this->id);
00554                 $bm->create();
00555 
00556                 $this->view();
00557         }
00558 
00562         function updateBookmark()
00563         {
00564                 // check title and target
00565                 if (empty($_POST["title"]))
00566                 {
00567                         $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
00568                 }
00569                 if (empty($_POST["target"]))
00570                 {
00571                         $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
00572                 }
00573 
00574                 // update bookmark
00575                 $bm = new ilBookmark($_GET["obj_id"]);
00576                 $bm->setTitle($_POST["title"]);
00577                 $bm->setTarget($_POST["target"]);
00578                 $bm->update();
00579 
00580                 $this->view();
00581         }
00582 
00586         function delete()
00587         {
00588 
00589                 $this->main_header();
00590 
00591                 if (!isset($_POST["id"]))
00592                 {
00593                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00594                 }
00595 
00596                 $this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.obj_confirm.html");
00597 
00598                 sendInfo($this->lng->txt("info_delete_sure"));
00599                 $this->tpl->setVariable("FORMACTION", "usr_bookmarks.php?bmf_id=".$this->id."&cmd=post");
00600 
00601                 // output table header
00602                 $cols = array("type", "title", "bookmark_target");
00603                 foreach ($cols as $key)
00604                 {
00605                         $this->tpl->setCurrentBlock("table_header");
00606                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
00607                         $this->tpl->parseCurrentBlock();
00608                 }
00609 
00610                 $_SESSION["saved_post"] = $_POST["id"];
00611 
00612                 foreach($_POST["id"] as $id)
00613                 {
00614                         list($type, $obj_id) = explode(":", $id);
00615                         switch($type)
00616                         {
00617                                 case "bmf":
00618                                         $BookmarkFolder = new ilBookmarkFolder($obj_id);
00619                                         $title = $BookmarkFolder->getTitle();
00620                                         $target = "&nbsp;";
00621                                         unset($BookmarkFolder);
00622                                         break;
00623 
00624                                 case "bm":
00625                                         $Bookmark = new ilBookmark($obj_id);
00626                                         $title = $Bookmark->getTitle();
00627                                         $target = $Bookmark->getTarget();
00628                                         unset($Bookmark);
00629                                         break;
00630                         }
00631 
00632                         // output type icon
00633                         $this->tpl->setCurrentBlock("table_cell");
00634                         $img_type = ($type == "bmf") ? "cat" : $type;
00635                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($img_type, $this->tpl->tplPath));
00636                         $this->tpl->parseCurrentBlock();
00637 
00638                         // output title
00639                         $this->tpl->setCurrentBlock("table_cell");
00640                         $this->tpl->setVariable("TEXT_CONTENT", $title);
00641                         $this->tpl->parseCurrentBlock();
00642 
00643                         // output target
00644                         $this->tpl->setCurrentBlock("table_cell");
00645                         $this->tpl->setVariable("TEXT_CONTENT", $target);
00646                         $this->tpl->parseCurrentBlock();
00647 
00648                         // output table row
00649                         $this->tpl->setCurrentBlock("table_row");
00650                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00651                         $this->tpl->parseCurrentBlock();
00652                 }
00653 
00654                 // cancel and confirm button
00655                 $buttons = array( "cancel"  => $this->lng->txt("cancel"),
00656                         "confirm"  => $this->lng->txt("confirm"));
00657 
00658                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00659                 foreach($buttons as $name => $value)
00660                 {
00661                         $this->tpl->setCurrentBlock("operation_btn");
00662                         $this->tpl->setVariable("BTN_NAME",$name);
00663                         $this->tpl->setVariable("BTN_VALUE",$value);
00664                         $this->tpl->parseCurrentBlock();
00665                 }
00666 
00667         }
00668 
00672         function cancel()
00673         {
00674                 session_unregister("saved_post");
00675                 $this->view();
00676         }
00677 
00681         function confirm()
00682         {
00683                 global $tree, $rbacsystem, $rbacadmin, $objDefinition;
00684 
00685                 // AT LEAST ONE OBJECT HAS TO BE CHOSEN.
00686                 if (!isset($_SESSION["saved_post"]))
00687                 {
00688                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00689                 }
00690 
00691                 // FOR ALL SELECTED OBJECTS
00692                 foreach ($_SESSION["saved_post"] as $id)
00693                 {
00694                         list($type, $id) = explode(":", $id);
00695 
00696                         // get node data and subtree nodes
00697                         $node_data = $this->tree->getNodeData($id);
00698                         $subtree_nodes = $this->tree->getSubTree($node_data);
00699 
00700                         // delete tree
00701                         $this->tree->deleteTree($node_data);
00702 
00703                         // delete objects of subtree nodes
00704                         foreach ($subtree_nodes as $node)
00705                         {
00706                                 switch ($node["type"])
00707                                 {
00708                                         case "bmf":
00709                                                 $BookmarkFolder = new ilBookmarkFolder($node["obj_id"]);
00710                                                 $BookmarkFolder->delete();
00711                                                 break;
00712 
00713                                         case "bm":
00714                                                 $Bookmark = new ilBookmark($node["obj_id"]);
00715                                                 $Bookmark->delete();
00716                                                 break;
00717                                 }
00718                         }
00719                 }
00720 
00721                 $this->main_header();
00722 
00723                 // Feedback
00724                 sendInfo($this->lng->txt("info_deleted"),true);
00725 
00726                 $this->view(false);
00727         }
00728 
00729 
00730 
00734         function showActions()
00735         {
00736                 global $objDefinition;
00737 
00738                 $notoperations = array();
00739                 // NO PASTE AND CLEAR IF CLIPBOARD IS EMPTY
00740                 if (empty($_SESSION["clipboard"]))
00741                 {
00742                         $notoperations[] = "paste";
00743                         $notoperations[] = "clear";
00744                 }
00745                 // CUT COPY PASTE LINK DELETE IS NOT POSSIBLE IF CLIPBOARD IS FILLED
00746                 if ($_SESSION["clipboard"])
00747                 {
00748                         $notoperations[] = "cut";
00749                         $notoperations[] = "copy";
00750                         $notoperations[] = "link";
00751                 }
00752 
00753                 $operations = array();
00754 
00755                 $d = $objDefinition->getActions("bmf");
00756 
00757                 foreach ($d as $row)
00758                 {
00759                         if (!in_array($row["name"], $notoperations))
00760                         {
00761                                 $operations[] = $row;
00762                         }
00763                 }
00764 
00765                 if (count($operations)>0)
00766                 {
00767                         foreach ($operations as $val)
00768                         {
00769                                 $this->tpl->setCurrentBlock("operation_btn");
00770                                 $this->tpl->setVariable("BTN_NAME", $val["lng"]);
00771                                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
00772                                 $this->tpl->parseCurrentBlock();
00773                         }
00774 
00775                         $this->tpl->setCurrentBlock("operation");
00776                         $this->tpl->parseCurrentBlock();
00777                 }
00778         }
00779 
00783         function showPossibleSubObjects()
00784         {
00785                 global $objDefinition;
00786 
00787                 $d = $objDefinition->getCreatableSubObjects("bmf");
00788 
00789                 if (count($d) > 0)
00790                 {
00791                         foreach ($d as $row)
00792                         {
00793                             $count = 0;
00794                                 if ($row["max"] > 0)
00795                                 {
00796                                         //how many elements are present?
00797                                         for ($i=0; $i<count($this->data["ctrl"]); $i++)
00798                                         {
00799                                                 if ($this->data["ctrl"][$i]["type"] == $row["name"])
00800                                                 {
00801                                                     $count++;
00802                                                 }
00803                                         }
00804                                 }
00805                                 if ($row["max"] == "" || $count < $row["max"])
00806                                 {
00807                                         $subobj[] = $row["name"];
00808                                 }
00809                         }
00810                 }
00811 
00812                 if (is_array($subobj))
00813                 {
00814                         //build form
00815                         $opts = ilUtil::formSelect("","type",$subobj);
00816 
00817                         $this->tpl->setCurrentBlock("add_object");
00818                         $this->tpl->setVariable("COLUMN_COUNTS", 7);
00819                         $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
00820                         $this->tpl->setVariable("BTN_NAME", "newForm");
00821                         $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00822                         $this->tpl->parseCurrentBlock();
00823                 }
00824 
00825                 $this->tpl->setVariable("TPLPATH",$this->tpl->tplPath);
00826 
00827                 $this->tpl->setCurrentBlock("tbl_action_select");
00828                 //$this->tpl->setVariable("SELECT_ACTION",ilUtil::formSelect("","action_type",$actions,false,true));
00829                 $this->tpl->setVariable("BTN_NAME","delete");
00830                 $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
00831                 $this->tpl->parseCurrentBlock();
00832 
00833         }
00834 }
00835 ?>

Generated on Fri Dec 13 2013 10:18:26 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1