ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCmiXapiUser Class Reference
+ Collaboration diagram for ilCmiXapiUser:

Public Member Functions

 __construct ($objId=null, $usrId=null, $privacyIdent=null)
 
 getObjId ()
 
 setObjId ($objId)
 
 getPrivacyIdent ()
 
 setPrivacyIdent ($privacyIdent)
 
 getUsrId ()
 
 setUsrId ($usrId)
 
 getUsrIdent ()
 
 setUsrIdent (string $usrIdent)
 
 getRegistration ()
 
 setRegistration (string $registration)
 
 hasProxySuccess ()
 
 setProxySuccess ($proxySuccess)
 
 setSatisfied ($satisfied)
 
 getSatisfied ()
 
 getFetchUntil ()
 
 setFetchUntil (ilCmiXapiDateTime $fetchUntil)
 
 load ()
 
 assignFromDbRow ($dbRow)
 
 save ()
 

Static Public Member Functions

static getIliasUuid ()
 
static getInstancesByObjectIdAndUsrId ($objId, $usrId)
 
static getInstanceByObjectIdAndUsrIdent ($objId, $usrIdent)
 
static saveProxySuccess ($objId, $usrId, $privacyIdent)
 
static getIdent ($userIdentMode, ilObjUser $user)
 
static getIdentAsId ($userIdentMode, ilObjUser $user)
 
static getName ($userNameMode, ilObjUser $user)
 
static getUsersForObject ($objId, $asUsrId=false)
 
static getUserIdents ($objId, $usrId)
 
static deleteUsersForObject (int $objId, ?array $users=[])
 
static exists ($objId, $usrId, $privacyIdent=999)
 
static getCmixObjectsHavingUsersMissingProxySuccess ()
 
static updateFetchedUntilForObjects (ilCmiXapiDateTime $fetchedUntil, $objectIds)
 
static lookupObjectIds ($usrId, $type='')
 
static getUserObjectUniqueId ($length=32)
 
static getUUID ($length=32)
 
static generateCMI5Registration ($objId, $usrId)
 
static generateRegistration (ilObjCmiXapi $obj, ilObjUser $user)
 
static getCMI5RegistrationFromAuthToken (ilCmiXapiAuthToken $authToken)
 
static getRegistrationFromAuthToken (ilCmiXapiAuthToken $authToken)
 

Data Fields

const DB_TABLE_NAME = 'cmix_users'
 

Static Protected Member Functions

static buildPseudoEmail ($mbox, $domain)
 

Protected Attributes

 $objId
 
 $usrId
 
 $privacyIdent
 
 $proxySuccess
 
 $satisfied
 
 $fetchUntil
 
 $usrIdent
 
 $registration
 

Static Private Member Functions

static userObjectUniqueIdExists ($id)
 

Detailed Description

Definition at line 15 of file class.ilCmiXapiUser.php.

Constructor & Destructor Documentation

◆ __construct()

ilCmiXapiUser::__construct (   $objId = null,
  $usrId = null,
  $privacyIdent = null 
)

Definition at line 60 of file class.ilCmiXapiUser.php.

References $objId, $privacyIdent, $usrId, IL_CAL_UNIX, and load().

61  {
62  $this->objId = $objId;
63  $this->usrId = $usrId;
64  $this->privacyIdent = $privacyIdent;
65  $this->proxySuccess = false;
66  $this->satisfied = false;
67  $this->fetchUntil = new ilCmiXapiDateTime(0, IL_CAL_UNIX);
68  $this->usrIdent = '';
69  $this->registration = '';
70 
71  if ($objId !== null && $usrId !== null && $privacyIdent !== null) {
72  $this->load();
73  }
74  }
const IL_CAL_UNIX
+ Here is the call graph for this function:

Member Function Documentation

◆ assignFromDbRow()

ilCmiXapiUser::assignFromDbRow (   $dbRow)

Definition at line 235 of file class.ilCmiXapiUser.php.

References IL_CAL_DATETIME, setFetchUntil(), setObjId(), setPrivacyIdent(), setProxySuccess(), setRegistration(), setSatisfied(), setUsrId(), and setUsrIdent().

Referenced by load().

236  {
237  $this->setObjId((int) $dbRow['obj_id']);
238  $this->setUsrId((int) $dbRow['usr_id']);
239  $this->setProxySuccess((bool) $dbRow['proxy_success']);
240  $this->setSatisfied((bool) $dbRow['satisfied']);
241  $this->setFetchUntil(new ilCmiXapiDateTime($dbRow['fetched_until'], IL_CAL_DATETIME));
242  $this->setUsrIdent((string) $dbRow['usr_ident']);
243  $this->setPrivacyIdent((int) $dbRow['privacy_ident']);
244  $this->setRegistration((string) $dbRow['registration']);
245  }
setFetchUntil(ilCmiXapiDateTime $fetchUntil)
const IL_CAL_DATETIME
setProxySuccess($proxySuccess)
setUsrIdent(string $usrIdent)
setPrivacyIdent($privacyIdent)
setRegistration(string $registration)
setSatisfied($satisfied)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildPseudoEmail()

static ilCmiXapiUser::buildPseudoEmail (   $mbox,
  $domain 
)
staticprotected
Parameters
string$mbox
string$domain
Returns
string

Definition at line 428 of file class.ilCmiXapiUser.php.

429  {
430  return "{$mbox}@{$domain}.ilias";
431  }

◆ deleteUsersForObject()

static ilCmiXapiUser::deleteUsersForObject ( int  $objId,
?array  $users = [] 
)
static
Parameters
int$objId
int[]$users

Definition at line 519 of file class.ilCmiXapiUser.php.

References $DIC, and $query.

520  {
521  global $DIC; /* @var \ILIAS\DI\Container $DIC */
522  $query = "DELETE FROM " . self::DB_TABLE_NAME . " WHERE obj_id = " . $DIC->database()->quote($objId, 'integer');
523  if (count($users) == 0) {
524  $DIC->database()->manipulate($query);
525  } else {
526  $DIC->database()->manipulateF(
527  $query . " AND usr_id = %s",
528  array('integer'),
529  $users
530  );
531  }
532  }
global $DIC
Definition: goto.php:24
$query

◆ exists()

static ilCmiXapiUser::exists (   $objId,
  $usrId,
  $privacyIdent = 999 
)
static

Definition at line 535 of file class.ilCmiXapiUser.php.

References $DIC, $objId, $privacyIdent, $query, $res, and $usrId.

Referenced by ilLPStatusCmiXapiAbstract\determineStatus(), and ilObjCmiXapiGUI\initInfoScreenToolbar().

