ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 10 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 15 of file class.ilPluginDBUpdate.php.

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

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

Member Function Documentation

◆ _DBUpdate()

ilPluginDBUpdate::_DBUpdate ( )

destructor

Returns
boolean

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

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

◆ checkQuery()

ilPluginDBUpdate::checkQuery (   $q)

This is a very simple check.

Could be done better.

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

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

◆ getCurrentVersion()

ilPluginDBUpdate::getCurrentVersion ( )

Get current DB version.

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

References ilDBUpdate\$currentVersion.

Referenced by __construct().

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

◆ getFileForStep()

ilPluginDBUpdate::getFileForStep (   $a_version)

Get db update file name for db step.

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

Referenced by __construct().

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

◆ loadXMLInfo()

ilPluginDBUpdate::loadXMLInfo ( )

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

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

◆ setCurrentVersion()

ilPluginDBUpdate::setCurrentVersion (   $a_version)

Set current DB version.

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

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

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