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

Renamed some comments and Constants

parent b00a3872
Branches
Tags
No related merge requests found
......@@ -106,10 +106,10 @@ class step_manager extends subplugin_manager {
}
/**
* Gets the list of currently enabled trigger subplugins.
* @return array of enabled trigger subplugins.
* Gets the list of step instances.
* @return array of step instances.
*/
public function get_steps() {
public function get_step_instances() {
global $DB;
return $DB->get_records('tool_cleanupcourses_step');
}
......
......@@ -237,19 +237,19 @@ class trigger_manager extends subplugin_manager {
* @param int $subplugin id of the subplugin
*/
public function handle_action($action, $subplugin) {
if ($action === ACTION_ENABLE_SUBPLUGIN) {
if ($action === ACTION_ENABLE_TRIGGER) {
$this->change_enabled($subplugin, true);
}
if ($action === ACTION_DISABLE_SUBPLUGIN) {
if ($action === ACTION_DISABLE_TRIGGER) {
$this->change_enabled($subplugin, false);
}
if ($action === ACTION_UP_SUBPLUGIN) {
if ($action === ACTION_UP_TRIGGER) {
$this->change_sortindex($subplugin, true);
}
if ($action === ACTION_DOWN_SUBPLUGIN) {
if ($action === ACTION_DOWN_TRIGGER) {
$this->change_sortindex($subplugin, false);
}
if ($action === ACTION_FOLLOWEDBY_SUBPLUGIN) {
if ($action === ACTION_FOLLOWEDBY_TRIGGER) {
$this->change_followedby($subplugin, optional_param('followedby', null, PARAM_INT));
}
}
......
......@@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Table listing active processes
* Table listing triggers
*
* @package tool_cleanupcourses
* @copyright 2017 Tobias Reischmann WWU
......@@ -42,10 +42,10 @@ class trigger_table extends \table_sql {
public function init() {
$this->define_columns(['name', 'enabled', 'sortindex', 'followedby']);
$this->define_headers([
get_string('subplugin_name', 'tool_cleanupcourses'),
get_string('subplugin_enabled', 'tool_cleanupcourses'),
get_string('subplugin_sortindex', 'tool_cleanupcourses'),
get_string('subplugin_followedby', 'tool_cleanupcourses'),
get_string('trigger_name', 'tool_cleanupcourses'),
get_string('trigger_enabled', 'tool_cleanupcourses'),
get_string('trigger_sortindex', 'tool_cleanupcourses'),
get_string('trigger_followedby', 'tool_cleanupcourses'),
]);
$this->sortable(false, 'sortindex');
$this->setup();
......@@ -73,11 +73,11 @@ class trigger_table extends \table_sql {
if ($row->enabled == 1) {
$alt = 'disable';
$icon = 't/hide';
$action = ACTION_DISABLE_SUBPLUGIN;
$action = ACTION_DISABLE_TRIGGER;
} else {
$alt = 'enable';
$icon = 't/show';
$action = ACTION_ENABLE_SUBPLUGIN;
$action = ACTION_ENABLE_TRIGGER;
}
return $this->format_icon_link($action, $row->id, $icon, get_string($alt));
......@@ -95,7 +95,7 @@ class trigger_table extends \table_sql {
if ($row->sortindex > 1) {
$alt = 'up';
$icon = 't/up';
$action = ACTION_UP_SUBPLUGIN;
$action = ACTION_UP_TRIGGER;
$output .= $this->format_icon_link($action, $row->id, $icon, get_string($alt));
} else {
$output .= $OUTPUT->spacer();
......@@ -104,7 +104,7 @@ class trigger_table extends \table_sql {
if ($row->sortindex < $manager->count_enabled_trigger()) {
$alt = 'down';
$icon = 't/down';
$action = ACTION_DOWN_SUBPLUGIN;
$action = ACTION_DOWN_TRIGGER;
$output .= $this->format_icon_link($action, $row->id, $icon, get_string($alt));
} else {
$output .= $OUTPUT->spacer();
......@@ -141,7 +141,7 @@ class trigger_table extends \table_sql {
global $PAGE, $OUTPUT;
$manager = new step_manager();
$steps = $manager->get_steps();
$steps = $manager->get_step_instances();
$options = array();
foreach ($steps as $id => $step) {
$options[$id] = get_string('pluginname', 'cleanupcoursesstep_' . $step->name);
......@@ -154,7 +154,7 @@ class trigger_table extends \table_sql {
}
return $OUTPUT->single_select(new \moodle_url($PAGE->url,
array('action' => ACTION_FOLLOWEDBY_SUBPLUGIN, 'subplugin' => $row->id, 'sesskey' => sesskey())),
array('action' => ACTION_FOLLOWEDBY_TRIGGER, 'subplugin' => $row->id, 'sesskey' => sesskey())),
'followedby', $options, $selected);
}
......
......@@ -31,11 +31,14 @@ $string['general_config_header'] = "General & Subplugins";
$string['active_processes_list_header'] = 'Active Processes';
$string['subpluginssettings_heading'] = 'Subplugin Workflow';
$string['subplugin_name'] = 'Subplugin Name';
$string['subplugin_type'] = 'Subplugin Type';
$string['subplugin_enabled'] = 'Enabled';
$string['subplugin_sortindex'] = 'Up/Down';
$string['subplugin_followedby'] = 'Followed by';
$string['trigger_name'] = 'Subplugin Name';
$string['trigger_enabled'] = 'Enabled';
$string['trigger_sortindex'] = 'Up/Down';
$string['trigger_followedby'] = 'Followed by';
$string['step_name'] = 'Step Type';
$string['step_instancename'] = 'Instance Name';
$string['step_followedby'] = 'Followed by';
$string['trigger'] = 'Trigger';
$string['step'] = 'Process step';
......
......@@ -22,8 +22,9 @@
defined('MOODLE_INTERNAL') || die();
define('ACTION_ENABLE_SUBPLUGIN', 'enable');
define('ACTION_DISABLE_SUBPLUGIN', 'disable');
define('ACTION_UP_SUBPLUGIN', 'up');
define('ACTION_DOWN_SUBPLUGIN', 'down');
define('ACTION_FOLLOWEDBY_SUBPLUGIN', 'followedby');
\ No newline at end of file
define('ACTION_ENABLE_TRIGGER', 'enable');
define('ACTION_DISABLE_TRIGGER', 'disable');
define('ACTION_UP_TRIGGER', 'up');
define('ACTION_DOWN_TRIGGER', 'down');
define('ACTION_FOLLOWEDBY_TRIGGER', 'followedby_trigger');
define('ACTION_FOLLOWEDBY_STEP', 'followedby_step');
\ No newline at end of file
......@@ -42,7 +42,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_up_first() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_UP_SUBPLUGIN, 1);
$manager->handle_action(ACTION_UP_TRIGGER, 1);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'sortindex' => 2)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'sortindex' => 3)));
......@@ -54,7 +54,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_up_second() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_UP_SUBPLUGIN, 2);
$manager->handle_action(ACTION_UP_TRIGGER, 2);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'sortindex' => 2)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'sortindex' => 3)));
......@@ -66,7 +66,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_up_third() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_UP_SUBPLUGIN, 3);
$manager->handle_action(ACTION_UP_TRIGGER, 3);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'sortindex' => 3)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'sortindex' => 2)));
......@@ -78,7 +78,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_down_first() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DOWN_SUBPLUGIN, 1);
$manager->handle_action(ACTION_DOWN_TRIGGER, 1);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'sortindex' => 2)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'sortindex' => 3)));
......@@ -90,7 +90,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_down_second() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DOWN_SUBPLUGIN, 2);
$manager->handle_action(ACTION_DOWN_TRIGGER, 2);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'sortindex' => 3)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'sortindex' => 2)));
......@@ -102,7 +102,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_down_third() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DOWN_SUBPLUGIN, 3);
$manager->handle_action(ACTION_DOWN_TRIGGER, 3);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'sortindex' => 2)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'sortindex' => 3)));
......@@ -114,7 +114,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_disable_first() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DISABLE_SUBPLUGIN, 1);
$manager->handle_action(ACTION_DISABLE_TRIGGER, 1);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger',
array('id' => 1, 'enabled' => 0, 'sortindex' => null)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger',
......@@ -129,7 +129,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_disable_second() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DISABLE_SUBPLUGIN, 2);
$manager->handle_action(ACTION_DISABLE_TRIGGER, 2);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger',
array('id' => 1, 'enabled' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger',
......@@ -144,7 +144,7 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_disable_third() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DISABLE_SUBPLUGIN, 3);
$manager->handle_action(ACTION_DISABLE_TRIGGER, 3);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger',
array('id' => 1, 'enabled' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger',
......@@ -159,8 +159,8 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_disable_and_enable_first() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DISABLE_SUBPLUGIN, 1);
$manager->handle_action(ACTION_ENABLE_SUBPLUGIN, 1);
$manager->handle_action(ACTION_DISABLE_TRIGGER, 1);
$manager->handle_action(ACTION_ENABLE_TRIGGER, 1);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'enabled' => 1, 'sortindex' => 3)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'enabled' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'enabled' => 1, 'sortindex' => 2)));
......@@ -172,8 +172,8 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_disable_and_enable_second() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DISABLE_SUBPLUGIN, 2);
$manager->handle_action(ACTION_ENABLE_SUBPLUGIN, 2);
$manager->handle_action(ACTION_DISABLE_TRIGGER, 2);
$manager->handle_action(ACTION_ENABLE_TRIGGER, 2);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'enabled' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'enabled' => 1, 'sortindex' => 3)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'enabled' => 1, 'sortindex' => 2)));
......@@ -185,8 +185,8 @@ class tool_cleanupcourses_subplugin_settings_testcase extends \advanced_testcase
public function test_disable_and_enable_third() {
global $DB;
$manager = new trigger_manager();
$manager->handle_action(ACTION_DISABLE_SUBPLUGIN, 3);
$manager->handle_action(ACTION_ENABLE_SUBPLUGIN, 3);
$manager->handle_action(ACTION_DISABLE_TRIGGER, 3);
$manager->handle_action(ACTION_ENABLE_TRIGGER, 3);
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 1, 'enabled' => 1, 'sortindex' => 1)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 2, 'enabled' => 1, 'sortindex' => 2)));
$this->assertNotEmpty($DB->get_records('tool_cleanupcourses_trigger', array('id' => 3, 'enabled' => 1, 'sortindex' => 3)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment