ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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{
17 protected $db;
18
19
23 public function __construct()
24 {
25 global $DIC;
26
27 $this->db = $DIC->database();
28 }
29
38 public function store($a_context, $a_user_id, $a_name, array $a_state)
39 {
41
42 if ($a_context == "" || $a_name == "") {
43 return;
44 }
45
46 $ilDB->replace(
47 "table_templates",
48 array(
49 "name" => array("text", $a_name),
50 "user_id" => array("integer", $a_user_id),
51 "context" => array("text", $a_context)),
52 array(
53 "value" => array("text", serialize($a_state))
54 )
55 );
56 }
57
66 public function load($a_context, $a_user_id, $a_name)
67 {
69
70 if ($a_context == "" || $a_name == "") {
71 return;
72 }
73
74 $set = $ilDB->query(
75 "SELECT value FROM table_templates " .
76 " WHERE name = " . $ilDB->quote($a_name, "text") .
77 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
78 " AND context = " . $ilDB->quote($a_context, "text")
79 );
80 $rec = $ilDB->fetchAssoc($set);
81 return unserialize($rec["value"]);
82 }
83
91 public function delete($a_context, $a_user_id, $a_name)
92 {
94
95 if ($a_context == "" || $a_name == "") {
96 return;
97 }
98
99 $ilDB->query(
100 "DELETE FROM table_templates " .
101 " WHERE name = " . $ilDB->quote($a_name, "text") .
102 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
103 " AND context = " . $ilDB->quote($a_context, "text")
104 );
105 }
106
114 public function getNames($a_context, $a_user_id)
115 {
117
118 if ($a_context == "") {
119 return;
120 }
121
122 $set = $ilDB->query(
123 "SELECT name FROM table_templates " .
124 " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
125 " AND context = " . $ilDB->quote($a_context, "text") .
126 " ORDER BY name"
127 );
128 $result = array();
129 while ($rec = $ilDB->fetchAssoc($set)) {
130 $result[] = $rec["name"];
131 }
132 return $result;
133 }
134}
$result
An exception for terminatinating execution or to throw for unit testing.
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
$DIC
Definition: xapitoken.php:46