Skip to content
Snippets Groups Projects
Unverified Commit a1166edf authored by Justus Dieckmann's avatar Justus Dieckmann Committed by GitHub
Browse files

Hide menu when there is no manual workflow (#195)

parent 421cc45b
Branches
No related tags found
No related merge requests found
......@@ -244,6 +244,14 @@ class workflow_manager {
$transaction->allow_commit();
}
/**
* Resets the 'does a manual workflow exist?'-cache.
*/
private static function reset_manual_workflow_cache() {
$cache = \cache::make('tool_lifecycle', 'application');
$cache->delete('manualworkflowexists');
}
/**
* Handles an action of the subplugin_settings.
*
......@@ -260,6 +268,7 @@ class workflow_manager {
}
if ($action === action::WORKFLOW_ACTIVATE) {
self::activate_workflow($workflowid);
self::reset_manual_workflow_cache();
} else if ($action === action::UP_WORKFLOW) {
self::change_sortindex($workflowid, true);
} else if ($action === action::DOWN_WORKFLOW) {
......@@ -270,10 +279,12 @@ class workflow_manager {
self::backup_workflow($workflowid);
} else if ($action === action::WORKFLOW_DISABLE) {
self::disable($workflowid);
self::reset_manual_workflow_cache();
return; // Return, since we do not want to redirect outside to deactivated workflows.
} else if ($action === action::WORKFLOW_ABORTDISABLE) {
self::disable($workflowid);
self::abortprocesses($workflowid);
self::reset_manual_workflow_cache();
return; // Return, since we do not want to redirect outside to deactivated workflows.
} else if ($action === action::WORKFLOW_ABORT) {
self::abortprocesses($workflowid);
......@@ -283,6 +294,7 @@ class workflow_manager {
if (self::get_workflow($workflowid) &&
self::is_removable($workflowid)) {
self::remove($workflowid);
self::reset_manual_workflow_cache();
} else {
\core\notification::add(get_string('workflow_not_removeable', 'tool_lifecycle')
, \core\notification::WARNING);
......
......@@ -28,4 +28,9 @@ $definitions = [
'mformdata' => [
'mode' => cache_store::MODE_SESSION,
],
'application' => [
'mode' => cache_store::MODE_APPLICATION,
'simplekeys' => true,
'simpledata' => true
]
];
......@@ -32,7 +32,7 @@
* @throws moodle_exception
*/
function tool_lifecycle_extend_navigation_course($navigation, $course, $context) {
global $PAGE;
global $DB, $PAGE;
// Only add this settings item on non-site course pages.
if (!$PAGE->course || $PAGE->course->id == SITEID) {
......@@ -43,8 +43,17 @@ function tool_lifecycle_extend_navigation_course($navigation, $course, $context)
return null;
}
$url = null;
$settingnode = null;
$cache = cache::make('tool_lifecycle', 'application');
if ($cache->has('manualworkflowexists')) {
$manualwfexists = $cache->get('manualworkflowexists');
} else {
$manualwfexists = $DB->record_exists_select('tool_lifecycle_workflow', 'manual = 1 AND timeactive IS NOT NULL');
$cache->set('manualworkflowsexist', $manualwfexists);
}
if (!$manualwfexists) {
return null;
}
$url = new moodle_url('/admin/tool/lifecycle/view.php', [
'contextid' => $context->id,
......
......@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die;
$plugin->maturity = MATURITY_BETA;
$plugin->version = 2023050200;
$plugin->version = 2024022000;
$plugin->component = 'tool_lifecycle';
$plugin->requires = 2020061500; // Requires Moodle 3.9+.
$plugin->release = 'v4.2-r1';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment