ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTableTemplatesStorage.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{
22 function store($a_context, $a_user_id, $a_name, array $a_state)
23 {
24 global $ilDB;
25
26 if ($a_context == "" || $a_name == "")
27 {
28 return;
29 }
30
31 $ilDB->replace("table_templates", array(
32 "name" => array("text", $a_name),
33 "user_id" => array("integer", $a_user_id),
34 "context" => array("text", $a_context)),
35 array(
36 "value" => array("text", serialize($a_state))
37 ));
38 }
39
48 function load($a_context, $a_user_id, $a_name)
49 {
50 global $ilDB;
51
52 if ($a_context == "" || $a_name == "")
53 {
54 return;
55 }
56
57 $set = $ilDB->query("SELECT value FROM table_templates ".
58 " WHERE name = ".$ilDB->quote($a_name, "text").
59 " AND user_id = ".$ilDB->quote($a_user_id, "integer").
60 " AND context = ".$ilDB->quote($a_context, "text")
61 );
62 $rec = $ilDB->fetchAssoc($set);
63 return unserialize($rec["value"]);
64 }
65
73 function delete($a_context, $a_user_id, $a_name)
74 {
75 global $ilDB;
76
77 if ($a_context == "" || $a_name == "")
78 {
79 return;
80 }
81
82 $ilDB->query("DELETE FROM table_templates ".
83 " WHERE name = ".$ilDB->quote($a_name, "text").
84 " AND user_id = ".$ilDB->quote($a_user_id, "integer").
85 " AND context = ".$ilDB->quote($a_context, "text")
86 );
87 }
88
96 function getNames($a_context, $a_user_id)
97 {
98 global $ilDB;
99
100 if ($a_context == "")
101 {
102 return;
103 }
104
105 $set = $ilDB->query("SELECT name FROM table_templates ".
106 " WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
107 " AND context = ".$ilDB->quote($a_context, "text").
108 " ORDER BY name"
109 );
110 $result = array();
111 while ($rec = $ilDB->fetchAssoc($set))
112 {
113 $result[] = $rec["name"];
114 }
115 return $result;
116 }
117}
118
119?>
$result
Saves (mostly asynchronously) user properties of tables (e.g.
load($a_context, $a_user_id, $a_name)
Get table template.
getNames($a_context, $a_user_id)
List templates.
store($a_context, $a_user_id, $a_name, array $a_state)
Store table template.
global $ilDB