/** * Hook called before we delete a category. * * @param \stdClass $category The category record. */ function tool_recyclebin_pre_course_category_delete($category) { // Delete all the items in the category recycle bin, regardless if it enabled or not. // It may have been enabled, then disabled later on, so may still have content. $categorybin = new \tool_recyclebin\category_bin($category->id); $categorybin->delete_all_items(); }
} break; // Delete it. // Delete it. case 'delete': if ($recyclebin->can_delete()) { $recyclebin->delete_item($item); redirect($PAGE->url, get_string('alertdeleted', 'tool_recyclebin', $item), 2); } else { print_error('nopermissions', 'error'); } break; // Empty it. // Empty it. case 'empty': $recyclebin->delete_all_items(); redirect($PAGE->url, get_string('alertemptied', 'tool_recyclebin'), 2); break; } } // Add a "Go Back" button. $goback = html_writer::start_tag('div', array('class' => 'backlink')); $goback .= html_writer::link($context->get_url(), get_string('backto', '', $context->get_context_name())); $goback .= html_writer::end_tag('div'); // Output header. echo $OUTPUT->header(); echo $OUTPUT->heading($heading); // Grab our items, check there is actually something to display. $items = $recyclebin->get_items(); // Nothing to show? Bail out early. if (empty($items)) {