Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00032 class ilMDCopyrightSelectionEntry
00033 {
00034 protected $db;
00035
00036 private $entry_id;
00037 private $title;
00038 private $decription;
00039 private $copyright;
00040 private $costs;
00041 private $language;
00042 private $copyright_and_other_restrictions;
00043
00044
00052 public function __construct($a_entry_id)
00053 {
00054 global $ilDB;
00055
00056 $this->db = $ilDB;
00057 $this->entry_id = $a_entry_id;
00058 $this->read();
00059 }
00060
00068 public static function _getEntries()
00069 {
00070 global $ilDB;
00071
00072 $query = "SELECT entry_id FROM il_md_copyright_selections ";
00073 $res = $ilDB->query($query);
00074 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00075 {
00076 $entries[] = new ilMDCopyrightSelectionEntry($row->entry_id);
00077 }
00078 return $entries ? $entries : array();
00079 }
00080
00089 public static function _lookupCopyright($a_cp_string)
00090 {
00091 global $ilDB;
00092
00093 if(!$entry_id = self::_extractEntryId($a_cp_string))
00094 {
00095 return $a_cp_string;
00096 }
00097
00098 $query = "SELECT copyright FROM il_md_copyright_selections ".
00099 "WHERE entry_id = ".$ilDB->quote($entry_id)." ";
00100 $res = $ilDB->query($query);
00101 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
00102 return $row->copyright ? $row->copyright : '';
00103 }
00104
00113 public static function _extractEntryId($a_cp_string)
00114 {
00115 if(!preg_match('/il_copyright_entry__([0-9]+)__([0-9]+)/',$a_cp_string,$matches))
00116 {
00117 return 0;
00118 }
00119 if($matches[1] != IL_INST_ID)
00120 {
00121 return 0;
00122 }
00123 return $matches[2] ? $matches[2] : 0;
00124 }
00125
00133 public function getUsage()
00134 {
00135 return $this->usage;
00136 }
00137
00145 public function getEntryId()
00146 {
00147 return $this->entry_id;
00148 }
00149
00157 public function setTitle($a_title)
00158 {
00159 $this->title = $a_title;
00160 }
00161
00168 public function getTitle()
00169 {
00170 return $this->title;
00171 }
00172
00180 public function setDescription($a_desc)
00181 {
00182 $this->description = $a_desc;
00183 }
00184
00190 public function getDescription()
00191 {
00192 return $this->description;
00193 }
00194
00202 public function setCopyright($a_copyright)
00203 {
00204 $this->copyright = $a_copyright;
00205 }
00206
00212 public function getCopyright()
00213 {
00214 return $this->copyright;
00215 }
00216
00224 public function setCosts($a_costs)
00225 {
00226 $this->costs = $a_costs;
00227 }
00228
00234 public function getCosts()
00235 {
00236 return $this->costs;
00237 }
00238
00246 public function setLanguage($a_lang_key)
00247 {
00248 $this->language = $a_lang_key;
00249 }
00250
00257 public function getLanguage()
00258 {
00259 return $this->language;
00260 }
00261
00268 public function setCopyrightAndOtherRestrictions($a_status)
00269 {
00270 $this->copyright_and_other_restrictions = $a_status;
00271 }
00272
00280 public function getCopyrightAndOtherRestrictions()
00281 {
00282
00283 return true;
00284 }
00285
00291 public function add()
00292 {
00293 $query = "INSERT INTO il_md_copyright_selections ".
00294 "SET title = ".$this->db->quote($this->getTitle()).", ".
00295 "description = ".$this->db->quote($this->getDescription()).", ".
00296 "copyright = ".$this->db->quote($this->getCopyright()).", ".
00297 "language = ".$this->db->quote($this->getLanguage()).", ".
00298 "costs = ".$this->db->quote($this->getCosts()).", ".
00299 "copyright_and_other_restrictions = ".$this->db->quote($this->getCopyrightAndOtherRestrictions())." ";
00300 $this->db->query($query);
00301 $this->entry_id = $this->db->getLastInsertId();
00302
00303 return true;
00304 }
00305
00312 public function update()
00313 {
00314 $query = "UPDATE il_md_copyright_selections ".
00315 "SET title = ".$this->db->quote($this->getTitle()).", ".
00316 "description = ".$this->db->quote($this->getDescription()).", ".
00317 "copyright = ".$this->db->quote($this->getCopyright()).", ".
00318 "language = ".$this->db->quote($this->getLanguage()).", ".
00319 "costs = ".$this->db->quote($this->getCosts()).", ".
00320 "copyright_and_other_restrictions = ".$this->db->quote($this->getCopyrightAndOtherRestrictions())." ".
00321 "WHERE entry_id = ".$this->db->quote($this->getEntryId())." ";
00322
00323 $this->db->query($query);
00324 }
00325
00332 public function delete()
00333 {
00334 $query = "DELETE FROM il_md_copyright_selections ".
00335 "WHERE entry_id = ".$this->db->quote($this->getEntryId())." ";
00336 $this->db->query($query);
00337
00338 }
00339
00347 public function validate()
00348 {
00349 if(!strlen($this->getTitle()))
00350 {
00351 return false;
00352 }
00353 return true;
00354 }
00355
00363 private function read()
00364 {
00365 $query = "SELECT * FROM il_md_copyright_selections ".
00366 "WHERE entry_id = ".$this->db->quote($this->entry_id)." ";
00367 $res = $this->db->query($query);
00368 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00369 {
00370 $this->setTitle($row->title);
00371 $this->setDescription($row->description);
00372 $this->setCopyright($row->copyright);
00373 $this->setLanguage($row->language);
00374 $this->setCosts($row->costs);
00375
00376 $this->setCopyrightAndOtherRestrictions(true);
00377 }
00378
00379 $query = "SELECT count(meta_rights_id) as used FROM il_meta_rights ".
00380 "WHERE description = 'il_copyright_entry__".IL_INST_ID.'__'.$this->getEntryId()."'";
00381 $res = $this->db->query($query);
00382 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
00383 $this->usage = $row->used;
00384 }
00385 }
00386 ?>