ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTablePropertiesStorageGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilTablePropertiesStorageGUI:
+ Collaboration diagram for ilTablePropertiesStorageGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 showFilter ()
 
 hideFilter ()
 
 storeProperty (string $a_table_id, int $a_user_id, string $a_property, string $a_value)
 
 getProperty (string $a_table_id, int $a_user_id, string $a_property)
 
 isValidProperty ($a_property)
 

Data Fields

array $properties
 

Protected Attributes

ILIAS Table TableGUIRequest $table_request = null
 
ilObjUser $user
 
ilCtrl $ctrl
 
ilDBInterface $db
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Saves (mostly asynchronously) user properties of tables (e.g. filter on/off)

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilTablePropertiesStorageGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTablePropertiesStorageGUI::__construct ( )

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

References $DIC, ILIAS\Repository\ctrl(), and ILIAS\Repository\user().

41  {
42  global $DIC;
43 
44  $this->user = $DIC->user();
45  $this->ctrl = $DIC->ctrl();
46  $this->db = $DIC->database();
47  if (isset($DIC["http"])) {
48  $this->table_request = new \ILIAS\Table\TableGUIRequest(
49  $DIC->http(),
50  $DIC->refinery()
51  );
52  }
53  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilTablePropertiesStorageGUI::executeCommand ( )

Definition at line 56 of file class.ilTablePropertiesStorageGUI.php.

References $ctrl, and ilCtrl\getCmd().

56  : void
57  {
58  $ilCtrl = $this->ctrl;
59  $cmd = $ilCtrl->getCmd();
60  $this->$cmd();
61  }
getCmd(string $fallback_command=null)
+ Here is the call graph for this function:

◆ getProperty()

ilTablePropertiesStorageGUI::getProperty ( string  $a_table_id,
int  $a_user_id,
string  $a_property 
)

Definition at line 131 of file class.ilTablePropertiesStorageGUI.php.

References $db, $ilDB, ANONYMOUS_USER_ID, ilSession\get(), and isValidProperty().

135  : string {
136  $ilDB = $this->db;
137 
138  if ($a_table_id == "" || !$this->isValidProperty($a_property)) {
139  return "";
140  }
141 
142  $storage = $this->properties[$a_property]["storage"];
143  if ($a_user_id == ANONYMOUS_USER_ID) {
144  $storage = "session";
145  }
146 
147  switch ($storage) {
148  case "session":
149  return ilSession::get("table_" . $a_table_id . "_" . $a_user_id . "_" . $a_property) ?? "";
150 
151  case "db":
152  $set = $ilDB->query(
153  $q = "SELECT value FROM table_properties " .
154  " WHERE table_id = " . $ilDB->quote($a_table_id, "text") .
155  " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
156  " AND property = " . $ilDB->quote($a_property, "text")
157  );
158  $rec = $ilDB->fetchAssoc($set);
159  return $rec["value"] ?? '';
160  }
161  return "";
162  }
static get(string $a_var)
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ Here is the call graph for this function:

◆ hideFilter()

ilTablePropertiesStorageGUI::hideFilter ( )

Definition at line 80 of file class.ilTablePropertiesStorageGUI.php.

References $ilUser, $requested_user_id, $user, and storeProperty().

80  : void
81  {
83 
84  $requested_user_id = $this->table_request->getUserId();
85  $requested_table_id = $this->table_request->getTableId();
86  if ($requested_user_id == $ilUser->getId()) {
87  $this->storeProperty(
88  $requested_table_id,
90  "filter",
91  0
92  );
93  }
94  }
storeProperty(string $a_table_id, int $a_user_id, string $a_property, string $a_value)
$requested_user_id
Definition: feed.php:39
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ isValidProperty()

ilTablePropertiesStorageGUI::isValidProperty (   $a_property)

Definition at line 168 of file class.ilTablePropertiesStorageGUI.php.

Referenced by getProperty(), and storeProperty().

168  : bool
169  {
170  if (array_key_exists($a_property, $this->properties)) {
171  return true;
172  }
173  return false;
174  }
+ Here is the caller graph for this function:

◆ showFilter()

ilTablePropertiesStorageGUI::showFilter ( )

Definition at line 63 of file class.ilTablePropertiesStorageGUI.php.

References $ilUser, $requested_user_id, $user, and storeProperty().

63  : void
64  {
66 
67  $requested_user_id = $this->table_request->getUserId();
68  $requested_table_id = $this->table_request->getTableId();
69 
70  if ($requested_user_id == $ilUser->getId()) {
71  $this->storeProperty(
72  $requested_table_id,
74  "filter",
75  1
76  );
77  }
78  }
storeProperty(string $a_table_id, int $a_user_id, string $a_property, string $a_value)
$requested_user_id
Definition: feed.php:39
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ storeProperty()

ilTablePropertiesStorageGUI::storeProperty ( string  $a_table_id,
int  $a_user_id,
string  $a_property,
string  $a_value 
)

Definition at line 96 of file class.ilTablePropertiesStorageGUI.php.

References $db, $ilDB, ANONYMOUS_USER_ID, isValidProperty(), and ilSession\set().

Referenced by hideFilter(), and showFilter().

101  : void {
102  $ilDB = $this->db;
103 
104  if ($a_table_id == "" || !$this->isValidProperty($a_property)) {
105  return;
106  }
107 
108  $storage = $this->properties[$a_property]["storage"];
109  if ($a_user_id == ANONYMOUS_USER_ID) {
110  $storage = "session";
111  }
112  switch ($storage) {
113  case "session":
114  ilSession::set("table_" . $a_table_id . "_" . $a_user_id . "_" . $a_property, $a_value);
115  break;
116 
117  case "db":
118  $ilDB->replace(
119  "table_properties",
120  array(
121  "table_id" => array("text", $a_table_id),
122  "user_id" => array("integer", $a_user_id),
123  "property" => array("text", $a_property)),
124  array(
125  "value" => array("text", $a_value)
126  )
127  );
128  }
129  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilTablePropertiesStorageGUI::$ctrl
protected

Definition at line 27 of file class.ilTablePropertiesStorageGUI.php.

Referenced by executeCommand().

◆ $db

ilDBInterface ilTablePropertiesStorageGUI::$db
protected

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

Referenced by getProperty(), and storeProperty().

◆ $properties

array ilTablePropertiesStorageGUI::$properties
Initial value:
= array(
"filter" => array("storage" => "db"),
"direction" => array("storage" => "db"),
"order" => array("storage" => "db"),
"rows" => array("storage" => "db"),
"offset" => array("storage" => "session"),
"selfields" => array("storage" => "db"),
"selfilters" => array("storage" => "db"),
"filter_values" => array("storage" => "db")
)

Definition at line 29 of file class.ilTablePropertiesStorageGUI.php.

◆ $table_request

ILIAS Table TableGUIRequest ilTablePropertiesStorageGUI::$table_request = null
protected

Definition at line 25 of file class.ilTablePropertiesStorageGUI.php.

◆ $user

ilObjUser ilTablePropertiesStorageGUI::$user
protected

Definition at line 26 of file class.ilTablePropertiesStorageGUI.php.

Referenced by hideFilter(), and showFilter().


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