ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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

string $date = ''
 
string $role = ''
 

Additional Inherited Members

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

Detailed Description

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

Member Function Documentation

◆ __getFields()

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

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

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

Referenced by save(), and update().

150  : array
151  {
152  return array(
153  'rbac_id' => array('integer', $this->getRBACId()),
154  'obj_id' => array('integer', $this->getObjId()),
155  'obj_type' => array('text', $this->getObjType()),
156  'parent_type' => array('text', $this->getParentType()),
157  'parent_id' => array('integer', $this->getParentId()),
158  'role' => array('text', $this->getRole()),
159  'c_date' => array('text', $this->getDate())
160  );
161  }
+ 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 209 of file class.ilMDContribute.php.

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

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

209  : array
210  {
211  global $DIC;
212 
213  $ilDB = $DIC['ilDB'];
214 
215  $query = "SELECT meta_contribute_id FROM il_meta_contribute " .
216  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
217  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
218  "AND parent_id = " . $ilDB->quote($a_parent_id, 'integer') . " " .
219  "AND parent_type = " . $ilDB->quote($a_parent_type, 'text');
220 
221  $res = $ilDB->query($query);
222  $ids = [];
223  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
224  $ids[] = (int) $row->meta_contribute_id;
225  }
226  return $ids;
227  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ 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 232 of file class.ilMDContribute.php.

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

Referenced by ilMDUtils\_fillHTMLMetaTags().

232  : array
233  {
234  global $DIC;
235 
236  $ilDB = $DIC['ilDB'];
237 
238  // Ask for 'author' later to use indexes
239  $authors = [];
240  $query = "SELECT entity,ent.parent_type,role FROM il_meta_entity ent " .
241  "JOIN il_meta_contribute con ON ent.parent_id = con.meta_contribute_id " .
242  "WHERE ent.rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
243  "AND ent.obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
244  $res = $ilDB->query($query);
245  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
246  if ($row->role === 'Author' && $row->parent_type === 'meta_contribute') {
247  $authors[] = trim($row->entity);
248  }
249  }
250  return $authors;
251  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ addEntity()

ilMDContribute::addEntity ( )

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

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

57  : ilMDEntity
58  {
59  $ent = new ilMDEntity($this->getRBACId(), $this->getObjId(), $this->getObjType());
60  $ent->setParentId($this->getMetaId());
61  $ent->setParentType('meta_contribute');
62 
63  return $ent;
64  }
+ Here is the call graph for this function:

◆ delete()

ilMDContribute::delete ( )

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

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

131  : bool
132  {
133  if ($this->getMetaId()) {
134  $query = "DELETE FROM il_meta_contribute " .
135  "WHERE meta_contribute_id = " . $this->db->quote($this->getMetaId(), 'integer');
136  $res = $this->db->manipulate($query);
137 
138  foreach ($this->getEntityIds() as $id) {
139  $ent = $this->getEntity($id);
140  $ent->delete();
141  }
142  return true;
143  }
144  return false;
145  }
$res
Definition: ltiservices.php:69
getEntity(int $a_entity_id)
$query
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getDate()

ilMDContribute::getDate ( )

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

References $date.

Referenced by __getFields(), and toXML().

105  : string
106  {
107  return $this->date;
108  }
+ Here is the caller graph for this function:

◆ getEntity()

ilMDContribute::getEntity ( int  $a_entity_id)

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

Referenced by delete(), and toXML().

46  : ?ilMDEntity
47  {
48  if (!$a_entity_id) {
49  return null;
50  }
51  $ent = new ilMDEntity();
52  $ent->setMetaId($a_entity_id);
53 
54  return $ent;
55  }
+ Here is the caller graph for this function:

◆ getEntityIds()

ilMDContribute::getEntityIds ( )
Returns
int[]

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

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

Referenced by delete(), and toXML().

