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

Public Member Functions

 getEntityIds ()
 
 getEntity (int $a_entity_id)
 
 addEntity ()
 
 setRole (string $a_role)
 
 getRole ()
 
 setDate (string $a_date)
 
 getDate ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (ilXmlWriter $writer)
 
- 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 _getIds (int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
 
static _lookupAuthors (int $a_rbac_id, int $a_obj_id, string $a_obj_type)
 

Private Attributes

const ROLE_TRANSLATION
 Compatibility fix for legacy MD classes for new db tables. More...
 
const string $date = ''
 
string $role = ''
 

Additional Inherited Members

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

Detailed Description

Definition at line 27 of file class.ilMDContribute.php.

Member Function Documentation

◆ __getFields()

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

Compatibility fix for legacy MD classes for new db tables

Definition at line 167 of file class.ilMDContribute.php.

References getDate(), ilMDBase\getObjId(), ilMDBase\getObjType(), ilMDBase\getParentId(), ilMDBase\getParentType(), ilMDBase\getRBACId(), and getRole().

Referenced by save(), and update().

167  : array
168  {
172  $role = (string) array_search(
173  $this->getRole(),
174  self::ROLE_TRANSLATION
175  );
176 
177  return array(
178  'rbac_id' => array('integer', $this->getRBACId()),
179  'obj_id' => array('integer', $this->getObjId()),
180  'obj_type' => array('text', $this->getObjType()),
181  'parent_type' => array('text', $this->getParentType()),
182  'parent_id' => array('integer', $this->getParentId()),
183  'role' => array('text', $role),
184  'c_date' => array('text', $this->getDate())
185  );
186  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getIds()

static ilMDContribute::_getIds ( int  $a_rbac_id,
int  $a_obj_id,
int  $a_parent_id,
string  $a_parent_type 
)
static
Returns
int[]

Definition at line 241 of file class.ilMDContribute.php.

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilMDLifecycle\getContributeIds(), and ilMDMetaMetadata\getContributeIds().

241  : array
242  {
243  global $DIC;
244 
245  $ilDB = $DIC['ilDB'];
246 
247  $query = "SELECT meta_contribute_id FROM il_meta_contribute " .
248  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
249  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
250  "AND parent_id = " . $ilDB->quote($a_parent_id, 'integer') . " " .
251  "AND parent_type = " . $ilDB->quote($a_parent_type, 'text');
252 
253  $res = $ilDB->query($query);
254  $ids = [];
255  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
256  $ids[] = (int) $row->meta_contribute_id;
257  }
258  return $ids;
259  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupAuthors()

static ilMDContribute::_lookupAuthors ( int  $a_rbac_id,
int  $a_obj_id,
string  $a_obj_type 
)
static
Returns
string[]

Definition at line 264 of file class.ilMDContribute.php.

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

Referenced by ilMDUtils\_fillHTMLMetaTags().

264  : array
265  {
266  global $DIC;
267 
268  $ilDB = $DIC['ilDB'];
269 
270  // Ask for 'author' later to use indexes
271  $authors = [];
272  $query = "SELECT entity,ent.parent_type,role FROM il_meta_entity ent " .
273  "JOIN il_meta_contribute con ON ent.parent_id = con.meta_contribute_id " .
274  "WHERE ent.rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
275  "AND ent.obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
276  $res = $ilDB->query($query);
277  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
278  if ($row->role === 'Author' && $row->parent_type === 'meta_contribute') {
279  $authors[] = trim($row->entity);
280  }
281  }
282  return $authors;
283  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ addEntity()

ilMDContribute::addEntity ( )

Definition at line 74 of file class.ilMDContribute.php.

References ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

74  : ilMDEntity
75  {
76  $ent = new ilMDEntity($this->getRBACId(), $this->getObjId(), $this->getObjType());
77  $ent->setParentId($this->getMetaId());
78  $ent->setParentType('meta_contribute');
79 
80  return $ent;
81  }
+ Here is the call graph for this function:

◆ delete()

ilMDContribute::delete ( )

Definition at line 148 of file class.ilMDContribute.php.

References $id, $res, getEntity(), getEntityIds(), and ilMDBase\getMetaId().

148  : bool
149  {
150  if ($this->getMetaId()) {
151  $query = "DELETE FROM il_meta_contribute " .
152  "WHERE meta_contribute_id = " . $this->db->quote($this->getMetaId(), 'integer');
153  $res = $this->db->manipulate($query);
154 
155  foreach ($this->getEntityIds() as $id) {
156  $ent = $this->getEntity($id);
157  $ent->delete();
158  }
159  return true;
160  }
161  return false;
162  }
$res
Definition: ltiservices.php:69
getEntity(int $a_entity_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getDate()

ilMDContribute::getDate ( )

Definition at line 122 of file class.ilMDContribute.php.

References $date.

Referenced by __getFields(), and toXML().

122  : string
123  {
124  return $this->date;
125  }
+ Here is the caller graph for this function:

◆ getEntity()

ilMDContribute::getEntity ( int  $a_entity_id)

Definition at line 63 of file class.ilMDContribute.php.

Referenced by delete(), and toXML().

63  : ?ilMDEntity
64  {
65  if (!$a_entity_id) {
66  return null;
67  }
68  $ent = new ilMDEntity();
69  $ent->setMetaId($a_entity_id);
70 
71  return $ent;
72  }
+ Here is the caller graph for this function:

◆ getEntityIds()

ilMDContribute::getEntityIds ( )
Returns
int[]

Definition at line 58 of file class.ilMDContribute.php.

References ilMDEntity\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), and toXML().

58  : array
59  {
60  return ilMDEntity::_getIds($this->getRBACId(), $this->getObjId(), (int) $this->getMetaId(), 'meta_contribute');
61  }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRole()

ilMDContribute::getRole ( )

Definition at line 112 of file class.ilMDContribute.php.

References $role.

Referenced by __getFields(), and toXML().

112  : string
113  {
114  return $this->role;
115  }
+ Here is the caller graph for this function:

◆ read()

ilMDContribute::read ( )

Compatibility fix for legacy MD classes for new db tables

Definition at line 188 of file class.ilMDContribute.php.

References $res, ilDBConstants\FETCHMODE_OBJECT, ilMDBase\getMetaId(), setDate(), ilMDBase\setObjId(), ilMDBase\setObjType(), ilMDBase\setParentId(), ilMDBase\setParentType(), ilMDBase\setRBACId(), and setRole().

188  : bool
189  {
190  if ($this->getMetaId()) {
191  $query = "SELECT * FROM il_meta_contribute " .
192  "WHERE meta_contribute_id = " . $this->db->quote($this->getMetaId(), 'integer');
193 
194  $res = $this->db->query($query);
195  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
199  if (key_exists($row->role ?? '', self::ROLE_TRANSLATION)) {
200  $row->role = self::ROLE_TRANSLATION[$row->role ?? ''];
201  }
202 
203  $this->setRBACId((int) $row->rbac_id);
204  $this->setObjId((int) $row->obj_id);
205  $this->setObjType($row->obj_type ?? '');
206  $this->setParentId((int) $row->parent_id);
207  $this->setParentType($row->parent_type ?? '');
208  $this->setRole($row->role ?? '');
209  $this->setDate($row->c_date ?? '');
210  }
211  }
212  return true;
213  }
$res
Definition: ltiservices.php:69
setRBACId(int $a_id)
setObjId(int $a_id)
setRole(string $a_role)
setDate(string $a_date)
setParentId(int $a_id)
setParentType(string $a_parent_type)
setObjType(string $a_type)
+ Here is the call graph for this function:

◆ save()

ilMDContribute::save ( )

Definition at line 127 of file class.ilMDContribute.php.

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

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

◆ setDate()

ilMDContribute::setDate ( string  $a_date)

Definition at line 117 of file class.ilMDContribute.php.

Referenced by read().

117  : void
118  {
119  $this->date = $a_date;
120  }
+ Here is the caller graph for this function:

◆ setRole()

ilMDContribute::setRole ( string  $a_role)

Definition at line 84 of file class.ilMDContribute.php.

Referenced by read().

84  : bool
85  {
86  switch ($a_role) {
87  case 'Author':
88  case 'Publisher':
89  case 'Unknown':
90  case 'Initiator':
91  case 'Terminator':
92  case 'Editor':
93  case 'GraphicalDesigner':
94  case 'TechnicalImplementer':
95  case 'ContentProvider':
96  case 'TechnicalValidator':
97  case 'EducationalValidator':
98  case 'ScriptWriter':
99  case 'InstructionalDesigner':
100  case 'SubjectMatterExpert':
101  case 'Creator':
102  case 'Validator':
103  case 'PointOfContact':
104  $this->role = $a_role;
105  return true;
106 
107  default:
108  return false;
109  }
110  }
+ Here is the caller graph for this function:

◆ toXML()

ilMDContribute::toXML ( ilXmlWriter  $writer)

Definition at line 215 of file class.ilMDContribute.php.

References $id, getDate(), getEntity(), getEntityIds(), ilMDBase\getObjId(), ilMDBase\getRBACId(), getRole(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

215  : void
216  {
217  $writer->xmlStartTag('Contribute', array(
218  'Role' => $this->getRole() ?: 'Author'
219  ));
220 
221  // Entities
222  $entities = $this->getEntityIds();
223  foreach ($entities as $id) {
224  $ent = $this->getEntity($id);
225  $ent->toXML($writer);
226  }
227  if (!count($entities)) {
228  $ent = new ilMDEntity($this->getRBACId(), $this->getObjId());
229  $ent->toXML($writer);
230  }
231 
232  $writer->xmlElement('Date', null, $this->getDate());
233  $writer->xmlEndTag('Contribute');
234  }
xmlEndTag(string $tag)
Writes an endtag.
getEntity(int $a_entity_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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()

ilMDContribute::update ( )

Definition at line 139 of file class.ilMDContribute.php.

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

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

Field Documentation

◆ $date

const string ilMDContribute::$date = ''
private

Definition at line 52 of file class.ilMDContribute.php.

Referenced by getDate().

◆ $role

string ilMDContribute::$role = ''
private

Definition at line 53 of file class.ilMDContribute.php.

Referenced by getRole().

◆ ROLE_TRANSLATION

const ilMDContribute::ROLE_TRANSLATION
private
Initial value:
= [
'author' => 'Author'

Compatibility fix for legacy MD classes for new db tables.

Definition at line 32 of file class.ilMDContribute.php.


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