ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMDCopyrightSelectionEntry.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 
33 {
34  protected $logger = null;
35  protected $db;
36 
37  private $entry_id;
38  private $title;
39  private $decription;
40  private $copyright;
41  private $costs;
42  private $language;
44 
45 
53  public function __construct($a_entry_id)
54  {
55  global $DIC;
56 
57 
58  $this->logger = $GLOBALS['DIC']->logger()->meta();
59  $this->db = $GLOBALS['DIC']->database();
60  $this->entry_id = $a_entry_id;
61  $this->read();
62  }
63 
71  public static function _getEntries()
72  {
73  global $ilDB;
74 
75  $query = "SELECT entry_id FROM il_md_cpr_selections ";
76  $res = $ilDB->query($query);
77  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
78  {
79  $entries[] = new ilMDCopyrightSelectionEntry($row->entry_id);
80  }
81  return $entries ? $entries : array();
82  }
83 
89  public static function lookupCopyyrightTitle($a_cp_string)
90  {
91  global $ilDB;
92 
93  if(!$entry_id = self::_extractEntryId($a_cp_string))
94  {
95  return $a_cp_string;
96  }
97 
98  $query = "SELECT title FROM il_md_cpr_selections ".
99  "WHERE entry_id = ".$ilDB->quote($entry_id)." ";
100  $res = $ilDB->query($query);
102  return $row->title ? $row->title : '';
103  }
104 
105 
114  public static function _lookupCopyright($a_cp_string)
115  {
116  global $ilDB;
117 
118  if(!$entry_id = self::_extractEntryId($a_cp_string))
119  {
120  return $a_cp_string;
121  }
122 
123  $query = "SELECT copyright FROM il_md_cpr_selections ".
124  "WHERE entry_id = ".$ilDB->quote($entry_id)." ";
125  $res = $ilDB->query($query);
127  return $row->copyright ? $row->copyright : '';
128  }
129 
138  public static function _extractEntryId($a_cp_string)
139  {
140  if(!preg_match('/il_copyright_entry__([0-9]+)__([0-9]+)/',$a_cp_string,$matches))
141  {
142  return 0;
143  }
144  if($matches[1] != IL_INST_ID)
145  {
146  return 0;
147  }
148  return $matches[2] ? $matches[2] : 0;
149  }
150 
158  public function getUsage()
159  {
160  return $this->usage;
161  }
162 
170  public function getEntryId()
171  {
172  return $this->entry_id;
173  }
174 
182  public function setTitle($a_title)
183  {
184  $this->title = $a_title;
185  }
186 
193  public function getTitle()
194  {
195  return $this->title;
196  }
197 
205  public function setDescription($a_desc)
206  {
207  $this->description = $a_desc;
208  }
209 
215  public function getDescription()
216  {
217  return $this->description;
218  }
219 
227  public function setCopyright($a_copyright)
228  {
229  $this->copyright = $a_copyright;
230  }
231 
237  public function getCopyright()
238  {
239  return $this->copyright;
240  }
241 
249  public function setCosts($a_costs)
250  {
251  $this->costs = $a_costs;
252  }
253 
259  public function getCosts()
260  {
261  return $this->costs;
262  }
263 
271  public function setLanguage($a_lang_key)
272  {
273  $this->language = $a_lang_key;
274  }
275 
282  public function getLanguage()
283  {
284  return $this->language;
285  }
286 
293  public function setCopyrightAndOtherRestrictions($a_status)
294  {
295  $this->copyright_and_other_restrictions = $a_status;
296  }
297 
306  {
307  // Fixed
308  return true;
309  }
310 
316  public function add()
317  {
318  global $ilDB;
319 
320  $next_id = $ilDB->nextId('il_md_cpr_selections');
321 
322  $ilDB->insert('il_md_cpr_selections',array(
323  'entry_id' => array('integer',$next_id),
324  'title' => array('text',$this->getTitle()),
325  'description' => array('clob',$this->getDescription()),
326  'copyright' => array('clob',$this->getCopyright()),
327  'language' => array('text',$this->getLanguage()),
328  'costs' => array('integer',$this->getCosts()),
329  'cpr_restrictions' => array('integer',$this->getCopyrightAndOtherRestrictions())
330  ));
331  $this->entry_id = $next_id;
332  return true;
333  }
334 
341  public function update()
342  {
343  global $ilDB;
344 
345  $ilDB->update('il_md_cpr_selections',array(
346  'title' => array('text',$this->getTitle()),
347  'description' => array('clob',$this->getDescription()),
348  'copyright' => array('clob',$this->getCopyright()),
349  'language' => array('text',$this->getLanguage()),
350  'costs' => array('integer',$this->getCosts()),
351  'cpr_restrictions' => array('integer',$this->getCopyrightAndOtherRestrictions())
352  ),array(
353  'entry_id' => array('integer',$this->getEntryId())
354  ));
355  return true;
356  }
357 
364  public function delete()
365  {
366  global $ilDB;
367 
368  $query = "DELETE FROM il_md_cpr_selections ".
369  "WHERE entry_id = ".$this->db->quote($this->getEntryId() ,'integer')." ";
370  $res = $ilDB->manipulate($query);
371 
372  }
373 
381  public function validate()
382  {
383  if(!strlen($this->getTitle()))
384  {
385  return false;
386  }
387  return true;
388  }
389 
397  private function read()
398  {
399  global $ilDB;
400 
401  $query = "SELECT * FROM il_md_cpr_selections ".
402  "WHERE entry_id = ".$this->db->quote($this->entry_id ,'integer')." ";
403  $res = $this->db->query($query);
404  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
405  {
406  $this->setTitle($row->title);
407  $this->setDescription($row->description);
408  $this->setCopyright($row->copyright);
409  $this->setLanguage($row->language);
410  $this->setCosts($row->costs);
411  // Fixed
413  }
414 
415  $query = "SELECT count(meta_rights_id) used FROM il_meta_rights ".
416  "WHERE description = ".$ilDB->quote('il_copyright_entry__'.IL_INST_ID.'__'.$this->getEntryId(),'text');
417 
418  $this->logger->debug($query);
419 
420  $res = $this->db->query($query);
422  $this->usage = $row->used;
423  }
424 }
425 ?>
getCopyrightAndOtherRestrictions()
get copyright and other restrictions
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setCopyrightAndOtherRestrictions($a_status)
set copyright and other restrictions
static _extractEntryId($a_cp_string)
extract entry id
static _lookupCopyright($a_cp_string)
lookup copyright by entry id
Create styles array
The data for the language used.
global $ilDB
static lookupCopyyrightTitle($a_cp_string)
Lookup copyright title.
global $DIC
Peak memory usage