ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilLicenseAccess.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 
20  public static function _isEnabled() {
21  static $enabled;
22 
23  if (isset($enabled)) {
24  return $enabled;
25  }
26 
27  $lic_set = new ilSetting("license");
28  if ($lic_set->get("license_counter")) {
29  $enabled = true;
30 
31  return true;
32  } else {
33  $enabled = false;
34 
35  return false;
36  }
37  }
38 
39 
52  public static function _checkAccess($a_usr_id, $a_obj_id) {
53  global $ilDB;
54 
55  // check the object license
56  $query = 'SELECT licenses, used FROM license_data WHERE obj_id = %s';
57  $result = $ilDB->queryF($query, array( 'integer' ), array( $a_obj_id ));
58 
59  if ($row = $ilDB->fetchObject($result)) {
60  // no licenses set or at least one free => grant access
61  if ($row->licenses == 0 or $row->used < $row->licenses) {
62  return true;
63  }
64  } else {
65  // no license data available => access granted
66  return true;
67  }
68 
69  // check if user has already accessed
70  $query = 'SELECT read_count FROM read_event ' . 'WHERE usr_id = %s AND obj_id = %s';
71 
72  $result = $ilDB->queryF($query, array( 'integer', 'integer' ), array( $a_usr_id, $a_obj_id ));
73 
74  if ($row = $ilDB->fetchObject($result)) {
75  return true;
76  }
77 
78  // all failed
79  return false;
80  }
81 }
ILIAS Setting Class.
$result
static _isEnabled()
Check, if licencing is enabled This check is called from the ilAccessHandler class.
Create styles array
The data for the language used.
static _checkAccess($a_usr_id, $a_obj_id)
Check, if a user can access an object by license.
global $ilDB