ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
15{
22 static function _isEnabled()
23 {
24 static $enabled;
25
26 if (isset($enabled))
27 {
28 return $enabled;
29 }
30
31 $lic_set = new ilSetting("license");
32 if ($lic_set->get("license_counter"))
33 {
34 $enabled = true;
35 return true;
36 }
37 else
38 {
39 $enabled = false;
40 return false;
41 }
42 }
43
44
57 static function _checkAccess($a_usr_id, $a_obj_id)
58 {
59 global $ilDB, $ilUser;
60
61 // check the object license
62 $query = 'SELECT licenses, used FROM license_data WHERE obj_id = %s';
63 $result = $ilDB->queryF($query, array('integer'), array($a_obj_id));
64
65 if ($row = $ilDB->fetchObject($result))
66 {
67 // no licenses set or at least one free => grant access
68 if ($row->licenses == 0
69 or $row->used < $row->licenses)
70 {
71 return true;
72 }
73 }
74 else
75 {
76 // no license data available => access granted
77 return true;
78 }
79
80 // check if user has already accessed
81 $query = 'SELECT read_count FROM read_event '
82 .'WHERE usr_id = %s AND obj_id = %s';
83
84 $result = $ilDB->queryF($query,
85 array('integer','integer'),
86 array($a_usr_id, $a_obj_id));
87
88 if ($row = $ilDB->fetchObject($result))
89 {
90 return true;
91 }
92
93 // all failed
94 return false;
95 }
96}
97
98?>
$result
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.
global $ilDB
global $ilUser
Definition: imgupload.php:15