ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSAHSLearningModuleAccess.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("classes/class.ilObjectAccess.php");
25 
36 {
49  function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
50  {
51  global $ilUser, $lng, $rbacsystem, $ilAccess;
52 
53  if ($a_user_id == "")
54  {
55  $a_user_id = $ilUser->getId();
56  }
57 
58  switch ($a_cmd)
59  {
60  case "view":
61 
63  && !$rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id))
64  {
65  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
66  return false;
67  }
68  break;
69  }
70 
71  switch ($a_permission)
72  {
73  case "visible":
75  (!$rbacsystem->checkAccessOfUser($a_user_id,'write', $a_ref_id)))
76  {
77  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
78  return false;
79  }
80  break;
81  }
82 
83 
84  return true;
85  }
86 
99  function _getCommands()
100  {
101  $commands = array
102  (
103  array("permission" => "read", "cmd" => "view", "lang_var" => "show",
104  "default" => true),
105  array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
106  );
107 
108  return $commands;
109  }
110 
111  //
112  // access relevant methods
113  //
114 
118  function _lookupOnline($a_id)
119  {
120  global $ilDB;
121 
122  $set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s',
123  array('integer'), array($a_id));
124  $rec = $ilDB->fetchAssoc($set);
125 
126  return ilUtil::yn2tf($rec["c_online"]);
127  }
128 
132  static function _lookupEditable($a_obj_id)
133  {
134  global $ilDB;
135 
136  $set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s',
137  array('integer'), array($a_obj_id));
138  $rec = $ilDB->fetchAssoc($set);
139 
140  return $rec["editable"];
141  }
142 
143 
147  function _checkGoto($a_target)
148  {
149  global $ilAccess;
150 
151  $t_arr = explode("_", $a_target);
152 
153  if ($t_arr[0] != "sahs" || ((int) $t_arr[1]) <= 0)
154  {
155  return false;
156  }
157 
158  if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
159  {
160  return true;
161  }
162  return false;
163  }
164 
170  function _lookupDiskUsage($a_id)
171  {
172  $lm_data_dir = ilUtil::getWebspaceDir('filesystem')."/lm_data";
173  $lm_dir = $lm_data_dir.DIRECTORY_SEPARATOR."lm_".$a_id;
174 
175  return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
176 
177  }
178 
184  public static function _lookupCertificate($a_id)
185  {
186  $certificatefile = CLIENT_WEB_DIR . "/certificates/scorm/" . $a_id . "/certificate.xml";
187  if (@file_exists($certificatefile))
188  {
189  return (ilSetting::_lookupValue('scorm', 'certificate_'.$a_id) == 1) ? true : false;
190  }
191  else
192  {
193  return false;
194  }
195  }
196 
203  public static function _lookupUserCertificate($obj_id, $usr_id = 0)
204  {
205  global $ilUser;
206  $uid = ($usr_id) ? $usr_id : $ilUser->getId();
207 
208  $completed = false;
209  // check for certificates
211  {
212  $lpdata = false;
213  include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
215  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
217  {
218  include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
219  $completed_user_ids_array = ilLPStatusWrapper::_getCompleted($obj_id);
220  if (in_array($uid, $completed_user_ids_array))
221  {
222  $completed = true;
223  }
224  $lpdata = true;
225  }
226  switch ($type)
227  {
228  case "scorm":
229  if (!$lpdata)
230  {
231  include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
232  $completed = ilObjSCORMLearningModule::_getCourseCompletionForUser($obj_id, $uid);
233  }
234  break;
235  case "scorm2004":
236  if (!$lpdata)
237  {
238  include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
240  }
241  break;
242  default:
243  break;
244  }
245  }
246  return $completed;
247  }
248 
257  static function _isOffline($a_obj_id)
258  {
259  return !self::_lookupOnline($a_obj_id);
260  }
261 }
262 
263 ?>