ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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, $tmp_flag=false)
 constructor More...
 
 getFileForStep ($a_version)
 Get db update file name for db step. More...
 
 initStep ($i)
 Init Step. More...
 
 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
 

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 getCurrentVersion(), ilPlugin\getDBUpdateScriptName(), getFileForStep(), ilPluginSlot\lookupSlotName(), ilDBUpdate\readDBUpdateFile(), ilDBUpdate\readFileVersion(), and ilDBUpdate\readLastUpdateFile().

19  {
20  $this->db_prefix = $a_db_prefix;
21 
22  // workaround to allow setup migration
23  if ($a_db_handler)
24  {
25  $this->db = $a_db_handler;
26 
27  if ($tmp_flag)
28  {
29  $this->PATH = "./";
30  }
31  else
32  {
33  $this->PATH = "../";
34  }
35  }
36  else
37  {
38  global $mySetup;
39  $this->db = $mySetup->db;
40  $this->PATH = "./";
41  }
42 
43  $this->ctype = $a_ctype;
44  $this->cname = $a_cname;
45  $this->slot_id = $a_slot_id;
46  $this->pname = $a_pname;
47 
48  include_once("./Services/Component/classes/class.ilPluginSlot.php");
49  $this->slot_name = ilPluginSlot::lookupSlotName($this->ctype,
50  $this->cname, $this->slot_id);
51 
52  $this->getCurrentVersion();
53 
54  // get update file for current version
55  $updatefile = $this->getFileForStep($this->currentVersion + 1);
56 
57  $this->current_file = $updatefile;
58  $this->DB_UPDATE_FILE = $this->PATH.
59  ilPlugin::getDBUpdateScriptName($this->ctype, $this->cname,
60  $this->slot_name, $this->pname);
61 
62  //
63  // NOTE: multiple update files for plugins are not supported yet
64  //
65  $this->LAST_UPDATE_FILE = $this->PATH.
66  ilPlugin::getDBUpdateScriptName($this->ctype, $this->cname,
67  $this->slot_name, $this->pname);
68 
69  $this->readDBUpdateFile();
70  $this->readLastUpdateFile();
71  $this->readFileVersion();
72  }
static lookupSlotName($a_ctype, $a_cname, $a_slot_id)
Lookup slot name for component and slot id.
static getDBUpdateScriptName($a_ctype, $a_cname, $a_slot_name, $a_pname)
Get DB update script filename (full path)
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 87 of file class.ilPluginDBUpdate.php.

88  {
89  // this may be used in setup!?
90 // $this->db->disconnect();
91  }

◆ checkQuery()

ilPluginDBUpdate::checkQuery (   $q)

This is a very simple check.

Could be done better.

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

136  {
137  if ((is_int(stripos($q, "create table")) || is_int(stripos($q, "alter table")) ||
138  is_int(stripos($q, "drop table")))
139  && !is_int(stripos($q, $this->db_prefix)))
140  {
141  return "Plugin may only create or alter tables that use prefix ".
142  $this->db_prefix;
143  }
144  else
145  {
146  return true;
147  }
148  }

◆ getCurrentVersion()

ilPluginDBUpdate::getCurrentVersion ( )

Get current DB version.

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

References ilDBUpdate\$currentVersion.

Referenced by __construct().

97  {
98  $q = "SELECT db_version FROM il_plugin ".
99  " WHERE component_type = ".$this->db->quote($this->ctype, "text").
100  " AND component_name = ".$this->db->quote($this->cname, "text").
101  " AND slot_id = ".$this->db->quote($this->slot_id, "text").
102  " AND name = ".$this->db->quote($this->pname, "text");
103  $set = $this->db->query($q);
104  $rec = $this->db->fetchAssoc($set);
105 
106  $this->currentVersion = (int) $rec["db_version"];
107 
108  return $this->currentVersion;
109  }
+ Here is the caller graph for this function:

◆ getFileForStep()

ilPluginDBUpdate::getFileForStep (   $a_version)

Get db update file name for db step.

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

Referenced by __construct().

78  {
79  return "dbupdate.php";
80  }
+ Here is the caller graph for this function:

◆ loadXMLInfo()

ilPluginDBUpdate::loadXMLInfo ( )

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

127  {
128  // to do: reload control structure information for plugin
129  return true;
130  }

◆ setCurrentVersion()

ilPluginDBUpdate::setCurrentVersion (   $a_version)

Set current DB version.

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

115  {
116  $q = "UPDATE il_plugin SET db_version = ".$this->db->quote((int) $a_version, "integer").
117  " WHERE component_type = ".$this->db->quote($this->ctype, "text").
118  " AND component_name = ".$this->db->quote($this->cname, "text").
119  " AND slot_id = ".$this->db->quote($this->slot_id, "text").
120  " AND name = ".$this->db->quote($this->pname, "text");
121  $this->db->manipulate($q);
122  $this->currentVersion = $a_version;
123  return true;
124  }

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