Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
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
00167 foreach ($ref_ids as $ref_id)
00168 {
00169
00170 if ($ilAccess->checkAccess("read", "", $ref_id))
00171 {
00172 return true;
00173 }
00174 }
00175 }
00176
00177 return false;
00178 }
00179
00180
00181 }
00182
00183 ?>