ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 28 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 166 of file class.ilMDLifecycle.php.

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

Referenced by save(), and update().

166  : array
167  {
171  $status = (string) array_search(
172  $this->getStatus(),
173  self::STATUS_TRANSLATION
174  );
175 
176  return array(
177  'rbac_id' => array('integer', $this->getRBACId()),
178  'obj_id' => array('integer', $this->getObjId()),
179  'obj_type' => array('text', $this->getObjType()),
180  'lifecycle_status' => array('text', $status),
181  'meta_version' => array('text', $this->getVersion()),
182  'version_language' => array('text', $this->getVersionLanguageCode())
183  );
184  }
+ 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 239 of file class.ilMDLifecycle.php.

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

Referenced by ilMD\getLifecycle().

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

◆ addContribute()

ilMDLifecycle::addContribute ( )

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

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

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

◆ delete()

ilMDLifecycle::delete ( )

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

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

146  : bool
147  {
148  // Delete 'contribute'
149  foreach ($this->getContributeIds() as $id) {
150  $con = $this->getContribute($id);
151  $con->delete();
152  }
153 
154  if ($this->getMetaId()) {
155  $query = "DELETE FROM il_meta_lifecycle " .
156  "WHERE meta_lifecycle_id = " . $this->db->quote($this->getMetaId(), 'integer');
157  $res = $this->db->manipulate($query);
158  return true;
159  }
160  return false;
161  }
$res
Definition: ltiservices.php:66
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 62 of file class.ilMDLifecycle.php.

References null.

Referenced by delete(), and toXML().

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

◆ getContributeIds()

ilMDLifecycle::getContributeIds ( )
Returns
int[]

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

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

Referenced by delete(), and toXML().

57  : array
58  {
59  return ilMDContribute::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_lifecycle');
60  }
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 47 of file class.ilMDLifecycle.php.

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

◆ getStatus()

ilMDLifecycle::getStatus ( )

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

References $status.

Referenced by __getFields(), and toXML().

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

◆ getVersion()

ilMDLifecycle::getVersion ( )

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

References $version.

Referenced by __getFields(), and toXML().

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

◆ getVersionLanguage()

ilMDLifecycle::getVersionLanguage ( )

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

References $version_language.

116  {
118  }
const ilMDLanguageItem $version_language

◆ getVersionLanguageCode()

ilMDLifecycle::getVersionLanguageCode ( )

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

Referenced by __getFields(), and toXML().

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

◆ read()

ilMDLifecycle::read ( )

Compatibility fix for legacy MD classes for new db tables

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

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

186  : bool
187  {
188  if ($this->getMetaId()) {
189  $query = "SELECT * FROM il_meta_lifecycle " .
190  "WHERE meta_lifecycle_id = " . $this->db->quote($this->getMetaId(), 'integer');
191 
192  $res = $this->db->query($query);
193  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
197  if (key_exists($row->lifecycle_status ?? '', self::STATUS_TRANSLATION)) {
198  $row->lifecycle_status = self::STATUS_TRANSLATION[$row->lifecycle_status ?? ''];
199  }
200 
201  $this->setRBACId((int) $row->rbac_id);
202  $this->setObjId((int) $row->obj_id);
203  $this->setObjType($row->obj_type ?? '');
204  $this->setStatus($row->lifecycle_status ?? '');
205  $this->setVersion($row->meta_version ?? '');
206  $this->setVersionLanguage(new ilMDLanguageItem($row->version_language ?? ''));
207  }
208  }
209  return true;
210  }
$res
Definition: ltiservices.php:66
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 125 of file class.ilMDLifecycle.php.

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

125  : int
126  {
127  $fields = $this->__getFields();
128  $fields['meta_lifecycle_id'] = array('integer', $next_id = $this->db->nextId('il_meta_lifecycle'));
129 
130  if ($this->db->insert('il_meta_lifecycle', $fields)) {
131  $this->setMetaId($next_id);
132  return $this->getMetaId();
133  }
134  return 0;
135  }
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 83 of file class.ilMDLifecycle.php.

Referenced by read().

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

◆ setVersion()

ilMDLifecycle::setVersion ( string  $a_version)

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

Referenced by read().

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

◆ setVersionLanguage()

ilMDLifecycle::setVersionLanguage ( ilMDLanguageItem  $lng_obj)

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

Referenced by read().

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

◆ toXML()

ilMDLifecycle::toXML ( ilXmlWriter  $writer)

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

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

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

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

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

Field Documentation

◆ $status

string ilMDLifecycle::$status = ""
private

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

Referenced by getStatus().

◆ $version

string ilMDLifecycle::$version = ""
private

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

Referenced by getVersion().

◆ $version_language

const ilMDLanguageItem ilMDLifecycle::$version_language = null
private

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


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