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

Started making trigger instance based

parent 582e4f13
No related branches found
No related tags found
No related merge requests found
...@@ -28,25 +28,19 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -28,25 +28,19 @@ defined('MOODLE_INTERNAL') || die();
class step_subplugin extends subplugin { class step_subplugin extends subplugin {
/** string instancename of the step*/
public $instancename;
/** int id of the workflow this step belongs to*/
public $workflowid;
/** int sort index, which defines the order, /** int sort index, which defines the order,
* in which the steps wihtin a workflow are executed*/ * in which the steps wihtin a workflow are executed*/
public $sortindex; public $sortindex;
/** /**
* Creates a subplugin with subpluginname and optional id. * Creates a subplugin with subpluginname and optional id.
* @oaram string $instancename name of the subplugin instance
* @param string $subpluginname name of the subplugin * @param string $subpluginname name of the subplugin
* @param int $workflowid id of the workflow the subplugin belongs to
* @param int $id id of the subplugin * @param int $id id of the subplugin
*/ */
public function __construct($instancename, $subpluginname, $workflowid, $id = null) { public function __construct($instancename, $subpluginname, $workflowid, $id = null) {
parent::__construct($subpluginname, $id); parent::__construct($instancename, $subpluginname, $workflowid, $id);
$this->instancename = $instancename;
$this->workflowid = $workflowid;
} }
/** /**
......
...@@ -31,16 +31,26 @@ abstract class subplugin{ ...@@ -31,16 +31,26 @@ abstract class subplugin{
/** int Id of subplugin */ /** int Id of subplugin */
public $id; public $id;
/** string instancename of the step*/
public $instancename;
/** int id of the workflow this step belongs to*/
public $workflowid;
/** string name of subplugin */ /** string name of subplugin */
public $subpluginname; public $subpluginname;
/** /**
* Creates a subplugin with subpluginname and optional id. * Creates a subplugin with subpluginname and optional id.
* @oaram string $instancename name of the subplugin instance
* @param string $subpluginname name of the subplugin * @param string $subpluginname name of the subplugin
* @param int $workflowid id of the workflow the subplugin belongs to
* @param int $id id of the subplugin * @param int $id id of the subplugin
*/ */
public function __construct($subpluginname, $id = null) { public function __construct($instancename, $subpluginname, $workflowid, $id = null) {
$this->subpluginname = $subpluginname; $this->subpluginname = $subpluginname;
$this->instancename = $instancename;
$this->workflowid = $workflowid;
$this->id = $id; $this->id = $id;
} }
......
...@@ -28,14 +28,16 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -28,14 +28,16 @@ defined('MOODLE_INTERNAL') || die();
class trigger_subplugin extends subplugin{ class trigger_subplugin extends subplugin{
/** bool is the subplugin enabled*/ /**
public $enabled = false; * Creates a subplugin with subpluginname and optional id.
* @oaram string $instancename name of the subplugin instance
/** int sortindex of subplugin */ * @param string $subpluginname name of the subplugin
public $sortindex; * @param int $workflowid id of the workflow the subplugin belongs to
* @param int $id id of the subplugin
/** int id of the workflow, which is started by this trigger*/ */
public $worflowid; public function __construct($instancename, $subpluginname, $workflowid, $id = null) {
parent::__construct($instancename, $subpluginname, $workflowid, $id);
}
/** /**
* Creates a subplugin from a db record. * Creates a subplugin from a db record.
...@@ -46,6 +48,12 @@ class trigger_subplugin extends subplugin{ ...@@ -46,6 +48,12 @@ class trigger_subplugin extends subplugin{
if (!object_property_exists($record, 'subpluginname')) { if (!object_property_exists($record, 'subpluginname')) {
return null; return null;
} }
if (!object_property_exists($record, 'instancename')) {
return null;
}
if (!object_property_exists($record, 'workflowid')) {
return null;
}
$instance = new self($record->subpluginname); $instance = new self($record->subpluginname);
foreach (array_keys((array) $record) as $field) { foreach (array_keys((array) $record) as $field) {
if (object_property_exists($instance, $field)) { if (object_property_exists($instance, $field)) {
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="admin/tool/cleanupcourses/db" VERSION="2017040900" COMMENT="XMLDB file for Moodle tool/cleanupcourses" <XMLDB PATH="admin/tool/cleanupcourses/db" VERSION="2018021301" COMMENT="XMLDB file for Moodle tool/cleanupcourses"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"> xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd">
<TABLES> <TABLES>
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="id of the step instance"/> <FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="id of the step instance"/>
<FIELD NAME="type" TYPE="char" LENGTH="7" NOTNULL="true" SEQUENCE="false" COMMENT="Type of the settings instance 'step' or 'trigger'"/>
<FIELD NAME="name" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the settings field"/> <FIELD NAME="name" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the settings field"/>
<FIELD NAME="value" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="value of the setting"/> <FIELD NAME="value" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="value of the setting"/>
</FIELDS> </FIELDS>
......
...@@ -133,6 +133,23 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) { ...@@ -133,6 +133,23 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018021300, 'tool', 'cleanupcourses'); upgrade_plugin_savepoint(true, 2018021300, 'tool', 'cleanupcourses');
} }
if ($oldversion < 2018021301) {
// Define field type to be added to tool_cleanupcourses_settings.
$table = new xmldb_table('tool_cleanupcourses_settings');
$field = new xmldb_field('type', XMLDB_TYPE_CHAR, '7', null, XMLDB_NOTNULL, null, null, 'instanceid');
// Conditionally launch add field type.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$DB->execute('update {tool_cleanupcourses_settings} set type = \'step\'');
// Cleanupcourses savepoint reached.
upgrade_plugin_savepoint(true, 2018021301, 'tool', 'cleanupcourses');
}
return true; return true;
} }
\ No newline at end of file
...@@ -32,6 +32,7 @@ define('ACTION_DOWN_STEP', 'down_step'); ...@@ -32,6 +32,7 @@ define('ACTION_DOWN_STEP', 'down_step');
define('ACTION_UP_WORKFLOW', 'up_workflow'); define('ACTION_UP_WORKFLOW', 'up_workflow');
define('ACTION_DOWN_WORKFLOW', 'down_workflow'); define('ACTION_DOWN_WORKFLOW', 'down_workflow');
define('ACTION_STEP_INSTANCE_FORM', 'step_instance_form'); define('ACTION_STEP_INSTANCE_FORM', 'step_instance_form');
define('ACTION_TRIGGER_INSTANCE_FORM', 'step_instance_form');
define('ACTION_STEP_INSTANCE_DELETE', 'step_instance_delete'); define('ACTION_STEP_INSTANCE_DELETE', 'step_instance_delete');
define('ACTION_WORKFLOW_INSTANCE_FROM', 'workflow_instance_form'); define('ACTION_WORKFLOW_INSTANCE_FROM', 'workflow_instance_form');
define('ACTION_WORKFLOW_DELETE', 'workflow_instance_delete'); define('ACTION_WORKFLOW_DELETE', 'workflow_instance_delete');
......
...@@ -23,5 +23,5 @@ ...@@ -23,5 +23,5 @@
defined('MOODLE_INTERNAL') || die; defined('MOODLE_INTERNAL') || die;
$plugin->version = 2018021300; $plugin->version = 2018021301;
$plugin->component = 'tool_cleanupcourses'; $plugin->component = 'tool_cleanupcourses';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment