ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGlossaryAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 include_once("./Services/Object/classes/class.ilObjectAccess.php");
7 
18 {
32  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
33  {
34  global $ilUser, $lng, $rbacsystem, $ilAccess;
35 
36  if ($a_user_id == "")
37  {
38  $a_user_id = $ilUser->getId();
39  }
40 
41  switch ($a_permission)
42  {
43  case "read":
45  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
46  {
47  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
48  return false;
49  }
50  break;
51 
52  case "visible":
53  if (!ilObjGlossaryAccess::_lookupOnline($a_obj_id) &&
54  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
55  {
56  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
57  return false;
58  }
59  break;
60  }
61 
62 
63  return true;
64  }
65 
78  function _getCommands()
79  {
80  $commands = array
81  (
82  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
83  "default" => true),
84  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit_content"),
85  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings")
86  );
87 
88  return $commands;
89  }
90 
91  //
92  // access relevant methods
93  //
94 
98  function _lookupOnline($a_id)
99  {
100  global $ilDB;
101 
102  $q = "SELECT * FROM glossary WHERE id = ".
103  $ilDB->quote($a_id, "integer");
104  $lm_set = $ilDB->query($q);
105  $lm_rec = $ilDB->fetchAssoc($lm_set);
106 
107  return ilUtil::yn2tf($lm_rec["is_online"]);
108  }
109 
113  function _checkGoto($a_target)
114  {
115  global $ilAccess;
116 
117  $t_arr = explode("_", $a_target);
118 
119  if (($t_arr[0] != "glo" && $t_arr[0] != "git") || ((int) $t_arr[1]) <= 0)
120  {
121  return false;
122  }
123 
124  if ($t_arr[0] == "glo")
125  {
126  if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
127  $ilAccess->checkAccess("visible", "", $t_arr[1]))
128  {
129  return true;
130  }
131  }
132 
133  if ($t_arr[0] == "git")
134  {
135  if ($t_arr[2] > 0)
136  {
137  $ref_ids = array($t_arr[2]);
138  }
139  else
140  {
141  // determine learning object
142  require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
143  $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]);
144  $ref_ids = ilObject::_getAllReferences($glo_id);
145  }
146  // check read permissions
147  foreach ($ref_ids as $ref_id)
148  {
149  // Permission check
150  if ($ilAccess->checkAccess("read", "", $ref_id))
151  {
152  return true;
153  }
154  }
155  }
156 
157  return false;
158  }
159 
160 
161 }
162 
163 ?>