ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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

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 28 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 168 of file class.ilMDContribute.php.

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

Referenced by save(), and update().

168  : array
169  {
173  $role = (string) array_search(
174  $this->getRole(),
175  self::ROLE_TRANSLATION
176  );
177 
178  return array(
179  'rbac_id' => array('integer', $this->getRBACId()),
180  'obj_id' => array('integer', $this->getObjId()),
181  'obj_type' => array('text', $this->getObjType()),
182  'parent_type' => array('text', $this->getParentType()),
183  'parent_id' => array('integer', $this->getParentId()),
184  'role' => array('text', $role),
185  'c_date' => array('text', $this->getDate())
186  );
187  }
+ 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 242 of file class.ilMDContribute.php.

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

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

242  : array
243  {
244  global $DIC;
245 
246  $ilDB = $DIC['ilDB'];
247 
248  $query = "SELECT meta_contribute_id FROM il_meta_contribute " .
249  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
250  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
251  "AND parent_id = " . $ilDB->quote($a_parent_id, 'integer') . " " .
252  "AND parent_type = " . $ilDB->quote($a_parent_type, 'text');
253 
254  $res = $ilDB->query($query);
255  $ids = [];
256  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
257  $ids[] = (int) $row->meta_contribute_id;
258  }
259  return $ids;
260  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ 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 265 of file class.ilMDContribute.php.

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

Referenced by ilMDUtils\_fillHTMLMetaTags().

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

◆ addEntity()

ilMDContribute::addEntity ( )

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

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

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

◆ delete()

ilMDContribute::delete ( )

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

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

149  : bool
150  {
151  if ($this->getMetaId()) {
152  $query = "DELETE FROM il_meta_contribute " .
153  "WHERE meta_contribute_id = " . $this->db->quote($this->getMetaId(), 'integer');
154  $res = $this->db->manipulate($query);
155 
156  foreach ($this->getEntityIds() as $id) {
157  $ent = $this->getEntity($id);
158  $ent->delete();
159  }
160  return true;
161  }
162  return false;
163  }
$res
Definition: ltiservices.php:66
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 123 of file class.ilMDContribute.php.

References $date.

Referenced by __getFields(), and toXML().

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

◆ getEntity()

ilMDContribute::getEntity ( int  $a_entity_id)

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

References null.

Referenced by delete(), and toXML().

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

◆ getEntityIds()

ilMDContribute::getEntityIds ( )
Returns
int[]

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

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

Referenced by delete(), and toXML().

59  : array
60  {
61  return ilMDEntity::_getIds($this->getRBACId(), $this->getObjId(), (int) $this->getMetaId(), 'meta_contribute');
62  }
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 113 of file class.ilMDContribute.php.

References $role.

Referenced by __getFields(), and toXML().

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

◆ read()

ilMDContribute::read ( )

Compatibility fix for legacy MD classes for new db tables

Definition at line 189 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().

189  : bool
190  {
191  if ($this->getMetaId()) {
192  $query = "SELECT * FROM il_meta_contribute " .
193  "WHERE meta_contribute_id = " . $this->db->quote($this->getMetaId(), 'integer');
194 
195  $res = $this->db->query($query);
196  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
200  if (key_exists($row->role ?? '', self::ROLE_TRANSLATION)) {
201  $row->role = self::ROLE_TRANSLATION[$row->role ?? ''];
202  }
203 
204  $this->setRBACId((int) $row->rbac_id);
205  $this->setObjId((int) $row->obj_id);
206  $this->setObjType($row->obj_type ?? '');
207  $this->setParentId((int) $row->parent_id);
208  $this->setParentType($row->parent_type ?? '');
209  $this->setRole($row->role ?? '');
210  $this->setDate($row->c_date ?? '');
211  }
212  }
213  return true;
214  }
$res
Definition: ltiservices.php:66
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 128 of file class.ilMDContribute.php.

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

128  : int
129  {
130  $fields = $this->__getFields();
131  $fields['meta_contribute_id'] = array('integer', $next_id = $this->db->nextId('il_meta_contribute'));
132 
133  if ($this->db->insert('il_meta_contribute', $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:

◆ setDate()

ilMDContribute::setDate ( string  $a_date)

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

Referenced by read().

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

◆ setRole()

ilMDContribute::setRole ( string  $a_role)

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

Referenced by read().

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

◆ toXML()

ilMDContribute::toXML ( ilXmlWriter  $writer)

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

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

216  : void
217  {
218  $writer->xmlStartTag('Contribute', array(
219  'Role' => $this->getRole() ?: 'Author'
220  ));
221 
222  // Entities
223  $entities = $this->getEntityIds();
224  foreach ($entities as $id) {
225  $ent = $this->getEntity($id);
226  $ent->toXML($writer);
227  }
228  if (!count($entities)) {
229  $ent = new ilMDEntity($this->getRBACId(), $this->getObjId());
230  $ent->toXML($writer);
231  }
232 
233  $writer->xmlElement('Date', null, $this->getDate());
234  $writer->xmlEndTag('Contribute');
235  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 140 of file class.ilMDContribute.php.

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

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

Field Documentation

◆ $date

const string ilMDContribute::$date = ''
private

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

Referenced by getDate().

◆ $role

string ilMDContribute::$role = ''
private

Definition at line 54 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 33 of file class.ilMDContribute.php.


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