5 require_once (
"./Services/Bookmarks/classes/class.ilBookmarkExplorer.php");
 
    6 require_once (
"./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
 
    7 require_once (
"./Services/Bookmarks/classes/class.ilBookmark.php");
 
    8 require_once (
"./Services/Table/classes/class.ilTableGUI.php");
 
   54                 $tpl->getStandardTemplate();
 
   58                 $this->
id = (empty(
$_GET[
"bmf_id"]))
 
   67                 $this->ctrl->setParameter($this, 
"bmf_id", $this->
id);
 
   68                 $this->user_id = $ilUser->getId();
 
   70                 $this->tree = 
new ilTree($this->user_id);
 
   71                 $this->tree->setTableNames(
'bookmark_tree', 
'bookmark_data');
 
   72                 $this->root_id = $this->tree->readRootId();
 
   82                 $next_class = $this->ctrl->getNextClass();
 
   87                                 $cmd = $this->ctrl->getCmd(
"view");
 
   96                 $this->tpl->show(
true);
 
  102                 switch(
$_POST[
"selected_cmd"])
 
  136                 $etpl = 
new ilTemplate(
"tpl.bookmark_explorer.html", 
true, 
true,
 
  137                         "Services/Bookmarks");
 
  140                 $exp->setTargetGet(
"bmf_id");
 
  141                 $exp->setSessionExpandVariable(
'mexpand');
 
  142                 $exp->setExpand($this->
id);
 
  143                 $this->ctrl->setParameter($this, 
"bmf_id", $this->
id);
 
  144                 $exp->setExpandTarget($this->ctrl->getLinkTarget($this));
 
  145                 if(
$_GET[
"mexpand"] == 
"")
 
  147                         $mtree = 
new ilTree($this->user_id);
 
  148                         $mtree->setTableNames(
'bookmark_tree', 
'bookmark_data');
 
  149                         $expanded = $mtree->readRootId();
 
  153                         $expanded = 
$_GET[
"mexpand"];
 
  156                 $exp->setExpand($expanded);
 
  157                 $exp->highlightNode(
$_GET[
"bmf_id"]);
 
  161                 $exp->highlightNode($this->
id);
 
  162                 $output = $exp->getOutput();
 
  165                 $etpl->setVariable(
"TXT_EXPLORER_HEADER", $this->lng->txt(
"bookmarks"));
 
  166                 $this->ctrl->setParameter($this, 
"bmf_id", 1);
 
  170                         $link = $_SERVER[
'REQUEST_URI'];
 
  171                         $link = ereg_replace(
'bmf_id=[0-9]*', 
'bmf_id=1', $link);
 
  172                         $etpl->setVariable(
"LINK_EXPLORER_HEADER", $link);
 
  175                         $etpl->setVariable(
"LINK_EXPLORER_HEADER", $this->ctrl->getLinkTarget($this));
 
  177                 $etpl->setVariable(
"EXPLORER", $output);
 
  178                 $tpl->setLeftNavContent($etpl->get());
 
  200                 $this->tpl->setTitle($this->lng->txt(
"bookmarks"));
 
  208                 if($this->
id > 0 && !$this->tree->isInTree($this->id))
 
  210                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  211                         $this->ctrl->redirect($this);
 
  216                 include_once 
'Services/Bookmarks/classes/class.ilBookmarkAdministrationTableGUI.php';
 
  218                 $table->setId(
'bookmark_adm_table');            
 
  219                 $table->setData($objects);
 
  220                 $this->tpl->setVariable(
"ADM_CONTENT", $table->getHTML());
 
  230                         $this->tpl->setCurrentBlock(
"begin_link");
 
  231                         $this->tpl->setVariable(
"LINK_TARGET", $link);
 
  232                         $this->tpl->parseCurrentBlock();
 
  233                         $this->tpl->touchBlock(
"end_link");
 
  236                 $this->tpl->setCurrentBlock(
"text");
 
  237                 $this->tpl->setVariable(
"TEXT_CONTENT", $val);
 
  238                 $this->tpl->parseCurrentBlock();
 
  239                 $this->tpl->setCurrentBlock(
"table_cell");
 
  240                 $this->tpl->parseCurrentBlock();
 
  255                 if(!$this->tree->isInTree($this->id))
 
  260                 $this->tpl->addBlockFile(
"LOCATOR", 
"locator", 
"tpl.locator.html", 
"Services/Locator");
 
  262                 $path = $this->tree->getPathFull($this->
id);
 
  267                 $this->tpl->setVariable(
"TXT_LOCATOR", $this->lng->txt(
"locator"));
 
  268                 $this->tpl->touchBlock(
"locator_separator");
 
  269                 $this->tpl->touchBlock(
"locator_item");
 
  279                         if($key < count(
$path) - $modifier)
 
  281                                 $this->tpl->touchBlock(
"locator_separator");
 
  284                         $this->tpl->setCurrentBlock(
"locator_item");
 
  286                                 $lng->txt(
"bookmarks") :
 
  288                         $this->tpl->setVariable(
"ITEM", 
$title);
 
  289                         $this->ctrl->setParameter($this, 
"bmf_id", 
$row[
"child"]);
 
  290                         $this->tpl->setVariable(
"LINK_ITEM",
 
  291                                 $this->ctrl->getLinkTarget($this));
 
  292                         $this->tpl->parseCurrentBlock();
 
  295                 $this->tpl->setCurrentBlock(
"locator");
 
  297                 $this->tpl->parseCurrentBlock();
 
  324                 if(!$this->tree->isInTree($this->id))
 
  326                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  327                         $this->ctrl->redirect($this);
 
  331                 $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
 
  342                 if(!$this->tree->isInTree($this->id))
 
  344                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  345                         $this->ctrl->redirect($this);
 
  348                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  350                 $form->setTopAnchor(
"bookmark_top");
 
  352                 $form->setTitle($lng->txt(
"bookmark_folder_new"));
 
  354                 if($action == 
'updateBookmarkFolder')
 
  356                         $ilCtrl->setParameter($this, 
'bmf_id', $this->
id);
 
  357                         $ilCtrl->setParameter($this, 
'obj_id', 
$_GET[
"obj_id"]);
 
  360                 $hash = ($ilUser->prefs[
"screen_reader_optimization"])
 
  364                 $form->setFormAction($ilCtrl->getFormAction($this, $action, $hash));
 
  366                 $ilCtrl->clearParameters($this);
 
  371                 $form->addItem($prop);
 
  374                 $form->addCommandButton($action, $lng->txt(
'save'));
 
  375                 $form->addCommandButton(
'cancel', $lng->txt(
'cancel'));
 
  384                 if(!$this->tree->isInTree(
$_GET[
"obj_id"]))
 
  386                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  387                         $this->ctrl->setParameter($this, 
'obj_id', 
'');
 
  388                         $this->ctrl->redirect($this);
 
  393                 $form->setValuesByArray
 
  397                                 "title"  => $this->
get_last(
"title", $bmf->getTitle()),
 
  398                                 "obj_id" => 
$_GET[
"obj_id"],
 
  401                 $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
 
  413                 if(!$this->tree->isInTree($this->id))
 
  415                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  416                         $this->ctrl->redirect($this);
 
  419                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  421                 $form->setTopAnchor(
"bookmark_top");
 
  423                 $form->setTitle($lng->txt(
"bookmark_new"));
 
  425                 if($action == 
'updateBookmark')
 
  427                         $ilCtrl->setParameter($this, 
'bmf_id', $this->
id);
 
  428                         $ilCtrl->setParameter($this, 
'obj_id', 
$_GET[
"obj_id"]);
 
  431                 $hash = ($ilUser->prefs[
"screen_reader_optimization"])
 
  435                 $form->setFormAction($ilCtrl->getFormAction($this, $action, $hash));
 
  436                 $ilCtrl->clearParameters($this);
 
  440                 $prop->setRequired(
true);
 
  441                 $form->addItem($prop);
 
  445                 $form->addItem($prop);
 
  448                 $prop = 
new ilTextInputGUI($lng->txt(
'bookmark_target'), 
'target');
 
  450                 $prop->setRequired(
true);
 
  451                 $form->addItem($prop);
 
  454                 if(
$_GET[
'return_to'])
 
  457                         $prop->setValue(
$_GET[
'return_to']);
 
  458                         $form->addItem($prop);
 
  461                         if(
$_GET[
'return_to_url'])
 
  462                                 $prop->setValue(
$_GET[
'return_to_url']);
 
  464                                 $prop->setValue(
$_GET[
'bm_link']);
 
  465                         $form->addItem($prop);
 
  469                 $form->addCommandButton($action, $lng->txt(
'save'));
 
  470                 $form->addCommandButton(
'cancel', $lng->txt(
'cancel'));
 
  493                 if(!$this->tree->isInTree($this->id))
 
  495                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  496                         $this->ctrl->redirect($this);
 
  499                 include_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  501                 $form->setFormAction($ilCtrl->getFormAction($this, 
"importFile")); 
 
  502                 $form->setTopAnchor(
"bookmark_top");
 
  503                 $form->setTitle($lng->txt(
"bkm_import"));
 
  509                 $form->addCommandButton(
"importFile", $lng->txt(
'import'));
 
  510                 $form->addCommandButton(
'cancel', $lng->txt(
'cancel'));
 
  521                 $html1 = $form->getHTML();
 
  526                         $html2 = 
"<br />" . $form2->getHTML();
 
  528                 $this->tpl->setVariable(
"ADM_CONTENT", $html1 . $html2);
 
  537                 return (!empty(
$_POST[$a_var])) ?
 
  549                 if(!$this->tree->isInTree(
$_GET[
"obj_id"]))
 
  551                         $this->ctrl->setParameter($this, 
'obj_id', 
'');
 
  552                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  553                         $this->ctrl->redirect($this);
 
  558                 $form->setValuesByArray
 
  562                                 "title"       => $bookmark->getTitle(),
 
  563                                 "target"      => $bookmark->getTarget(),
 
  564                                 "description" => $bookmark->getDescription(),
 
  565                                 "obj_id"      => 
$_GET[
"obj_id"],
 
  568                 $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
 
  577                 if(!$this->tree->isInTree($this->id))
 
  579                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  580                         $this->ctrl->redirect($this);
 
  584                 if(empty(
$_POST[
"title"]))
 
  594                         $bmf->setParent($this->
id);
 
  598                         $ilCtrl->saveParameter($this, 
'bmf_id');
 
  599                         $ilCtrl->redirect($this, 
'view');
 
  609                 if(!$this->tree->isInTree(
$_GET[
"obj_id"]))
 
  611                         $this->ctrl->setParameter($this, 
'obj_id', 
'');
 
  612                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  613                         $this->ctrl->redirect($this);
 
  617                 if(empty(
$_POST[
"title"]))
 
  630                         $ilCtrl->saveParameter($this, 
'bmf_id');
 
  631                         $ilCtrl->redirect($this, 
'view');
 
  643                 if(!$this->tree->isInTree($this->id))
 
  645                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  646                         $this->ctrl->redirect($this);
 
  650                 if(empty(
$_POST[
"title"]))
 
  655                 else if(empty(
$_POST[
"target"]))
 
  667                         $bm->setParent($this->
id);
 
  676                                 $ilCtrl->saveParameter($this, 
'bmf_id');
 
  677                                 $ilCtrl->redirect($this, 
'view');
 
  687                 if(!$this->tree->isInTree(
$_GET[
"obj_id"]))
 
  689                         $this->ctrl->setParameter($this, 
'obj_id', 
'');
 
  690                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  691                         $this->ctrl->redirect($this);
 
  695                 if(empty(
$_POST[
"title"]))
 
  700                 else if(empty(
$_POST[
"target"]))
 
  726                         $this->ilias->raiseError($this->lng->txt(
"no_checkbox"), $this->ilias->error_obj->MESSAGE);
 
  728                 $export_ids = array();
 
  729                 foreach($bm_ids as 
$id)
 
  731                         if($this->tree->isInTree($id))
 
  739                 require_once (
"./Services/Bookmarks/classes/class.ilBookmarkImportExport.php");
 
  741                         $this->lng->txt(
"bookmarks_of") . 
" " . $this->ilias->account->getFullname());
 
  749                         return $html_content;
 
  759                 include_once 
