ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTablePropertiesStorage.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 "filter" => array("storage" => "db"),
16 "direction" => array("storage" => "db"),
17 "order" => array("storage" => "db"),
18 "rows" => array("storage" => "db"),
19 "offset" => array("storage" => "session"),
20 "selfields" => array("storage" => "db"),
21 "selfilters" => array("storage" => "db"),
22 "filter_values" => array("storage" => "db")
23 );
24
28 function &executeCommand()
29 {
30 global $ilUser, $ilCtrl;
31
32 $cmd = $ilCtrl->getCmd();
33// $next_class = $this->ctrl->getNextClass($this);
34
35 $this->$cmd();
36 }
37
41 function showFilter()
42 {
43 global $ilUser;
44
45 if ($_GET["user_id"] == $ilUser->getId())
46 {
47 $this->storeProperty($_GET["table_id"], $_GET["user_id"],
48 "filter", 1);
49 }
50 }
51
55 function hideFilter()
56 {
57 global $ilUser;
58
59 if ($_GET["user_id"] == $ilUser->getId())
60 {
61 $this->storeProperty($_GET["table_id"], $_GET["user_id"],
62 "filter", 0);
63 }
64 }
65
69 function storeProperty($a_table_id, $a_user_id, $a_property,
70 $a_value)
71 {
72 global $ilDB;
73
74 if ($a_table_id == "" || !$this->isValidProperty($a_property))
75 {
76 return;
77 }
78
79 $storage = $this->properties[$a_property]["storage"];
80 if ($a_user_id == ANONYMOUS_USER_ID)
81 {
82 $storage = "session";
83 }
84
85 switch ($storage)
86 {
87 case "session":
88 $_SESSION["table"][$a_table_id][$a_user_id][$a_property]
89 = $a_value;
90 break;
91
92 case "db":
93 $ilDB->replace("table_properties", array(
94 "table_id" => array("text", $a_table_id),
95 "user_id" => array("integer", $a_user_id),
96 "property" => array("text", $a_property)),
97 array(
98 "value" => array("text", $a_value)
99 ));
100 }
101 }
102
106 function getProperty($a_table_id, $a_user_id, $a_property)
107 {
108 global $ilDB;
109
110 if ($a_table_id == "" || !$this->isValidProperty($a_property))
111 {
112 return;
113 }
114
115 $storage = $this->properties[$a_property]["storage"];
116 if ($a_user_id == ANONYMOUS_USER_ID)
117 {
118 $storage = "session";
119 }
120
121 switch ($storage)
122 {
123 case "session":
124 return $_SESSION["table"][$a_table_id][$a_user_id][$a_property];
125 break;
126
127 case "db":
128 $set = $ilDB->query($q = "SELECT value FROM table_properties ".
129 " WHERE table_id = ".$ilDB->quote($a_table_id, "text").
130 " AND user_id = ".$ilDB->quote($a_user_id, "integer").
131 " AND property = ".$ilDB->quote($a_property, "text")
132 );
133 $rec = $ilDB->fetchAssoc($set);
134 return $rec["value"];
135 break;
136 }
137 }
138
145 function isValidProperty($a_property)
146 {
147 if(array_key_exists($a_property, $this->properties))
148 {
149 return true;
150 }
151 return false;
152 }
153}
154
155?>
$_GET["client_id"]
$_SESSION["AccountId"]
Saves (mostly asynchronously) user properties of tables (e.g.
storeProperty($a_table_id, $a_user_id, $a_property, $a_value)
Store property in session or db.
isValidProperty($a_property)
Check if given property id is valid.
getProperty($a_table_id, $a_user_id, $a_property)
Get property in session or db.
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
global $ilDB
global $ilUser
Definition: imgupload.php:15