MDL-65967 tool_recyclebin: add recycle bin link to category edit menu

This commit is contained in:
Thiagolivramento 2020-03-16 13:42:59 -03:00 committed by Daniel Neis Araujo
parent 9df4a4de18
commit 934ad2c869
2 changed files with 53 additions and 0 deletions

View File

@ -127,3 +127,36 @@ Feature: Basic recycle bin functionality
And I press "Yes"
And I should see "Recycle bin has been emptied"
And I should see "There are no items in the recycle bin."
@javascript
Scenario: Show recycle bin on category action menu
Given I log in as "admin"
And I navigate to "Courses > Manage courses and categories" in site administration
And I click on "Actions menu" "link"
And I click on "Recycle bin" "link"
Then I should see "There are no items in the recycle bin."
@javascript
Scenario: Not show recycle bin empty on category action menu whit autohide enable
Given I log in as "admin"
And the following config values are set as admin:
| categorybinenable | 0 | tool_recyclebin |
And I navigate to "Courses > Manage courses and categories" in site administration
And I click on "Actions menu" "link"
Then I should not see "Recycle bin"
@javascript
Scenario: Show recycle bin not empty on category action menu whit autohide enable
Given I log in as "admin"
And the following config values are set as admin:
| autohide | 1 | tool_recyclebin |
And I navigate to "Courses > Manage courses and categories" in site administration
And I click on "Actions menu" "link"
Then I should not see "Recycle bin"
And I click on "delete" action for "Course 2" in management course listing
And I press "Delete"
And I should see "Deleting C2"
And I should see "C2 has been completely deleted"
And I press "Continue"
When I click on "Actions menu" "link"
Then I should see "Recycle bin"

View File

@ -330,6 +330,26 @@ class helper {
'string' => new \lang_string('restorecourse', 'admin')
);
}
// Recyclebyn.
if (\tool_recyclebin\category_bin::is_enabled()) {
$categorybin = new \tool_recyclebin\category_bin($category->id);
if ($categorybin->can_view()) {
$autohide = get_config('tool_recyclebin', 'autohide');
if ($autohide) {
$items = $categorybin->get_items();
} else {
$items = [];
}
if (!$autohide || !empty($items)) {
$pluginname = get_string('pluginname', 'tool_recyclebin');
$actions['recyclebin'] = [
'url' => new \moodle_url('/admin/tool/recyclebin/index.php', ['contextid' => $category->get_context()->id]),
'icon' => new \pix_icon('trash', $pluginname, 'tool_recyclebin'),
'string' => $pluginname
];
}
}
}
return $actions;
}