3 declare(strict_types=1);
    43     public function getStatesFor(
int $lso_ref_id, array $usr_ids = []): array
    47         foreach ($usr_ids as $usr_id) {
    49             if (array_key_exists($usr_id, 
$data)) {
    50                 $ret[$usr_id] = 
$data[$usr_id][self::STATES];
    64         foreach ($usr_ids as $usr_id) {
    66             if (array_key_exists($usr_id, 
$data)) {
    67                 $ret[$usr_id] = 
$data[$usr_id][self::CURRENT_ITEM_ID];
    82         foreach ($usr_ids as $usr_id) {
    84             if (array_key_exists($usr_id, 
$data)) {
    85                 $ret[$usr_id] = 
$data[$usr_id][self::FIRST_ACCESS];
   100         foreach ($usr_ids as $usr_id) {
   101             $ret[$usr_id] = 
'-1';
   102             if (array_key_exists($usr_id, 
$data)) {
   103                 $ret[$usr_id] = 
$data[$usr_id][self::LAST_ACCESS];
   118         ILIAS\KioskMode\State $state,
   119         int $current_item = null
   121         $insert_first = $this->
entryExistsFor($lso_ref_id, $usr_id) === 
false;
   123         $states = $states[$usr_id];
   126         if (is_null($current_item)) {
   130         $ilAtomQuery = $this->db->buildAtomQuery();
   131         $ilAtomQuery->addTableLock(static::TABLE_NAME);
   132         $ilAtomQuery->addQueryCallable(
   133             function (
ilDBInterface $db) use ($insert_first, $lso_ref_id, $usr_id, $current_item, $serialized): 
void {
   135                     $this->
insert($lso_ref_id, $usr_id);
   137                 $this->
update($db, $lso_ref_id, $usr_id, $current_item, $serialized);
   146         return $this->
select($lso_ref_id, [$usr_id]) !== [];
   149     protected function insert(
int $lso_ref_id, 
int $usr_id): void
   151         $first_access = date(
"d.m.Y H:i:s");
   153             "lso_ref_id" => array(
"integer", $lso_ref_id),
   154             "usr_id" => array(
"integer", $usr_id),
   155             "first_access" => array(
"text", $first_access)
   158         $this->db->insert(static::TABLE_NAME, $values);
   168         $last_access = date(
"d.m.Y H:i:s");
   170             "lso_ref_id" => array(
"integer", $lso_ref_id),
   171             "usr_id" => array(
"integer", $usr_id)
   174             "current_item" => array(
"integer", $current_item),
   175             "states" => array(
"text", $serialized),
   176             "last_access" => array(
"text", $last_access)
   179         $db->
update(static::TABLE_NAME, $values, $where);
   185     public function deleteFor(
int $lso_ref_id, array $usr_ids = []): void
   188              "DELETE FROM " . static::TABLE_NAME . PHP_EOL
   189             . 
"WHERE lso_ref_id = " . $this->db->quote($lso_ref_id, 
"integer") . PHP_EOL
   192         if ($usr_ids !== []) {
   193             $query .= 
"AND usr_id IN (" . implode(
',', $usr_ids) . 
")";
   196         $this->db->manipulate($query);
   201         $all_states = $this->
select($lso_ref_id);
   202         if ($all_states === []) {
   206         $ilAtomQuery = $this->db->buildAtomQuery();
   207         $ilAtomQuery->addTableLock(static::TABLE_NAME);
   208         $ilAtomQuery->addQueryCallable(
   209             function (
ilDBInterface $db) use ($lso_ref_id, $all_states, $item_ref_id): 
void {
   210                 foreach ($all_states as $usr_id => $state_entry) {
   211                     $current_item = $state_entry[
'current_item'];
   212                     $states = $state_entry[
'states'];
   214                     if ($current_item === $item_ref_id) {
   218                     if (array_key_exists($item_ref_id, $states)) {
   219                         unset($states[$item_ref_id]);
   222                     $this->
update($db, $lso_ref_id, (
int) $usr_id, $current_item, $serialized);
   237         $data = json_decode($serialized, 
true);
   240             if (is_array($kvpair)) {
   241                 foreach ($kvpair as $key => $value) {
   256         foreach ($states as 
$ref_id => $state) {
   260         $result = json_encode(
$data);
   262         if ($result === 
false) {
   273     protected function select(
int $lso_ref_id, array $usr_ids = []): array
   276              "SELECT usr_id, current_item, states, first_access, last_access" . PHP_EOL
   277             . 
"FROM " . static::TABLE_NAME . PHP_EOL
   278             . 
"WHERE lso_ref_id = " . $this->db->quote($lso_ref_id, 
"integer") . PHP_EOL
   281         if ($usr_ids !== []) {
   282             $query .= 
"AND usr_id IN (" . implode(
',', $usr_ids) . 
")";
   285         $result = $this->db->query($query);
   288         while ($row = $this->db->fetchAssoc($result)) {
   289             $ret[$row[
'usr_id']] = [
   290                 self::CURRENT_ITEM_ID => (
int) $row[self::CURRENT_ITEM_ID],
   291                 self::STATES => $this->
buildStates($row[self::STATES]),
   292                 self::FIRST_ACCESS => $row[self::FIRST_ACCESS],
   293                 self::LAST_ACCESS => $row[self::LAST_ACCESS]
 entryExistsFor(int $lso_ref_id, int $usr_id)
 
getCurrentItemsFor(int $lso_ref_id, array $usr_ids=[])
 
deleteFor(int $lso_ref_id, array $usr_ids=[])
 
serializeStates(array $states)
 
Interface Observer  Contains several chained tasks and infos about them. 
 
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only. 
 
insert(int $lso_ref_id, int $usr_id)
 
getFirstAccessFor(int $lso_ref_id, array $usr_ids=[])
 
deleteForItem(int $lso_ref_id, int $item_ref_id)
 
updateState(int $lso_ref_id, int $usr_id, int $ref_id, ILIAS\KioskMode\State $state, int $current_item=null)
update a single State (for the item with ref_id); if $current_item is not set, assume that $ref_id is...
 
update(ilDBInterface $db, int $lso_ref_id, int $usr_id, int $current_item, string $serialized)
 
getStatesFor(int $lso_ref_id, array $usr_ids=[])
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
buildStates(string $serialized)
 
__construct(ilDBInterface $db)
 
select(int $lso_ref_id, array $usr_ids=[])
 
getLastAccessFor(int $lso_ref_id, array $usr_ids=[])