Announcement : pluging for complete user data deletion in development

Announcement : pluging for complete user data deletion in development

by Eric Villard -
Number of replies: 20
Hi every body,

I'm very happy and proud to integrate the moodle community. sourire

I create this thread to announce that I'm working on a little functionality that permits to remove all the data of one or more users from the database and their documents from the moodle data directories. Preserving only their threads in forums, their contributions in wikis and glossaries, replacing them by an anonymous account.
My client, Grenoble Ecole de Management has this need, and we want to know if this kind of utility will interest some of you.

For the moment, the plugin in test is very basic, but seems to work correctly.
It offers the administrator the possibility to look for all users that have not been logged since a particular date, to select how many users the administrator wants and removes them definitively.

The principle of the plugin is to :
  • create an anonymous user account
  • delete all documents of the user to be deleted except from the forums, wikis and glossaries
  • replace the references of the user by the reference of the anonymous account in the forums, wikis and glossaries
  • look for all the database tables where a field corresponds to the id of the user and remove the records
I will add some improvements like just swapping the delete flag of the user database table.
But before I want to make it a little more clean before offer it to the community for testing purpose.

This thread is open to get some comments, ideas, criticisms...

thanks by advance for your suggestions

Eric
Average of ratings: -
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development

by Valery Fremaux -

Hi Eric, from not so far... (Cergy)

Your plugin should be quite valuable. I did recently that kind of cleanup "with my own hands", long process on a 1.8 version.

Be sure mass user functions in new 1.9 version do not do this already. I'll check it for you.

As a comment, it would be very valuable that other modules know how to get rid of user related data when your script is run. That is, calling an additional (and documented) callback, or relying on the new Moodle event API. The great power of Moodle is that it is extendible, and that transversal features as yours could continue to be propagated to new plugins without patching your code.

Thanks for you participation.

Valéry. 

In reply to Valery Fremaux

Re: Announcement : pluging for complete user data deletion in development

by Robert Brenstein -
See MDL-7918 and MDL-7919, both collecting dust...
Average of ratings: Useful (1)
In reply to Robert Brenstein

Re: Announcement : pluging for complete user data deletion in development

by Eric Villard -
Thanks Robert. I've linked this thread in one of the two issues.
Not the right I think. Can you do something please ?

Eric
In reply to Valery Fremaux

Re: Announcement : pluging for complete user data deletion in development

by Eric Villard -
Valery, thanks for your comment.

In fact, the plugin I've made cleans up all the data of users the administrator have selected, and does this in the entire database, including activity modules. Only the administrator can access this feature by a link in his administration menu.
I'm going to look for the Moodle Event API, because it seems to be very interesting.
But in the case described here, I don't know if it has a real interest because this is the plugin itself that has the responsability of the deletion of all the data, not the modules. But maybe it isn't the good way.

What do you think about ?

Eric

PS : can you link here some subjects or documentations that has an interest with this problematic ?
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development

by Valery Fremaux -

Excuse moi de ma réponse tardive à ce sujet. Je n'avais pas vu passer le message.

En effet, le problème que tu vas avoir en laissant toute la responsabilité de la suppression de données à ton module est le problème de l'extensibilité du service aux futurs modules. Si des modules sont développés ultérieurement à ta sous application, il ne seront jamais pris en charge. C'est dommage.

Par contre si tu propose aux modules d'appeler un callback, tu as un autre problème, les premiers module ne seront pas revus ni patchés par leurs anciens concepteurs.

La solution est donc... ailleurs.

En fait la meilleure stratégie est une combinaison des deux. Les anciens sont pris en charge par ton appli sur la base de l'existant, et un appel à un callback détecté "à chaud" dans les modules permet de continuer à prendre en charge les futures propositions.

C'est comme ça que j'ai résolu le problème du moteur de recherche global, qui avait exactement ce même problème de pérénisation. 

In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Eric Villard -
hi,

here is a standalone version of our "in development" plugin for complete user data deletion.
This version is for testing purpose.
Despite all tests and precautions, we can not guarantee any computer damage that could be caused by this plugin. Don't test it on a production server !!!

The main part of the code is documented, please excuse-me for my "french" english wink.

The plugin is available in french and english (I'll made the traduction, so ... the same as before...)

To install it, just unzip the mam and the admin folders to your moodle root directory.

To access the plugin, log you as admin or with an account that have admin privileges.
In the site administration menu, you should see a "Data Base Maintenance" ("Maintenance de la base de données" for the french version) folder. Open it and you should see the link "User data cleanup" ("Nettoyage des données utilisateurs" for the french version) to access the plugin.

We'll hope to have some comments, suggestions, criticisms about it, and if you have any questions please feel free to ask me, I'll be glad to answer you.

Thanks by advance for your contribution

Eric
Average of ratings: Useful (1)
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Eugenio Rodríguez Peláez -
Hi!. I tested the pluging on moodle 1.9 and it has worked very wellrisa. I am very grateful to plug this because I had serious problems with undesirable persons who were registered on my site.
Very good.Congratulations.Thank you and pardon for my English.tímido
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Hoang Quang Huy -
Thank you! It works well with Moodle 1.8.
But It can only delete users who did not log in for a time.
I want to search and then delete a group of users by their login name ( examples containing 2005).
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Elizabeth Senger -

This is great - just what we needed!

However, I just installed it, and when I clicked on the User Data Cleanup link I just get a completely white page.  It's pointing to http://www.xxxxxxx/com/mam/addons/usercleaner/gui/usercleaner.php, which I assume is the correct script.

The odd thing is that the new menu shows up when I click the "Home" page, but it doesn't appear when I'm anywhere else in the admin menus.

I turned debugging on, and the error is:

Catchable fatal error: Object of class admin_root could not be converted to string in /admin/pagelib.php on line 149

In reply to Elizabeth Senger

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Eric Villard -
Hi Elizabeth,

some definitions of admin functions seem to have change since Moodle 1.8.x.

To correct this bug replace ./mam/addons/usercleaner/gui/usercleaner.php by the file linked here

hope that's help

best regards

Eric
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Elizabeth Senger -
Thanks so much - that worked perfectly!
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Monica Franz -
Hi Eric!

Is your plugin listed in Moodle "Modules and Plugins"? If yes, what's the name?

Cheers,

Monica
In reply to Monica Franz

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Eric Villard -
Hi Monica,

not at this time, I don't have any access to the contribution repository.

Eric
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Hubert Chathi -
You don't need contrib access to add an entry to the Modules and Plugins database. You can just click on "Add an entry" (although your entry will need to be approved before it shows up).
Average of ratings: Useful (1)
In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Guillermo Madero -

Does it work for 1.9.9? I installed it and got the following:

Notice: Undefined property: stdClass::$users in G:\Prj\www\web\moodle\mam\addons\usercleaner\lib\usercleanerlib.php on line 34
None of the users had been removed.

Thanks in advance,

Guillermo M.

In reply to Guillermo Madero

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Eric Villard -

hi Guillermo,

I'm sorry but I didn't see your post before.

Here is a version that should work.

Just extract the two folders of this archive in your moodle root directory.

best regards

Eric

In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Guillermo Madero -

Merci beaucoup! I'll try it.

Cheers!

In reply to Eric Villard

Re: Announcement : pluging for complete user data deletion in development - a standalone version is linked

by Adele Thomas -

Thank you for reminding me not to test this on a production server! You saved me a lot of trouble. Logging in as an admin is fun but scary at the same time. I found the userdata cleanup plug-in really helpful! I also think your English is great smile.

http://moodle.org/mod/data/iaq source/view.php?id=6009

There's a link if you need it!

Thanks again!

Adele