536  {
537  global $DIC; /* @var \ILIAS\DI\Container $DIC */
538  if ($privacyIdent == 999) {
539  $query = "SELECT count(*) cnt FROM " . self::DB_TABLE_NAME . " WHERE obj_id = %s AND usr_id = %s";
540  $res = $DIC->database()->queryF(
541  $query,
542  array('integer', 'integer'),
543  array($objId, $usrId)
544  );
545  } else {
546  $query = "SELECT count(*) cnt FROM " . self::DB_TABLE_NAME . " WHERE obj_id = %s AND usr_id = %s AND privacy_ident = %s";
547  $res = $DIC->database()->queryF(
548  $query,
549  array('integer', 'integer', 'integer'),
550  array($objId, $usrId, $privacyIdent)
551  );
552  }
553 
554  while ($row = $DIC->database()->fetchAssoc($res)) {
555  return (bool) $row['cnt'];
556  }
557 
558  return false;
559  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
+ Here is the caller graph for this function:

◆ generateCMI5Registration()

static ilCmiXapiUser::generateCMI5Registration (   $objId,
  $usrId 
)
static

Definition at line 688 of file class.ilCmiXapiUser.php.

References $objId, and $usrId.

Referenced by ilCmiXapiLaunchGUI\initCmixUser().

689  {
690  return (new \Ramsey\Uuid\UuidFactory())->uuid3(self::getIliasUuid(), $objId . '-' . $usrId);
691  }
+ Here is the caller graph for this function:

◆ generateRegistration()

static ilCmiXapiUser::generateRegistration ( ilObjCmiXapi  $obj,
ilObjUser  $user 
)
static

Definition at line 693 of file class.ilCmiXapiUser.php.

References ilObject\getId(), and ilObject2\getRefId().

Referenced by ilCmiXapiLaunchGUI\CMI5preLaunch(), and ilCmiXapiLaunchGUI\getLaunchParameters().

694  {
695  return (new \Ramsey\Uuid\UuidFactory())->uuid3(self::getIliasUuid(), $obj->getRefId() . '-' . $user->getId());
696  }
getId()
get object id public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCMI5RegistrationFromAuthToken()

static ilCmiXapiUser::getCMI5RegistrationFromAuthToken ( ilCmiXapiAuthToken  $authToken)
static

Definition at line 698 of file class.ilCmiXapiUser.php.

References ilCmiXapiAuthToken\getObjId(), and ilCmiXapiAuthToken\getUsrId().

Referenced by XapiProxy\XapiProxyRequest\handleGetStatementsRequest().

698  : \Ramsey\Uuid\UuidInterface
699  {
700  return (new \Ramsey\Uuid\UuidFactory())->uuid3(self::getIliasUuid(), $authToken->getObjId() . '-' . $authToken->getUsrId());
701  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCmixObjectsHavingUsersMissingProxySuccess()

static ilCmiXapiUser::getCmixObjectsHavingUsersMissingProxySuccess ( )
static

Definition at line 561 of file class.ilCmiXapiUser.php.

References $DIC, $query, and $res.

Referenced by ilXapiResultsCronjob\getObjectsToBeReported().

562  {
563  global $DIC; /* @var \ILIAS\DI\Container $DIC */
564 
565  $query = "
566  SELECT DISTINCT cu.obj_id
567  FROM " . self::DB_TABLE_NAME . " cu
568  INNER JOIN object_data od
569  ON od.obj_id = cu.obj_id
570  AND od.type = 'cmix'
571  WHERE cu.proxy_success != %s
572  ";
573 
574  $res = $DIC->database()->queryF($query, array('integer'), array(1));
575 
576  $objects = array();
577 
578  while ($row = $DIC->database()->fetchAssoc($res)) {
579  $objects[] = $row['obj_id'];
580  }
581 
582  return $objects;
583  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
+ Here is the caller graph for this function:

◆ getFetchUntil()

ilCmiXapiUser::getFetchUntil ( )
Returns
ilCmiXapiDateTime

Definition at line 207 of file class.ilCmiXapiUser.php.

References $fetchUntil.

Referenced by ilObjCmiXapiGUI\fetchXapiStatements(), save(), and ilObjCmiXapiGUI\sendLastFetchInfo().

+ Here is the caller graph for this function:

◆ getIdent()

static ilCmiXapiUser::getIdent (   $userIdentMode,
ilObjUser  $user 
)
static
Parameters
string$userIdentMode
ilObjUser$user
Returns
string

Definition at line 333 of file class.ilCmiXapiUser.php.

References $_SERVER, ilObjUser\_isAnonymous(), ilObject\getCreateDate(), ilObjUser\getEmail(), ilObjUser\getExternalAccount(), ilObject\getId(), ilObjUser\getLogin(), ilUtil\is_email(), ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_EXT_ACCOUNT, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_LOGIN, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_RANDOM, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_SHA256, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_SHA256URL, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_USER_ID, and ilObjCmiXapi\PRIVACY_IDENT_REAL_EMAIL.

Referenced by ilLTIConsumerContentGUI\getStartButtonTxt11(), ilCmiXapiLaunchGUI\initCmixUser(), and ilLTIConsumerContentGUI\initCmixUser().

334  {
335  if (ilObjUser::_isAnonymous($user->getId())) {
336  return self::buildPseudoEmail(hash("sha256", (string) microtime()), self::getIliasUuid());
337  }
338  switch ($userIdentMode) {
340 
341  return self::buildPseudoEmail($user->getId(), self::getIliasUuid());
342 
344 
345  if (!ilUtil::is_email($user->getLogin())) {
346  return self::buildPseudoEmail($user->getLogin(), self::getIliasUuid());
347  } else {
348  return $user->getLogin();
349  }
350 
351  // no break
353 
354  return self::buildPseudoEmail($user->getExternalAccount(), self::getIliasUuid());
355 
357 
358  return self::buildPseudoEmail(hash("sha256", '' . $user->getId() . $user->getCreateDate()), self::getIliasUuid());
359 
361  $tmpHash = hash("sha256", '' . $user->getId() . $user->getCreateDate()) . '@' . str_replace('www.', '', $_SERVER['HTTP_HOST']);
362  if (strlen($tmpHash) > 80) {
363  $tmpHash = substr($tmpHash, strlen($tmpHash) - 80);
364  }
365  return $tmpHash;
366 
368 
369  return self::buildPseudoEmail(self::getUserObjectUniqueId(), self::getIliasUuid());
370 
372 
373  return $user->getEmail();
374  }
375 
376  return '';
377  }
const PRIVACY_IDENT_IL_UUID_SHA256URL
getLogin()
get login / username public
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
getCreateDate()
get create date public
const PRIVACY_IDENT_IL_UUID_RANDOM
const PRIVACY_IDENT_IL_UUID_EXT_ACCOUNT
const PRIVACY_IDENT_REAL_EMAIL
getExternalAccount()
get external account
const PRIVACY_IDENT_IL_UUID_SHA256
getEmail()
get email address public
getId()
get object id public
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
const PRIVACY_IDENT_IL_UUID_LOGIN
const PRIVACY_IDENT_IL_UUID_USER_ID
static _isAnonymous($usr_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdentAsId()

static ilCmiXapiUser::getIdentAsId (   $userIdentMode,
ilObjUser  $user 
)
static
Parameters
string$userIdentMode
ilObjUser$user
Returns
integer/string

Definition at line 384 of file class.ilCmiXapiUser.php.

References $_SERVER, ilObject\getCreateDate(), ilObjUser\getExternalAccount(), ilObject\getId(), ilObjUser\getLogin(), ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_EXT_ACCOUNT, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_LOGIN, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_RANDOM, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_SHA256, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_SHA256URL, ilObjCmiXapi\PRIVACY_IDENT_IL_UUID_USER_ID, and ilObjCmiXapi\PRIVACY_IDENT_REAL_EMAIL.

Referenced by ilObjLTIConsumer\buildLaunchParameters().

385  {
386  switch ($userIdentMode) {
388 
389  return $user->getId();
390 
392 
393  return $user->getLogin();
394 
396 
397  return $user->getExternalAccount();
398 
400 
401  return hash("sha256", '' . $user->getId() . $user->getCreateDate());
402 
404  $tmpHash = hash("sha256", '' . $user->getId() . $user->getCreateDate());
405  $tmpHost = '@' . str_replace('www.', '', $_SERVER['HTTP_HOST']);
406  if (strlen($tmpHash . $tmpHost) > 80) {
407  $tmpHash = substr($tmpHash, strlen($tmpHash) - (80 - strlen($tmpHost)));
408  }
409  return $tmpHash;
410 
412 
413  return self::getUserObjectUniqueId();
414 
416 
417  return 'realemail' . $user->getId();
418  }
419 
420  return '';
421  }
const PRIVACY_IDENT_IL_UUID_SHA256URL
getLogin()
get login / username public
getCreateDate()
get create date public
const PRIVACY_IDENT_IL_UUID_RANDOM
const PRIVACY_IDENT_IL_UUID_EXT_ACCOUNT
const PRIVACY_IDENT_REAL_EMAIL
getExternalAccount()
get external account
const PRIVACY_IDENT_IL_UUID_SHA256
getId()
get object id public
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
const PRIVACY_IDENT_IL_UUID_LOGIN
const PRIVACY_IDENT_IL_UUID_USER_ID
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIliasUuid()

static ilCmiXapiUser::getIliasUuid ( )
static
Returns
string

Definition at line 159 of file class.ilCmiXapiUser.php.

Referenced by ilCmiXapiSettingsGUI\buildForm(), ilObjCmiXapiAdministrationGUI\buildLrsTypeForm(), ilCmiXapiContentUploadImporter\generateActivityId(), and ilLTIConsumeProviderFormGUI\initForm().

159  : string
160  {
161  $setting = new ilSetting('cmix');
162  // Fallback
163  if (!$setting->get('ilias_uuid', false)) {
164  // $uuid = (new \Ramsey\Uuid\UuidFactory())->uuid4()->toString();
165  $uuid = self::getUUID(32);
166  $setting->set('ilias_uuid', $uuid);
167  }
168  $ilUuid = $setting->get('ilias_uuid');
169  return $ilUuid;
170  }
+ Here is the caller graph for this function:

◆ getInstanceByObjectIdAndUsrIdent()

static ilCmiXapiUser::getInstanceByObjectIdAndUsrIdent (   $objId,
  $usrIdent 
)
static

Definition at line 287 of file class.ilCmiXapiUser.php.

References $DIC, $objId, $res, and $usrIdent.

Referenced by ilXapiStatementEvaluation\getCmixUser().

288  {
289  global $DIC; /* @var \ILIAS\DI\Container $DIC */
290 
291  $res = $DIC->database()->queryF(
292  "SELECT * FROM " . self::DB_TABLE_NAME . " WHERE obj_id = %s AND usr_ident = %s",
293  array('integer', 'text'),
294  array($objId, $usrIdent)
295  );
296 
297  $cmixUser = new self();
298 
299  while ($row = $DIC->database()->fetchAssoc($res)) {
300  $cmixUser->assignFromDbRow($row);
301  }
302 
303  return $cmixUser;
304  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
+ Here is the caller graph for this function:

◆ getInstancesByObjectIdAndUsrId()

static ilCmiXapiUser::getInstancesByObjectIdAndUsrId (   $objId,
  $usrId 
)
static

Definition at line 270 of file class.ilCmiXapiUser.php.

References $DIC, $objId, $res, and $usrId.

271  {
272  global $DIC; /* @var \ILIAS\DI\Container $DIC */
273  $res = $DIC->database()->queryF(
274  "SELECT * FROM " . self::DB_TABLE_NAME . " WHERE obj_id = %s AND usr_id = %s",
275  array('integer', 'integer'),
276  array($objId, $usrId)
277  );
278  $cmixUsers = array();
279  while ($row = $DIC->database()->fetchAssoc($res)) {
280  $cmixUser = new self();
281  $cmixUser->assignFromDbRow($row);
282  $cmixUsers[] = $cmixUser;
283  }
284  return $cmixUsers;
285  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24

◆ getName()

static ilCmiXapiUser::getName (   $userNameMode,
ilObjUser  $user 
)
static
Parameters
string$userNameMode
ilObjUser$user
Returns
string|null

Definition at line 438 of file class.ilCmiXapiUser.php.

References ilObjUser\getFirstname(), ilObjUser\getFullname(), ilObjUser\getLastname(), ilObjUser\getUTitle(), ilObjCmiXapi\PRIVACY_NAME_FIRSTNAME, ilObjCmiXapi\PRIVACY_NAME_FULLNAME, ilObjCmiXapi\PRIVACY_NAME_LASTNAME, and ilObjCmiXapi\PRIVACY_NAME_NONE.

Referenced by ilObjCmiXapi\getStatementActor().

439  {
440  switch ($userNameMode) {
442  $usrName = $user->getFirstname();
443  break;
444 
446  $usrName = $user->getUTitle() ? $user->getUTitle() . ' ' : '';
447  $usrName .= $user->getLastname();
448  break;
449 
451  $usrName = $user->getFullname();
452  break;
453 
455  default:
456  $usrName = '-';
457  break;
458  }
459  return $usrName;
460  }
getFirstname()
get firstname public
getLastname()
get lastname public
getUTitle()
get user title (note: don't mix up this method with getTitle() that is derived from ilObject and gets...
getFullname($a_max_strlen=0)
get fullname public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjId()

ilCmiXapiUser::getObjId ( )
Returns
int

Definition at line 79 of file class.ilCmiXapiUser.php.

References $objId.

Referenced by load(), and save().

80  {
81  return $this->objId;
82  }
+ Here is the caller graph for this function:

◆ getPrivacyIdent()

ilCmiXapiUser::getPrivacyIdent ( )
Returns
int

Definition at line 95 of file class.ilCmiXapiUser.php.

References $privacyIdent.

Referenced by load(), and save().

96  {
97  return $this->privacyIdent;
98  }
+ Here is the caller graph for this function:

◆ getRegistration()

ilCmiXapiUser::getRegistration ( )
Returns
string

Definition at line 143 of file class.ilCmiXapiUser.php.

References $registration.

Referenced by save().

143  : string
144  {
145  return $this->registration;
146  }
+ Here is the caller graph for this function:

◆ getRegistrationFromAuthToken()

static ilCmiXapiUser::getRegistrationFromAuthToken ( ilCmiXapiAuthToken  $authToken)
static

Definition at line 703 of file class.ilCmiXapiUser.php.

References ilCmiXapiAuthToken\getRefId(), and ilCmiXapiAuthToken\getUsrId().

Referenced by XapiProxy\XapiProxyRequest\handleGetStatementsRequest().

703  : \Ramsey\Uuid\UuidInterface
704  {
705  return (new \Ramsey\Uuid\UuidFactory())->uuid3(self::getIliasUuid(), $authToken->getRefId() . '-' . $authToken->getUsrId());
706  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSatisfied()

ilCmiXapiUser::getSatisfied ( )
Returns
bool $satisfied

Definition at line 199 of file class.ilCmiXapiUser.php.

References $satisfied.

Referenced by save().

200  {
201  return $this->satisfied;
202  }
+ Here is the caller graph for this function:

◆ getUserIdents()

static ilCmiXapiUser::getUserIdents (   $objId,
  $usrId 
)
static
Parameters
int$objId
int$usrId
Returns
string[] $usrIdents

Definition at line 498 of file class.ilCmiXapiUser.php.

References $DIC, $objId, $res, and $usrId.

Referenced by ilCmiXapiStatementsReportLinkBuilder\buildFilterStage().

498  : array
499  {
500  global $DIC; /* @var \ILIAS\DI\Container $DIC */
501 
502  $res = $DIC->database()->queryF(
503  "SELECT usr_ident FROM " . self::DB_TABLE_NAME . " WHERE obj_id = %s AND usr_id = %s",
504  array('integer','integer'),
505  array($objId,$usrId)
506  );
507 
508  $usrIdents = [];
509  while ($row = $DIC->database()->fetchAssoc($res)) {
510  $usrIdents[] = $row['usr_ident'];
511  }
512  return $usrIdents;
513  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
+ Here is the caller graph for this function:

◆ getUserObjectUniqueId()

static ilCmiXapiUser::getUserObjectUniqueId (   $length = 32)
static
Parameters
int$length
Returns
string

Definition at line 630 of file class.ilCmiXapiUser.php.

631  {
632  // $storedId = self::readUserObjectUniqueId();
633  // if( (bool)strlen($storedId) ) {
634  // return strstr($storedId,'@', true);
635  // }
636 
637  // $getId = function( $length ) {
638  // $multiplier = floor($length/8) * 2;
639  // $uid = str_shuffle(str_repeat(uniqid(), $multiplier));
640 
641  // try {
642  // $ident = bin2hex(random_bytes($length));
643  // } catch (Exception $e) {
644  // $ident = $uid;
645  // }
646 
647  // $start = rand(0, strlen($ident) - $length - 1);
648  // return substr($ident, $start, $length);
649  // };
650 
651  $id = self::getUUID($length);//$getId($length);
652  $exists = self::userObjectUniqueIdExists($id);
653  while ($exists) {
654  $id = self::getUUID($length);//$getId($length);
655  $exists = self::userObjectUniqueIdExists($id);
656  }
657 
658  return $id;
659  }

◆ getUsersForObject()

static ilCmiXapiUser::getUsersForObject (   $objId,
  $asUsrId = false 
)
static
Parameters
int$object
Returns
ilCmiXapiUser[]

Definition at line 466 of file class.ilCmiXapiUser.php.

References $DIC, $objId, and $res.

Referenced by ilCmiXapiHighscoreReport\__construct(), ilCmiXapiStatementsReport\__construct(), ilCmiXapiStatementsReportLinkBuilder\buildFilterStage(), ilCmiXapiHighscoreReportLinkBuilder\getUsersStack(), ilCmiXapiStatementsGUI\initTableData(), and ilLPStatusCmiXapiAbstract\loadStatusInfo().

466  : array
467  {
468  global $DIC; /* @var \ILIAS\DI\Container $DIC */
469 
470  $res = $DIC->database()->queryF(
471  "SELECT * FROM " . self::DB_TABLE_NAME . " WHERE obj_id = %s",
472  array('integer'),
473  array($objId)
474  );
475 
476  $users = [];
477 
478  if ($asUsrId === false) {
479  while ($row = $DIC->database()->fetchAssoc($res)) {
480  $cmixUser = new self();
481  $cmixUser->assignFromDbRow($row);
482 
483  $users[] = $cmixUser;
484  }
485  } else {
486  while ($row = $DIC->database()->fetchAssoc($res)) {
487  $users[] = $row['usr_id'];
488  }
489  }
490  return $users;
491  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
+ Here is the caller graph for this function:

◆ getUsrId()

ilCmiXapiUser::getUsrId ( )
Returns
int

Definition at line 111 of file class.ilCmiXapiUser.php.

References $usrId.

Referenced by ilCmiXapiStatementsTableGUI\getUsername(), load(), and save().

112  {
113  return $this->usrId;
114  }
+ Here is the caller graph for this function:

◆ getUsrIdent()

ilCmiXapiUser::getUsrIdent ( )
Returns
string

Definition at line 127 of file class.ilCmiXapiUser.php.

References $usrIdent.

Referenced by ilObjLTIConsumer\buildLaunchParameters(), ilCmiXapiLaunchGUI\initCmixUser(), ilLTIConsumerContentGUI\initCmixUser(), and save().

127  : string
128  {
129  return $this->usrIdent;
130  }
+ Here is the caller graph for this function:

◆ getUUID()

static ilCmiXapiUser::getUUID (   $length = 32)
static

Definition at line 661 of file class.ilCmiXapiUser.php.

References Vendor\Package\$e.

662  {
663  $multiplier = floor($length / 8) * 2;
664  $uid = str_shuffle(str_repeat(uniqid(), $multiplier));
665 
666  try {
667  $ident = bin2hex(random_bytes($length));
668  } catch (Exception $e) {
669  $ident = $uid;
670  }
671 
672  $start = rand(0, strlen($ident) - $length - 1);
673  return substr($ident, $start, $length);
674  }

◆ hasProxySuccess()

ilCmiXapiUser::hasProxySuccess ( )
Returns
bool

Definition at line 175 of file class.ilCmiXapiUser.php.

References $proxySuccess.

Referenced by ilObjCmiXapiGUI\isFetchXapiStatementsRequired(), and save().

176  {
177  return $this->proxySuccess;
178  }
+ Here is the caller graph for this function:

◆ load()

ilCmiXapiUser::load ( )

Definition at line 220 of file class.ilCmiXapiUser.php.

References $DIC, $res, assignFromDbRow(), getObjId(), getPrivacyIdent(), and getUsrId().

Referenced by __construct().

221  {
222  global $DIC; /* @var \ILIAS\DI\Container $DIC */
223 
224  $res = $DIC->database()->queryF(
225  "SELECT * FROM " . self::DB_TABLE_NAME . " WHERE obj_id = %s AND usr_id = %s AND privacy_ident = %s",
226  array('integer', 'integer', 'integer'),
227  array($this->getObjId(), $this->getUsrId(), $this->getPrivacyIdent())
228  );
229 
230  while ($row = $DIC->database()->fetchAssoc($res)) {
231  $this->assignFromDbRow($row);
232  }
233  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupObjectIds()

static ilCmiXapiUser::lookupObjectIds (   $usrId,
  $type = '' 
)
static

Definition at line 595 of file class.ilCmiXapiUser.php.

References $DIC, $query, $res, and $type.

596  {
597  global $DIC; /* @var \ILIAS\DI\Container $DIC */
598 
599  $TYPE_JOIN = '';
600 
601  if (strlen($type)) {
602  $TYPE_JOIN = "
603  INNER JOIN object_data od
604  ON od.obj_id = cu.obj_id
605  AND od.type = {$DIC->database()->quote($type, 'text')}
606  ";
607  }
608 
609  $query = "
610  SELECT cu.obj_id
611  FROM " . self::DB_TABLE_NAME . " cu
612  {$TYPE_JOIN}
613  WHERE cu.usr_id = {$DIC->database()->quote($usrId, 'integer')}
614  ";
615 
616  $res = $DIC->database()->query($query);
617 
618  $objIds = [];
619 
620  while ($row = $DIC->database()->fetchAssoc($res)) {
621  $objIds[] = $row['obj_id'];
622  }
623 
624  return $objIds;
625  }
$type
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query

◆ save()

ilCmiXapiUser::save ( )

Definition at line 247 of file class.ilCmiXapiUser.php.

References $DIC, ilObjUser\_isAnonymous(), getFetchUntil(), getObjId(), getPrivacyIdent(), getRegistration(), getSatisfied(), getUsrId(), getUsrIdent(), hasProxySuccess(), and IL_CAL_DATETIME.

248  {
249  global $DIC; /* @var \ILIAS\DI\Container $DIC */
250  if (!ilObjUser::_isAnonymous($this->getUsrId())) {
251  $DIC->database()->replace(
252  self::DB_TABLE_NAME,
253  array(
254  'obj_id' => array('integer', (int) $this->getObjId()),
255  'usr_id' => array('integer', (int) $this->getUsrId()),
256  'privacy_ident' => array('integer', (int) $this->getPrivacyIdent())
257  ),
258  array(
259  'proxy_success' => array('integer', (int) $this->hasProxySuccess()),
260  'fetched_until' => array('timestamp', $this->getFetchUntil()->get(IL_CAL_DATETIME)),
261  'usr_ident' => array('text', $this->getUsrIdent()),
262  'registration' => array('text', $this->getRegistration()),
263  'satisfied' => array('integer', (int) $this->getSatisfied())
264  )
265  );
266  }
267  }
const IL_CAL_DATETIME
global $DIC
Definition: goto.php:24
static _isAnonymous($usr_id)
+ Here is the call graph for this function:

◆ saveProxySuccess()

static ilCmiXapiUser::saveProxySuccess (   $objId,
  $usrId,
  $privacyIdent 
)
static
Parameters
int$objId
int$usrId
int$privacyIdent

Definition at line 311 of file class.ilCmiXapiUser.php.

References $DIC, $objId, $privacyIdent, and $usrId.

Referenced by XapiProxy\XapiProxyPolyFill\getLrsType().

312  {
313  global $DIC; /* @var \ILIAS\DI\Container $DIC */
314 
315  $DIC->database()->update(
316  self::DB_TABLE_NAME,
317  array(
318  'proxy_success' => array('integer', 1)
319  ),
320  array(
321  'obj_id' => array('integer', (int) $objId),
322  'usr_id' => array('integer', (int) $usrId),
323  'privacy_ident' => array('integer', (int) $privacyIdent)
324  )
325  );
326  }
global $DIC
Definition: goto.php:24
+ Here is the caller graph for this function:

◆ setFetchUntil()

ilCmiXapiUser::setFetchUntil ( ilCmiXapiDateTime  $fetchUntil)
Parameters
ilCmiXapiDateTime$fetchUntil

Definition at line 215 of file class.ilCmiXapiUser.php.

References $fetchUntil.

Referenced by assignFromDbRow().

216  {
217  $this->fetchUntil = $fetchUntil;
218  }
+ Here is the caller graph for this function:

◆ setObjId()

ilCmiXapiUser::setObjId (   $objId)
Parameters
int$objId

Definition at line 87 of file class.ilCmiXapiUser.php.

References $objId.

Referenced by assignFromDbRow().

88  {
89  $this->objId = $objId;
90  }
+ Here is the caller graph for this function:

◆ setPrivacyIdent()

ilCmiXapiUser::setPrivacyIdent (   $privacyIdent)
Parameters
int$privacyIdent

Definition at line 103 of file class.ilCmiXapiUser.php.

References $privacyIdent.

Referenced by assignFromDbRow().

104  {
105  $this->privacyIdent = $privacyIdent;
106  }
+ Here is the caller graph for this function:

◆ setProxySuccess()

ilCmiXapiUser::setProxySuccess (   $proxySuccess)
Parameters
bool$proxySuccess

Definition at line 183 of file class.ilCmiXapiUser.php.

References $proxySuccess.

Referenced by assignFromDbRow().

184  {
185  $this->proxySuccess = $proxySuccess;
186  }
+ Here is the caller graph for this function:

◆ setRegistration()

ilCmiXapiUser::setRegistration ( string  $registration)
Parameters
string

Definition at line 151 of file class.ilCmiXapiUser.php.

References $registration.

Referenced by assignFromDbRow().

152  {
153  $this->registration = $registration;
154  }
+ Here is the caller graph for this function:

◆ setSatisfied()

ilCmiXapiUser::setSatisfied (   $satisfied)
Parameters
bool$satisfied

Definition at line 191 of file class.ilCmiXapiUser.php.

References $satisfied.

Referenced by assignFromDbRow().

192  {
193  $this->satisfied = $satisfied;
194  }
+ Here is the caller graph for this function:

◆ setUsrId()

ilCmiXapiUser::setUsrId (   $usrId)
Parameters
int$usrId

Definition at line 119 of file class.ilCmiXapiUser.php.

References $usrId.

Referenced by assignFromDbRow().

120  {
121  $this->usrId = $usrId;
122  }
+ Here is the caller graph for this function:

◆ setUsrIdent()

ilCmiXapiUser::setUsrIdent ( string  $usrIdent)
Parameters
string$usrIdent

Definition at line 135 of file class.ilCmiXapiUser.php.

References $usrIdent.

Referenced by assignFromDbRow().

136  {
137  $this->usrIdent = $usrIdent;
138  }
+ Here is the caller graph for this function:

◆ updateFetchedUntilForObjects()

static ilCmiXapiUser::updateFetchedUntilForObjects ( ilCmiXapiDateTime  $fetchedUntil,
  $objectIds 
)
static

Definition at line 585 of file class.ilCmiXapiUser.php.

References $DIC, $query, ilDateTime\get(), and IL_CAL_DATETIME.

Referenced by ilXapiResultsCronjob\run().

586  {
587  global $DIC; /* @var \ILIAS\DI\Container $DIC */
588 
589  $IN_objIds = $DIC->database()->in('obj_id', $objectIds, false, 'integer');
590 
591  $query = "UPDATE " . self::DB_TABLE_NAME . " SET fetched_until = %s WHERE $IN_objIds";
592  $DIC->database()->manipulateF($query, array('timestamp'), array($fetchedUntil->get(IL_CAL_DATETIME)));
593  }
const IL_CAL_DATETIME
global $DIC
Definition: goto.php:24
$query
get($a_format, $a_format_str='', $a_tz='')
get formatted date
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ userObjectUniqueIdExists()

static ilCmiXapiUser::userObjectUniqueIdExists (   $id)
staticprivate

Definition at line 676 of file class.ilCmiXapiUser.php.

References $DIC, $query, and $result.

677  {
678  global $DIC; /* @var \ILIAS\DI\Container $DIC */
679 
680  $query = "SELECT usr_ident FROM " . self::DB_TABLE_NAME . " WHERE " . $DIC->database()->like('usr_ident', 'text', $id . '@%');
681  $result = $DIC->database()->query($query);
682  if ($result->numRows() == 0) {
683  return false;
684  }
685  return true;
686  }
$result
global $DIC
Definition: goto.php:24
$query

Field Documentation

◆ $fetchUntil

ilCmiXapiUser::$fetchUntil
protected

Definition at line 47 of file class.ilCmiXapiUser.php.

Referenced by getFetchUntil(), and setFetchUntil().

◆ $objId

◆ $privacyIdent

ilCmiXapiUser::$privacyIdent
protected

◆ $proxySuccess

ilCmiXapiUser::$proxySuccess
protected

Definition at line 37 of file class.ilCmiXapiUser.php.

Referenced by hasProxySuccess(), and setProxySuccess().

◆ $registration

ilCmiXapiUser::$registration
protected

Definition at line 57 of file class.ilCmiXapiUser.php.

Referenced by getRegistration(), and setRegistration().

◆ $satisfied

ilCmiXapiUser::$satisfied
protected

Definition at line 42 of file class.ilCmiXapiUser.php.

Referenced by getSatisfied(), and setSatisfied().

◆ $usrId

◆ $usrIdent

ilCmiXapiUser::$usrIdent
protected

◆ DB_TABLE_NAME

const ilCmiXapiUser::DB_TABLE_NAME = 'cmix_users'

Definition at line 17 of file class.ilCmiXapiUser.php.


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