ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAccordionPropertiesStorage.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14 var $properties = array (
15 "opened" => array("storage" => "session")
16 );
17
21 function &executeCommand()
22 {
23 global $ilUser, $ilCtrl;
24
25 $cmd = $ilCtrl->getCmd();
26// $next_class = $this->ctrl->getNextClass($this);
27
28 $this->$cmd();
29 }
30
34 function setOpenedTab()
35 {
36 global $ilUser;
37
38 if ($_GET["user_id"] == $ilUser->getId())
39 {
40 switch ($_GET["act"])
41 {
42
43 case "add":
44 $cur = $this->getProperty($_GET["accordion_id"], (int) $_GET["user_id"],
45 "opened");
46 $cur_arr = explode(";", $cur);
47 if (!in_array((int) $_GET["tab_nr"], $cur_arr))
48 {
49 $cur_arr[] = (int) $_GET["tab_nr"];
50 }
51 $this->storeProperty($_GET["accordion_id"], (int) $_GET["user_id"],
52 "opened", implode($cur_arr, ";"));
53 break;
54
55 case "rem":
56 $cur = $this->getProperty($_GET["accordion_id"], (int) $_GET["user_id"],
57 "opened");
58 $cur_arr = explode(";", $cur);
59 if(($key = array_search((int) $_GET["tab_nr"], $cur_arr)) !== false) {
60 unset($cur_arr[$key]);
61 }
62 $this->storeProperty($_GET["accordion_id"], (int) $_GET["user_id"],
63 "opened", implode($cur_arr, ";"));
64 break;
65
66 case "clear":
67 $this->storeProperty($_GET["accordion_id"], (int) $_GET["user_id"],
68 "opened", "");
69 break;
70
71 case "set":
72 default:
73 $this->storeProperty($_GET["accordion_id"], (int) $_GET["user_id"],
74 "opened", $_GET["tab_nr"]);
75 break;
76 }
77 }
78 }
79
83 function storeProperty($a_table_id, $a_user_id, $a_property,
84 $a_value)
85 {
86 global $ilDB;
87
88 switch ($this->properties[$a_property]["storage"])
89 {
90 case "session":
91 $_SESSION["accordion"][$a_table_id][$a_user_id][$a_property]
92 = $a_value;
93 break;
94
95 case "db":
96/*
97 $ilDB->replace("table_properties", array(
98 "table_id" => array("text", $a_table_id),
99 "user_id" => array("integer", $a_user_id),
100 "property" => array("text", $a_property)),
101 array(
102 "value" => array("text", $a_value)
103 ));
104*/
105 }
106 }
107
111 function getProperty($a_table_id, $a_user_id, $a_property)
112 {
113 global $ilDB;
114
115 switch ($this->properties[$a_property]["storage"])
116 {
117 case "session":
118 $r = $_SESSION["accordion"][$a_table_id][$a_user_id][$a_property];
119//echo "<br><br><br><br><br><br><br><br>get-".$r;
120 return $r;
121 break;
122
123 case "db":
124/*
125 $set = $ilDB->query("SELECT value FROM table_properties ".
126 " WHERE table_id = ".$ilDB->quote($a_table_id, "text").
127 " AND user_id = ".$ilDB->quote($a_user_id, "integer").
128 " AND property = ".$ilDB->quote($a_property, "text")
129 );
130 $rec = $ilDB->fetchAssoc($set);
131 return $rec["value"];
132 break;
133*/
134 }
135 }
136
137
138}
139?>
$_GET["client_id"]
$_SESSION["AccountId"]
Saves (mostly asynchronously) user properties of accordions.
getProperty($a_table_id, $a_user_id, $a_property)
Get property in session or db.
storeProperty($a_table_id, $a_user_id, $a_property, $a_value)
Store property in session or db.
$r
Definition: example_031.php:79
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
global $ilDB
global $ilUser
Definition: imgupload.php:15