41  : array
42  {
43  return ilMDEntity::_getIds($this->getRBACId(), $this->getObjId(), (int) $this->getMetaId(), 'meta_contribute');
44  }
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 95 of file class.ilMDContribute.php.

References $role.

Referenced by __getFields(), and toXML().

95  : string
96  {
97  return $this->role;
98  }
+ Here is the caller graph for this function:

◆ read()

ilMDContribute::read ( )

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

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

163  : bool
164  {
165  if ($this->getMetaId()) {
166  $query = "SELECT * FROM il_meta_contribute " .
167  "WHERE meta_contribute_id = " . $this->db->quote($this->getMetaId(), 'integer');
168 
169  $res = $this->db->query($query);
170  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
171  $this->setRBACId((int) $row->rbac_id);
172  $this->setObjId((int) $row->obj_id);
173  $this->setObjType((string) $row->obj_type);
174  $this->setParentId((int) $row->parent_id);
175  $this->setParentType((string) $row->parent_type);
176  $this->setRole((string) $row->role);
177  $this->setDate((string) $row->c_date);
178  }
179  }
180  return true;
181  }
$res
Definition: ltiservices.php:69
setRBACId(int $a_id)
setObjId(int $a_id)
setRole(string $a_role)
setDate(string $a_date)
$query
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 110 of file class.ilMDContribute.php.

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

110  : int
111  {
112  $fields = $this->__getFields();
113  $fields['meta_contribute_id'] = array('integer', $next_id = $this->db->nextId('il_meta_contribute'));
114 
115  if ($this->db->insert('il_meta_contribute', $fields)) {
116  $this->setMetaId($next_id);
117  return $this->getMetaId();
118  }
119  return 0;
120  }
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 100 of file class.ilMDContribute.php.

Referenced by read().

100  : void
101  {
102  $this->date = $a_date;
103  }
+ Here is the caller graph for this function:

◆ setRole()

ilMDContribute::setRole ( string  $a_role)

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

Referenced by read().

67  : bool
68  {
69  switch ($a_role) {
70  case 'Author':
71  case 'Publisher':
72  case 'Unknown':
73  case 'Initiator':
74  case 'Terminator':
75  case 'Editor':
76  case 'GraphicalDesigner':
77  case 'TechnicalImplementer':
78  case 'ContentProvider':
79  case 'TechnicalValidator':
80  case 'EducationalValidator':
81  case 'ScriptWriter':
82  case 'InstructionalDesigner':
83  case 'SubjectMatterExpert':
84  case 'Creator':
85  case 'Validator':
86  case 'PointOfContact':
87  $this->role = $a_role;
88  return true;
89 
90  default:
91  return false;
92  }
93  }
+ Here is the caller graph for this function:

◆ toXML()

ilMDContribute::toXML ( ilXmlWriter  $writer)

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

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

183  : void
184  {
185  $writer->xmlStartTag('Contribute', array(
186  'Role' => $this->getRole() ?: 'Author'
187  ));
188 
189  // Entities
190  $entities = $this->getEntityIds();
191  foreach ($entities as $id) {
192  $ent = $this->getEntity($id);
193  $ent->toXML($writer);
194  }
195  if (!count($entities)) {
196  $ent = new ilMDEntity($this->getRBACId(), $this->getObjId());
197  $ent->toXML($writer);
198  }
199 
200  $writer->xmlElement('Date', null, $this->getDate());
201  $writer->xmlEndTag('Contribute');
202  }
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 122 of file class.ilMDContribute.php.

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

122  : bool
123  {
124  return $this->getMetaId() && $this->db->update(
125  'il_meta_contribute',
126  $this->__getFields(),
127  array("meta_contribute_id" => array('integer', $this->getMetaId()))
128  );
129  }
+ Here is the call graph for this function:

Field Documentation

◆ $date

string ilMDContribute::$date = ''
private

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

Referenced by getDate().

◆ $role

string ilMDContribute::$role = ''
private

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

Referenced by getRole().


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