ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
14
21 public static function _isEnabled()
22 {
23 static $enabled;
24
25 if (isset($enabled)) {
26 return $enabled;
27 }
28
29 $lic_set = new ilSetting("license");
30 if ($lic_set->get("license_counter")) {
31 $enabled = true;
32
33 return true;
34 } else {
35 $enabled = false;
36
37 return false;
38 }
39 }
40
41
54 public static function _checkAccess($a_usr_id, $a_obj_id)
55 {
56 global $ilDB;
57
58 // check the object license
59 $query = 'SELECT licenses, used FROM license_data WHERE obj_id = %s';
60 $result = $ilDB->queryF($query, array( 'integer' ), array( $a_obj_id ));
61
62 if ($row = $ilDB->fetchObject($result)) {
63 // no licenses set or at least one free => grant access
64 if ($row->licenses == 0 or $row->used < $row->licenses) {
65 return true;
66 }
67 } else {
68 // no license data available => access granted
69 return true;
70 }
71
72 // check if user has already accessed
73 $query = 'SELECT read_count FROM read_event ' . 'WHERE usr_id = %s AND obj_id = %s';
74
75 $result = $ilDB->queryF($query, array( 'integer', 'integer' ), array( $a_usr_id, $a_obj_id ));
76
77 if ($row = $ilDB->fetchObject($result)) {
78 return true;
79 }
80
81 // all failed
82 return false;
83 }
84}
$result
An exception for terminatinating execution or to throw for unit testing.
static _isEnabled()
Check, if licencing is enabled This check is called from the ilAccessHandler class.
static _checkAccess($a_usr_id, $a_obj_id)
Check, if a user can access an object by license.
ILIAS Setting Class.
$query
global $ilDB