Skip to content
Snippets Groups Projects
Commit ddf6ffae authored by TamaraGunkel's avatar TamaraGunkel
Browse files

Added displaytitle to workflow entity + form

parent c90ec42b
Branches
Tags
No related merge requests found
...@@ -230,6 +230,7 @@ class admin_settings { ...@@ -230,6 +230,7 @@ class admin_settings {
if ($data->id) { if ($data->id) {
$workflow = workflow_manager::get_workflow($data->id); $workflow = workflow_manager::get_workflow($data->id);
$workflow->title = $data->title; $workflow->title = $data->title;
$workflow->displaytitle = $data->displaytitle;
$newworkflow = false; $newworkflow = false;
} else { } else {
$workflow = workflow::from_record($data); $workflow = workflow::from_record($data);
......
...@@ -46,13 +46,17 @@ class workflow { ...@@ -46,13 +46,17 @@ class workflow {
/** bool|null true if workflow is manually triggered*/ /** bool|null true if workflow is manually triggered*/
public $manual; public $manual;
private function __construct($id, $title, $active, $timeactive, $sortindex, $manual) { /** title that is displayed to users */
public $displaytitle;
private function __construct($id, $title, $active, $timeactive, $sortindex, $manual, $displaytitle) {
$this->id = $id; $this->id = $id;
$this->title = $title; $this->title = $title;
$this->active = $active; $this->active = $active;
$this->timeactive = $timeactive; $this->timeactive = $timeactive;
$this->sortindex = $sortindex; $this->sortindex = $sortindex;
$this->manual = $manual; $this->manual = $manual;
$this->displaytitle = $displaytitle;
} }
/** /**
...@@ -94,7 +98,13 @@ class workflow { ...@@ -94,7 +98,13 @@ class workflow {
} }
} }
$instance = new self($id, $record->title, $active, $timeactive, $sortindex, $manual); if (!object_property_exists($record, 'displaytitle') || !$record->displaytitle) {
$displaytitle = $record->title;
} else {
$displaytitle = $record->displaytitle;
}
$instance = new self($id, $record->title, $active, $timeactive, $sortindex, $manual, $displaytitle);
return $instance; return $instance;
} }
......
...@@ -74,6 +74,14 @@ class form_workflow_instance extends \moodleform { ...@@ -74,6 +74,14 @@ class form_workflow_instance extends \moodleform {
$mform->setDefault($elementname, $this->workflow->title); $mform->setDefault($elementname, $this->workflow->title);
} }
$elementname = 'displaytitle';
$mform->addElement('text', $elementname, get_string('workflow_displaytitle', 'tool_cleanupcourses'));
$mform->addHelpButton($elementname, 'workflow_displaytitle', 'tool_cleanupcourses');
$mform->setType($elementname, PARAM_TEXT);
if (isset($this->workflow)) {
$mform->setDefault($elementname, $this->workflow->displaytitle);
}
$this->add_action_buttons(); $this->add_action_buttons();
} }
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="admin/tool/cleanupcourses/db" VERSION="2018022101" COMMENT="XMLDB file for Moodle tool/cleanupcourses" <XMLDB PATH="admin/tool/cleanupcourses/db" VERSION="2018022102" 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"
> >
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<FIELD NAME="timeactive" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="timestamp the workflow was set active"/> <FIELD NAME="timeactive" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="timestamp the workflow was set active"/>
<FIELD NAME="sortindex" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false" COMMENT="Sortindex for active workflows"/> <FIELD NAME="sortindex" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false" COMMENT="Sortindex for active workflows"/>
<FIELD NAME="manual" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false" COMMENT="Specifies for active workflows if the workflow is manually or automatically triggered. True, if manual. False, if automatic."/> <FIELD NAME="manual" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false" COMMENT="Specifies for active workflows if the workflow is manually or automatically triggered. True, if manual. False, if automatic."/>
<FIELD NAME="displaytitle" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
......
...@@ -268,5 +268,20 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) { ...@@ -268,5 +268,20 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018022101, 'tool', 'cleanupcourses'); upgrade_plugin_savepoint(true, 2018022101, 'tool', 'cleanupcourses');
} }
if ($oldversion < 2018022102) {
// Define field displaytitle to be added to tool_cleanupcourses_workflow.
$table = new xmldb_table('tool_cleanupcourses_workflow');
$field = new xmldb_field('displaytitle', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'manual');
// Conditionally launch add field displaytitle.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Cleanupcourses savepoint reached.
upgrade_plugin_savepoint(true, 2018022102, 'tool', 'cleanupcourses');
}
return true; return true;
} }
\ No newline at end of file
...@@ -65,6 +65,8 @@ $string['trigger_workflow'] = 'Workflow'; ...@@ -65,6 +65,8 @@ $string['trigger_workflow'] = 'Workflow';
$string['add_workflow'] = 'Add Workflow'; $string['add_workflow'] = 'Add Workflow';
$string['workflow_title'] = 'Title'; $string['workflow_title'] = 'Title';
$string['workflow_displaytitle'] = 'Displayed workflow title';
$string['workflow_displaytitle_help'] = 'This title is displayed to users when managing their courses.';
$string['workflow_active'] = 'Active'; $string['workflow_active'] = 'Active';
$string['workflow_processes'] = 'Active processes'; $string['workflow_processes'] = 'Active processes';
$string['workflow_timeactive'] = 'Active since'; $string['workflow_timeactive'] = 'Active since';
......
...@@ -23,5 +23,5 @@ ...@@ -23,5 +23,5 @@
defined('MOODLE_INTERNAL') || die; defined('MOODLE_INTERNAL') || die;
$plugin->version = 2018022101; $plugin->version = 2018022102;
$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