Moodle

Plug-in bulk user actions architecture

Details

  • Type: Sub-task Sub-task
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.9, 1.9.1, 1.9.2, 1.9.3
  • Fix Version/s: None
  • Component/s: Administration, Usability
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE

Description

The updated tool has plugin structure, very similar to gradebook reports structure - it was the base to start from. All actions are stored in /admin/user/actions/ folder; each action has its own folder with index.php, other scripts if necessary, and lang folder to store strings.
Updated user_bulk.php and user_bulk_forms.php now generate a list of actions from the list of folders in /action/, and the names of plug-ins are fetched from their corresponding string files.
When the user selects the action, the script redirects browser to /actions/[action_folder]/index.php - it's the main action page. The list of users to manipulate is still taken from $SESSION->bulk_users variable, and each action uses it as necessary. Any action-specific language strings can be stored in /lang/ subfolder of the action.

Implementing new actions are much easier:
1. Create new folder /actions/[actionname]/
2. Put index.php there to run the action
3. Put version.php with datestamps
4. Create /lang/en_utf8/ (and other language directories if necessary) subfolders
5. Put bulkuseractions_[actionname].php string file to language subfolders. The string file must include "pluginname" string to identify the action in action list.

The "standard" actions were reorganized to comply to this structure - in fact, they were just put to their corresponding folders and slightly edited.

Attached archive contains a patch which converts bulk user actions tool to plug-in architecture. It deletes standard actions and re-creates them in their corresponding folders.

Issue Links

Activity

Hide
Vlas Voloshin added a comment -

New functionality was added to bulk user actions architecture: now all actions are required to contain settings.php file with capability, needed to use that action. This is added merely for convenience, as this capability is checked for each action to determine whether to show this action in the action list. Actual capabilities needed to run the action are checked in the action itself. of course.
settings.php file has the following format:

<?php
$requirecapability = 'moodle/user:update';
?>

where 'moodle/user:update' should be changed to a needed capability.
If settings.php file is missing, the action is not included in the list.
To install this update, simply unpack the contents of BUA_update.zip to your /admin/user directory. The archive already contains settings.php files for all standard actions, as well as bulk enrolment and unenrolment.

Another new functionality may be to add db/access.php files to actions, which require new capabilities to be added into the system. But this will work only if we include code to check and update capabilities:

// /admin/index.php:486
upgrade_plugins('admin/user/actions', $CFG->admin.'/user/actions', "$CFG->wwwroot/$CFG->admin/index.php");

and new plugin type to /lib/access.php, function load_capability_def.
The question is - is there any need to add it? Or maybe standard capabilities are enough for bulk user actions to limit their display in the list - and their usage? Any suggestions are welcome.

Show
Vlas Voloshin added a comment - New functionality was added to bulk user actions architecture: now all actions are required to contain settings.php file with capability, needed to use that action. This is added merely for convenience, as this capability is checked for each action to determine whether to show this action in the action list. Actual capabilities needed to run the action are checked in the action itself. of course. settings.php file has the following format: <?php $requirecapability = 'moodle/user:update'; ?> where 'moodle/user:update' should be changed to a needed capability. If settings.php file is missing, the action is not included in the list. To install this update, simply unpack the contents of BUA_update.zip to your /admin/user directory. The archive already contains settings.php files for all standard actions, as well as bulk enrolment and unenrolment. Another new functionality may be to add db/access.php files to actions, which require new capabilities to be added into the system. But this will work only if we include code to check and update capabilities: // /admin/index.php:486 upgrade_plugins('admin/user/actions', $CFG->admin.'/user/actions', "$CFG->wwwroot/$CFG->admin/index.php"); and new plugin type to /lib/access.php, function load_capability_def. The question is - is there any need to add it? Or maybe standard capabilities are enough for bulk user actions to limit their display in the list - and their usage? Any suggestions are welcome.
Hide
Anthony Borrow added a comment -

Here is a possible example of where having a modular/plugin-able structure for bulk user actions would be helpful. Getting MDL-17010 resolved may allow something like CONTRIB-1656 to be a plugin rather than a patch. I certainly would like to see this improvement in Moodle 2.0 but think an argument could be made for adding it to 1.9. For admins, the improved functionality would facilitate greater control over managing their users but since bulk actions are restricted to admins it is not likely that any regressions would impact the majority of users. Peace - Anthony

Show
Anthony Borrow added a comment - Here is a possible example of where having a modular/plugin-able structure for bulk user actions would be helpful. Getting MDL-17010 resolved may allow something like CONTRIB-1656 to be a plugin rather than a patch. I certainly would like to see this improvement in Moodle 2.0 but think an argument could be made for adding it to 1.9. For admins, the improved functionality would facilitate greater control over managing their users but since bulk actions are restricted to admins it is not likely that any regressions would impact the majority of users. Peace - Anthony
Hide
Anthony Borrow added a comment -

Currently, CONTRIB-1656 makes use of the local folder to create the database; however, I wonder if it might be helpful for a bulk user action plugin to also include support for creating database so that we would have $CFG->admin/user/actions/pluginname/db. Peace - Anthony

Show
Anthony Borrow added a comment - Currently, CONTRIB-1656 makes use of the local folder to create the database; however, I wonder if it might be helpful for a bulk user action plugin to also include support for creating database so that we would have $CFG->admin/user/actions/pluginname/db. Peace - Anthony
Hide
Anthony Borrow added a comment -

Similarly, I would like for the bulk user plugin type to support its own language strings so perhaps something like /admin/user/actions/pluginname/lang/en_utf8/bulkaction_pluginname.php could be used. Peace - Anthony

Show
Anthony Borrow added a comment - Similarly, I would like for the bulk user plugin type to support its own language strings so perhaps something like /admin/user/actions/pluginname/lang/en_utf8/bulkaction_pluginname.php could be used. Peace - Anthony
Hide
Artem Andreev added a comment -

Bulk user actions improvement reworked from major patch to admin report "Advanced bulk user actions" to simplify development process. Git: https://github.com/andreev-artem/moodle_admin_report_advuserbulk

Show
Artem Andreev added a comment - Bulk user actions improvement reworked from major patch to admin report "Advanced bulk user actions" to simplify development process. Git: https://github.com/andreev-artem/moodle_admin_report_advuserbulk

People

Vote (5)
Watch (4)

Dates

  • Created:
    Updated: