ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $entries[] = new ilMDCopyrightSelectionEntry($row->entry_id);
79 }
80 return $entries ? $entries : array();
81 }
82
88 public static function lookupCopyyrightTitle($a_cp_string)
89 {
90 global $ilDB;
91
92 if (!$entry_id = self::_extractEntryId($a_cp_string)) {
93 return $a_cp_string;
94 }
95
96 $query = "SELECT title FROM il_md_cpr_selections " .
97 "WHERE entry_id = " . $ilDB->quote($entry_id) . " ";
98 $res = $ilDB->query($query);
100 return $row->title ? $row->title : '';
101 }
102
103
112 public static function _lookupCopyright($a_cp_string)
113 {
114 global $ilDB;
115
116 if (!$entry_id = self::_extractEntryId($a_cp_string)) {
117 return $a_cp_string;
118 }
119
120 $query = "SELECT copyright FROM il_md_cpr_selections " .
121 "WHERE entry_id = " . $ilDB->quote($entry_id) . " ";
122 $res = $ilDB->query($query);
124 return $row->copyright ? $row->copyright : '';
125 }
126
135 public static function _extractEntryId($a_cp_string)
136 {
137 if (!preg_match('/il_copyright_entry__([0-9]+)__([0-9]+)/', $a_cp_string, $matches)) {
138 return 0;
139 }
140 if ($matches[1] != IL_INST_ID) {
141 return 0;
142 }
143 return $matches[2] ? $matches[2] : 0;
144 }
145
153 public function getUsage()
154 {
155 return $this->usage;
156 }
157
165 public function getEntryId()
166 {
167 return $this->entry_id;
168 }
169
177 public function setTitle($a_title)
178 {
179 $this->title = $a_title;
180 }
181
188 public function getTitle()
189 {
190 return $this->title;
191 }
192
200 public function setDescription($a_desc)
201 {
202 $this->description = $a_desc;
203 }
204
210 public function getDescription()
211 {
212 return $this->description;
213 }
214
222 public function setCopyright($a_copyright)
223 {
224 $this->copyright = $a_copyright;
225 }
226
232 public function getCopyright()
233 {
234 return $this->copyright;
235 }
236
244 public function setCosts($a_costs)
245 {
246 $this->costs = $a_costs;
247 }
248
254 public function getCosts()
255 {
256 return $this->costs;
257 }
258
266 public function setLanguage($a_lang_key)
267 {
268 $this->language = $a_lang_key;
269 }
270
277 public function getLanguage()
278 {
279 return $this->language;
280 }
281
288 public function setCopyrightAndOtherRestrictions($a_status)
289 {
290 $this->copyright_and_other_restrictions = $a_status;
291 }
292
301 {
302 // Fixed
303 return true;
304 }
305
311 public function add()
312 {
313 global $ilDB;
314
315 $next_id = $ilDB->nextId('il_md_cpr_selections');
316
317 $ilDB->insert('il_md_cpr_selections', array(
318 'entry_id' => array('integer',$next_id),
319 'title' => array('text',$this->getTitle()),
320 'description' => array('clob',$this->getDescription()),
321 'copyright' => array('clob',$this->getCopyright()),
322 'language' => array('text',$this->getLanguage()),
323 'costs' => array('integer',$this->getCosts()),
324 'cpr_restrictions' => array('integer',$this->getCopyrightAndOtherRestrictions())
325 ));
326 $this->entry_id = $next_id;
327 return true;
328 }
329
336 public function update()
337 {
338 global $ilDB;
339
340 $ilDB->update('il_md_cpr_selections', array(
341 'title' => array('text',$this->getTitle()),
342 'description' => array('clob',$this->getDescription()),
343 'copyright' => array('clob',$this->getCopyright()),
344 'language' => array('text',$this->getLanguage()),
345 'costs' => array('integer',$this->getCosts()),
346 'cpr_restrictions' => array('integer',$this->getCopyrightAndOtherRestrictions())
347 ), array(
348 'entry_id' => array('integer',$this->getEntryId())
349 ));
350 return true;
351 }
352
359 public function delete()
360 {
361 global $ilDB;
362
363 $query = "DELETE FROM il_md_cpr_selections " .
364 "WHERE entry_id = " . $this->db->quote($this->getEntryId(), 'integer') . " ";
365 $res = $ilDB->manipulate($query);
366 }
367
375 public function validate()
376 {
377 if (!strlen($this->getTitle())) {
378 return false;
379 }
380 return true;
381 }
382
390 private function read()
391 {
392 global $ilDB;
393
394 $query = "SELECT * FROM il_md_cpr_selections " .
395 "WHERE entry_id = " . $this->db->quote($this->entry_id, 'integer') . " ";
396 $res = $this->db->query($query);
397 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
398 $this->setTitle($row->title);
399 $this->setDescription($row->description);
400 $this->setCopyright($row->copyright);
401 $this->setLanguage($row->language);
402 $this->setCosts($row->costs);
403 // Fixed
405 }
406
407 $query = "SELECT count(meta_rights_id) used FROM il_meta_rights " .
408 "WHERE description = " . $ilDB->quote('il_copyright_entry__' . IL_INST_ID . '__' . $this->getEntryId(), 'text');
409
410 $this->logger->debug($query);
411
412 $res = $this->db->query($query);
414 $this->usage = $row->used;
415 }
416}
An exception for terminatinating execution or to throw for unit testing.
static _extractEntryId($a_cp_string)
extract entry id
setCopyrightAndOtherRestrictions($a_status)
set copyright and other restrictions
static lookupCopyyrightTitle($a_cp_string)
Lookup copyright title.
getCopyrightAndOtherRestrictions()
get copyright and other restrictions
static _lookupCopyright($a_cp_string)
lookup copyright by entry id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$query
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB