ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 27 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 166 of file class.ilMDRights.php.

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

Referenced by save(), and update().

166  : array
167  {
171  $costs = (string) array_search(
172  $this->getCosts(),
173  self::YES_NO_TRANSLATION
174  );
175  $cpr_and_or = (string) array_search(
177  self::YES_NO_TRANSLATION
178  );
179 
180  return array(
181  'rbac_id' => array('integer', $this->getRBACId()),
182  'obj_id' => array('integer', $this->getObjId()),
183  'obj_type' => array('text', $this->getObjType()),
184  'costs' => array('text', $costs),
185  'cpr_and_or' => array('text', $cpr_and_or),
186  'description' => array('text', $this->getDescription()),
187  'description_language' => array('text', $this->getDescriptionLanguageCode())
188  );
189  }
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 268 of file class.ilMDRights.php.

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

Referenced by ilMD\getRights().

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

◆ _lookupDescription()

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

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

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

249  : string
250  {
251  global $DIC;
252 
253  $ilDB = $DIC->database();
254 
255  $query = "SELECT description FROM il_meta_rights " .
256  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
257  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
258  $res = $ilDB->query($query);
259  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
260 
261  if (isset($row) && isset($row->description)) {
262  return $row->description;
263  }
264  return '';
265  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22

◆ delete()

ilMDRights::delete ( )

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

References ilMDBase\getMetaId().

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

◆ getCopyrightAndOtherRestrictions()

ilMDRights::getCopyrightAndOtherRestrictions ( )

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

References $caor.

Referenced by __getFields(), and toXML().

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

◆ getCosts()

ilMDRights::getCosts ( )

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

References $costs.

Referenced by __getFields(), and toXML().

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

◆ getDescription()

ilMDRights::getDescription ( )

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

References $description.

Referenced by __getFields(), and toXML().

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

◆ getDescriptionLanguage()

ilMDRights::getDescriptionLanguage ( )

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

References null.

120  {
121  return is_object($this->description_language) ? $this->description_language : null;
122  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDescriptionLanguageCode()

ilMDRights::getDescriptionLanguageCode ( )

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

Referenced by __getFields(), and toXML().

124  : string
125  {
126  return is_object($this->description_language) ? $this->description_language->getLanguageCode() : '';
127  }
+ 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 47 of file class.ilMDRights.php.

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

47  : array
48  {
49  global $DIC;
50 
51  $db = $DIC->database();
52 
53  $query = 'SELECT rbac_id FROM il_meta_rights ' .
54  'WHERE ' . $db->in('obj_type', $a_types, false, 'text') . ' ' .
55  'AND ' . $db->in('description', $a_copyright, false, 'text');
56  $res = $db->query($query);
57 
58  ilLoggerFactory::getLogger('meta')->info($query);
59 
60  $obj_ids = [];
61  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
62  $obj_ids[] = (int) $row->rbac_id;
63  }
64  return $obj_ids;
65  }
$res
Definition: ltiservices.php:66
static getLogger(string $a_component_id)
Get component logger.
ilDBInterface $db
global $DIC
Definition: shib_login.php:22
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:

◆ parseDescriptionFromImport()

ilMDRights::parseDescriptionFromImport ( string  $a_description)

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

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

239  : void
240  {
241  $entry_id = ilMDCopyrightSelectionEntry::lookupCopyrightFromImport($a_description);
242  if (!$entry_id) {
243  $this->setDescription($a_description);
244  } else {
246  }
247  }
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 191 of file class.ilMDRights.php.

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

191  : bool
192  {
193  if ($this->getMetaId()) {
194  $query = "SELECT * FROM il_meta_rights " .
195  "WHERE meta_rights_id = " . $this->db->quote($this->getMetaId(), 'integer');
196 
197  $res = $this->db->query($query);
198  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
202  if (key_exists($row->costs ?? '', self::YES_NO_TRANSLATION)) {
203  $row->costs = self::YES_NO_TRANSLATION[$row->costs ?? ''];
204  }
205  if (key_exists($row->cpr_and_or ?? '', self::YES_NO_TRANSLATION)) {
206  $row->cpr_and_or = self::YES_NO_TRANSLATION[$row->cpr_and_or ?? ''];
207  }
208 
209  $this->setRBACId((int) $row->rbac_id);
210  $this->setObjId((int) $row->obj_id);
211  $this->setObjType($row->obj_type ?? '');
212  $this->setDescription($row->description ?? '');
213  $this->setDescriptionLanguage(new ilMDLanguageItem($row->description_language ?? ''));
214  $this->setCosts($row->costs ?? '');
215  $this->setCopyrightAndOtherRestrictions($row->cpr_and_or ?? '');
216  }
217  return true;
218  }
219  return false;
220  }
$res
Definition: ltiservices.php:66
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 129 of file class.ilMDRights.php.

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

129  : int
130  {
131  $fields = $this->__getFields();
132  $fields['meta_rights_id'] = array('integer', $next_id = $this->db->nextId('il_meta_rights'));
133 
134  if ($this->db->insert('il_meta_rights', $fields)) {
135  $this->setMetaId($next_id);
136  return $this->getMetaId();
137  }
138  return 0;
139  }
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 86 of file class.ilMDRights.php.

Referenced by read().

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

◆ setCosts()

ilMDRights::setCosts ( string  $a_costs)

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

Referenced by read().

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

◆ setDescription()

ilMDRights::setDescription ( string  $a_description)

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

Referenced by parseDescriptionFromImport(), and read().

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

◆ setDescriptionLanguage()

ilMDRights::setDescriptionLanguage ( ilMDLanguageItem  $lng_obj)

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

Referenced by read().

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

◆ toXML()

ilMDRights::toXML ( ilXmlWriter  $writer)

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

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

222  : void
223  {
224  $writer->xmlStartTag('Rights', array(
225  'Cost' => $this->getCosts() ?: 'No',
226  'CopyrightAndOtherRestrictions' => $this->getCopyrightAndOtherRestrictions() ?: 'No'
227  ));
228 
229  $writer->xmlElement(
230  'Description',
231  [
232  'Language' => $this->getDescriptionLanguageCode() ?: 'en'
233  ],
235  );
236  $writer->xmlEndTag('Rights');
237  }
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 141 of file class.ilMDRights.php.

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

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

Field Documentation

◆ $caor

string ilMDRights::$caor = ''
private

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

Referenced by getCopyrightAndOtherRestrictions().

◆ $costs

const string ilMDRights::$costs = ''
private

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

Referenced by getCosts().

◆ $description

string ilMDRights::$description = ''
private

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

Referenced by getDescription().

◆ $description_language

ilMDLanguageItem ilMDRights::$description_language = null
private

Definition at line 40 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 32 of file class.ilMDRights.php.


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