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

Public Member Functions

 getPossibleSubelements ()
 
 getContributeIds ()
 
 getContribute (int $a_contribute_id)
 
 addContribute ()
 
 setStatus (string $a_status)
 
 getStatus ()
 
 setVersion (string $a_version)
 
 getVersion ()
 
 setVersionLanguage (ilMDLanguageItem $lng_obj)
 
 getVersionLanguage ()
 
 getVersionLanguageCode ()
 
 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 _getId (int $a_rbac_id, int $a_obj_id)
 

Private Attributes

const STATUS_TRANSLATION
 Compatibility fix for legacy MD classes for new db tables. More...
 
const ilMDLanguageItem $version_language = null
 
string $version = ""
 
string $status = ""
 

Additional Inherited Members

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

Detailed Description

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

Member Function Documentation

◆ __getFields()

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

Compatibility fix for legacy MD classes for new db tables

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

References ilMDBase\getObjId(), ilMDBase\getObjType(), ilMDBase\getRBACId(), getStatus(), getVersion(), and getVersionLanguageCode().

Referenced by save(), and update().

165  : array
166  {
170  $status = (string) array_search(
171  $this->getStatus(),
172  self::STATUS_TRANSLATION
173  );
174 
175  return array(
176  'rbac_id' => array('integer', $this->getRBACId()),
177  'obj_id' => array('integer', $this->getObjId()),
178  'obj_type' => array('text', $this->getObjType()),
179  'lifecycle_status' => array('text', $status),
180  'meta_version' => array('text', $this->getVersion()),
181  'version_language' => array('text', $this->getVersionLanguageCode())
182  );
183  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getId()

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

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

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

Referenced by ilMD\getLifecycle().

238  : int
239  {
240  global $DIC;
241 
242  $ilDB = $DIC->database();
243 
244  $query = "SELECT meta_lifecycle_id FROM il_meta_lifecycle " .
245  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
246  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
247 
248  $res = $ilDB->query($query);
249  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
250  return (int) $row->meta_lifecycle_id;
251  }
252  return 0;
253  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ addContribute()

ilMDLifecycle::addContribute ( )

Definition at line 72 of file class.ilMDLifecycle.php.

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

73  {
74  $con = new ilMDContribute($this->getRBACId(), $this->getObjId(), $this->getObjType());
75  $con->setParentId($this->getMetaId());
76  $con->setParentType('meta_lifecycle');
77 
78  return $con;
79  }
+ Here is the call graph for this function:

◆ delete()

ilMDLifecycle::delete ( )

Definition at line 145 of file class.ilMDLifecycle.php.

References $id, $res, getContribute(), getContributeIds(), and ilMDBase\getMetaId().

145  : bool
146  {
147  // Delete 'contribute'
148  foreach ($this->getContributeIds() as $id) {
149  $con = $this->getContribute($id);
150  $con->delete();
151  }
152 
153  if ($this->getMetaId()) {
154  $query = "DELETE FROM il_meta_lifecycle " .
155  "WHERE meta_lifecycle_id = " . $this->db->quote($this->getMetaId(), 'integer');
156  $res = $this->db->manipulate($query);
157  return true;
158  }
159  return false;
160  }
$res
Definition: ltiservices.php:69
getContribute(int $a_contribute_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getContribute()

ilMDLifecycle::getContribute ( int  $a_contribute_id)

Definition at line 61 of file class.ilMDLifecycle.php.

Referenced by delete(), and toXML().

62  {
63  if (!$a_contribute_id) {
64  return null;
65  }
66  $con = new ilMDContribute();
67  $con->setMetaId($a_contribute_id);
68 
69  return $con;
70  }
+ Here is the caller graph for this function:

◆ getContributeIds()

ilMDLifecycle::getContributeIds ( )
Returns
int[]

Definition at line 56 of file class.ilMDLifecycle.php.

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

Referenced by delete(), and toXML().

56  : array
57  {
58  return ilMDContribute::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_lifecycle');
59  }
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:

◆ getPossibleSubelements()

ilMDLifecycle::getPossibleSubelements ( )
Returns
array<string, string>

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

46  : array
47  {
48  $subs['Contribute'] = 'meta_contribute';
49 
50  return $subs;
51  }

◆ getStatus()

ilMDLifecycle::getStatus ( )

Definition at line 94 of file class.ilMDLifecycle.php.

References $status.

Referenced by __getFields(), and toXML().

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

◆ getVersion()

ilMDLifecycle::getVersion ( )

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

References $version.

Referenced by __getFields(), and toXML().

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

◆ getVersionLanguage()

ilMDLifecycle::getVersionLanguage ( )

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

References $version_language.

115  {
117  }
const ilMDLanguageItem $version_language

◆ getVersionLanguageCode()

ilMDLifecycle::getVersionLanguageCode ( )

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

Referenced by __getFields(), and toXML().

119  : string
120  {
121  return is_object($this->version_language) ? $this->version_language->getLanguageCode() : '';
122  }
+ Here is the caller graph for this function:

◆ read()

ilMDLifecycle::read ( )

Compatibility fix for legacy MD classes for new db tables

Definition at line 185 of file class.ilMDLifecycle.php.

References $res, ilDBConstants\FETCHMODE_OBJECT, ilMDBase\getMetaId(), ilMDBase\setObjId(), ilMDBase\setObjType(), ilMDBase\setRBACId(), setStatus(), setVersion(), and setVersionLanguage().

185  : bool
186  {
187  if ($this->getMetaId()) {
188  $query = "SELECT * FROM il_meta_lifecycle " .
189  "WHERE meta_lifecycle_id = " . $this->db->quote($this->getMetaId(), 'integer');
190 
191  $res = $this->db->query($query);
192  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
196  if (key_exists($row->lifecycle_status ?? '', self::STATUS_TRANSLATION)) {
197  $row->lifecycle_status = self::STATUS_TRANSLATION[$row->lifecycle_status ?? ''];
198  }
199 
200  $this->setRBACId((int) $row->rbac_id);
201  $this->setObjId((int) $row->obj_id);
202  $this->setObjType($row->obj_type ?? '');
203  $this->setStatus($row->lifecycle_status ?? '');
204  $this->setVersion($row->meta_version ?? '');
205  $this->setVersionLanguage(new ilMDLanguageItem($row->version_language ?? ''));
206  }
207  }
208  return true;
209  }
$res
Definition: ltiservices.php:69
setVersion(string $a_version)
setVersionLanguage(ilMDLanguageItem $lng_obj)
setRBACId(int $a_id)
setObjId(int $a_id)
setStatus(string $a_status)
setObjType(string $a_type)
+ Here is the call graph for this function:

◆ save()

ilMDLifecycle::save ( )

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

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

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

◆ setStatus()

ilMDLifecycle::setStatus ( string  $a_status)

Definition at line 82 of file class.ilMDLifecycle.php.

Referenced by read().

82  : void
83  {
84  switch ($a_status) {
85  case 'Draft':
86  case 'Final':
87  case 'Revised':
88  case 'Unavailable':
89  $this->status = $a_status;
90  break;
91  }
92  }
+ Here is the caller graph for this function:

◆ setVersion()

ilMDLifecycle::setVersion ( string  $a_version)

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

Referenced by read().

99  : void
100  {
101  $this->version = $a_version;
102  }
+ Here is the caller graph for this function:

◆ setVersionLanguage()

ilMDLifecycle::setVersionLanguage ( ilMDLanguageItem  $lng_obj)

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

Referenced by read().

109  : void
110  {
111  $this->version_language = $lng_obj;
112  }
+ Here is the caller graph for this function:

◆ toXML()

ilMDLifecycle::toXML ( ilXmlWriter  $writer)

Definition at line 211 of file class.ilMDLifecycle.php.

References $id, getContribute(), getContributeIds(), ilMDBase\getObjId(), ilMDBase\getRBACId(), getStatus(), getVersion(), getVersionLanguageCode(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

211  : void
212  {
213  $writer->xmlStartTag('Lifecycle', array(
214  'Status' => $this->getStatus() ?: 'Draft'
215  ));
216  $writer->xmlElement(
217  'Version',
218  array(
219  'Language' => $this->getVersionLanguageCode() ?: 'en'
220  ),
221  $this->getVersion()
222  );
223 
224  // contribute
225  $contributes = $this->getContributeIds();
226  foreach ($contributes as $id) {
227  $con = $this->getContribute($id);
228  $con->toXML($writer);
229  }
230  if (!count($contributes)) {
231  $con = new ilMDContribute($this->getRBACId(), $this->getObjId());
232  $con->toXML($writer);
233  }
234  $writer->xmlEndTag('Lifecycle');
235  }
getContribute(int $a_contribute_id)
xmlEndTag(string $tag)
Writes an endtag.
$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()

ilMDLifecycle::update ( )

Definition at line 136 of file class.ilMDLifecycle.php.

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

136  : bool
137  {
138  return $this->getMetaId() && $this->db->update(
139  'il_meta_lifecycle',
140  $this->__getFields(),
141  array("meta_lifecycle_id" => array('integer', $this->getMetaId()))
142  );
143  }
+ Here is the call graph for this function:

Field Documentation

◆ $status

string ilMDLifecycle::$status = ""
private

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

Referenced by getStatus().

◆ $version

string ilMDLifecycle::$version = ""
private

Definition at line 40 of file class.ilMDLifecycle.php.

Referenced by getVersion().

◆ $version_language

const ilMDLanguageItem ilMDLifecycle::$version_language = null
private

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

Referenced by getVersionLanguage().

◆ STATUS_TRANSLATION

const ilMDLifecycle::STATUS_TRANSLATION
private
Initial value:
= [
'draft' => 'Draft'

Compatibility fix for legacy MD classes for new db tables.

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


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