'./Services/Mail/classes/class.ilFileDataMail.php';
 
  760                 require_once 
"Services/Mail/classes/class.ilFormatMail.php";
 
  764                 $html_content = $this->
export(
false);
 
  766                 $fp           = fopen($tempfile, 
'w');
 
  767                 fwrite($fp, $html_content);
 
  770                 $mfile->copyAttachmentFile($tempfile, 
$filename);
 
  771                 $umail->savePostData($ilUser->getId(), array(
$filename),
 
  776                 require_once 
'Services/Mail/classes/class.ilMailFormCall.php';
 
  788                         $this->ilias->raiseError($this->lng->txt(
"no_checkbox"), $this->ilias->error_obj->MESSAGE);
 
  791                 $this->ctrl->setParameter($this, 
"bmf_id", $this->
id);
 
  794                 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
 
  796                 $cgui->setFormAction($this->ctrl->getFormAction($this));
 
  797                 $cgui->setHeaderText($this->lng->txt(
"info_delete_sure"));
 
  798                 $cgui->setCancel($this->lng->txt(
"cancel"), 
"cancel");
 
  799                 $cgui->setConfirm($this->lng->txt(
"confirm"), 
"confirm");
 
  801                 foreach($bm_ids as $obj_id)
 
  805                         if(!$this->tree->isInTree($obj_id))
 
  814                                         $title          = $BookmarkFolder->getTitle();
 
  816                                         unset($BookmarkFolder);
 
  821                                         $title    = $Bookmark->getTitle();
 
  822                                         $target   = $Bookmark->getTarget();
 
  834                         $cgui->addItem(
"id[]", $obj_id, $caption);
 
  837                 $this->tpl->setContent($cgui->getHTML());
 
  856                 global 
$tree, $rbacsystem, $rbacadmin;
 
  860                         $this->ilias->raiseError($this->lng->txt(
"no_checkbox"), $this->ilias->error_obj->MESSAGE);
 
  869                         if($this->tree->isInTree($id))
 
  871                                 $node_data     = $this->tree->getNodeData($id);
 
  872                                 $subtree_nodes = $this->tree->getSubTree($node_data);
 
  880                         $this->tree->deleteTree($node_data);
 
  883                         foreach($subtree_nodes as $node)
 
  885                                 switch($node[
"type"])
 
  889                                                 $BookmarkFolder->delete();
 
  913                         "delete"  => $this->lng->txt(
"delete"),
 
  914                         "export"  => $this->lng->txt(
"export"),
 
  915                         "sendmail"=> $this->lng->txt(
"bkm_sendmail"),
 
  918                 $subobj = array(
"bm", 
"bmf");
 
  920                 if(is_array($subobj))
 
  925                         $this->tpl->setCurrentBlock(
"add_object");
 
  926                         $this->tpl->setVariable(
"COLUMN_COUNTS", 7);
 
  927                         $this->tpl->setVariable(
"SELECT_OBJTYPE", $opts);
 
  928                         $this->tpl->setVariable(
"BTN_NAME", 
"newForm");
 
  929                         $this->tpl->setVariable(
"TXT_ADD", $this->lng->txt(
"add"));
 
  930                         $this->tpl->parseCurrentBlock();
 
  933                 $this->tpl->setVariable(
"TPLPATH", $this->tpl->tplPath);
 
  935                 $this->tpl->setCurrentBlock(
"tbl_action_select");
 
  936                 $this->tpl->setVariable(
"SELECT_ACTION", 
ilUtil::formSelect(
$_SESSION[
"error_post_vars"][
'action'], 
"action", $actions, 
false, 
true));
 
  937                 $this->tpl->setVariable(
"BTN_NAME", 
"executeAction");
 
  938                 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"execute"));
 
  949                 $this->tpl->parseCurrentBlock();
 
  958                 include_once(
"./Services/Bookmarks/classes/class.ilBookmarkBlockGUI.php");
 
  961                 return $bookmark_block_gui->getHTML();
 
  972                 if(!$this->tree->isInTree($this->id))
 
  974                         $this->ctrl->setParameter($this, 
'bmf_id', 
'');
 
  975                         $this->ctrl->redirect($this);
 
  978                 if($_FILES[
"bkmfile"][
"error"] > UPLOAD_ERR_OK)
 
  984                 require_once (
"./Services/Bookmarks/classes/class.ilBookmarkImportExport.php");
 
  986                 if($objects === 
false)
 
  993                 $num_create = array(
'bm'=> 0, 
'bmf'=> 0);
 
  997                         $num_create[
'bmf']));
 
 1013                 if(is_array($objects[$start_key]))
 
 1015                         foreach($objects[$start_key] as $obj_key=> $object)
 
 1017                                 switch($object[
'type'])
 
 1020                                                 if(!$object[
"title"]) 
continue;
 
 1021                                                 if(!$object[
"target"]) 
continue;
 
 1023                                                 $bm->setTitle($object[
"title"]);
 
 1024                                                 $bm->setDescription($object[
"description"]);
 
 1025                                                 $bm->setTarget($object[
"target"]);
 
 1026                                                 $bm->setParent($folder_id);
 
 1028                                                 $num_create[
'bm']++;
 
 1031                                                 if(!$object[
"title"]) 
continue;
 
 1033                                                 $bmf->setTitle($object[
"title"]);
 
 1034                                                 $bmf->setParent($folder_id);
 
 1036                                                 $num_create[
'bmf']++;
 
 1037                                                 if(is_array($objects[$obj_key]))
 
 1040                                                                 $bmf->getId(), $obj_key);
 
 1056                         return $this->
