ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPageContentUsage.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
13 {
17  static function saveUsage($a_pc_type, $a_pc_id, $a_usage_type, $a_usage_id, $a_usage_hist_nr = 0)
18  {
19  global $ilDB;
20 
21  $ilDB->replace("page_pc_usage", array (
22  "pc_type" => array("text", $a_pc_type),
23  "pc_id" => array("integer", (int) $a_pc_id),
24  "usage_type" => array("text", $a_usage_type),
25  "usage_id" => array("integer", (int) $a_usage_id),
26  "usage_hist_nr" => array("integer", (int) $a_usage_hist_nr)
27  ),array());
28  }
29 
33  static function deleteAllUsages($a_pc_type, $a_usage_type, $a_usage_id, $a_usage_hist_nr = 0)
34  {
35  global $ilDB;
36 
37  $ilDB->manipulate($q = "DELETE FROM page_pc_usage WHERE usage_type = ".
38  $ilDB->quote($a_usage_type, "text").
39  " AND usage_id = ".$ilDB->quote((int) $a_usage_id, "integer").
40  " AND usage_hist_nr = ".$ilDB->quote((int) $a_usage_hist_nr, "integer").
41  " AND pc_type = ".$ilDB->quote($a_pc_type, "text"));
42  }
43 
47  function getUsages($a_pc_type, $a_pc_id, $a_incl_hist = true)
48  {
49  global $ilDB;
50 
51  $q = "SELECT * FROM page_pc_usage ".
52  " WHERE pc_type = ".$ilDB->quote($a_pc_type, "text").
53  " AND pc_id = ".$ilDB->quote($a_pc_id, "integer");
54 
55  if (!$a_incl_hist)
56  {
57  $q.= " AND usage_hist_nr = ".$ilDB->quote(0, "integer");
58  }
59 
60  $set = $ilDB->query($q);
61  $usages = array();
62  while ($rec = $ilDB->fetchAssoc($set))
63  {
64  $usages[] = $rec;
65  }
66  return $usages;
67  }
68 
75  function getUsagesOfPage($a_usage_id, $a_usage_type, $a_hist_nr = 0, $a_all_hist_nrs = false)
76  {
77  global $ilDB;
78 
79  if (!$a_all_hist_nrs)
80  {
81  $hist_str = " AND usage_hist_nr = ".$ilDB->quote($a_hist_nr, "integer");
82  }
83 
84  $set = $ilDB->query("SELECT pc_type, pc_id FROM page_pc_usage WHERE ".
85  " usage_id = ".$ilDB->quote($a_usage_id, "integer")." AND ".
86  " usage_type = ".$ilDB->quote($a_usage_type, "text").
87  $hist_str
88  );
89 
90  $usages = array();
91  while ($rec = $ilDB->fetchAssoc($set))
92  {
93  $usages[$rec["pc_type"].":".$rec["pc_id"]] = array(
94  "type" => $rec["pc_type"],
95  "id" => $rec["pc_id"]
96  );
97  }
98 
99  return $usages;
100  }
101 
102 }