ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilOerHarvesterObjectStatus.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
13  private $obj_id = 0;
14 
15  private $harvest_ref_id = 0;
16 
17  private $blocked = false;
18 
19  private $db = null;
20 
21 
26  public function __construct($obj_id = 0)
27  {
28  global $DIC;
29 
30  $this->db = $DIC->database();
31 
32  $this->obj_id = $obj_id;
33  if ($this->obj_id) {
34  $this->read();
35  }
36  }
37 
42  public static function lookupHarvested()
43  {
44  global $DIC;
45 
46  $db = $DIC->database();
47 
48  $query = 'SELECT href_id FROM il_meta_oer_stat ';
49  $res = $db->query($query);
50 
51  $hids = [];
52  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
53  $hids[] = $row->href_id;
54  }
55  return $hids;
56  }
57 
61  public static function lookupObjIdByHarvestingId($a_href_id)
62  {
63  global $DIC;
64 
65  $db = $DIC->database();
66  $query = 'SELECT obj_id FROM il_meta_oer_stat ' .
67  'WHERE href_id = ' . $db->quote($a_href_id, 'integer');
68  $res = $db->query($query);
69  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
70  return $row->obj_id;
71  }
72  }
73 
74  public function setObjId($a_obj_id)
75  {
76  $this->obj_id = $a_obj_id;
77  }
78 
79  public function getObjId()
80  {
81  return $this->obj_id;
82  }
83 
84  public function setHarvestRefId($a_ref_id)
85  {
86  $this->harvest_ref_id = $a_ref_id;
87  }
88 
89  public function getHarvestRefId()
90  {
91  return $this->harvest_ref_id;
92  }
93 
94  public function setBlocked($a_stat)
95  {
96  $this->blocked = $a_stat;
97  }
98 
99  public function isBlocked()
100  {
101  return $this->blocked;
102  }
103 
104  public function isCreated()
105  {
106  return (bool) $this->harvest_ref_id;
107  }
108 
112  public function save()
113  {
114  $this->delete();
115  $query = 'INSERT INTO il_meta_oer_stat ' .
116  '(obj_id, href_id, blocked ) ' .
117  'VALUES (' .
118  $this->db->quote($this->getObjId(), 'integer') . ', ' .
119  $this->db->quote($this->getHarvestRefId(), 'integer') . ', ' .
120  $this->db->quote($this->isBlocked(), 'integer') .
121  ')';
122  $res = $this->db->manipulate($query);
123  return true;
124  }
125 
129  public function delete()
130  {
131  $query = 'DELETE FROM il_meta_oer_stat ' .
132  'WHERE obj_id = ' . $this->db->quote($this->getObjId(), 'integer');
133  $this->db->manipulate($query);
134  return true;
135  }
136 
137 
141  public function read()
142  {
143  $query = 'SELECT * FROM il_meta_oer_stat ' .
144  'WHERE obj_id = ' . $this->db->quote($this->getObjId(), 'integer');
145  $res = $this->db->query($query);
146  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
147  $this->setObjId($row->obj_id);
148  $this->setHarvestRefId($row->href_id);
149  $this->setBlocked((bool) $row->blocked);
150  }
151  }
152 }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
__construct($obj_id=0)
ilOerHarvesterObjectStatus constructor.