view();
 
 1059                 $ilTabs->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTarget($this));
 
 1061                 $this->ctrl->setParameter($this, 
"bm_id_tgt", implode(
";", $bm_ids));
 
 1062                 $exp = 
new ilBookmarkExplorer($this->ctrl->getLinkTarget($this, 
"confirmedMove"), $ilUser->getId());
 
 1064                 $exp->setTargetGet(
"bmfmv_id");
 
 1065                 $exp->forceExpandAll(
true, 
false);
 
 1066                 $exp->addRoot($this->lng->txt(
"bookmarks"));
 
 1070                 $this->tpl->setContent($exp->getOutput());
 
 1073                 $this->mode = 
"flat";
 
 1081                 $bm_ids = explode(
";", 
$_REQUEST[
'bm_id_tgt']);
 
 1082                 if(!$bm_ids || !$tgt)
 
 1085                         return $this->
view();
 
 1089                 $tree->setTableNames(
'bookmark_tree', 
'bookmark_data');
 
 1091                 $tgt_node = 
$tree->getNodeData($tgt);
 
 1094                 foreach($bm_ids as $node_id)
 
 1096                         if(
$tree->isGrandChild($node_id, $tgt))
 
 1099                                 $this->ctrl->redirect($this, 
"view");
 
 1102                         $node = 
$tree->getNodeData($node_id);
 
 1105                         if($node[
"parent"] == $tgt)
 
 1110                         $tree->moveTree($node_id, $tgt);
 
 1114                 $this->ctrl->setParameter($this, 
"bmf_id", $tgt);
 
 1115                 $this->ctrl->redirect($this, 
"view");