ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMDRights Class Reference
+ Inheritance diagram for ilMDRights:
+ Collaboration diagram for ilMDRights:

Public Member Functions

 setCosts (string $a_costs)
 
 getCosts ()
 
 setCopyrightAndOtherRestrictions (string $a_caor)
 
 getCopyrightAndOtherRestrictions ()
 
 setDescription (string $a_description)
 
 getDescription ()
 
 setDescriptionLanguage (ilMDLanguageItem $lng_obj)
 
 getDescriptionLanguage ()
 
 getDescriptionLanguageCode ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (ilXmlWriter $writer)
 
 parseDescriptionFromImport (string $a_description)
 
- Public Member Functions inherited from ilMDBase
 __construct (int $a_rbac_id=0, int $a_obj_id=0, string $a_type='')
 constructor More...
 
 read ()
 
 setRBACId (int $a_id)
 
 getRBACId ()
 
 setObjId (int $a_id)
 
 getObjId ()
 
 setObjType (string $a_type)
 
 getObjType ()
 
 setMetaId (int $a_meta_id, bool $a_read_data=true)
 
 getMetaId ()
 
 setParentType (string $a_parent_type)
 
 getParentType ()
 
 setParentId (int $a_id)
 
 getParentId ()
 
 setExportMode (bool $a_export_mode=true)
 
 getExportMode ()
 
 validate ()
 
 update ()
 
 save ()
 
 delete ()
 
 toXML (ilXmlWriter $writer)
 

Static Public Member Functions

static lookupRightsByTypeAndCopyright (array $a_types, array $a_copyright)
 
static _lookupDescription (int $a_rbac_id, int $a_obj_id)
 
static _getId (int $a_rbac_id, int $a_obj_id)
 

Private Attributes

const YES_NO_TRANSLATION
 Compatibility fix for legacy MD classes for new db tables. More...
 
const string $costs = ''
 
string $caor = ''
 
string $description = ''
 
ilMDLanguageItem $description_language = null
 

Additional Inherited Members

- Protected Attributes inherited from ilMDBase
ilLogger $log
 
ilDBInterface $db
 

Detailed Description

Definition at line 26 of file class.ilMDRights.php.

Member Function Documentation

◆ __getFields()

ilMDRights::__getFields ( )
Returns
array<string, array<string, mixed>>

Compatibility fix for legacy MD classes for new db tables

Definition at line 165 of file class.ilMDRights.php.

