Skip to content
Snippets Groups Projects
Commit c0decfab authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Introduced sortindex for trigger

parent 9ae9bb84
No related branches found
No related tags found
No related merge requests found
......@@ -28,10 +28,6 @@ defined('MOODLE_INTERNAL') || die();
class step_subplugin extends subplugin {
/** int sort index, which defines the order,
* in which the steps wihtin a workflow are executed*/
public $sortindex;
/**
* Creates a subplugin from a db record.
* @param $record
......
......@@ -40,6 +40,10 @@ abstract class subplugin{
/** string name of subplugin */
public $subpluginname;
/** int sort index, which defines the order,
* in which the steps wihtin a workflow are executed*/
public $sortindex;
/**
* Creates a subplugin with subpluginname and optional id.
* @oaram string $instancename name of the subplugin instance
......
......@@ -48,6 +48,10 @@ class trigger_subplugin extends subplugin{
$id = $record->id;
}
$instance = new self($record->instancename, $record->subpluginname, $record->workflowid, $id);
if (object_property_exists($record, 'sortindex') ) {
$instance->sortindex = $record->sortindex;
}
return $instance;
}
......
......@@ -36,6 +36,7 @@
<FIELD NAME="instancename" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="instancename of the trigger"/>
<FIELD NAME="subpluginname" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the subplugin"/>
<FIELD NAME="workflowid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="id of the workflow"/>
<FIELD NAME="sortindex" TYPE="int" LENGTH="5" NOTNULL="true" SEQUENCE="false" COMMENT="Order in which the triggers are checked for the workflow."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
......@@ -283,5 +283,21 @@ function xmldb_tool_lifecycle_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018022102, 'tool', 'lifecycle');
}
if ($oldversion < 2018101000) {
// Define field sortindex to be added to tool_lifecycle_trigger.
$table = new xmldb_table('tool_lifecycle_trigger');
$field = new xmldb_field('sortindex', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, 1, 'workflowid');
// Conditionally launch add field sortindex.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Lifecycle savepoint reached.
upgrade_plugin_savepoint(true, 2018101000, 'tool', 'lifecycle');
}
return true;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment