ILIAS  release_8 Revision v8.24
class.arConnectorSession.php
Go to the documentation of this file.
1<?php
2
3/******************************************************************************
4 *
5 * This file is part of ILIAS, a powerful learning management system.
6 *
7 * ILIAS is licensed with the GPL-3.0, you should have received a copy
8 * of said license along with the source code.
9 *
10 * If this is not the case or you just want to try ILIAS, you'll find
11 * us at:
12 * https://www.ilias.de
13 * https://github.com/ILIAS-eLearning
14 *
15 *****************************************************************************/
22{
23 public const AR_CONNECTOR_SESSION = 'arConnectorSession';
24
25 public static function resetSession(): void
26 {
27 $_SESSION[self::AR_CONNECTOR_SESSION] = array();
28 }
29
33 public static function getSession(): array
34 {
35 if (!$_SESSION[self::AR_CONNECTOR_SESSION]) {
37 }
38
39 return $_SESSION[self::AR_CONNECTOR_SESSION];
40 }
41
45 public static function getSessionForActiveRecord(ActiveRecord $ar): array
46 {
48 $ar_session = $session[$ar::returnDbTableName()];
49 if (!is_array($ar_session)) {
50 $ar_session = array();
51 }
52
53 return $ar_session;
54 }
55
56 public function checkConnection(ActiveRecord $ar): bool
57 {
58 return is_array(self::getSession());
59 }
60
64 public function nextID(ActiveRecord $ar): int
65 {
66 return count(self::getSessionForActiveRecord($ar)) + 1;
67 }
68
69 public function installDatabase(ActiveRecord $ar, array $fields): bool
70 {
71 return $this->resetDatabase($ar);
72 }
73
74 public function updateDatabase(ActiveRecord $ar): bool
75 {
76 return true;
77 }
78
79 public function resetDatabase(ActiveRecord $ar): bool
80 {
81 $_SESSION[self::AR_CONNECTOR_SESSION][$ar::returnDbTableName()] = array();
82
83 return true;
84 }
85
86 public function truncateDatabase(ActiveRecord $ar): bool
87 {
88 return $this->resetDatabase($ar);
89 }
90
91 public function checkTableExists(ActiveRecord $ar): bool
92 {
93 return is_array(self::getSessionForActiveRecord($ar));
94 }
95
96 public function checkFieldExists(ActiveRecord $ar, string $field_name): bool
97 {
99
100 return array_key_exists($field_name, $session[0]);
101 }
102
106 public function removeField(ActiveRecord $ar, string $field_name): bool
107 {
108 return true;
109 }
110
114 public function renameField(ActiveRecord $ar, string $old_name, string $new_name): bool
115 {
116 return true;
117 }
118
119 public function create(ActiveRecord $ar): void
120 {
121 $_SESSION[self::AR_CONNECTOR_SESSION][$ar::returnDbTableName()][$ar->getPrimaryFieldValue()] = $ar->asStdClass();
122 }
123
127 public function read(ActiveRecord $ar): array
128 {
130
131 return array($session[$ar->getPrimaryFieldValue()]);
132 }
133
134 public function update(ActiveRecord $ar): void
135 {
136 $this->create($ar);
137 }
138
139 public function delete(ActiveRecord $ar): void
140 {
141 unset($_SESSION[self::AR_CONNECTOR_SESSION][$ar::returnDbTableName()][$ar->getPrimaryFieldValue()]);
142 }
143
148 public function readSet(ActiveRecordList $arl): array
149 {
151 foreach ($session as $i => $s) {
152 $session[$i] = (array) $s;
153 }
154 foreach ($arl->getArWhereCollection()->getWheres() as $w) {
155 $fieldname = $w->getFieldname();
156 $v = $w->getValue();
157 $operator = $w->getOperator();
158
159 foreach ($session as $i => $s) {
160 $session[$i] = (array) $s;
161 if (($operator === '=') && $s[$fieldname] !== $v) {
162 unset($session[$i]);
163 }
164 }
165 }
166
167 return $session;
168 }
169
170 public function affectedRows(ActiveRecordList $arl): int
171 {
172 return count($this->readSet($arl));
173 }
174
178 public function quote($value, string $type): string
179 {
180 return $value;
181 }
182
183 public function updateIndices(ActiveRecord $ar): void
184 {
185 // TODO: Implement updateIndices() method.
186 }
187}
@noinspection NullPointerExceptionInspection
Class ActiveRecord.
Class arConnectorSession.
removeField(ActiveRecord $ar, string $field_name)
quote($value, string $type)
updateDatabase(ActiveRecord $ar)
updateIndices(ActiveRecord $ar)
affectedRows(ActiveRecordList $arl)
checkConnection(ActiveRecord $ar)
readSet(ActiveRecordList $arl)
truncateDatabase(ActiveRecord $ar)
renameField(ActiveRecord $ar, string $old_name, string $new_name)
installDatabase(ActiveRecord $ar, array $fields)
resetDatabase(ActiveRecord $ar)
static getSessionForActiveRecord(ActiveRecord $ar)
checkFieldExists(ActiveRecord $ar, string $field_name)
checkTableExists(ActiveRecord $ar)
Class arConnector.
$i
Definition: metadata.php:41
$type
$session