ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLicense Class Reference
+ Collaboration diagram for ilLicense:

Public Member Functions

 ilLicense ($a_obj_id)
 Constructor public.
 setLicenses ($a_licenses=0)
 getLicenses ()
 setRemarks ($a_remarks= '')
 getRemarks ()
 getAccesses ()
 getRemainingLicenses ()
 getPotentialAccesses ()
 Get the number of users who may access the object but don't have yet a license.
 read ()
 Read the license data from the database.
 update ()
 Update the license data in the database.
 delete ()
 Delete all data of the license.
 _checkAccess ($a_usr_id, $a_obj_id)
 Check, if a user can access an object by license.
 _noteAccess ($a_obj_id, $a_type, $a_ref_id)
 Note the access of the current usr to an object.
 _getLicensedObjects ()
 Get a list of all objects with activated licensing.
 _getLicensedChildObjects ($a_ref_id)
 Get a list of all sub objects with activated licensing.
 _isLicensed ($a_obj_id)
 Check if an object has licensing activated.

Detailed Description

Definition at line 13 of file class.ilLicense.php.

Member Function Documentation

ilLicense::_checkAccess (   $a_usr_id,
  $a_obj_id 
)

Check, if a user can access an object by license.

The user can access, if he/she already accessed the object or if a license is available for the object. This check is called from the ilAccessHandler class.

static

Parameters
intuser id
intobject id (not reference)
Returns
boolean access is possible (true/false)

Definition at line 193 of file class.ilLicense.php.

{
// Implementation moved
require_once("Services/License/classes/class.ilLicenseAccess.php");
return ilLicenseAccess::_checkAccess($a_usr_id, $a_obj_id);
}
ilLicense::_getLicensedChildObjects (   $a_ref_id)

Get a list of all sub objects with activated licensing.

static

Parameters
intref_id of the repository node to check
Returns
array array of object data arrays (obj_id, title, desc)

Definition at line 291 of file class.ilLicense.php.

References $data, and $ilDB.

Referenced by ilObjCourseGUI\checkLicenses(), and ilLicenseOverviewGUI\showLicenses().

{
global $ilDB, $tree;
$objects = array();
$childs = $tree->getChilds($a_ref_id, 'title');
foreach ($childs as $data)
{
if (in_array($data['type'], array('sahs','htlm'))
and self::_isLicensed($data['obj_id']))
{
$objects[] = $data;
}
}
return $objects;
}

+ Here is the caller graph for this function:

ilLicense::_getLicensedObjects ( )

Get a list of all objects with activated licensing.

static

Returns
array array of object data arrays (obj_id, type, title, description)

Definition at line 259 of file class.ilLicense.php.

References $ilDB, $query, and $row.

Referenced by ilLicenseOverviewGUI\showLicenses().

{
global $ilDB;
$objects = array();
$query = 'SELECT od.obj_id, od.type, od.title, od.description, re.ref_id '
. 'FROM license_data ld '
. 'INNER JOIN object_data od ON od.obj_id = ld.obj_id '
. 'INNER JOIN object_reference re ON re.obj_id = od.obj_id '
. 'WHERE ld.licenses > 0 '
. 'ORDER BY od.title, od.obj_id';
$result = $ilDB->query($query);
$obj_id = 0;
while ($row = $ilDB->fetchAssoc($result))
{
if ($row['obj_id'] != $obj_id)
{
$objects[] = $row;
$obj_id = $row['obj_id'];
}
}
return $objects;
}

+ Here is the caller graph for this function:

ilLicense::_isLicensed (   $a_obj_id)

Check if an object has licensing activated.

static

Parameters
intobject id
Returns
boolean object has licensing (true/false)

Definition at line 315 of file class.ilLicense.php.

References $ilDB, $query, and $row.

{
global $ilDB;
$query = "SELECT licenses FROM license_data ".
"WHERE obj_id = %s ".
"AND licenses > 0";
$result = $ilDB->queryF($query, array('integer'), array($a_obj_id));
if ($row = $ilDB->fetchObject($result))
{
return true;
}
}
ilLicense::_noteAccess (   $a_obj_id,
  $a_type,
  $a_ref_id 
)

Note the access of the current usr to an object.

This function has to be called if an object is accessed for viewing.

static

Parameters
intobject id (not reference)

Definition at line 209 of file class.ilLicense.php.

References $ilDB, $ilSetting, $query, $row, ilLicenseAccess\_isEnabled(), and ilChangeEvent\_recordReadEvent().

Referenced by ilSAHSPresentationGUI\executeCommand(), and ilObjFileBasedLMGUI\showLearningModule().

