Recycle bin functionality

Recycle bin functionality

by Frederik Evans -
Number of replies: 14

Can anybody help me on this issue. I created a plugin, but i can't get it to work with recycle bin functionality

The documentation is extremely poor and non existent

I have taken the label as a model, and i still can't get it to work, i tried everything to no avail

I expect that there is something external to the plugin itself, maybe a function somewhere in the moodle root directory, that will make it work, but what that external code is, and where it resides, is anyone's guess.

I implemented the same backup files as in the label plugin,  just replacing the name of plugin, folder and db fields, but that did not work. I have checked the lib.php, but there's nothing there. I believe there is an API for the recycle bin, but as the documentation on the latter is extremely poor it is very difficult to find out what functions you have that may help.

attached are the files in my backup folder

Average of ratings: -
In reply to Frederik Evans

Re: Recycle bin functionality

by Anthony Rimmer -
Hi Frederik,

What's not happening specifically - Can you tell us more?

Anthony
In reply to Anthony Rimmer

Re: Recycle bin functionality

by Frederik Evans -
nothing happens. If you click on delete, and run your cron job, you would typically expect the deleted plugin to appear in your recycle bin. This does not occur and is excluded. I have tried everything, but nothing i do will make it appear in the recycle bin.

for example i have a plugin that shoes the above, called catalogue, if i delete it, i would expect to see it in the recycle bin. However, this does not occur. Instead, its empty.
In reply to Frederik Evans

Re: Recycle bin functionality

by Anthony Rimmer -
Have you turned on debugging and error messages to see if it gives you any hints?

Does the item delete, despite not appearing in the recycle bin? - Could it be a record isn't being added to the right table to establish that it has been deleted 'recently'?

I'll have a quick look myself to see if there is anything I can see that relates to the process.
In reply to Anthony Rimmer

Re: Recycle bin functionality

by Anthony Rimmer -
The only things I could see which differ to the standard files are:

restore_modulecatalogue_stepslib.php Line 29 has process_catalogue instead of process_modulecatalogue
backup_modulecatalogue_stepslib.php Line 21 and 23 refer to catalogue/mod_catalogue instead of modulecatalogue/mod_modulecatalogue

I did a copy of the label resource and made similar changes, bumped the plugin version and then ran the cron - had output errors and the resource didn't shown in the recycle bin when deleted.

May or may not be the issue, but hope it helps.
In reply to Anthony Rimmer

Re: Recycle bin functionality

by Frederik Evans -
how can you see the results of the cron job, when we run it, its so fast. impossible to read that fast.

i have this in cron job

C:\php-7.2\php.exe  -f C:\Apache24/htdocs/moodle/admin/cli/cron.php

if i include > C:\Apache24/htdocs/moodle/admin/cli/cron_log.txt it does not run, so i expect its not possible to have it output to a file
In reply to Frederik Evans

Re: Recycle bin functionality

by Ken Task -
Picture of Particularly helpful Moodlers

Not a Windows person ... nor a developer ... so maybe I shouldn't respond ... but a guess ...

Do you have a phpcli.exe installed?

php.exe -f is telling php to execute a file.   Does that output of the command you run without the redirect have any HTML in it?

'SoS', Ken


In reply to Frederik Evans

Re: Recycle bin functionality

by Anthony Rimmer -
You could potentially try running the cron from within Moodle and looking at the output:
moodleulr/admin/settings.php?section=sitepolicies
In reply to Anthony Rimmer

Re: Recycle bin functionality

by Frederik Evans -
i already made the necessary changes. but strangely, it still does not appear. is there some unknown function or something that causes it to appear in the recycle bin, I Can't find anything, so am strongly suspecting there might be something external to the plugin itself, somewhere in the root directory of moodle that lists which plugins it will work with and which not. i have found that in other activities, there are two fields intro and introformat which are both consistent in all other plugins, maybe that external file looks for those fields and if it does not find them it excludes them ? i have wasted all avenues to no avail.
In reply to Frederik Evans

Re: Recycle bin functionality

by Anthony Rimmer -
From the guidance, 'intro' and 'introformat' are required fields for your install.xml file:
https://docs.moodle.org/dev/Activity_modules

I did note the following in the mod/pluginname/mod_form.php as well, which should add the fields to the instance
$this->standard_intro_elements(get_string('pluginname', 'pluginname'));

To be honest, it might be easier to work backwards and duplicate the label mod and put your custom functionality in it. All I did was duplicate it and rename instances of 'label' with 'catalogue', in both filenames and strings. There is also 'Label' in the language file that you'll want to update with e.g. 'Catalogue'
In reply to Anthony Rimmer

Re: Recycle bin functionality

by Frederik Evans -
Yes, we did, but that did not help at all. Any ideas? Why is it not possible to see the recycle bin.?

i am seeing this error message

Warning: rename(C:\Apache24\moodledata/cache/cachestore_file/default_application/core_plugin_functions/aft-cache/hShLCI5FK7.604e158dc3e189.42492905.temp,C:\Apache24\moodledata/cache/cachestore_file/default_application/core_plugin_functions/aft-cache/after_config_libphp-63895cd5cbf95a9bf8fe91c00f5e38de.cache): Access is denied. (code: 5) in C:\Apache24\htdocs\moodle\cache\stores\file\lib.php on line 733

but that does not give us much information on why certain plugins are not showing up on recycle bin.


In reply to Anthony Rimmer

Re: Recycle bin functionality

by Frederik Evans -
if the two fields intro and introformat are compulsory, is it possible these can not be populated, or better still, with the name of the plugin, but not appear on the mod_form. so far i have noticed that it is compulsory and must be in the mod_form
In reply to Anthony Rimmer

Re: Recycle bin functionality

by Frederik Evans -
i am doing that. i noticed there are two fields in the table, intro and introformat. What do these do, can we not have them appearing in the mod-form? the template should only show the report in html format. displays a moustache file.
In reply to Anthony Rimmer

Re: Recycle bin functionality

by Frederik Evans -
the activity is actually deleted. I checked the table, the information is cleared, however, we don't see it coming up on the recycle bin. we reran cron job and still does not show up. however any other activity we deleted immediately after, do show up. so definitively, it should have come up.
In reply to Frederik Evans

Re: Recycle bin functionality

by Anthony Rimmer -
Did you bump the version number of your plugin after you updated those lines?