Skip to content

Commit cde0dbc

Browse files
committed
smooth uninstall only with the triggers
1 parent d8f8fe5 commit cde0dbc

File tree

14 files changed

+830
-0
lines changed

14 files changed

+830
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
namespace lifecycletrigger_delayedcourses\privacy;
18+
19+
use core_privacy\local\metadata\null_provider;
20+
21+
/**
22+
* Privacy subsystem implementation for lifecycletrigger_delayedcourses.
23+
*
24+
* @package lifecycletrigger_delayedcourses
25+
* @copyright 2022 ISB Bayern
26+
* @author Philipp Memmel
27+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28+
*/
29+
class provider implements null_provider {
30+
31+
/**
32+
* Get the language string identifier with the component's language
33+
* file to explain why this plugin stores no data.
34+
*
35+
* @return string the reason
36+
*/
37+
public static function get_reason(): string {
38+
return 'privacy:metadata';
39+
}
40+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Lang strings for delayed course trigger
19+
*
20+
* @package lifecycletrigger_delayedcourses
21+
* @copyright 2017 Tobias Reischmann WWU
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
25+
$string['delay'] = 'Dieser Trigger wird alle Kurse ausschließen, die durch Nutzerinteraktion verzögert wurden.';
26+
$string['plugindescription'] = 'Schließt Kurse von diesem Workflow aus, die durch Nutzeraktion verzögert wurden.';
27+
$string['pluginname'] = 'Verzögerte Kurse ausschließen - Trigger';
28+
$string['privacy:metadata'] = 'Dieses Subplugin speichert keine persönlichen Daten.';
29+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Lang strings for delayed course trigger
19+
*
20+
* @package lifecycletrigger_delayedcourses
21+
* @copyright 2017 Tobias Reischmann WWU
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
25+
$string['delay'] = 'This module will exclude all courses, which were delayed by user interaction';
26+
$string['plugindescription'] = 'Exludes all courses which were delayed by user interaction.';
27+
$string['pluginname'] = 'Exclude delayed courses trigger';
28+
$string['privacy:metadata'] = 'This subplugin does not store any personal data.';

trigger/delayedcourses/lib.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Trigger subplugin to exclude delayed courses.
19+
*
20+
* @package lifecycletrigger_delayedcourses
21+
* @copyright 2017 Tobias Reischmann WWU
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
namespace tool_lifecycle\trigger;
25+
26+
use tool_lifecycle\local\response\trigger_response;
27+
use tool_lifecycle\local\manager\delayed_courses_manager;
28+
29+
defined('MOODLE_INTERNAL') || die();
30+
require_once(__DIR__ . '/../lib.php');
31+
32+
/**
33+
* Class which implements the basic methods necessary for a life cycle trigger subplugin
34+
* @package lifecycletrigger_delayedcourses
35+
* @copyright 2017 Tobias Reischmann WWU
36+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37+
*/
38+
class delayedcourses extends base_automatic {
39+
40+
41+
/**
42+
* Checks the course and returns a repsonse, which tells if the course should be further processed.
43+
* @param object $course Course to be processed.
44+
* @param int $triggerid Id of the trigger instance.
45+
* @return trigger_response
46+
*/
47+
public function check_course($course, $triggerid) {
48+
return trigger_response::exclude();
49+
}
50+
51+
/**
52+
* Return sql which excludes delayed courses.
53+
* @param int $triggerid Id of the trigger.
54+
* @return array A list containing the constructed sql fragment and an array of parameters.
55+
*/
56+
public function get_course_recordset_where($triggerid) {
57+
return delayed_courses_manager::get_course_delayed_wheresql();
58+
}
59+
60+
61+
/**
62+
* The return value should be equivalent with the name of the subplugin folder.
63+
* @return string technical name of the subplugin
64+
*/
65+
public function get_subpluginname() {
66+
return 'delayedcourses';
67+
}
68+
69+
/**
70+
* Has only one instance and results in a preset workflow.
71+
* @return bool
72+
*/
73+
public function has_multiple_instances() {
74+
return false;
75+
}
76+
77+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* lifecycletrigger_delayedcourses generator tests
19+
*
20+
* @package lifecycletrigger_delayedcourses
21+
* @category test
22+
* @copyright 2018 Tobias Reischmann WWU
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
use tool_lifecycle\local\entity\trigger_subplugin;
27+
use tool_lifecycle\local\entity\workflow;
28+
use tool_lifecycle\local\manager\trigger_manager;
29+
use tool_lifecycle\local\manager\workflow_manager;
30+
31+
/**
32+
* lifecycletrigger_delayedcourses generator tests
33+
*
34+
* @package lifecycletrigger_delayedcourses
35+
* @category test
36+
* @copyright 2018 Tobias Reischmann WWU
37+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38+
*/
39+
class tool_lifecycle_trigger_delayedcourses_generator extends testing_module_generator {
40+
41+
/**
42+
* Creates a trigger delayedcourses for an artificial workflow without steps.
43+
* @return trigger_subplugin the created delayedcourses trigger.
44+
* @throws dml_exception
45+
* @throws dml_transaction_exception
46+
*/
47+
public static function create_trigger_with_workflow() {
48+
// Create Workflow.
49+
$record = new stdClass();
50+
$record->id = null;
51+
$record->title = 'myworkflow';
52+
$workflow = workflow::from_record($record);
53+
workflow_manager::insert_or_update($workflow);
54+
// Create trigger.
55+
$record = new stdClass();
56+
$record->subpluginname = 'delayedcourses';
57+
$record->instancename = 'delayedcourses';
58+
$record->workflowid = $workflow->id;
59+
$trigger = trigger_subplugin::from_record($record);
60+
trigger_manager::insert_or_update($trigger);
61+
return $trigger;
62+
}
63+
64+
/**
65+
* Creates a workflow, which delays only for upcomming processes of itself.
66+
* @return workflow.
67+
* @throws dml_exception
68+
* @throws dml_transaction_exception
69+
*/
70+
public static function create_workflow() {
71+
// Create Workflow.
72+
$record = new stdClass();
73+
$record->id = null;
74+
$record->title = 'myworkflow';
75+
$record->rollbackdelay = 10000;
76+
$record->finishdelay = 10000;
77+
$record->delayforallworkflows = 0;
78+
$workflow = workflow::from_record($record);
79+
workflow_manager::insert_or_update($workflow);
80+
return $workflow;
81+
}
82+
83+
/**
84+
* Creates a workflow, which delays upcomming processes for all workflows.
85+
* @return workflow.
86+
* @throws dml_exception
87+
* @throws dml_transaction_exception
88+
*/
89+
public static function create_workflow_delaying_for_all_workflows() {
90+
// Create Workflow.
91+
$record = new stdClass();
92+
$record->id = null;
93+
$record->title = 'myworkflow';
94+
$record->rollbackdelay = 10000;
95+
$record->finishdelay = 10000;
96+
$record->delayforallworkflows = 1;
97+
$workflow = workflow::from_record($record);
98+
workflow_manager::insert_or_update($workflow);
99+
return $workflow;
100+
}
101+
}

0 commit comments

Comments
 (0)