user contact block

user contact block

by Heather P -
Number of replies: 2

Hello

this block was formerly called the  contact block. It is still in the old plugins list thing https://moodle.org/mod/data/view.php?d=13&rid=4513 and it says Moodle 2.

I'm trying to make it work in a 2.4.3 has anybody else got it to work properly? The version for Moodle 2 is definitely an upgrade on the one we have had for years.

I particularly want it as we have been using it for several years on the home page of our Moodle as a report worries / concerns button. Gives the students a form so they don't need an email client. We have it configured to only email 3 specific people (i.e we created a role for it) I can get it to look like it is working on a course page, but as soon as you click to use it it throws an error (QuickForm Error: element already exists Element 'cf_teacher3' already exists in HTML_QuickForm::addElement()
Backtrace :  etc. etc.) On the home page - it errors as soon as you try to add it to the page and it ends up making me delete the whole plugin in order to recover the home page.

If this one doesn't work, is there anything available for Moodle 2.4.3 that amounts to being a form in a block?

I've looked at the the new course contacts block, but that seems to be much more of an email type of thing rather than a small form we can click send on.

Thanks

Heather

Average of ratings: -
In reply to Heather P

Re: user contact block

by Chidambaresan ananthan -

Try People Block.It is Somewhat relavant to course contact block.

In reply to Chidambaresan ananthan

Re: user contact block

by Heather P -

Hi

Thank you. 

Clearly I've failed to make any sense at all. I've just looked at the people block and it is absolutely nothing like what I was trying to achieve! The people block is a bit like the new contacts block but nothing like the old user contact block. The new one is more teacher contacting student and the old one was more student contacting the teacher.

I've added an attachment showing what appears on the home page of my moodle. You click the button and it goes to a form. If the user is logged in it pre-populates with their name and email address, if they aren't it puts up a pair of boxes for the user to type into. It then has a subject box and then a message field and then at the bottom we have the reCAPTCHA stuff and a send or cancel button.

We have a dedicated role set up to receive messages from this block.

When I try to use the version 2 one in a Moodle 2.4.3 even before I've edited out the text for an image it fails on the home page with a coding error.

I currently have debug turned on and this is what it says:-

Coding error detected, it must be fixed by a programmer: PHP catchable fatal error
Debug info: Argument 1 passed to get_users_by_capability() must be an instance of context, null given, called in [dirroot]\blocks\user_contact\lib.php on line 32 and defined
Error code: codingerror
Stack trace:
line 406 of \lib\setuplib.php: coding_exception thrown
line 3510 of \lib\accesslib.php: call to default_error_handler()
line 32 of \blocks\user_contact\lib.php: call to get_users_by_capability()
line 84 of \blocks\user_contact\block_user_contact.php: call to user_contact_getallhiddenrecipients()
line 284 of \blocks\moodleblock.class.php: call to block_user_contact->get_content()
line 232 of \blocks\moodleblock.class.php: call to block_base->formatted_contents()
line 953 of \lib\blocklib.php: call to block_base->get_content_for_output()
line 1005 of \lib\blocklib.php: call to block_manager->create_block_contents()
line 353 of \lib\blocklib.php: call to block_manager->ensure_content_created()
line 6 of \theme\boxxie\layout\general.php: call to block_manager->region_has_content()
line 804 of \lib\outputrenderers.php: call to include()
line 734 of \lib\outputrenderers.php: call to core_renderer->render_page_layout()
line ? of unknownfile: call to core_renderer->header()
line 234 of \lib\outputrenderers.php: call to call_user_func_array()
line 313 of \admin\renderer.php: call to plugin_renderer_base->__call()
line 313 of \admin\renderer.php: call to core_admin_renderer->header()
line 488 of \admin\index.php: call to core_admin_renderer->admin_notifications_page()

 

Line 32 in the lib file is all about hidden users 

$hiddenrecipients = get_users_by_capability($blockcontext, 'block/user_contact:hiddenrecipient', 'u.id, u.firstname, u.lastname, u.email, u.mailformat', 'u.lastname ASC','','','','',false);
if ($debug) {

Sadly I'm not a php programmer so I'm lost at the first hurdle.

Hence wondering is there something new that replaces this very old block. If not, well maybe it is time to get started on learning to programme in php, it has been on the list of things to do for ling enoughsmile

Thank you.

Attachment ScreenShot008.png