{
global $ilDB, $ilUser, $ilSetting;
// don't note the access if licensing is globally disabled
require_once("Services/License/classes/class.ilLicenseAccess.php");
{
return;
}
// check if user has already accessed
$query = 'SELECT read_count FROM read_event '
.'WHERE usr_id = %s AND obj_id = %s';
$result = $ilDB->queryF($query,
array('integer','integer'),
array($ilUser->getId(), $a_obj_id));
if ($row = $ilDB->fetchObject($result))
{
// already accessed -> nothing to do
return;
}
else
{
// note access
require_once('Services/Tracking/classes/class.ilChangeEvent.php');
ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $ilUser->getId());
if (self::_isLicensed($a_obj_id))
{
// increase used licenses
$query = "UPDATE license_data SET used = used + 1 "
."WHERE obj_id = %s";
$ilDB->manipulateF($query, array('integer'), array($a_obj_id));
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLicense::delete ( )

Delete all data of the license.

public

Definition at line 169 of file class.ilLicense.php.

References $ilDB, and $query.

{
global $ilDB;
$query = 'DELETE FROM license_data WHERE obj_id = %s';
$ilDB->manipulateF($query, array('integer'), array($this->obj_id));
}
ilLicense::getAccesses ( )

Definition at line 44 of file class.ilLicense.php.

{
return $this->accesses;
}
ilLicense::getLicenses ( )

Definition at line 32 of file class.ilLicense.php.

{
return $this->licenses;
}
ilLicense::getPotentialAccesses ( )

Get the number of users who may access the object but don't have yet a license.

public

Returns
int number of potential accesses

Definition at line 59 of file class.ilLicense.php.

References $ilDB, $query, $row, and ilRbacReview\_getOperationIdsByName().

{
global $ilDB;
// get the operation id for read access
$ops_ids = ilRbacReview::_getOperationIdsByName(array('read'));
// first get all roles with read access
$role_ids = array();
$query = 'SELECT DISTINCT pa.rol_id'
. ' FROM rbac_pa pa'
. ' INNER JOIN object_reference ob ON ob.ref_id = pa.ref_id'
. ' WHERE '.$ilDB->like('pa.ops_id', 'text', '%%i:'.$ops_ids[0].';%%')
. ' AND ob.obj_id = ' . $ilDB->quote($this->obj_id, 'integer');
$result = $ilDB->query($query);
while ($row = $ilDB->fetchObject($result))
{
$role_ids[] = $row->rol_id;
}
if (!count($role_ids))
{
return 0;
}
// then count all users of these roles without read events
$query = 'SELECT COUNT(DISTINCT(usr_id)) accesses '
. ' FROM rbac_ua'
. ' WHERE '. $ilDB->in('rol_id', $role_ids, false, 'integer')
. ' AND usr_id NOT IN'
. ' (SELECT usr_id FROM read_event'
. ' WHERE obj_id = ' . $ilDB->quote($this->obj_id, 'integer') . ')';
$result = $ilDB->query($query);
$row = $ilDB->fetchObject($result);
return $row->accesses;
}

+ Here is the call graph for this function:

ilLicense::getRemainingLicenses ( )

Definition at line 48 of file class.ilLicense.php.

{
return max(0, $this->licenses - $this->accesses);
}
ilLicense::getRemarks ( )

Definition at line 40 of file class.ilLicense.php.

{
return $this->remarks;
}
ilLicense::ilLicense (   $a_obj_id)

Constructor public.

Definition at line 19 of file class.ilLicense.php.

References read().

{
$this->obj_id = (int) $a_obj_id;
$this->read();
}

+ Here is the call graph for this function:

ilLicense::read ( )

Read the license data from the database.

public

Definition at line 107 of file class.ilLicense.php.

References $ilDB, $query, and $row.

Referenced by ilLicense().

{
global $ilDB;
$query = 'SELECT * FROM license_data WHERE obj_id = %s';
$result = $ilDB->queryF($query, array('integer'), array($this->obj_id));
if ($row = $ilDB->fetchObject($result))
{
$this->licenses = $row->licenses;
$this->accesses = $row->used;
$this->remarks = $row->remarks;
}
else
{
$this->licenses = 0;
$this->accesses = 0;
$this->remarks = '';
}
}

+ Here is the caller graph for this function:

ilLicense::setLicenses (   $a_licenses = 0)

Definition at line 28 of file class.ilLicense.php.

{
$this->licenses = (int) $a_licenses;
}
ilLicense::setRemarks (   $a_remarks = '')

Definition at line 36 of file class.ilLicense.php.

{
$this->remarks = $a_remarks;
}
ilLicense::update ( )

Update the license data in the database.

public

Definition at line 133 of file class.ilLicense.php.

References $ilDB, $query, and $row.

{
global $ilDB;
$query = 'SELECT * FROM license_data WHERE obj_id = %s';
$result = $ilDB->queryF($query, array('integer'), array($this->obj_id));
if ($row = $ilDB->fetchObject($result))
{
$ilDB->update('license_data',
array(
'licenses' => array('integer', $this->licenses),
'used' => array('integer', $this->accesses),
'remarks' => array('clob', $this->remarks)
),
array(
'obj_id' => array('integer', $this->obj_id),
)
);
}
else
{
$ilDB->insert('license_data', array(
'obj_id' => array('integer', $this->obj_id),
'licenses' => array('integer', $this->licenses),
'used' => array('integer', $this->accesses),
'remarks' => array('clob', $this->remarks)
));
}
}

The documentation for this class was generated from the following file: