ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilPluginDBUpdate Class Reference

Database Update class. More...

+ Inheritance diagram for ilPluginDBUpdate:
+ Collaboration diagram for ilPluginDBUpdate:

Public Member Functions

 __construct ( $a_ctype, $a_cname, $a_slot_id, $a_pname, $a_db_handler, $tmp_flag, $a_db_prefix)
 constructor More...
 
 getFileForStep ($a_version)
 Get db update file name for db step. More...
 
 _DBUpdate ()
 destructor More...
 
 getCurrentVersion ()
 Get current DB version. More...
 
 setCurrentVersion ($a_version)
 Set current DB version. More...
 
 loadXMLInfo ()
 
 checkQuery ($q)
 This is a very simple check. More...
 
- Public Member Functions inherited from ilDBUpdate
 __construct ($a_db_handler=0, $client_ini=null)
 ilDBUpdate constructor. More...
 
 getFileForStep ($a_version)
 Get db update file name for db step. More...
 
 initStep ($i)
 
 readDBUpdateFile ()
 
 readLastUpdateFile ()
 
 getCurrentVersion ()
 
 setCurrentVersion ($a_version)
 
 setRunningStatus ($a_nr)
 Set running status for a step. More...
 
 getRunningStatus ()
 Get running status. More...
 
 clearRunningStatus ()
 Clear running status. More...
 
 readFileVersion ()
 
 getFileVersion ()
 Get Version of file. More...
 
 execQuery ($db, $str)
 execute a query More...
 
 checkQuery ($q)
 check query More...
 
 applyUpdate ($a_break=0)
 Apply update. More...
 
 loadXMLInfo ()
 
 applyUpdateNr ($nr, $hotfix=false, $custom_update=false)
 apply an update More...
 
 getDBVersionStatus ()
 
 getTables ()
 
 getTableStatus ($table)
 
 getHotfixCurrentVersion ()
 Get current hotfix version. More...
 
 setHotfixCurrentVersion ($a_version)
 Set current hotfix version. More...
 
 getHotfixFileVersion ()
 Get current hotfix version. More...
 
 readHotfixFileVersion ($a_file_content)
 Set current hotfix version. More...
 
 readHotfixInfo ($a_force=false)
 Get status of hotfix file. More...
 
 hotfixAvailable ()
 Get status of hotfix file. More...
 
 applyHotfix ()
 Apply hotfix. More...
 
 getCustomUpdatesCurrentVersion ()
 
 setCustomUpdatesCurrentVersion ($a_version)
 
 getCustomUpdatesFileVersion ()
 
 readCustomUpdatesFileVersion ($a_file_content)
 
 readCustomUpdatesInfo ($a_force=false)
 
 customUpdatesAvailable ()
 
 applyCustomUpdates ()
 
 getUpdateSteps ($a_break=0)
 Get update steps as string (for presentation) More...
 
 getHotfixSteps ()
 Get hotfix steps. More...
 
 getUpdateStepNr ($nr, $hotfix=false, $custom_update=false)
 Get single update step for presentation. More...
 

Additional Inherited Members

- Data Fields inherited from ilDBUpdate
 $DB_UPDATE_FILE
 db update file More...
 
 $currentVersion
 
 $fileVersion
 
 $updateMsg
 

Detailed Description

Database Update class.

Author
Peter Gabriel pgabr.nosp@m.iel@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
Id
class.ilDBUpdate.php 15875 2008-02-03 13:56:32Z akill

Definition at line 12 of file class.ilPluginDBUpdate.php.

Constructor & Destructor Documentation

◆ __construct()

ilPluginDBUpdate::__construct (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_pname,
  $a_db_handler,
  $tmp_flag,
  $a_db_prefix 
)

constructor

Definition at line 17 of file class.ilPluginDBUpdate.php.

References $DIC, getCurrentVersion(), ilPlugin\getDBUpdateScriptName(), getFileForStep(), ilPluginSlot\lookupSlotName(), PATH, ilDBUpdate\readDBUpdateFile(), ilDBUpdate\readFileVersion(), and ilDBUpdate\readLastUpdateFile().

