Commit 8a217b04 authored by Penny Leach's avatar Penny Leach
Browse files

changed the cron,event, installed tables to be $plugintype_* rather

than *_$plugintype
parent e7fa46f4
......@@ -45,15 +45,15 @@ class PluginArtefactInternal extends PluginArtefact {
if (is_array($types)) {
foreach ($types as $type) {
$ph[] = '?';
if (!record_exists('installed_artefact_type', 'plugin', $plugin, 'name', $type)) {
if (!record_exists('artefact_installed_type', 'plugin', $plugin, 'name', $type)) {
$t = new StdClass;
$t->name = $type;
$t->plugin = $plugin;
insert_record('installed_artefact_type',$t);
insert_record('artefact_installed_type',$t);
}
// @todo handle case that two plugins provide artefacts with the same name.
}
delete_records_select('installed_artefact_type','(plugin = ? AND name NOT IN (' . implode(',', $ph) . '))',
delete_records_select('artefact_installed_type','(plugin = ? AND name NOT IN (' . implode(',', $ph) . '))',
array_merge(array($plugin),$types));
}
}
......
......@@ -4,7 +4,7 @@
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="installed_artefact">
<TABLE NAME="artefact_installed">
<FIELDS>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" />
......@@ -15,7 +15,7 @@
<KEY NAME="primary" TYPE="primary" FIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="installed_artefact_type">
<TABLE NAME="artefact_installed_type">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" />
......@@ -24,10 +24,10 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="nameuk" TYPE="unique" FIELDS="name,plugin" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="installed_artefact" REFFIELDS="name" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="artefact_installed" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="installed_auth">
<TABLE NAME="auth_installed">
<FIELDS>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" />
......@@ -47,7 +47,7 @@
<KEY NAME="primary" TYPE="primary" FIELDS="field" />
</KEYS>
</TABLE>
<TABLE NAME="config_artefact">
<TABLE NAME="artefact_config">
<FIELDS>
<FIELD NAME="plugin" TYPE="char" LENGTH="100" NOTNULL="true" />
<FIELD NAME="field" TYPE="char" LENGTH="100" NOTNULL="true" />
......@@ -55,10 +55,10 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="plugin,field" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="installed_artefact" REFFIELDS="name" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="artefact_installed" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="config_auth">
<TABLE NAME="auth_config">
<FIELDS>
<FIELD NAME="plugin" TYPE="char" LENGTH="100" NOTNULL="true" />
<FIELD NAME="field" TYPE="char" LENGTH="100" NOTNULL="true" />
......@@ -66,7 +66,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="plugin,field" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="installed_auth" REFFIELDS="name" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="auth_installed" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="usr">
......@@ -100,7 +100,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="typefk" TYPE="foreign" FIELDS="artefacttype" REFTABLE="installed_artefact_type" REFFIELDS="id" />
<KEY NAME="typefk" TYPE="foreign" FIELDS="artefacttype" REFTABLE="artefact_installed_type" REFFIELDS="id" />
<KEY NAME="parentfk" TYPE="foreign" FIELDS="parentid" REFTABLE="artefact" REFFIELDS="id" />
</KEYS>
</TABLE>
......@@ -119,7 +119,7 @@
<KEY NAME="primary" TYPE="primary" FIELDS="callfunction" />
</KEYS>
</TABLE>
<TABLE NAME="cron_artefact">
<TABLE NAME="artefact_cron">
<FIELDS>
<FIELD NAME="plugin" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="callfunction" TYPE="char" LENGTH="255" NOTNULL="true" />
......@@ -132,10 +132,10 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="plugin,callfunction" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="installed_artefact" REFFIELDS="name" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="artefact_installed" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="cron_auth">
<TABLE NAME="auth_cron">
<FIELDS>
<FIELD NAME="plugin" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="callfunction" TYPE="char" LENGTH="255" NOTNULL="true" />
......@@ -148,7 +148,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="plugin,callfunction" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="installed_auth" REFFIELDS="name" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="auth_installed" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="event">
......@@ -168,7 +168,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="installed_artefact" REFFIELDS="name" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="artefact_installed" REFFIELDS="name" />
<KEY NAME="eventfk" TYPE="foreign" FIELDS="event" REFTABLE="event" REFFIELDS="name" />
<KEY NAME="subscruk" TYPE="unique" FIELDS="plugin,event,callfunction" />
</KEYS>
......@@ -182,7 +182,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="installed_auth" REFFIELDS="name" />
<KEY NAME="pluginfk" TYPE="foreign" FIELDS="plugin" REFTABLE="auth_installed" REFFIELDS="name" />
<KEY NAME="eventfk" TYPE="foreign" FIELDS="event" REFTABLE="event" REFFIELDS="name" />
<KEY NAME="subscruk" TYPE="unique" FIELDS="plugin,event,callfunction" />
</KEYS>
......
......@@ -342,7 +342,7 @@ function get_config_plugin($plugintype, $pluginname, $key) {
// @todo: an optimisation might be to get all fields related to the plugin instead, as
// it may be quite likely that if one config item is requested for a plugin another
// might be.
if (!$value = get_field('config_'.$plugintype,'value','plugin',$pluginname,'field',$key)) {
if (!$value = get_field($plugintype . '_config', 'value', 'plugin', $pluginname, 'field', $key)) {
$value = null;
}
......@@ -352,7 +352,7 @@ function get_config_plugin($plugintype, $pluginname, $key) {
function set_config_plugin($plugintype, $pluginname, $key, $value) {
global $CFG;
$table = 'config_' . $plugintype;
$table = $plugintype . '_config';
if (false !== get_field($table, 'value', 'plugin', $pluginname, 'field', $key)) {
//if (set_field($table, 'value', $key, 'plugin', $pluginname, 'field', $value)) {
......
......@@ -111,7 +111,7 @@ function check_upgrades($name = null) {
// definitely fail
$pluginversion = 0;
if (!$installing) {
if ($installed = get_record('installed_' . $plugintype, 'name', $pluginname)) {
if ($installed = get_record($plugintype . '_installed', 'name', $pluginname)) {
$pluginversion = $installed->version;
$pluginrelease = $installed->release;
}
......@@ -219,7 +219,7 @@ function upgrade_plugin($upgrade) {
$installed->name = $pluginname;
$installed->version = $upgrade->to;
$installed->release = $upgrade->torelease;
$installtable = 'installed_' . $plugintype;
$installtable = $plugintype . '_installed';
if (!empty($upgrade->install)) {
insert_record($installtable,$installed);
......@@ -244,18 +244,19 @@ function upgrade_plugin($upgrade) {
throw new InstallationException("cron $cron->callfunction for $pcname supplied but wasn't callable");
}
$new = false;
$table = $plugintype . '_cron';
if (!empty($upgrade->install)) {
$new = true;
}
else if (!record_exists('cron_' . $plugintype, 'plugin', $pluginname, 'function', $cron->callfunction)) {
else if (!record_exists($table, 'plugin', $pluginname, 'function', $cron->callfunction)) {
$new = true;
}
$cron->plugin = $pluginname;
if (!empty($new)) {
insert_record('cron_' . $plugintype, $cron);
insert_record($table, $cron);
}
else {
update_record('cron_' . $plugintype, $cron, array('plugin', 'name'));
update_record($table, $cron, array('plugin', 'name'));
}
}
}
......@@ -277,15 +278,16 @@ function upgrade_plugin($upgrade) {
throw new InstallationException("event $event->event with function $event->callfunction for $pcname supplied but wasn't callable");
}
$exists = false;
$table = $plugtype . '_event_subscription';
if (empty($upgrade->install)) {
$exists = record_exists('event_subscription_' . $plugintype, 'plugin' , $pluginname, 'event', $event->event());
$exists = record_exists($table, 'plugin' , $pluginname, 'event', $event->event());
}
$event->plugin = $pluginname;
if (empty($exists)) {
insert_record('event_subscription_' . $plugintype, $event);
insert_record($table, $event);
}
else {
update_record('event_subscription_' . $plugintype, $event, array('id', $exists->id));
update_record($table, $event, array('id', $exists->id));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment