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

classes/class.ilRepositoryExplorer.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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 /*
00025 * Repository Explorer
00026 *
00027 * @author Alex Killing <alex.killing@gmx.de>
00028 * @version $Id: class.ilRepositoryExplorer.php 12360 2006-10-25 12:24:58Z smeyer $
00029 *
00030 * @package core
00031 */
00032 
00033 require_once("classes/class.ilExplorer.php");
00034 
00035 class ilRepositoryExplorer extends ilExplorer
00036 {
00037 
00043         var $root_id;
00044         var $output;
00045         var $ctrl;
00052         function ilRepositoryExplorer($a_target)
00053         {
00054                 global $tree,$ilCtrl;
00055 
00056                 $this->ctrl = $ilCtrl;
00057 
00058                 parent::ilExplorer($a_target);
00059                 $this->tree = $tree;
00060                 $this->root_id = $this->tree->readRootId();
00061                 $this->order_column = "title";
00062                 $this->setSessionExpandVariable("repexpand");
00063 
00064                 // please do not uncomment this
00065                 $this->addFilter("root");
00066                 $this->addFilter("cat");
00067                 //$this->addFilter("exc");
00068                 //$this->addFilter("sahs");
00069                 $this->addFilter("grp");
00070                 //$this->addFilter("lm");
00071                 //$this->addFilter("htlm");
00072                 //$this->addFilter("mep");
00073                 //$this->addFilter("frm");
00074                 //$this->addFilter("dbk");
00075                 //$this->addFilter("chat");
00076                 //$this->addFilter("glo");
00077                 //$this->addFilter("file");
00078                 $this->addFilter("icrs");
00079                 $this->addFilter("crs");
00080                 //$this->addFilter('tst');
00081                 $this->setFiltered(true);
00082                 $this->setFilterMode(IL_FM_POSITIVE);
00083         }
00084 
00088         function buildLinkTarget($a_node_id, $a_type)
00089         {
00090                 global $ilCtrl;
00091 
00092                 switch($a_type)
00093                 {
00094                         case "cat":
00095                                 return "repository.php?ref_id=".$a_node_id;
00096 
00097                         case "lm":
00098                         case "dbk":
00099                                 return "ilias.php?baseClass=ilLMPresentationGUI&ref_id=".$a_node_id;
00100 
00101                         case "htlm":
00102                                 return "content/fblm_presentation.php?ref_id=".$a_node_id;
00103 
00104                         case "sahs":
00105                                 return "ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=".$a_node_id;
00106 
00107                         case "mep":
00108                                 return "";
00109 
00110                         case "grp":
00111                                 return "repository.php?ref_id=".$a_node_id."&cmdClass=ilobjgroupgui";
00112 
00113                         case "crs":
00114                                 return "repository.php?ref_id=".$a_node_id."&cmdClass=ilobjcoursegui&cmd=view";
00115                                 
00116                         case "frm":
00117                                 return "repository.php?ref_id=".$a_node_id."&cmdClass=ilobjforumgui";
00118 
00119                         case "glo":
00120                                 return "ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=".$a_node_id;
00121 
00122                         case "exc":
00123                                 return "exercise.php?cmd=view&ref_id=".$a_node_id;
00124 
00125                         case "chat":
00126                                 return "chat.php?cmd=view&ref_id=".$a_node_id;
00127 
00128                         case "fold":
00129                                 return "repository.php?ref_id=".$a_node_id."&cmdClass=ilobjfoldergui";
00130                                 
00131                         case "file":
00132                                 return "repository.php?cmd=sendfile&ref_id=".$a_node_id;
00133 
00134                         case 'tst':
00135                                 return "ilias.php?cmd=infoScreen&baseClass=ilObjTestGUI&ref_id=".$a_node_id;
00136 
00137                         case 'svy':
00138                                 return "ilias.php?baseClass=ilObjSurveyGUI&cmd=run&ref_id=".$a_node_id;
00139 
00140                         case 'spl':
00141                                 return "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".$a_node_id;
00142 
00143                         case 'qpl':
00144                                 return "ilias.php?baseClass=ilObjQuestionPoolGUI&cmd=questions&ref_id=".$a_node_id;
00145 
00146                         case 'crsg':
00147                                 return "repository.php?ref_id=".$a_node_id;
00148 
00149                         case 'webr':
00150                                 return "./link/link_resources.php?ref_id=".$a_node_id;
00151                                 
00152                         case "icrs":
00153                                 return "repository.php?ref_id=".$a_node_id."&cmdClass=ilobjilinccoursegui";
00154                 }
00155         }
00156         
00161         function buildEditLinkTarget($a_node_id, $a_type)
00162         {
00163                 global $ilCtrl;
00164 
00165                 switch($a_type)
00166                 {
00167                         case "cat":
00168                                 return "repository.php?cmd=edit&ref_id=".$a_node_id;
00169 
00170                         case "lm":
00171                         case "dbk":
00172                                 return "content/lm_edit.php?ref_id=".$a_node_id;
00173 
00174                         case "htlm":
00175                                 return "content/fblm_edit.php?ref_id=".$a_node_id;
00176 
00177                         case "sahs":
00178                                 return "content/sahs_edit.php?ref_id=".$a_node_id;
00179 
00180                         case "mep":
00181                                 return "content/mep_edit.php?ref_id=".$a_node_id;
00182 
00183                         case "grp":
00184                                 return; // following link is the same as "read" link
00185                                 return "repository.php?ref_id=".$a_node_id."&cmdClass=ilobjgroupgui";
00186 
00187                         case "crs":
00188                                 return "repository.php?ref_id=".$a_node_id."&cmdClass=ilobjcoursegui&cmd=edit";
00189                                 return "ilias.php?ref_id=".$a_node_id."cmdClass=ilobjcoursegui&cmd=edit";
00190                                 
00191                         case "frm":
00192                                 return "repository.php?cmd=edit&ref_id=".$a_node_id;
00193 
00194                         case "glo":
00195                                 return "ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$a_node_id;
00196 
00197                         case "exc":
00198                                 return "exercise.php?cmd=view&ref_id=".$a_node_id;
00199 
00200                         case "chat":
00201                                 return "chat.php?cmd=view&ref_id=".$a_node_id;
00202 
00203                         case "fold":
00204                                 return "repository.php?cmd=edit&ref_id=".$a_node_id;
00205                                 
00206                         case "file":
00207                                 return "repository.php?cmd=edit&cmdClass=ilobjfilegui&ref_id=".$a_node_id;
00208 
00209                         case 'tst':
00210                                 return "ilias.php?baseClass=ilObjTestGUI&ref_id=".$a_node_id;
00211                                 #return "assessment/test.php?ref_id=".$a_node_id;
00212                                 
00213                         case 'svy':
00214                                 return "survey/survey.php?ref_id=".$a_node_id;
00215                                 
00216                         case 'qpl':
00217                                 return "assessment/questionpool.php?ref_id=".$a_node_id
00218                                         ."&cmd=questions";
00219                                         
00220                         case 'spl':
00221                                 return "survey/questionpool.php?ref_id=".$a_node_id
00222                                         ."&cmd=questions";
00223 
00224                         case 'svy':
00225                                 return "survey/survey.php?ref_id=".$a_node_id;
00226 
00227                         case 'crsg':
00228                                 return "repository.php?cmd=edit&ref_id=".$a_node_id;
00229 
00230                         case 'webr':
00231                                 return "./link/link_resources.php?cmd=editItems&ref_id=".$a_node_id;
00232                 }
00233         }               
00234 
00241         function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
00242         {
00243                 global $ilias;
00244                 
00245                 
00246                 
00247                 switch($a_type)
00248                 {
00249                         case "cat":
00250                                 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "cat");
00251                                 return $t_frame;
00252 
00253                         case "lm":
00254                         case "dbk":
00255                         case "htlm":
00256                         case "sahs":
00257                                 // Determine whether the view of a learning resource should
00258                                 // be shown in the frameset of ilias, or in a separate window.
00259                                 //$showViewInFrameset = $ilias->ini->readVariable("layout","view_target") == "frame";
00260                                 $showViewInFrameset = true;
00261 
00262                                 if ($showViewInFrameset) 
00263                                 {
00264                                         return ilFrameTargetInfo::_getFrame("MainContent");
00265                                         //return "bottom";
00266                                 }
00267                                 else
00268                                 {
00269                                         return "ilContObj".$a_obj_id;
00270                                 }
00271 
00272                         case "grp":
00273                                 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grp");
00274                                 return $t_frame;
00275 
00276                         case "crs":
00277                                 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crs");
00278                                 return $t_frame;
00279 
00280                         case "frm":
00281                                 return "";
00282 
00283                         case "glo":
00284                                 return "";
00285 
00286                         case "tst":
00287                                 //$showViewInFrameset = $ilias->ini->readVariable("layout","view_target") == "frame";
00288                                 $showViewInFrameset = true;
00289                                 if ($showViewInFrameset) 
00290                                 {
00291                                         return ilFrameTargetInfo::_getFrame("MainContent");
00292                                         //return "bottom";
00293                                 }
00294                                 else
00295                                 {
00296                                         return "ilTest".$a_obj_id;
00297                                 }
00298                                 break;
00299 
00300                         case "icrs":
00301                                 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "icrs");
00302                                 return $t_frame;
00303 
00304                         default:
00305                                 return "";
00306                 }
00307         }
00308         
00312         function getImage($a_name, $a_type = "", $a_obj_id = "")
00313         {
00314                 if ($a_type != "")
00315                 {
00316                         // custom icons
00317                         if ($this->ilias->getSetting("custom_icons") &&
00318                                 in_array($a_type, array("cat","grp","crs")))
00319                         {
00320                                 require_once("classes/class.ilContainer.php");
00321                                 if (($path = ilContainer::_lookupIconPath($a_obj_id, "small")) != "")
00322                                 {
00323                                         return $path;
00324                                 }
00325                         }
00326                 }
00327                 
00328                 return parent::getImage($a_name);
00329         }
00330 
00331         function isClickable($a_type, $a_ref_id,$a_obj_id = 0)
00332         {
00333                 global $rbacsystem,$tree,$ilDB,$ilUser;
00334 
00335                 if(!ilConditionHandler::_checkAllConditionsOfTarget($a_obj_id))
00336                 {
00337                         return false;
00338                 }
00339 
00340                 switch ($a_type)
00341                 {
00342                         case "crs":
00343                                 include_once './course/classes/class.ilObjCourse.php';
00344 
00345                                 // Has to be replaced by ilAccess calls
00346                                 if(!ilObjCourse::_isActivated($a_obj_id) and !$rbacsystem->checkAccess('write',$a_ref_id))
00347                                 {
00348                                         return false;
00349                                 }
00350                                 
00351                                 include_once './course/classes/class.ilCourseMembers.php';
00352 
00353                                 if(ilCourseMembers::_isBlocked($a_obj_id,$ilUser->getId()))
00354                                 {
00355                                         return false;
00356                                 }
00357                                 if(($rbacsystem->checkAccess('join',$a_ref_id) or
00358                                         $rbacsystem->checkAccess('read',$a_ref_id)))
00359                                 {
00360                                         return true;
00361                                 }
00362                                 return false;
00363 
00364                         // visible groups can allways be clicked; group processing decides
00365                         // what happens next
00366                         case "grp":
00367                                 return true;
00368                                 break;
00369 
00370                         case 'tst':
00371                                 if(!$rbacsystem->checkAccess("read", $a_ref_id))
00372                                 {
00373                                         return false;
00374                                 }
00375 
00376                                 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s",$a_obj_id);
00377                                 $res = $ilDB->query($query);
00378                                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00379                                 {
00380                                         return (bool) $row->complete;
00381                                 }
00382                                 return false;
00383 
00384                         case 'svy':
00385                                 if(!$rbacsystem->checkAccess("read", $a_ref_id))
00386                                 {
00387                                         return false;
00388                                 }
00389 
00390                                 $query = sprintf("SELECT * FROM survey_survey WHERE obj_fi=%s",$a_obj_id);
00391                                 $res = $ilDB->query($query);
00392                                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00393                                 {
00394                                         return (bool) $row->complete;
00395                                 }
00396                                 return false;
00397 
00398                         // media pools can only be edited
00399                         case "mep":
00400                                 if ($rbacsystem->checkAccess("read", $a_ref_id))
00401                                 {
00402                                         return true;
00403                                 }
00404                                 else
00405                                 {
00406                                         return false;
00407                                 }
00408                                 break;
00409 
00410                         // all other types are only clickable, if read permission is given
00411                         default:
00412                                 if ($rbacsystem->checkAccess("read", $a_ref_id))
00413                                 {
00414                                         // check if lm is online
00415                                         if ($a_type == "lm")
00416                                         {
00417                                                 include_once("content/classes/class.ilObjLearningModule.php");
00418                                                 $lm_obj =& new ilObjLearningModule($a_ref_id);
00419                                                 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
00420                                                 {
00421                                                         return false;
00422                                                 }
00423                                         }
00424                                         // check if fblm is online
00425                                         if ($a_type == "htlm")
00426                                         {
00427                                                 include_once("content/classes/class.ilObjFileBasedLM.php");
00428                                                 $lm_obj =& new ilObjFileBasedLM($a_ref_id);
00429                                                 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
00430                                                 {
00431                                                         return false;
00432                                                 }
00433                                         }
00434                                         // check if fblm is online
00435                                         if ($a_type == "sahs")
00436                                         {
00437                                                 include_once("content/classes/class.ilObjSAHSLearningModule.php");
00438                                                 $lm_obj =& new ilObjSAHSLearningModule($a_ref_id);
00439                                                 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
00440                                                 {
00441                                                         return false;
00442                                                 }
00443                                         }
00444                                         // check if glossary is online
00445                                         if ($a_type == "glo")
00446                                         {
00447                                                 $obj_id = ilObject::_lookupObjectId($a_ref_id);
00448                                                 include_once("content/classes/class.ilObjGlossary.php");
00449                                                 if((!ilObjGlossary::_lookupOnline($obj_id)) &&
00450                                                         (!$rbacsystem->checkAccess('write',$a_ref_id)))
00451                                                 {
00452                                                         return false;
00453                                                 }
00454                                         }
00455 
00456                                         return true;
00457                                 }
00458                                 else
00459                                 {
00460                                         return false;
00461                                 }
00462                                 break;
00463                 }
00464         }
00465 
00466         function showChilds($a_ref_id,$a_obj_id = 0)
00467         {
00468                 global $rbacsystem,$tree;
00469 //vd($a_ref_id);
00470 
00471                 if ($a_ref_id == 0)
00472                 {
00473                         return true;
00474                 }
00475                 if(!ilConditionHandler::_checkAllConditionsOfTarget($a_obj_id))
00476                 {
00477                         return false;
00478                 }
00479                 if ($rbacsystem->checkAccess("read", $a_ref_id))
00480                 {
00481                         return true;
00482                 }
00483                 else
00484                 {
00485                         return false;
00486                 }
00487         }
00488 
00489         function isVisible($a_ref_id,$a_type)
00490         {
00491                 global $rbacsystem,$tree;
00492 
00493                 if(!$rbacsystem->checkAccess('visible',$a_ref_id))
00494                 {
00495                         return false;
00496                 }
00497                 if($crs_id = $tree->checkForParentType($a_ref_id,'crs'))
00498                 {
00499                         if(!$rbacsystem->checkAccess('write',$crs_id))
00500                         {
00501                                 // Show only activated courses
00502                                 $tmp_obj =& ilObjectFactory::getInstanceByRefId($crs_id,false);
00503 
00504                                 if(!$tmp_obj->isActivated())
00505                                 {
00506                                         unset($tmp_obj);
00507                                         return false;
00508                                 }
00509                                 if(($crs_id != $a_ref_id) and $tmp_obj->isArchived())
00510                                 {
00511                                         return false;
00512                                 }
00513                                 // Show only activated course items
00514                                 include_once "./course/classes/class.ilCourseItems.php";
00515 
00516                                 if(($crs_id != $a_ref_id) and (!ilCourseItems::_isActivated($a_ref_id)))
00517                                 {
00518                                         return false;
00519                                 }
00520                         }
00521                 }
00522                 return true;
00523         }
00524 
00525 
00526 
00534         function formatHeader(&$tpl, $a_obj_id,$a_option)
00535         {
00536                 global $lng, $ilias;
00537 
00538                 $tpl->setCurrentBlock("icon");
00539                 $tpl->setVariable("ICON_IMAGE", ilUtil::getImagePath("icon_root.gif"));
00540                 $tpl->setVariable("TXT_ALT_IMG", $lng->txt("repository"));
00541                 $tpl->parseCurrentBlock();
00542 
00543                 $tpl->setCurrentBlock("link");
00544                 $tpl->setVariable("TITLE", $lng->txt("repository"));
00545                 $tpl->setVariable("LINK_TARGET", "repository.php?ref_id=1");
00546                 $tpl->setVariable("TARGET", " target=\"rep_content\"");
00547                 $tpl->parseCurrentBlock();
00548 
00549                 $tpl->setCurrentBlock("element");
00550                 $tpl->parseCurrentBlock();
00551         }
00552 
00553 } // END class ilRepositoryExplorer
00554 ?>

Generated on Fri Dec 13 2013 13:52:08 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1