Anyways, my modifications were direct and I didn't bother to make this functionality 'modular.' It is more of a patch really. I would just like to post my mods for anyone else to use and hopefully get some feedback on whether you think this is a useful addition and if there are any bugs I overlooked.
I changed 2 of the base block files and created two more. All files are included in the .zip and can be applied by simply extracting into your moodle folder.
The two files I changed were:
/moodle/blocks/moodleblock.class.php
/moodle/lib/blocklib.php
IMPORTANT NOTE: If you are planning on applying these modifications, I would highly recommend backing up the original copies of the files.
I also created two files:
/moodle/blocks/config.html
/moodle/lib/rolespecific.php
Good luck to all, and I would really appreciate some feedback, thanks
Dave
EDIT: I called this functionality a Capability for convenience when in actual implementation it doesn't use the capabilities system in Moodle at all.
Re: New Role Specific Block Capability - need feedback
I have not yet had a chance to implement this and should be able to look at this next week, but reading it sounds like something we could use.
BTW: How easy could this type of functionality be to implement for the main page resouces i.e. Labels etc. As I would like to be able to hide specific labels etc., for different users.
Unfortunately I am not in a position to do this myself, due to I am new to Moodle and PHP.
Regards,
Chris Plaistow
Re: New Role Specific Block Capability - need feedback
When I find the time I plan on writing a simple script to apply the 'patch' and create backups of the replaced files automatically (permissions allowing) to make implementing this functionality a little more user friendly.
I don't know too much about how resources work in comparison to blocks but I will take a look at them when I get the chance although I can't see it being overly difficult to implement the same sort of functionality. I'll keep you posted,
Dave
Dave
Just found your "minor adjustments" - excellent job. I needed to have no blocks at all for users in courses and did not want to have to get the admin block every time I wanted to change settings. Just what the doctor ordered!
Took your advise and backed up the original files (oh ye of little faith ) but am pleased to report that it all went smoothly (1.8, MySQL) - works like a dream. Thanks for contributing it.
I did experience something worth mentioning - it was caused by my stupidity . I restricted the Site Administration block to administrators as it disappeared - why I did it, I don't know as it is already hidden to everyone else. It certainly made me sweat for a minute though as I thought I'd locked myself out of the site settings and would have to start again - doing a new instance so not backed up yet. Got it back using the Back button (disabled role specific capability in block settings and resaved). Mentioned this just in case there is someone else as daft as me out there in Moodleland!!!!
Regards
Carl
Thanks for your feedback! I looked into the points you made and it turns out its a bug I missed. Exactly the reason I put it up here in the first place, great job.
As you mentioned, the bug basically allows you to restrict access to the block from ALL types of accounts effectively making it disappear. I was under the impression that Moodle would still print the skeleton of the block (which includes the edit icon) to an admin account when editing was on, even if you specified not to display to admin, allowing them to at least edit (to restore privileges). Turns out this is not the case and blocks are disappearing.
Thanks again to Carl for finding this bug and I will be fixing it very soon (seeing as I can't find a way to get the blocks back without going into the DB).
Thanks for this!
Very helpful!
This was REALLY helpful to me.
I'm finding now that I have so many users I won't have time to manually add and subtract people from each course.
However, I do have several large groups of users (3,500 in one, 250, in another) and a few smaller groups (10-20).
I'm trying to figure out how to get moodle to auto add based on an external feild from my databse when I grab the students from that external database with an ODBC connection.
Make any sense?
thoughts?
THanks again for the patch, it was JUST what I was looking for!
Re: New Role Specific Block Capability - need feedback
Just found this patch on a Moodle I administer. Why would this be needed? AFAICS, the functionality is available in Moodle already...
- login with an admin acct
- on the homepage, "turn editing on"
- every block on the page has a face-and-mask icon, the mouseover tooltop says "assign roles" -- choose a block to experiment and click on that icon...
- you'll be on a role-assign / role-override page specific for that block
- click on "override roles" to switch to viewing overrides
- click on the "Guest" role, you'll see some capabilities, including "moodle/block:view" - set it to "prevent" and click submit
- repeat the previous step for all the roles that should not see the block
- login as different users to corroborate the effect.
Is there any flaw in the process I've outlined? What use cases are not covered with this?
Re: New Role Specific Block Capability - need feedback
moodle/site:accessallgroups ) Which doesn't do much. Currently (1.8.3) view type capabilities have to coded on a per-block basis (such as View course menu block/course_menu:view for course menu).
It would be great to have some basic capabilities like view, edit, etc. be settable for all blocks.
Re: New Role Specific Block Capability - need feedback
The flaw in Martín's plan is that its a new capability and thus won't work on 1.8.
Dan
Re: New Role Specific Block Capability - need feedback
Ah! That explains -- I was just going to say that every block has moodle/block:view on my setup... naturally this is a prod site running 1.9.
Thanks Dan!
Re: New Role Specific Block Capability - need feedback
y0u 4r3 7h3 3|173!
So 1.9 will have the ability to hide / display blocks via Martín's method built in?
Will this include custom blocks, or will they need the correct attributes assigning to them?
Thanks,
Alistair
Re: New Role Specific Block Capability - need feedback
Actually, I've run into a bit of a roadblock with my pure-roles implementation based on the options you've added. See http://moodle.org/mod/forum/discuss.php?d=84472