25  {
26  $this->db_prefix = $a_db_prefix;
27 
28  // workaround to allow setup migration
29  if ($a_db_handler) {
30  $this->db = $a_db_handler;
31 
32  if ($tmp_flag) {
33  $this->PATH = "./";
34  } else {
35  $this->PATH = "../";
36  }
37  } else {
38  global $DIC;
39  $mySetup = $DIC['mySetup'];
40  $this->db = $mySetup->db;
41  $this->PATH = "./";
42  }
43 
44  $this->ctype = $a_ctype;
45  $this->cname = $a_cname;
46  $this->slot_id = $a_slot_id;
47  $this->pname = $a_pname;
48 
49  include_once("./Services/Component/classes/class.ilPluginSlot.php");
50  $this->slot_name = ilPluginSlot::lookupSlotName(
51  $this->ctype,
52  $this->cname,
53  $this->slot_id
54  );
55 
56  $this->getCurrentVersion();
57 
58  // get update file for current version
59  $updatefile = $this->getFileForStep($this->currentVersion + 1);
60 
61  $this->current_file = $updatefile;
62  $this->DB_UPDATE_FILE = $this->PATH .
64  $this->ctype,
65  $this->cname,
66  $this->slot_name,
67  $this->pname
68  );
69 
70  //
71  // NOTE: multiple update files for plugins are not supported yet
72  //
73  $this->LAST_UPDATE_FILE = $this->PATH .
75  $this->ctype,
76  $this->cname,
77  $this->slot_name,
78  $this->pname
79  );
80 
81  $this->readDBUpdateFile();
82  $this->readLastUpdateFile();
83  $this->readFileVersion();
84  }
global $DIC
Definition: saml.php:7
static getDBUpdateScriptName(string $a_ctype, string $a_cname, string $a_slot_name, string $a_pname)
static lookupSlotName($a_ctype, $a_cname, $a_slot_id)
Lookup slot name for component and slot id.
const PATH
Definition: proxy_ylocal.php:8
getCurrentVersion()
Get current DB version.
getFileForStep($a_version)
Get db update file name for db step.
+ Here is the call graph for this function:

Member Function Documentation

◆ _DBUpdate()

ilPluginDBUpdate::_DBUpdate ( )

destructor

Returns
boolean

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

100  {
101  // this may be used in setup!?
102 // $this->db->disconnect();
103  }

◆ checkQuery()

ilPluginDBUpdate::checkQuery (   $q)

This is a very simple check.

Could be done better.

Definition at line 147 of file class.ilPluginDBUpdate.php.

148  {
149  if ((is_int(stripos($q, "create table")) || is_int(stripos($q, "alter table")) ||
150  is_int(stripos($q, "drop table")))
151  && !is_int(stripos($q, $this->db_prefix))) {
152  return "Plugin may only create or alter tables that use prefix " .
153  $this->db_prefix;
154  } else {
155  return true;
156  }
157  }

◆ getCurrentVersion()

ilPluginDBUpdate::getCurrentVersion ( )

Get current DB version.

Definition at line 108 of file class.ilPluginDBUpdate.php.

References ilDBUpdate\$currentVersion.

Referenced by __construct().

109  {
110  $q = "SELECT db_version FROM il_plugin " .
111  " WHERE component_type = " . $this->db->quote($this->ctype, "text") .
112  " AND component_name = " . $this->db->quote($this->cname, "text") .
113  " AND slot_id = " . $this->db->quote($this->slot_id, "text") .
114  " AND name = " . $this->db->quote($this->pname, "text");
115  $set = $this->db->query($q);
116  $rec = $this->db->fetchAssoc($set);
117 
118  $this->currentVersion = (int) $rec["db_version"];
119 
120  return $this->currentVersion;
121  }
+ Here is the caller graph for this function:

◆ getFileForStep()

ilPluginDBUpdate::getFileForStep (   $a_version)

Get db update file name for db step.

Definition at line 89 of file class.ilPluginDBUpdate.php.

Referenced by __construct().

90  {
91  return "dbupdate.php";
92  }
+ Here is the caller graph for this function:

◆ loadXMLInfo()

ilPluginDBUpdate::loadXMLInfo ( )

Definition at line 138 of file class.ilPluginDBUpdate.php.

139  {
140  // to do: reload control structure information for plugin
141  return true;
142  }

◆ setCurrentVersion()

ilPluginDBUpdate::setCurrentVersion (   $a_version)

Set current DB version.

Definition at line 126 of file class.ilPluginDBUpdate.php.

127  {
128  $q = "UPDATE il_plugin SET db_version = " . $this->db->quote((int) $a_version, "integer") .
129  " WHERE component_type = " . $this->db->quote($this->ctype, "text") .
130  " AND component_name = " . $this->db->quote($this->cname, "text") .
131  " AND slot_id = " . $this->db->quote($this->slot_id, "text") .
132  " AND name = " . $this->db->quote($this->pname, "text");
133  $this->db->manipulate($q);
134  $this->currentVersion = $a_version;
135  return true;
136  }

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