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

content/classes/class.ilObjGlossaryAccess.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.ilObjectAccess.php");
00025 
00035 class ilObjGlossaryAccess extends ilObjectAccess
00036 {
00050         function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
00051         {
00052                 global $ilUser, $lng, $rbacsystem, $ilAccess;
00053 
00054                 if ($a_user_id == "")
00055                 {
00056                         $a_user_id = $ilUser->getId();
00057                 }
00058 
00059                 switch ($a_cmd)
00060                 {
00061                         case "view":
00062 
00063                                 if(!ilObjGlossaryAccess::_lookupOnline($a_obj_id)
00064                                         && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
00065                                 {
00066                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00067                                         return false;
00068                                 }
00069                                 break;
00070                 }
00071 
00072                 switch ($a_permission)
00073                 {
00074                         case "visible":
00075                                 if (!ilObjGlossaryAccess::_lookupOnline($a_obj_id) &&
00076                                         (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
00077                                 {
00078                                         $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
00079                                         return false;
00080                                 }
00081                                 break;
00082                 }
00083 
00084 
00085                 return true;
00086         }
00087         
00100         function _getCommands()
00101         {
00102                 $commands = array
00103                 (
00104                         array("permission" => "read", "cmd" => "view", "lang_var" => "show",
00105                                 "default" => true),
00106                         array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
00107                 );
00108                 
00109                 return $commands;
00110         }
00111 
00112         //
00113         // access relevant methods
00114         //
00115 
00119         function _lookupOnline($a_id)
00120         {
00121                 global $ilDB;
00122 
00123                 $q = "SELECT * FROM glossary WHERE id = '".$a_id."'";
00124                 $lm_set = $ilDB->query($q);
00125                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00126 
00127                 return ilUtil::yn2tf($lm_rec["online"]);
00128         }
00129 
00133         function _checkGoto($a_target)
00134         {
00135                 global $ilAccess;
00136                 
00137                 $t_arr = explode("_", $a_target);
00138 
00139                 if (($t_arr[0] != "glo" && $t_arr[0] != "git") || ((int) $t_arr[1]) <= 0)
00140                 {
00141                         return false;
00142                 }
00143 
00144                 if ($t_arr[0] == "glo")
00145                 {
00146                         if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
00147                                 $ilAccess->checkAccess("visible", "", $t_arr[1]))
00148                         {
00149                                 return true;
00150                         }
00151                 }
00152 
00153                 if ($t_arr[0] == "git")
00154                 {
00155                         if ($t_arr[2] > 0)
00156                         {
00157                                 $ref_ids = array($t_arr[2]);
00158                         }
00159                         else
00160                         {
00161                                 // determine learning object
00162                                 include_once("content/classes/class.ilGlossaryTerm.php");
00163                                 $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]);
00164                                 $ref_ids = ilObject::_getAllReferences($glo_id);
00165                         }
00166                         // check read permissions
00167                         foreach ($ref_ids as $ref_id)
00168                         {
00169                                 // Permission check
00170                                 if ($ilAccess->checkAccess("read", "", $ref_id))
00171                                 {
00172                                         return true;
00173                                 }
00174                         }
00175                 }
00176 
00177                 return false;
00178         }
00179 
00180 
00181 }
00182 
00183 ?>

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