ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAdvancedMDRecordScope.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 {
16  private $db;
17 
18  private $entry_exists = false;
19 
20  private $scope_id;
21  private $record_id;
22  private $ref_id;
23 
24 
28  private $logger = null;
29 
34  public function __construct($a_scope_id = 0)
35  {
36  $this->db = $GLOBALS['DIC']->database();
37  $this->logger = $GLOBALS['DIC']->logger()->amet();
38 
39  $this->scope_id = $a_scope_id;
40  $this->read();
41  }
42 
43  public function setRecordId($a_record_id)
44  {
45  $this->record_id = $a_record_id;
46  }
47 
48  public function getRecordId()
49  {
50  return $this->record_id;
51  }
52 
53  public function setScopeId($a_scope_id)
54  {
55  $this->scope_id = $a_scope_id;
56  }
57 
58  public function getScopeId()
59  {
60  return $this->scope_id;
61  }
62 
63  public function setRefId($a_ref_id)
64  {
65  $this->ref_id = $a_ref_id;
66  }
67 
68  public function getRefId()
69  {
70  return $this->ref_id;
71  }
72 
73 
74  public function save()
75  {
76  $this->logger->debug('Create new entry.');
77  // create
78  $this->scope_id = $this->db->nextId('adv_md_record_scope');
79  $query = 'INSERT INTO adv_md_record_scope (scope_id, record_id, ref_id) ' .
80  'VALUES ( ' .
81  $this->db->quote($this->scope_id, 'integer') . ', ' .
82  $this->db->quote($this->record_id, 'integer') . ', ' .
83  $this->db->quote($this->ref_id, 'integer') .
84  ')';
85  $this->db->manipulate($query);
86  $this->entry_exists = true;
87  }
88 
89  public function update()
90  {
91  $this->logger->debug('Update entry.');
92  // update (update of record ids not supported)
93  $query = 'UPDATE adv_md_record_scope ' .
94  'SET ref_id = ' . $this->db->quote($this->ref_id, 'integer') . ' ' .
95  'WHERE scope_id = ' . $this->db->quote($this->scope_id, 'integer');
96  $this->db->manipulate($query);
97  }
98 
99 
100 
104  public function delete()
105  {
106  $query = 'DELETE FROM adv_md_record_scope ' .
107  'WHERE scope_id = ' . $this->db->quote($this->scope_id, 'integer');
108  $this->db->manipulate($query);
109  $this->entry_exists = false;
110  return true;
111  }
112 
117  public static function deleteByRecordI($a_record_id)
118  {
119  $db = $GLOBALS['DIC']->database();
120 
121  $query = 'DELETE FROM adv_md_record_scope ' .
122  'WHERE record_id = ' . $db->quote($a_record_id, 'integer');
123  $db->manipulate($query);
124  }
125 
126 
130  protected function read()
131  {
132  if (!$this->scope_id) {
133  return;
134  }
135  $query = 'SELECT * FROM adv_md_record_scope ' .
136  'WHERE scope_id = ' . $this->db->quote($this->scope_id, 'integer');
137  $res = $this->db->query($query);
138  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
139  $this->entry_exists = true;
140  $this->record_id = $row->record_id;
141  $this->ref_id = $row->ref_id;
142  }
143  }
144 }
Scope restrictions for advanced md records.
static deleteByRecordI($a_record_id)
delete by record id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
foreach($_POST as $key=> $value) $res
__construct($a_scope_id=0)
Constructor.
$query