ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAccordionPropertiesStorageGUI 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 ilAccordionPropertiesStorageGUI:
+ Collaboration diagram for ilAccordionPropertiesStorageGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 setOpenedTab ()
 
 storeProperty (string $a_table_id, int $a_user_id, string $a_property, string $a_value)
 Store property in session. More...
 
 getProperty (string $a_table_id, int $a_user_id, string $a_property)
 
 getPropertyForIdStartsWith (string $id_starts_with, int $user_id, string $property)
 

Data Fields

array $properties
 

Protected Attributes

string $tab_nr
 
string $req_acc_id
 
int $user_id
 
ILIAS Accordion StandardGUIRequest $request
 
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 accordions

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

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

Constructor & Destructor Documentation

◆ __construct()

ilAccordionPropertiesStorageGUI::__construct ( )

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

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

37  {
38  global $DIC;
39 
40  $this->user = $DIC->user();
41  $this->ctrl = $DIC->ctrl();
42  $this->db = $DIC->database();
43  $this->request = new \ILIAS\Accordion\StandardGUIRequest(
44  $DIC->http(),
45  $DIC->refinery()
46  );
47  $this->user_id = $this->request->getUserId();
48  $this->req_acc_id = $this->request->getId();
49  $this->tab_nr = $this->request->getTabNr();
50  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilAccordionPropertiesStorageGUI::executeCommand ( )

Definition at line 52 of file class.ilAccordionPropertiesStorageGUI.php.

References $ctrl, and ilCtrl\getCmd().

52  : void
53  {
54  $ilCtrl = $this->ctrl;
55  $cmd = $ilCtrl->getCmd();
56  $this->$cmd();
57  }
getCmd(?string $fallback_command=null)
+ Here is the call graph for this function:

◆ getProperty()

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

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

References ilSession\get(), and ilSession\has().

Referenced by setOpenedTab().

147  : string {
148  $acc = [];
149  if (ilSession::has("accordion")) {
150  $acc = ilSession::get("accordion");
151  }
152  return $acc[$a_table_id][$a_user_id][$a_property] ?? "";
153  }
static get(string $a_var)
static has($a_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPropertyForIdStartsWith()

ilAccordionPropertiesStorageGUI::getPropertyForIdStartsWith ( string  $id_starts_with,
int  $user_id,
string  $property 
)

Definition at line 156 of file class.ilAccordionPropertiesStorageGUI.php.

References $id, $user_id, ilSession\get(), and ilSession\has().

160  : array {
161  $ret = [];
162  switch ($this->properties[$property]["storage"]) {
163  case "session":
164  if (ilSession::has("accordion")) {
165  $acc = ilSession::get("accordion");
166  foreach ($acc as $id => $user_values) {
167  if (substr($id, 0, strlen($id_starts_with)) === $id_starts_with) {
168  if (isset($user_values[$user_id][$property])) {
169  $ret[$id] = $user_values[$user_id][$property];
170  }
171  }
172  }
173  }
174  break;
175  }
176  return $ret;
177  }
static get(string $a_var)
static has($a_var)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ setOpenedTab()

ilAccordionPropertiesStorageGUI::setOpenedTab ( )

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

References $tab_nr, $user, getProperty(), and storeProperty().

59  : void
60  {
61  $ilUser = $this->user;
62 
63  if ($this->user_id == $ilUser->getId()) {
64  switch ($this->request->getAction()) {
65  case "add":
66  $cur = $this->getProperty(
67  $this->req_acc_id,
68  $this->user_id,
69  "opened"
70  );
71  $cur_arr = explode(";", $cur);
72  if (!in_array($this->tab_nr, $cur_arr)) {
73  $cur_arr[] = $this->tab_nr;
74  }
75  $this->storeProperty(
76  $this->req_acc_id,
77  $this->user_id,
78  "opened",
79  implode(";", $cur_arr)
80  );
81  break;
82 
83  case "rem":
84  $cur = $this->getProperty(
85  $this->req_acc_id,
86  $this->user_id,
87  "opened"
88  );
89  $cur_arr = explode(";", $cur);
90  if (($key = array_search($this->tab_nr, $cur_arr)) !== false) {
91  unset($cur_arr[$key]);
92  }
93  $this->storeProperty(
94  $this->req_acc_id,
95  $this->user_id,
96  "opened",
97  implode(";", $cur_arr)
98  );
99  break;
100 
101  case "clear":
102  $this->storeProperty(
103  $this->req_acc_id,
104  $this->user_id,
105  "opened",
106  ""
107  );
108  break;
109 
110  case "set":
111  default:
112  $this->storeProperty(
113  $this->req_acc_id,
114  $this->user_id,
115  "opened",
116  $this->tab_nr
117  );
118  break;
119  }
120  }
121  }
storeProperty(string $a_table_id, int $a_user_id, string $a_property, string $a_value)
Store property in session.
getProperty(string $a_table_id, int $a_user_id, string $a_property)
+ Here is the call graph for this function:

◆ storeProperty()

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

Store property in session.

Definition at line 126 of file class.ilAccordionPropertiesStorageGUI.php.

References ilSession\get(), ilSession\has(), and ilSession\set().

Referenced by setOpenedTab().

131  : void {
132  switch ($this->properties[$a_property]["storage"]) {
133  case "session":
134  if (ilSession::has("accordion")) {
135  $acc = ilSession::get("accordion");
136  }
137  $acc[$a_table_id][$a_user_id][$a_property] = $a_value;
138  ilSession::set("accordion", $acc);
139  break;
140  }
141  }
static get(string $a_var)
static has($a_var)
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 ilAccordionPropertiesStorageGUI::$ctrl
protected

Definition at line 30 of file class.ilAccordionPropertiesStorageGUI.php.

Referenced by executeCommand().

◆ $db

ilDBInterface ilAccordionPropertiesStorageGUI::$db
protected

Definition at line 31 of file class.ilAccordionPropertiesStorageGUI.php.

◆ $properties

array ilAccordionPropertiesStorageGUI::$properties
Initial value:
= array(
"opened" => array("storage" => "session")
)

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

◆ $req_acc_id

string ilAccordionPropertiesStorageGUI::$req_acc_id
protected

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

◆ $request

ILIAS Accordion StandardGUIRequest ilAccordionPropertiesStorageGUI::$request
protected

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

◆ $tab_nr

string ilAccordionPropertiesStorageGUI::$tab_nr
protected

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

Referenced by setOpenedTab().

◆ $user

ilObjUser ilAccordionPropertiesStorageGUI::$user
protected

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

Referenced by setOpenedTab().

◆ $user_id

int ilAccordionPropertiesStorageGUI::$user_id
protected

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