References getCopyrightAndOtherRestrictions(), getCosts(), getDescription(), getDescriptionLanguageCode(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

Referenced by save(), and update().

165  : array
166  {
170  $costs = (string) array_search(
171  $this->getCosts(),
172  self::YES_NO_TRANSLATION
173  );
174  $cpr_and_or = (string) array_search(
176  self::YES_NO_TRANSLATION
177  );
178 
179  return array(
180  'rbac_id' => array('integer', $this->getRBACId()),
181  'obj_id' => array('integer', $this->getObjId()),
182  'obj_type' => array('text', $this->getObjType()),
183  'costs' => array('text', $costs),
184  'cpr_and_or' => array('text', $cpr_and_or),
185  'description' => array('text', $this->getDescription()),
186  'description_language' => array('text', $this->getDescriptionLanguageCode())
187  );
188  }
const string $costs
getCopyrightAndOtherRestrictions()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getId()

static ilMDRights::_getId ( int  $a_rbac_id,
int  $a_obj_id 
)
static

Definition at line 267 of file class.ilMDRights.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilMD\getRights().

267  : int
268  {
269  global $DIC;
270 
271  $ilDB = $DIC->database();
272 
273  $query = "SELECT meta_rights_id FROM il_meta_rights " .
274  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
275  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
276 
277  $res = $ilDB->query($query);
278  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
279  return (int) $row->meta_rights_id;
280  }
281  return 0;
282  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _lookupDescription()

static ilMDRights::_lookupDescription ( int  $a_rbac_id,
int  $a_obj_id 
)
static

Definition at line 248 of file class.ilMDRights.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilOerHarvester\deleteDeprecated().

248  : string
249  {
250  global $DIC;
251 
252  $ilDB = $DIC->database();
253 
254  $query = "SELECT description FROM il_meta_rights " .
255  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
256  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
257  $res = $ilDB->query($query);
258  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
259 
260  if (isset($row) && isset($row->description)) {
261  return $row->description;
262  }
263  return '';
264  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ delete()

ilMDRights::delete ( )

Definition at line 149 of file class.ilMDRights.php.

References ilMDBase\getMetaId().

149  : bool
150  {
151  if ($this->getMetaId()) {
152  $query = "DELETE FROM il_meta_rights " .
153  "WHERE meta_rights_id = " . $this->db->quote($this->getMetaId(), 'integer');
154 
155  $this->db->query($query);
156 
157  return true;
158  }
159  return false;
160  }
+ Here is the call graph for this function:

◆ getCopyrightAndOtherRestrictions()

ilMDRights::getCopyrightAndOtherRestrictions ( )

Definition at line 98 of file class.ilMDRights.php.

References $caor.

Referenced by __getFields(), and toXML().

98  : string
99  {
100  return $this->caor;
101  }
+ Here is the caller graph for this function:

◆ getCosts()

ilMDRights::getCosts ( )

Definition at line 80 of file class.ilMDRights.php.

References $costs.

Referenced by __getFields(), and toXML().

80  : string
81  {
82  return $this->costs;
83  }
const string $costs
+ Here is the caller graph for this function:

◆ getDescription()

ilMDRights::getDescription ( )

Definition at line 108 of file class.ilMDRights.php.

References $description.

Referenced by __getFields(), and toXML().

108  : string
109  {
110  return $this->description;
111  }
string $description
+ Here is the caller graph for this function:

◆ getDescriptionLanguage()

ilMDRights::getDescriptionLanguage ( )

Definition at line 118 of file class.ilMDRights.php.

119  {
120  return is_object($this->description_language) ? $this->description_language : null;
121  }

◆ getDescriptionLanguageCode()

ilMDRights::getDescriptionLanguageCode ( )

Definition at line 123 of file class.ilMDRights.php.

Referenced by __getFields(), and toXML().

123  : string
124  {
125  return is_object($this->description_language) ? $this->description_language->getLanguageCode() : '';
126  }
+ Here is the caller graph for this function:

◆ lookupRightsByTypeAndCopyright()

static ilMDRights::lookupRightsByTypeAndCopyright ( array  $a_types,
array  $a_copyright 
)
static
Parameters
string[]$a_types
string[]$a_copyright
Returns
int[]

Definition at line 46 of file class.ilMDRights.php.

References ilMDBase\$db, $DIC, $res, ilDBConstants\FETCHMODE_OBJECT, ilLoggerFactory\getLogger(), ilDBInterface\in(), ILIAS\Repository\int(), and ilDBInterface\query().

Referenced by ilOerHarvester\collect().

46  : array
47  {
48  global $DIC;
49 
50  $db = $DIC->database();
51 
52  $query = 'SELECT rbac_id FROM il_meta_rights ' .
53  'WHERE ' . $db->in('obj_type', $a_types, false, 'text') . ' ' .
54  'AND ' . $db->in('description', $a_copyright, false, 'text');
55  $res = $db->query($query);
56 
57  ilLoggerFactory::getLogger('meta')->info($query);
58 
59  $obj_ids = [];
60  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
61  $obj_ids[] = (int) $row->rbac_id;
62  }
63  return $obj_ids;
64  }
$res
Definition: ltiservices.php:69
static getLogger(string $a_component_id)
Get component logger.
ilDBInterface $db
global $DIC
Definition: feed.php:28
query(string $query)
Run a (read-only) Query on the database.
in(string $field, array $values, bool $negate=false, string $type="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseDescriptionFromImport()

ilMDRights::parseDescriptionFromImport ( string  $a_description)

Definition at line 238 of file class.ilMDRights.php.

References ilMDCopyrightSelectionEntry\createIdentifier(), ilMDCopyrightSelectionEntry\lookupCopyrightFromImport(), and setDescription().

238  : void
239  {
240  $entry_id = ilMDCopyrightSelectionEntry::lookupCopyrightFromImport($a_description);
241  if (!$entry_id) {
242  $this->setDescription($a_description);
243  } else {
245  }
246  }
static lookupCopyrightFromImport(string $copyright_text)
setDescription(string $a_description)
+ Here is the call graph for this function:

◆ read()

ilMDRights::read ( )

Compatibility fix for legacy MD classes for new db tables

Definition at line 190 of file class.ilMDRights.php.

References $res, ilDBConstants\FETCHMODE_OBJECT, ilMDBase\getMetaId(), setCopyrightAndOtherRestrictions(), setCosts(), setDescription(), setDescriptionLanguage(), ilMDBase\setObjId(), ilMDBase\setObjType(), and ilMDBase\setRBACId().

190  : bool
191  {
192  if ($this->getMetaId()) {
193  $query = "SELECT * FROM il_meta_rights " .
194  "WHERE meta_rights_id = " . $this->db->quote($this->getMetaId(), 'integer');
195 
196  $res = $this->db->query($query);
197  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
201  if (key_exists($row->costs ?? '', self::YES_NO_TRANSLATION)) {
202  $row->costs = self::YES_NO_TRANSLATION[$row->costs ?? ''];
203  }
204  if (key_exists($row->cpr_and_or ?? '', self::YES_NO_TRANSLATION)) {
205  $row->cpr_and_or = self::YES_NO_TRANSLATION[$row->cpr_and_or ?? ''];
206  }
207 
208  $this->setRBACId((int) $row->rbac_id);
209  $this->setObjId((int) $row->obj_id);
210  $this->setObjType($row->obj_type ?? '');
211  $this->setDescription($row->description ?? '');
212  $this->setDescriptionLanguage(new ilMDLanguageItem($row->description_language ?? ''));
213  $this->setCosts($row->costs ?? '');
214  $this->setCopyrightAndOtherRestrictions($row->cpr_and_or ?? '');
215  }
216  return true;
217  }
218  return false;
219  }
$res
Definition: ltiservices.php:69
setRBACId(int $a_id)
setObjId(int $a_id)
setDescriptionLanguage(ilMDLanguageItem $lng_obj)
setCopyrightAndOtherRestrictions(string $a_caor)
setDescription(string $a_description)
setCosts(string $a_costs)
setObjType(string $a_type)
+ Here is the call graph for this function:

◆ save()

ilMDRights::save ( )

Definition at line 128 of file class.ilMDRights.php.

References __getFields(), ilMDBase\getMetaId(), and ilMDBase\setMetaId().

128  : int
129  {
130  $fields = $this->__getFields();
131  $fields['meta_rights_id'] = array('integer', $next_id = $this->db->nextId('il_meta_rights'));
132 
133  if ($this->db->insert('il_meta_rights', $fields)) {
134  $this->setMetaId($next_id);
135  return $this->getMetaId();
136  }
137  return 0;
138  }
setMetaId(int $a_meta_id, bool $a_read_data=true)
+ Here is the call graph for this function:

◆ setCopyrightAndOtherRestrictions()

ilMDRights::setCopyrightAndOtherRestrictions ( string  $a_caor)

Definition at line 85 of file class.ilMDRights.php.

Referenced by read().

85  : bool
86  {
87  switch ($a_caor) {
88  case 'Yes':
89  case 'No':
90  $this->caor = $a_caor;
91  return true;
92 
93  default:
94  return false;
95  }
96  }
+ Here is the caller graph for this function:

◆ setCosts()

ilMDRights::setCosts ( string  $a_costs)

Definition at line 67 of file class.ilMDRights.php.

Referenced by read().

67  : bool
68  {
69  switch ($a_costs) {
70  case 'Yes':
71  case 'No':
72  $this->costs = $a_costs;
73  return true;
74 
75  default:
76  return false;
77  }
78  }
+ Here is the caller graph for this function:

◆ setDescription()

ilMDRights::setDescription ( string  $a_description)

Definition at line 103 of file class.ilMDRights.php.

Referenced by parseDescriptionFromImport(), and read().

103  : void
104  {
105  $this->description = $a_description;
106  }
+ Here is the caller graph for this function:

◆ setDescriptionLanguage()

ilMDRights::setDescriptionLanguage ( ilMDLanguageItem  $lng_obj)

Definition at line 113 of file class.ilMDRights.php.

Referenced by read().

113  : void
114  {
115  $this->description_language = $lng_obj;
116  }
+ Here is the caller graph for this function:

◆ toXML()

ilMDRights::toXML ( ilXmlWriter  $writer)

Definition at line 221 of file class.ilMDRights.php.

References ilMDCopyrightSelectionEntry\_lookupCopyrightForExport(), getCopyrightAndOtherRestrictions(), getCosts(), getDescription(), getDescriptionLanguageCode(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

221  : void
222  {
223  $writer->xmlStartTag('Rights', array(
224  'Cost' => $this->getCosts() ?: 'No',
225  'CopyrightAndOtherRestrictions' => $this->getCopyrightAndOtherRestrictions() ?: 'No'
226  ));
227 
228  $writer->xmlElement(
229  'Description',
230  [
231  'Language' => $this->getDescriptionLanguageCode() ?: 'en'
232  ],
234  );
235  $writer->xmlEndTag('Rights');
236  }
static _lookupCopyrightForExport(string $a_cp_string)
xmlEndTag(string $tag)
Writes an endtag.
getCopyrightAndOtherRestrictions()
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

◆ update()

ilMDRights::update ( )

Definition at line 140 of file class.ilMDRights.php.

References __getFields(), and ilMDBase\getMetaId().

140  : bool
141  {
142  return $this->getMetaId() && $this->db->update(
143  'il_meta_rights',
144  $this->__getFields(),
145  array("meta_rights_id" => array('integer', $this->getMetaId()))
146  );
147  }
+ Here is the call graph for this function:

Field Documentation

◆ $caor

string ilMDRights::$caor = ''
private

Definition at line 37 of file class.ilMDRights.php.

Referenced by getCopyrightAndOtherRestrictions().

◆ $costs

const string ilMDRights::$costs = ''
private

Definition at line 36 of file class.ilMDRights.php.

Referenced by getCosts().

◆ $description

string ilMDRights::$description = ''
private

Definition at line 38 of file class.ilMDRights.php.

Referenced by getDescription().

◆ $description_language

ilMDLanguageItem ilMDRights::$description_language = null
private

Definition at line 39 of file class.ilMDRights.php.

◆ YES_NO_TRANSLATION

const ilMDRights::YES_NO_TRANSLATION
private
Initial value:
= [
'yes' => 'Yes'

Compatibility fix for legacy MD classes for new db tables.

Definition at line 31 of file class.ilMDRights.php.


The documentation for this class was generated from the following file: