2

I am working on a project that implements the Drupalchat module. Everything works perfectly, but the client requests some custom changes.

They want people to be unable to have private conversations with eachother, but they do need to be able to see eachother!

They can only chat in the public chatroom, that Drupalchat provides by default.

A moderator user (drupal user role) however can chat privately with other users.

Is there a clean way to "hook" into the drupalchat.js file and alter the behaviour for this?

I have found the portion of code that needs to be altered, but of course I don't want to hack the contrib module.

I tried IRC about this, but nobody seemed to have a clue how to implement this.

Anyone done something like this in the past?

Thanks in advance!

  • 2
    It's javascript so possibilities are few - either the library you're trying to integrate with has provided callbacks or (in an ideal world) a promise-based workflow that you can hook into, or you'll just need to rewrite the code that's already there until it does what you need. You can monkey-patch to avoid actually hacking contrib files, but you'll still need to do manual checks when you update to check nothing has broken. I don't know for sure, but I suspect converting a single-chat-room JS app to a multi-private-chat-room JS app is not going to be a 5 minute job – Clive Jun 22 '15 at 15:15
0

I believe this has already been answered here: How to override jQuery from contrib module

To override the JavaScript file added to a page from a module, you need to implement hook_js_alter()....

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.