ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPageContentUsage.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
32 {
36  static function saveUsage($a_pc_type, $a_pc_id, $a_usage_type, $a_usage_id, $a_usage_hist_nr = 0)
37  {
38  global $ilDB;
39 
40  $ilDB->replace("page_pc_usage", array (
41  "pc_type" => array("text", $a_pc_type),
42  "pc_id" => array("integer", (int) $a_pc_id),
43  "usage_type" => array("text", $a_usage_type),
44  "usage_id" => array("integer", (int) $a_usage_id),
45  "usage_hist_nr" => array("integer", (int) $a_usage_hist_nr)
46  ),array());
47  }
48 
52  static function deleteAllUsages($a_pc_type, $a_usage_type, $a_usage_id, $a_usage_hist_nr = 0)
53  {
54  global $ilDB;
55 
56  $ilDB->manipulate($q = "DELETE FROM page_pc_usage WHERE usage_type = ".
57  $ilDB->quote($a_usage_type, "text").
58  " AND usage_id = ".$ilDB->quote((int) $a_usage_id, "integer").
59  " AND usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer").
60  " AND pc_type = ".$ilDB->quote($a_pc_type, "text"));
61  }
62 
66  function getUsages($a_pc_type, $a_pc_id)
67  {
68  global $ilDB;
69 
70  $set = $ilDB->query("SELECT * FROM page_pc_usage ".
71  " WHERE pc_type = ".$ilDB->quote($a_pc_type, "text").
72  " AND pc_id = ".$ilDB->quote($a_pc_id, "integer")
73  );
74  $usages = array();
75  while ($rec = $ilDB->fetchAssoc($set))
76  {
77  $usages[] = $rec;
78  }
79  return $usages;
80  }
81 
88  function getUsagesOfPage($a_usage_id, $a_usage_type, $a_hist_nr = 0, $a_all_hist_nrs = false)
89  {
90  global $ilDB;
91 
92  if (!$a_all_hist_nrs)
93  {
94  $hist_str = " AND usage_hist_nr = ".$ilDB->quote($a_hist_nr, "integer");
95  }
96 
97  $set = $ilDB->query("SELECT pc_type, pc_id FROM page_pc_usage WHERE ".
98  " usage_id = ".$ilDB->quote($a_usage_id, "integer")." AND ".
99  " usage_type = ".$ilDB->quote($a_usage_type, "text").
100  $hist_str
101  );
102 
103  $usages = array();
104  while ($rec = $ilDB->fetchAssoc($set))
105  {
106  $usages[$rec["pc_type"].":".$rec["pc_id"]] = array(
107  "type" => $rec["pc_type"],
108  "id" => $rec["pc_id"]
109  );
110  }
111 
112  return $usages;
113  }
114 
115 }