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

Modules/WebResource/classes/class.ilObjLinkResourceGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 "./classes/class.ilObjectGUI.php";
00025 
00037 class ilObjLinkResourceGUI extends ilObjectGUI
00038 {
00043         function ilObjLinkResourceGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00044         {
00045                 global $ilCtrl;
00046 
00047                 $this->type = "webr";
00048                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
00049 
00050                 // CONTROL OPTIONS
00051                 $this->ctrl =& $ilCtrl;
00052                 $this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
00053 
00054                 $this->lng->loadLanguageModule('webr');
00055         }
00056 
00057         function &executeCommand()
00058         {
00059                 global $rbacsystem;
00060 
00061                 //if($this->ctrl->getTargetScript() == 'link_resources.php')
00062                 if($_GET["baseClass"] == 'ilLinkResourceHandlerGUI')
00063                 {
00064                         $this->__prepareOutput();
00065                 }
00066                 
00067                 if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00068                         $this->getCreationMode() == true)
00069                 {
00070                         $this->prepareOutput();
00071                 }
00072 
00073 
00074                 $next_class = $this->ctrl->getNextClass($this);
00075                 $cmd = $this->ctrl->getCmd();
00076 
00077                 switch($next_class)
00078                 {
00079                         case "ilinfoscreengui":
00080                                 $this->infoScreen();    // forwards command
00081                                 break;
00082 
00083                         case 'ilmdeditorgui':
00084 
00085                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00086 
00087                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00088                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00089 
00090                                 $this->ctrl->forwardCommand($md_gui);
00091                                 break;
00092                                 
00093                         case 'ilpermissiongui':
00094                                 include_once("./classes/class.ilPermissionGUI.php");
00095                                 $perm_gui =& new ilPermissionGUI($this);
00096                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00097                                 break;
00098 
00099                         default:
00100                                 if(!$cmd)
00101                                 {
00102                                         $cmd = "view";
00103                                 }
00104                                 $cmd .= "Object";
00105                                 $this->$cmd();
00106                                         
00107                                 break;
00108                 }
00109                 
00110                 if(!$this->getCreationMode())
00111                 {
00112                         // Fill meta header tags
00113                         include_once('Services/MetaData/classes/class.ilMDUtils.php');
00114                         ilMDUtils::_fillHTMLMetaTags($this->object->getId(),$this->object->getId(),'webr');
00115                 }
00116                 return true;
00117         }
00118         
00126         public function createObject()
00127         {
00128                 parent::createObject();
00129                 $this->fillCloneTemplate('CLONE_WIZARD',$_REQUEST['new_type']);
00130         }
00131 
00132         function viewObject()
00133         {
00134                 global $ilAccess,$ilErr;
00135                 
00136                 if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
00137                 {
00138                         $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);        
00139                 }
00140                 
00141                 
00142                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00143                 {
00144                         parent::viewObject();
00145                         return true;
00146                 }
00147                 else
00148                 {
00149                         $this->listItemsObject();
00150 
00151                         return true;
00152                 }
00153         }
00154 
00155         function listItemsObject()
00156         {
00157                 global $rbacsystem;
00158 
00159                 include_once "./Services/Table/classes/class.ilTableGUI.php";
00160                 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
00161 
00162                 // MINIMUM ACCESS LEVEL = 'read'
00163                 if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
00164                 {
00165                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00166                 }
00167 
00168                 $this->object->initLinkResourceItemsObject();
00169                 if(!count($items = $this->object->items_obj->getActivatedItems()))
00170                 {
00171                         ilUtil::sendInfo($this->lng->txt('webr_no_items_created'));
00172 
00173                         return true;
00174                 }
00175 
00176                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.lnkr_view_items.html","Modules/WebResource");
00177                 
00178                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00179                 #$items_sliced = array_slice($items, $_GET["offset"], $_GET["limit"]);
00180 
00181                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.lnkr_view_items_row.html",'Modules/WebResource');
00182 
00183                 $items = ilUtil::sortArray($items,
00184                                                                    'title',
00185                                                                    $_GET['sort_order'] ? $_GET['sort_order'] : 'asc');
00186                 $counter = 0;
00187                 foreach($items as $item_id => $item)
00188                 {
00189                         if(ilParameterAppender::_isEnabled())
00190                         {
00191                                 $item = ilParameterAppender::_append($item);
00192                         }
00193                         if(strlen($item['description']))
00194                         {
00195                                 $tpl->setCurrentBlock("description");
00196                                 $tpl->setVariable("DESCRIPTION",$item['description']);
00197                                 $tpl->parseCurrentBlock();
00198                         }
00199                         $tpl->setCurrentBlock("row");
00200                         $tpl->setVariable("ROW_CSS",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
00201                         $tpl->setVariable("TITLE",$item['title']);
00202                         $tpl->setVariable("TARGET",$item['target']);
00203                         $tpl->parseCurrentBlock();
00204                 }
00205 
00206                 // create table
00207                 $tbl = new ilTableGUI();
00208 
00209                 // title & header columns
00210                 $tbl->setTitle($this->lng->txt("web_resources"),"icon_webr.gif",$this->lng->txt("web_resources"));
00211                 $tbl->setHeaderNames(array($this->lng->txt("title")));
00212                 $tbl->setHeaderVars(array("title"),array("ref_id" => $this->object->getRefId(),
00213                                                                                                            "cmd" => 'listItems'));
00214                 $tbl->setColumnWidth(array("100%"));
00215                 $tbl->disable('linkbar');
00216                 $tbl->disable('numinfo');
00217 
00218                 $tbl->setOrderColumn('title');
00219                 $tbl->setOrderDirection($_GET['sort_order']);
00220                 $tbl->setLimit($_GET["limit"]);
00221                 $tbl->setOffset($_GET["offset"]);
00222                 $tbl->setMaxCount(count($items));
00223 
00224                 // render table
00225                 $tbl->setTemplate($tpl);
00226                 $tbl->render();
00227 
00228                 $this->tpl->setVariable("ITEM_TABLE", $tpl->get());
00229 
00230                 return true;
00231         }
00232 
00233         function editItemsObject()
00234         {
00235                 global $rbacsystem;
00236 
00237                 include_once "./Services/Table/classes/class.ilTableGUI.php";
00238                 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
00239                 
00240 
00241                 // MINIMUM ACCESS LEVEL = 'read'
00242                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00243                 {
00244                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00245                 }
00246 
00247                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.lnkr_edit_items.html","Modules/WebResource");
00248                 $this->__showButton('showAddItem',$this->lng->txt('webr_add_item'));
00249 
00250                 $this->object->initLinkResourceItemsObject();
00251                 if(!count($items = $this->object->items_obj->getAllItems()))
00252                 {
00253                         ilUtil::sendInfo($this->lng->txt('webr_no_items_created'));
00254 
00255                         return true;
00256                 }
00257                 
00258                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00259                 #$items_sliced = array_slice($items, $_GET["offset"], $_GET["limit"]);
00260 
00261                 $tpl->setCurrentBlock("tbl_form_header");
00262                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00263                 $tpl->parseCurrentBlock();
00264 
00265                 $tpl->setCurrentBlock("tbl_action_btn");
00266                 $tpl->setVariable("BTN_NAME",'askDeleteItems');
00267                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('delete'));
00268                 $tpl->parseCurrentBlock();
00269                 
00270                 $tpl->setCurrentBlock("plain_buttons");
00271                 $tpl->setVariable("PBTN_NAME",'updateItems');
00272                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt('save'));
00273                 $tpl->parseCurrentBlock();
00274                 
00275                 $tpl->setCurrentBlock("tbl_action_row");
00276                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00277                 $tpl->setVariable("COLUMN_COUNTS",ilParameterAppender::_isEnabled() ? 8 : 7);
00278                 $tpl->parseCurrentBlock();
00279                 
00280 
00281 
00282                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.lnkr_edit_items_row.html",'Modules/WebResource');
00283 
00284                 $items = ilUtil::sortArray($items,
00285                                                                    $_GET['sort_by'] ? $_GET['sort_by'] : 'title',
00286                                                                    $_GET['sort_order'] ? $_GET['sort_order'] : 'asc');
00287                 
00288                 $counter = 0;
00289                 foreach($items as $item_id => $item)
00290                 {
00291                         if(ilParameterAppender::_isEnabled())
00292                         {
00293                                 $params_list = array();
00294                                 foreach($params = ilParameterAppender::_getParams($item['link_id']) as $id => $param)
00295                                 {
00296                                         $txt_param = $param['name'];
00297                                         switch($param['value'])
00298                                         {
00299                                                 case LINKS_USER_ID:
00300                                                         $txt_param .= '=IL_USER_ID';
00301                                                         break;
00302 
00303                                                 case LINKS_SESSION_ID:
00304                                                         $txt_param .= '=IL_SESSION_ID';
00305                                                         break;
00306                                                 
00307                                                 case LINKS_LOGIN:
00308                                                         $txt_param .= '=IL_LOGIN';
00309                                                         break;
00310                                         }
00311                                         $params_list[] = $txt_param;
00312                                 }
00313                                 $tpl->setCurrentBlock("params");
00314                                 $tpl->setVariable("DYN_PARAM",count($params_list) ? 
00315                                                                   implode('<br />',$params_list) :
00316                                                                   $this->lng->txt('links_not_available'));
00317                                 $tpl->parseCurrentBlock();
00318                         }                       
00319 
00320 
00321                         if(strlen($item['description']))
00322                         {
00323                                 $tpl->setCurrentBlock("description");
00324                                 $tpl->setVariable("DESCRIPTION",$item['description']);
00325                                 $tpl->parseCurrentBlock();
00326                         }
00327 
00328                         $tpl->setCurrentBlock("row");
00329                         $tpl->setVariable("ROW_CSS",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
00330                         
00331                         $tpl->setVariable("CHECK_ITEM",ilUtil::formCheckbox(0,'item_id[]',$item['link_id']));
00332                         $tpl->setVariable("TITLE",$item['title']);
00333 
00334                         if($item['last_check'])
00335                         {
00336                                 $last_check = date('Y-m-d H:i:s',$item['last_check']);
00337                         }
00338                         else
00339                         {
00340                                 $last_check = $this->lng->txt('webr_never_checked');
00341                         }
00342                         $tpl->setVariable("TXT_LAST_CHECK",$this->lng->txt('webr_last_check_table'));
00343                         $tpl->setVariable("LAST_CHECK",$last_check);
00344 
00345                         $target = substr($item['target'],0,70);
00346                         if(strlen($item['target']) > 70)
00347                         {
00348                                 $target = substr($item['target'],0,70).'...';
00349                         }
00350                         else
00351                         {
00352                                 $target = $item['target'];
00353                         }
00354 
00355                                 
00356 
00357                         $tpl->setVariable("TARGET",$target);
00358                         $tpl->setVariable("VALID",ilUtil::formCheckbox($item['valid'] ? 1 : 0,'valid['.$item['link_id'].']',1));
00359                         $tpl->setVariable("ACTIVE",ilUtil::formCheckbox($item['active'] ? 1 : 0,'active['.$item['link_id'].']',1));
00360                         $tpl->setVariable("DISABLE_CHECK",ilUtil::formCheckbox($item['disable_check'] ? 1 : 0,'disable['.$item['link_id'].']',1));
00361                         $tpl->setVariable("EDIT_IMG",ilUtil::getImagePath('icon_pencil.gif'));
00362                         $tpl->setVariable("EDIT_ALT",$this->lng->txt('edit'));
00363 
00364                         $this->ctrl->setParameter($this,'item_id',$item['link_id']);
00365                         $tpl->setVariable("EDIT_LINK",$this->ctrl->getLinkTarget($this,'editItem'));
00366 
00367                         $tpl->parseCurrentBlock();
00368                 }
00369 
00370                 // create table
00371                 $tbl = new ilTableGUI();
00372 
00373 
00374 
00375 
00376                 // title & header columns
00377                 $tbl->setTitle($this->lng->txt("web_resources"),"icon_webr.gif",$this->lng->txt("web_resources"));
00378 
00379                 if(!ilParameterAppender::_isEnabled())
00380                 {
00381                         $tbl->setHeaderNames(array('',
00382                                                                            $this->lng->txt("title"),
00383                                                                            $this->lng->txt("target"),
00384                                                                            $this->lng->txt('valid'),
00385                                                                            $this->lng->txt('active'),
00386                                                                            $this->lng->txt('disable_check'),
00387                                                                            $this->lng->txt('details')));
00388                         $tbl->setHeaderVars(array("",
00389                                                                           "title",
00390                                                                           "target",
00391                                                                           "valid",
00392                                                                           "active",
00393                                                                           "disable_check",
00394                                                                           ""),array("ref_id" => $this->object->getRefId(),
00395                                                                                                 "cmd" => 'editItems'));
00396                         $tbl->setColumnWidth(array("",
00397                                                                            "50%",
00398                                                                            "30%",
00399                                                                            "5%",
00400                                                                            "5%",
00401                                                                            "5%",
00402                                                                            "5%"));
00403                 }
00404                 else
00405                 {
00406                         $tbl->setHeaderNames(array('',
00407                                                                            $this->lng->txt("title"),
00408                                                                            $this->lng->txt("target"),
00409                                                                            $this->lng->txt("links_dyn_parameter"),
00410                                                                            $this->lng->txt('valid'),
00411                                                                            $this->lng->txt('active'),
00412                                                                            $this->lng->txt('disable_check'),
00413                                                                            $this->lng->txt('details')));
00414                         
00415                         $tbl->setHeaderVars(array("",
00416                                                                           "title",
00417                                                                           "target",
00418                                                                           "parameter",
00419                                                                           "valid",
00420                                                                           "active",
00421                                                                           "disable_check",
00422                                                                           ""),array("ref_id" => $this->object->getRefId(),
00423                                                                                                 "cmd" => 'editItems'));
00424                         $tbl->setColumnWidth(array("",
00425                                                                            "40%",
00426                                                                            "20%",
00427                                                                            "20%",
00428                                                                            "5%",
00429                                                                            "5%",
00430                                                                            "5%",
00431                                                                            "5%"));
00432                 }
00433                 $tbl->disable('linkbar');
00434                 $tbl->disable('numinfo');
00435                 $tbl->enable('sort');
00436 
00437                 $tbl->setOrderColumn($_GET['sort_by']);
00438                 $tbl->setOrderDirection($_GET['sort_order']);
00439                 $tbl->setLimit($_GET["limit"]);
00440                 $tbl->setOffset($_GET["offset"]);
00441                 $tbl->setMaxCount(count($items));
00442 
00443                 // render table
00444                 $tbl->setTemplate($tpl);
00445                 $tbl->render();
00446 
00447                 $this->tpl->setVariable("ITEM_TABLE", $tpl->get());
00448 
00449                 return true;
00450         }
00451 
00452         function askDeleteItemsObject()
00453         {
00454                 global $rbacsystem;
00455 
00456                 // MINIMUM ACCESS LEVEL = 'write'
00457                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00458                 {
00459                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00460                 }
00461                 if(!count($_POST['item_id']))
00462                 {
00463                         ilUtil::sendInfo($this->lng->txt('webr_select_one'));
00464                         $this->editItemsObject();
00465 
00466                         return true;
00467                 }
00468 
00469                 ilUtil::sendInfo($this->lng->txt('webr_sure_delete_items'));
00470                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.lnkr_ask_delete.html','Modules/WebResource');
00471 
00472                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00473                 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath('icon_webr.gif'));
00474                 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt('obj_webr'));
00475                 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('webr_delete_items'));
00476                 $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('title'));
00477                 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
00478                 $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
00479 
00480                 $this->object->initLinkResourceItemsObject();
00481                 
00482                 $counter = 0;
00483                 foreach($_POST['item_id'] as $id)
00484                 {
00485                         $this->object->items_obj->readItem($id);
00486                         $this->tpl->setCurrentBlock("item_row");
00487                         $this->tpl->setVariable("ITEM_TITLE",$this->object->items_obj->getTitle());
00488                         $this->tpl->setVariable("TXT_TARGET",$this->lng->txt('target'));
00489                         $this->tpl->setVariable("TARGET",$this->object->items_obj->getTarget());
00490                         $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00491                         $this->tpl->parseCurrentBlock();
00492                 }
00493                 $_SESSION['webr_item_ids'] = $_POST['item_id'];
00494 
00495                 return true;
00496         }
00497 
00498         function deleteItemsObject()
00499         {
00500                 global $rbacsystem;
00501 
00502                 // MINIMUM ACCESS LEVEL = 'write'
00503                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00504                 {
00505                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00506                 }
00507                 if(!count($_SESSION['webr_item_ids']))
00508                 {
00509                         ilUtil::sendInfo($this->lng->txt('webr_select_one'));
00510                         $this->editItemsObject();
00511 
00512                         return true;
00513                 }
00514 
00515                 $this->object->initLinkResourceItemsObject();
00516                 foreach($_SESSION['webr_item_ids'] as $id)
00517                 {
00518                         $this->object->items_obj->delete($id);
00519                 }
00520                 ilUtil::sendInfo($this->lng->txt('webr_deleted_items'));
00521 
00522                 $this->editItemsObject();
00523                 return true;
00524         }
00525                 
00526 
00527         function updateItemsObject()
00528         {
00529                 global $rbacsystem;
00530 
00531                 // MINIMUM ACCESS LEVEL = 'write'
00532                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00533                 {
00534                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00535                 }
00536                 $this->object->initLinkResourceItemsObject();
00537                 foreach($this->object->items_obj->getAllItems() as $item)
00538                 {
00539                         $update = false;
00540 
00541                         $valid = (int) $_POST['valid'][$item['link_id']];
00542                         $active = (int) $_POST['active'][$item['link_id']];
00543                         $disable = (int) $_POST['disable'][$item['link_id']];
00544 
00545                         if($valid != $item['valid'] or
00546                            $active != $item['active'] or 
00547                            $disable != $item['disable_check'])
00548                         {
00549                                 $this->object->items_obj->readItem($item['link_id']);
00550                                 $this->object->items_obj->setValidStatus($valid);
00551                                 $this->object->items_obj->setActiveStatus($active);
00552                                 $this->object->items_obj->setDisableCheckStatus($disable);
00553                                 $this->object->items_obj->update();
00554                         }
00555                 }
00556 
00557                 ilUtil::sendInfo($this->lng->txt('webr_modified_items'));
00558                 $this->editItemsObject();
00559 
00560                 return true;
00561         }
00562 
00563         function editItemObject()
00564         {
00565                 global $rbacsystem;
00566 
00567                 // MINIMUM ACCESS LEVEL = 'write'
00568                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00569                 {
00570                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00571                 }
00572 
00573                 $this->object->initLinkResourceItemsObject();
00574                 $item = $this->object->items_obj->getItem($_GET['item_id'] ? $_GET['item_id'] : $_SESSION['webr_item_id']);
00575 
00576 
00577                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.lnkr_edit_item.html','Modules/WebResource');
00578 
00579                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00580                 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath('icon_webr.gif'));
00581                 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt('obj_webr'));
00582                 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('webr_edit_item'));
00583                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
00584                 $this->tpl->setVariable("TXT_DESCRIPTION",$this->lng->txt('description'));
00585                 $this->tpl->setVariable("TITLE",ilUtil::prepareFormOutput($item['title']));
00586                 $this->tpl->setVariable("DESCRIPTION",ilUtil::prepareFormOutput($item['description']));
00587                 $this->tpl->setVariable("TXT_TARGET",$this->lng->txt('target'));
00588                 $this->tpl->setVariable("TARGET",ilUtil::prepareFormOutput($item['target']));
00589                 $this->tpl->setVariable("TXT_ACTIVE",$this->lng->txt('webr_active'));
00590                 $this->tpl->setVariable("ACTIVE_CHECK",ilUtil::formCheckbox($item['active'] ? 1 : 0,'active',1));
00591                 $this->tpl->setVariable("TXT_VALID",$this->lng->txt('valid'));
00592                 $this->tpl->setVariable("VALID_CHECK",ilUtil::formCheckbox($item['valid'] ? 1 : 0,'valid',1));
00593                 $this->tpl->setVariable("TXT_DISABLE",$this->lng->txt('disable_check'));
00594                 $this->tpl->setVariable("DISABLE_CHECK",ilUtil::formCheckbox($item['disable_check'] ? 1 : 0,'disable',1));
00595                 $this->tpl->setVariable("TXT_CREATED",$this->lng->txt('created'));
00596                 $this->tpl->setVariable("CREATED",date('Y-m-d H:i:s',$item['create_date']));
00597                 $this->tpl->setVariable("TXT_MODIFIED",$this->lng->txt('last_change'));
00598                 $this->tpl->setVariable("MODIFIED",date('Y-m-d H:i:s',$item['last_update']));
00599                 $this->tpl->setVariable("TXT_LAST_CHECK",$this->lng->txt('webr_last_check'));
00600 
00601                 // add dynamic params
00602                 include_once('./Modules/WebResource/classes/class.ilParameterAppender.php');
00603 
00604                 if(ilParameterAppender::_isEnabled())
00605                 {
00606                         $counter = 0;
00607                         foreach($params = ilParameterAppender::_getParams($item['link_id']) as $id => $param)
00608                         {
00609                                 if(!$counter++)
00610                                 {
00611                                         $this->tpl->setCurrentBlock("header_info");
00612                                         $this->tpl->setVariable("TXT_PARAM_EXIST",$this->lng->txt('links_existing_params'));
00613                                         $this->tpl->parseCurrentBlock();
00614                                 }
00615                                 $this->tpl->setCurrentBlock("show_params");
00616                                 
00617                                 $txt_param = $param['name'];
00618                                 switch($param['value'])
00619                                 {
00620                                         case LINKS_USER_ID:
00621                                                 $txt_param .= '=IL_USER_ID';
00622                                                 break;
00623 
00624                                         case LINKS_SESSION_ID:
00625                                                 $txt_param .= '=IL_SESSION_ID';
00626                                                 break;
00627                                                 
00628                                         case LINKS_LOGIN:
00629                                                 $txt_param .= '=IL_LOGIN';
00630                                                 break;
00631                                 }
00632                                 $this->tpl->setVariable("PARAMETER",$txt_param);
00633                                 
00634                                 // Delete link
00635                                 $this->ctrl->setParameter($this,'param_id',$id);
00636                                 $this->tpl->setVariable("DEL_TARGET",$this->ctrl->getLinkTarget($this,'deleteParameter'));
00637                                 $this->tpl->setVariable("TXT_DELETE",$this->lng->txt('delete'));
00638                                 $this->tpl->parseCurrentBlock();
00639                         }
00640 
00641                         $this->tpl->setCurrentBlock("params");
00642                         $this->tpl->setVariable("TXT_ADD_PARAM",$this->lng->txt('links_add_param'));
00643                         $this->tpl->setVariable("TXT_DYNAMIC",$this->lng->txt('links_dynamic'));
00644                         $this->tpl->setVariable("TXT_NAME",$this->lng->txt('links_name'));
00645                         $this->tpl->setVariable("TXT_VALUE",$this->lng->txt('links_value'));
00646                         $this->tpl->setVariable("DYNAMIC_INFO",$this->lng->txt('link_dynamic_info'));
00647 
00648                         $this->tpl->setVariable("NAME",$_POST['name'] ? ilUtil::prepareFormOutput($_POST['name'],true) : '');
00649                         $this->tpl->setVariable("VAL_SEL",ilUtil::formSelect((int) $_POST['value'],
00650                                                                                                                                  'value',
00651                                                                                                                                  ilParameterAppender::_getOptionSelect(),
00652                                                                                                                                  false,
00653                                                                                                                                  true));
00654                         $this->tpl->parseCurrentBlock();
00655                 }
00656 
00657                 
00658 
00659                 if($item['last_check'])
00660                 {
00661                         $last_check = date('Y-m-d H:i:s',$item['last_check']);
00662                 }
00663                 else
00664                 {
00665                         $last_check = $this->lng->txt('webr_never_checked');
00666                 }
00667 
00668                 $this->tpl->setVariable("LAST_CHECK",$last_check);
00669                 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
00670                 $this->tpl->setVariable("BTN_UPDATE",$this->lng->txt('save'));
00671 
00672                 $_SESSION['webr_item_id'] = $_GET['item_id'] ? $_GET['item_id'] : $_SESSION['webr_item_id'];
00673 
00674                 return true;
00675         }
00676 
00677         function deleteParameterObject()
00678         {
00679                 if(!((int) $_GET['param_id']))
00680                 {
00681                         ilUtil::sendInfo('No parameter id given');
00682                         $this->editItemObject();
00683 
00684                         return false;
00685                 }
00686 
00687                 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
00688 
00689                 $appender = new ilParameterAppender($this->object->getId());
00690                 $appender->delete((int) $_GET['param_id']);
00691 
00692                 ilUtil::sendInfo($this->lng->txt('links_parameter_deleted'));
00693 
00694                 $this->editItemObject();
00695                 return true;
00696         }
00697 
00698 
00699         function updateItemObject()
00700         {
00701                 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
00702 
00703                 global $rbacsystem;
00704 
00705                 // MINIMUM ACCESS LEVEL = 'write'
00706                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00707                 {
00708                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00709                 }
00710                 if(!$_POST['title'] or $_POST['target'] == 'http://')
00711                 {
00712                         ilUtil::sendInfo($this->lng->txt('webr_fillout_all'));
00713 
00714                         $this->editItemObject();
00715                         return false;
00716                 }
00717                 if(ilParameterAppender::_isEnabled())
00718                 {
00719                         $appender =& new ilParameterAppender($this->object->getId());
00720                         $appender->setName(ilUtil::stripSlashes($_POST['name']));
00721                         $appender->setValue(ilUtil::stripSlashes($_POST['value']));
00722                         
00723                         if(!$appender->validate())
00724                         {
00725                                 switch($appender->getErrorCode())
00726                                 {
00727                                         case LINKS_ERR_NO_NAME:
00728                                                 ilUtil::sendInfo($this->lng->txt('links_no_name_given'));
00729                                                 $this->editItemObject();
00730                                                 return false;
00731 
00732                                         case LINKS_ERR_NO_VALUE:
00733                                                 ilUtil::sendInfo($this->lng->txt('links_no_value_given'));
00734                                                 $this->editItemObject();
00735                                                 return false;
00736 
00737                                         default:
00738                                                 break;
00739                                 }
00740                         }
00741                 }
00742 
00743                 $this->object->initLinkResourceItemsObject();
00744 
00745                 $this->object->items_obj->readItem($_SESSION['webr_item_id']);
00746                 $this->object->items_obj->setLinkId($_SESSION['webr_item_id']);
00747                 $this->object->items_obj->setTitle(ilUtil::stripSlashes($_POST['title']));
00748                 $this->object->items_obj->setDescription(ilUtil::stripSlashes($_POST['description']));
00749                 $this->object->items_obj->setTarget(ilUtil::stripSlashes($_POST['target']));
00750                 $this->object->items_obj->setActiveStatus($_POST['active']);
00751                 $this->object->items_obj->setValidStatus($_POST['valid']);
00752                 $this->object->items_obj->setDisableCheckStatus($_POST['disable']);
00753                 $this->object->items_obj->update();
00754 
00755                 if(is_object($appender))
00756                 {
00757                         $appender->add($_SESSION['webr_item_id']);
00758                 }
00759 
00760                 unset($_SESSION['webr_item_id']);
00761                 ilUtil::sendInfo($this->lng->txt('webr_item_updated'));
00762                 $this->editItemsObject();
00763                 
00764                 return true;
00765         }
00766 
00767                 
00768 
00769         function showAddItemObject()
00770         {
00771                 global $rbacsystem;
00772 
00773                 $this->tabs_gui->setTabActive('edit_content');
00774 
00775                 // MINIMUM ACCESS LEVEL = 'read'
00776                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00777                 {
00778                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00779                 }
00780 
00781                 $title = $_POST['title'] ? ilUtil::prepareFormOutput($_POST['title'],true) : '';
00782                 $target = $_POST['target'] ? ilUtil::prepareFormOutput($_POST['target'],true) : 'http://';
00783 
00784 
00785                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.lnkr_add_item.html","Modules/WebResource");
00786 
00787                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00788                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt('webr_add_item'));
00789                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
00790                 $this->tpl->setVariable("TXT_DESC",$this->lng->txt('description'));
00791                 $this->tpl->setVariable("TXT_TARGET",$this->lng->txt('target'));
00792                 $this->tpl->setVariable("TARGET",$target);
00793                 $this->tpl->setVariable("TXT_ACTIVE",$this->lng->txt('active'));
00794                 $this->tpl->setVariable("TXT_CHECK",$this->lng->txt('webr_disable_check'));
00795                 $this->tpl->setVariable("TXT_REQUIRED_FLD",$this->lng->txt('required_field'));
00796                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00797                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt('add'));
00798                 $this->tpl->setVariable("CMD_SUBMIT",'addItem');
00799                 $this->tpl->setVariable("CMD_CANCEL",'editItems');
00800 
00801                 // Params
00802                 include_once('./Modules/WebResource/classes/class.ilParameterAppender.php');
00803 
00804                 if(ilParameterAppender::_isEnabled())
00805                 {
00806                         $this->tpl->setCurrentBlock("params");
00807                         $this->tpl->setVariable("TXT_DYNAMIC",$this->lng->txt('links_dynamic'));
00808                         $this->tpl->setVariable("TXT_NAME",$this->lng->txt('links_name'));
00809                         $this->tpl->setVariable("TXT_VALUE",$this->lng->txt('links_value'));
00810                         $this->tpl->setVariable("DYNAMIC_INFO",$this->lng->txt('links_dynamic_info'));
00811 
00812                         $this->tpl->setVariable("NAME",$_POST['name'] ? ilUtil::prepareFormOutput($_POST['name'],true) : '');
00813                         $this->tpl->setVariable("VAL_SEL",ilUtil::formSelect((int) $_POST['value'],
00814                                                                                                                                  'value',
00815                                                                                                                                  ilParameterAppender::_getOptionSelect(),
00816                                                                                                                                  false,
00817                                                                                                                                  true));
00818                         $this->tpl->parseCurrentBlock();
00819                 }
00820 
00821                 $this->tpl->setVariable("ACTIVE_CHECK",ilUtil::formCheckBox(1,'active',1));
00822                 $this->tpl->setVariable("CHECK_CHECK",ilUtil::formCheckBox(0,'disable_check',1));
00823         
00824         }
00825 
00826         function addItemObject()
00827         {
00828                 include_once('./Modules/WebResource/classes/class.ilParameterAppender.php');
00829 
00830                 global $rbacsystem;
00831 
00832                 // MINIMUM ACCESS LEVEL = 'read'
00833                 if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00834                 {
00835                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00836                 }
00837 
00838                 $this->object->initLinkResourceItemsObject();
00839 
00840                 if(!$_POST['title'] or $_POST['target'] == 'http://')
00841                 {
00842                         ilUtil::sendInfo($this->lng->txt('webr_fillout_all'));
00843 
00844                         $this->showAddItemObject();
00845                         return false;
00846                 }
00847                 if(ilParameterAppender::_isEnabled())
00848                 {
00849                         $appender =& new ilParameterAppender($this->object->getId());
00850                         $appender->setName(ilUtil::stripSlashes($_POST['name']));
00851                         $appender->setValue(ilUtil::stripSlashes($_POST['value']));
00852                         
00853                         if(!$appender->validate())
00854                         {
00855                                 switch($appender->getErrorCode())
00856                                 {
00857                                         case LINKS_ERR_NO_NAME:
00858                                                 ilUtil::sendInfo($this->lng->txt('links_no_name_given'));
00859                                                 $this->showAddItemObject();
00860                                                 return false;
00861 
00862                                         case LINKS_ERR_NO_VALUE:
00863                                                 ilUtil::sendInfo($this->lng->txt('links_no_name_given'));
00864                                                 $this->showAddItemObject();
00865                                                 return false;
00866 
00867                                         default:
00868                                                 break;
00869                                 }
00870                         }
00871                 }
00872                 $this->object->items_obj->setTitle(ilUtil::stripSlashes($_POST['title']));
00873                 $this->object->items_obj->setDescription(ilUtil::stripSlashes($_POST['description']));
00874                 $this->object->items_obj->setTarget(ilUtil::stripSlashes($_POST['target']));
00875                 $this->object->items_obj->setActiveStatus($_POST['active']);
00876                 $this->object->items_obj->setDisableCheckStatus($_POST['disable_check']);
00877                 $link_id = $this->object->items_obj->add();
00878 
00879                 if(is_object($appender))
00880                 {
00881                         $appender->add($link_id);
00882                 }
00883                 $this->editItemsObject();
00884         }
00885         
00891         function infoScreenObject()
00892         {
00893                 $this->ctrl->setCmd("showSummary");
00894                 $this->ctrl->setCmdClass("ilinfoscreengui");
00895                 $this->infoScreen();
00896         }
00897 
00901         function infoScreen()
00902         {
00903                 global $ilAccess;
00904 
00905                 if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
00906                 {
00907                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00908                 }
00909 
00910                 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
00911                 $info = new ilInfoScreenGUI($this);
00912                 
00913                 $info->enablePrivateNotes();
00914                 
00915                 // standard meta data
00916                 $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
00917                 
00918                 // forward the command
00919                 $this->ctrl->forwardCommand($info);
00920         }
00921 
00922 
00923         function historyObject()
00924         {
00925                 global $rbacsystem;
00926 
00927                 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
00928                 {
00929                         $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
00930                 }
00931 
00932                 include_once("classes/class.ilHistoryGUI.php");
00933                 
00934                 $hist_gui =& new ilHistoryGUI($this->object->getId());
00935                 
00936                 $hist_html = $hist_gui->getHistoryTable(array("ref_id" => $_GET["ref_id"], 
00937                                                                                                           "cmd" => "history",
00938                                                                                                           "cmdClass" =>$_GET["cmdClass"],
00939                                                                                                           "cmdNode" =>$_GET["cmdNode"]));
00940                 
00941                 $this->tpl->setVariable("ADM_CONTENT", $hist_html);
00942         }
00943 
00948         function saveObject()
00949         {
00950                 global $rbacadmin;
00951 
00952                 // create and insert forum in objecttree
00953                 $newObj = parent::saveObject();
00954 
00955                 // setup rolefolder & default local roles
00956                 //$roles = $newObj->initDefaultRoles();
00957 
00958                 // ...finally assign role to creator of object
00959                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
00960 
00961                 // put here object specific stuff
00962 
00963                 // always send a message
00964                 //ilUtil::sendInfo($this->lng->txt("object_added"),true);
00965                 ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=".$newObj->getRefId().
00966                         "&cmd=showAddItem");
00967                 
00968                 //ilUtil::redirect($this->getReturnLocation("save",'adm_object.php?ref_id='.$newObj->getRefId()));
00969         }
00970 
00971         
00972         function linkCheckerObject()
00973         {
00974                 global $ilias,$ilUser;
00975 
00976                 $this->__initLinkChecker();
00977                 $this->object->initLinkResourceItemsObject();
00978 
00979                 $invalid_links = $this->link_checker_obj->getInvalidLinksFromDB();
00980 
00981 
00982                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.link_check.html",'Modules/WebResource');
00983 
00984                 if($last_access = $this->link_checker_obj->getLastCheckTimestamp())
00985                 {
00986                         $this->tpl->setCurrentBlock("LAST_MODIFIED");
00987                         $this->tpl->setVariable("AS_OF",$this->lng->txt('last_change').": ");
00988                         $this->tpl->setVariable("LAST_CHECK",date('Y-m-d H:i:s',$last_access));
00989                         $this->tpl->parseCurrentBlock();
00990                 }
00991 
00992 
00993                 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
00994 
00995                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_webr.gif'));
00996                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_webr'));
00997                 $this->tpl->setVariable("TITLE",$this->object->getTitle().' ('.$this->lng->txt('link_check').')');
00998                 $this->tpl->setVariable("PAGE_TITLE",$this->lng->txt('title'));
00999                 $this->tpl->setVariable("URL",$this->lng->txt('url'));
01000                 $this->tpl->setVariable("OPTIONS",$this->lng->txt('edit'));
01001 
01002                 if(!count($invalid_links))
01003                 {
01004                         $this->tpl->setCurrentBlock("no_invalid");
01005                         $this->tpl->setVariable("TXT_NO_INVALID",$this->lng->txt('no_invalid_links'));
01006                         $this->tpl->parseCurrentBlock();
01007                 }
01008                 else
01009                 {
01010                         $counter = 0;
01011                         foreach($invalid_links as $invalid)
01012                         {
01013                                 $this->object->items_obj->readItem($invalid['page_id']);
01014 
01015                                 $this->tpl->setCurrentBlock("invalid_row");
01016                                 $this->tpl->setVariable("ROW_COLOR",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
01017                                 $this->tpl->setVariable("ROW_PAGE_TITLE",$this->object->items_obj->getTitle());
01018                                 $this->tpl->setVariable("ROW_URL",$invalid['url']);
01019 
01020 
01021                                 // EDIT IMAGE
01022                                 $this->ctrl->setParameter($this,'item_id',$invalid['page_id']);
01023                                 $this->tpl->setVariable("ROW_EDIT_LINK",$this->ctrl->getLinkTarget($this,'editItem'));
01024                                 $this->tpl->setVariable("ROW_IMG",ilUtil::getImagePath('icon_pencil.gif'));
01025                                 $this->tpl->setVariable("ROW_ALT_IMG",$this->lng->txt('edit'));
01026                                 $this->tpl->parseCurrentBlock();
01027                         }
01028                 }
01029                 if((bool) $ilias->getSetting('cron_web_resource_check'))
01030                 {
01031                         include_once './classes/class.ilLinkCheckNotify.php';
01032 
01033                         // Show message block
01034                         $this->tpl->setCurrentBlock("MESSAGE_BLOCK");
01035                         $this->tpl->setVariable("INFO_MESSAGE",$this->lng->txt('link_check_message_a'));
01036                         $this->tpl->setVariable("CHECK_MESSAGE",ilUtil::formCheckbox(
01037                                                                                 ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(),$this->object->getId()),
01038                                                                                 'link_check_message',
01039                                                                                 1));
01040                         $this->tpl->setVariable("INFO_MESSAGE_LONG",$this->lng->txt('link_check_message_b'));
01041                         $this->tpl->parseCurrentBlock();
01042 
01043                         // Show save button
01044                         $this->tpl->setCurrentBlock("CRON_ENABLED");
01045                         $this->tpl->setVariable("DOWNRIGHT_IMG",ilUtil::getImagePath('arrow_downright.gif'));
01046                         $this->tpl->setVariable("BTN_SUBMIT_LINK_CHECK",$this->lng->txt('save'));
01047                         $this->tpl->parseCurrentBlock();
01048                 }
01049                 $this->tpl->setVariable("BTN_REFRESH",$this->lng->txt('refresh'));
01050 
01051                 return true;
01052 
01053         }
01054         function saveLinkCheckObject()
01055         {
01056                 global $ilDB,$ilUser;
01057 
01058                 include_once './classes/class.ilLinkCheckNotify.php';
01059 
01060                 $link_check_notify =& new ilLinkCheckNotify($ilDB);
01061                 $link_check_notify->setUserId($ilUser->getId());
01062                 $link_check_notify->setObjId($this->object->getId());
01063 
01064                 if($_POST['link_check_message'])
01065                 {
01066                         ilUtil::sendInfo($this->lng->txt('link_check_message_enabled'));
01067                         $link_check_notify->addNotifier();
01068                 }
01069                 else
01070                 {
01071                         ilUtil::sendInfo($this->lng->txt('link_check_message_disabled'));
01072                         $link_check_notify->deleteNotifier();
01073                 }
01074                 $this->linkCheckerObject();
01075 
01076                 return true;
01077         }
01078                 
01079 
01080 
01081         function refreshLinkCheckObject()
01082         {
01083                 $this->__initLinkChecker();
01084 
01085                 if(!$this->link_checker_obj->checkPear())
01086                 {
01087                         ilUtil::sendInfo($this->lng->txt('missing_pear_library'));
01088                         $this->linkCheckerObject();
01089 
01090                         return false;
01091                 }
01092 
01093 
01094                 $this->object->initLinkResourceItemsObject();
01095 
01096                 // Set all link to valid. After check invalid links will be set to invalid
01097                 $this->object->items_obj->updateValidByCheck();
01098                 
01099                 foreach($this->link_checker_obj->checkWebResourceLinks() as $invalid)
01100                 {
01101                         $this->object->items_obj->readItem($invalid['page_id']);
01102                         $this->object->items_obj->setActiveStatus(false);
01103                         $this->object->items_obj->setValidStatus(false);
01104                         $this->object->items_obj->update(false);
01105                 }
01106                 
01107                 $this->object->items_obj->updateLastCheck();
01108                 ilUtil::sendInfo($this->lng->txt('link_checker_refreshed'));
01109 
01110                 $this->linkCheckerObject();
01111 
01112                 return true;
01113         }
01114 
01115         function __initLinkChecker()
01116         {
01117                 global $ilDB;
01118 
01119                 include_once './classes/class.ilLinkChecker.php';
01120 
01121                 $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
01122                 $this->link_checker_obj->setObjId($this->object->getId());
01123 
01124                 return true;
01125         }
01131         function getTabs(&$tabs_gui)
01132         {
01133                 global $rbacsystem,$rbacreview,$ilAccess;
01134 
01135                 if ($ilAccess->checkAccess('read','',$this->object->getRefId()))
01136                 {
01137                         $tabs_gui->addTarget("view_content",
01138                                 $this->ctrl->getLinkTarget($this, "view"), array("", "view"),
01139                                 array(strtolower(get_class($this)), ""));
01140                 }
01141 
01142                 if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
01143                 {
01144                         $tabs_gui->addTarget("edit_content",
01145                                 $this->ctrl->getLinkTarget($this, "editItems"),
01146                                 array("editItems", "addItem", "deleteItems", "editItem", "updateItem"),
01147                                 "");
01148                 }
01149                 
01150                 if ($ilAccess->checkAccess('visible','',$this->ref_id))
01151                 {
01152                         // this is not nice. tabs should be displayed in ilcoursegui
01153                         // not via ilrepositorygui, then next_class == ilinfoscreengui
01154                         // could be checked
01155                         $force_active = (strtolower($_GET["cmdClass"]) == "ilinfoscreengui"
01156                                 || $_GET["cmd"] == "infoScreen"
01157                                 || strtolower($_GET["cmdClass"]) == "ilnotegui")
01158                                 ? true
01159                                 : false;
01160                         $tabs_gui->addTarget("info_short",
01161                                                                  $this->ctrl->getLinkTargetByClass(
01162                                                                  array("ilobjlinkresourcegui", "ilinfoscreengui"), "showSummary"),
01163                                                                  "infoScreen",
01164                                                                  "", "", $force_active);
01165                 }
01166 
01167                 if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
01168                 {
01169                         $tabs_gui->addTarget("meta_data",
01170                                  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
01171                                  "", 'ilmdeditorgui');
01172                 }
01173 
01174                 if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
01175                 {
01176                         $tabs_gui->addTarget("history",
01177                                 $this->ctrl->getLinkTarget($this, "history"), "history", get_class($this));
01178                 }
01179 
01180                 if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
01181                 {
01182                         // Check if pear library is available
01183                         if(@include_once('HTTP/Request.php'))
01184                         {
01185                                 $tabs_gui->addTarget("link_check",
01186                                                                          $this->ctrl->getLinkTarget($this, "linkChecker"),
01187                                                                          array("linkChecker", "refreshLinkCheck"), get_class($this));
01188                         }
01189                 }
01190 
01191                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
01192                 {
01193                         $tabs_gui->addTarget("perm_settings",
01194                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01195                 }
01196         }
01197 
01198         // PRIVATE
01199         function __prepareOutput()
01200         {
01201                 // output objects
01202                 //$this->tpl->addBlockFile("CONTENT", "content", "tpl.link_resource.html",'link');
01203                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01204                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01205 
01206                 // output locator
01207                 $this->__setLocator();
01208 
01209                 // output message
01210                 if ($this->message)
01211                 {
01212                         ilUtil::sendInfo($this->message);
01213                 }
01214 
01215                 // display infopanel if something happened
01216                 ilUtil::infoPanel();
01217 
01218                 // set header
01219                 $this->__setHeader();
01220         }
01221 
01222         function __setHeader()
01223         {
01224                 include_once './classes/class.ilTabsGUI.php';
01225 
01226                 $this->tpl->setCurrentBlock("header_image");
01227                 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_webr_b.gif"));
01228                 $this->tpl->parseCurrentBlock();
01229                 $this->tpl->setVariable("HEADER",$this->object->getTitle());
01230                 $this->tpl->setVariable("H_DESCRIPTION",$this->object->getDescription());
01231 
01232                 #$tabs_gui =& new ilTabsGUI();
01233                 $this->getTabs($this->tabs_gui);
01234 
01235                 // output tabs
01236                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
01237         }
01238 
01239         function __setLocator()
01240         {
01241                 global $tree;
01242                 global $ilias_locator, $lng;
01243 
01244                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
01245 
01246                 $counter = 0;
01247                 
01248                 //$this->tpl->touchBlock('locator_separator');
01249                 //$this->tpl->touchBlock('locator_item');
01250                 
01251                 foreach ($tree->getPathFull($this->object->getRefId()) as $key => $row)
01252                 {
01253                         
01254                         //if ($row["child"] == $tree->getRootId())
01255                         //{
01256                         //      continue;
01257                         //}
01258                         
01259                         if($counter++)
01260                         {
01261                                 $this->tpl->touchBlock('locator_separator_prefix');
01262                         }
01263 
01264                         if ($row["child"] > 0)
01265                         {
01266                                 $this->tpl->setCurrentBlock("locator_img");
01267                                 $this->tpl->setVariable("IMG_SRC",
01268                                         ilUtil::getImagePath("icon_".$row["type"]."_s.gif"));
01269                                 $this->tpl->setVariable("IMG_ALT",
01270                                         $lng->txt("obj_".$type));
01271                                 $this->tpl->parseCurrentBlock();
01272                         }
01273 
01274                         $this->tpl->setCurrentBlock("locator_item");
01275 
01276                         if($row["type"] == 'webr')
01277                         {
01278                                 $this->tpl->setVariable("ITEM",$this->object->getTitle());
01279                                 $this->tpl->setVariable("LINK_ITEM",$this->ctrl->getLinkTarget($this));
01280                         }
01281                         elseif ($row["child"] != $tree->getRootId())
01282                         {
01283                                 $this->tpl->setVariable("ITEM", $row["title"]);
01284                                 $this->tpl->setVariable("LINK_ITEM","./repository.php?ref_id=".$row["child"]);
01285                         }
01286                         else
01287                         {
01288                                 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
01289                                 $this->tpl->setVariable("LINK_ITEM","./repository.php?ref_id=".$row["child"]);
01290                         }
01291 
01292                         $this->tpl->parseCurrentBlock();
01293                 }
01294 
01295                 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
01296                 $this->tpl->parseCurrentBlock();
01297         }
01298 
01299         function _goto($a_target)
01300         {
01301                 global $ilAccess, $ilErr, $lng;
01302 
01303                 // Will be replaced in future releases by ilAccess::checkAccess()
01304                 if ($ilAccess->checkAccess("read", "", $a_target))
01305                 {
01306                         ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=$a_target");
01307                 }
01308                 else
01309                 {
01310                         // to do: force flat view
01311                         if ($ilAccess->checkAccess("visible", "", $a_target))
01312                         {
01313                                 ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=".$a_target."&cmd=infoScreen");
01314                         }
01315                         else
01316                         {
01317                                 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
01318                                 {
01319                                         $_GET["cmd"] = "frameset";
01320                                         $_GET["target"] = "";
01321                                         $_GET["ref_id"] = ROOT_FOLDER_ID;
01322                                         ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
01323                                                 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
01324                                         include("repository.php");
01325                                         exit;
01326                                 }
01327                         }
01328                 }
01329 
01330                 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
01331         }
01332 
01333 
01334 } // END class.ilObjLinkResource
01335 ?>

Generated on Fri Dec 13 2013 17:56:54 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1