Opigno Chat - Remove class and course chatrooms

Tim Sparrow
Forums
I am trying to remove all chatrooms other than public chatroom. I have taken a look at the opigno_chat_app.module but can't get my head around how to remove all groups other than the public chatroom. I can see the module is querying the ogmembership table and creating an array of groups the user is a member of, but am not sure how best to hard code so only the public chatroom is returned. (by gid, by name, other??) Many thanks, Tim
James Aparicio

Hi Tim,

Hi Tim,

Inside opigno_chat_app_drupal_chat_users you have a hook_drupal_chat_users.

By default only the Public chatroom exists. What the function does is that it adds the online users that are part of courses or classes that you are part of aswell, and creates rooms for each of those courses/classes. If you simply comment the code between:

$users['rooms'] = array();$users['users'] = array();and return $users;What will happen is exactly what you want. Only the public chatroom will be available. 

 

Best regards

Tim Sparrow

Thanks James. Makes perfect

Thanks James. Makes perfect sense once you explained it, however, I am now getting an error in the drupal_chat.module on line 920: *"Fatal error: Unsupported operand types in /home/****removed*****/public_html/sites/all/modules/drupalchat/drupalchat.module on line 920"* Below is my commented opigno_chat_app.module file: "<?php function opigno_chat_app_drupalchat_users() { Global $user, $base_url; $users['rooms'] = array(); $users['users'] = array(); /* TS - Commenting out to remove all class and course groups from the chat window $query = db_select('og_membership', 'ogm'); $query->fields('ogm', array()); $query->condition('ogm.etid', $user->uid, '='); $query->join('node', 'n', 'ogm.gid = n.nid'); $query->fields('n', array('title')); $query->join('og_membership', 'ogm2', 'ogm2.gid = ogm.gid'); $query->fields('ogm2', array()); $query->condition('ogm2.entity_type', 'user', '='); $query->condition('ogm2.state', '1', '='); $query->groupBy('ogm.gid'); $query->join('drupalchat_users', 'dcu', 'ogm2.etid = dcu.uid'); $query->condition('dcu.timestamp', (time() - variable_get('drupalchat_user_latency', 2)), '>='); $query->fields('dcu'); $query->condition('dcu.uid', $user->uid, '<>'); $query->addExpression('GROUP_CONCAT(dcu.uid)', 'alluids'); $query->addExpression('GROUP_CONCAT(dcu.name)', 'allnames'); $query->addExpression('GROUP_CONCAT(dcu.status)', 'allstatus'); $result = $query->execute(); while ($record = $result->fetchAssoc()) { $chatindex = 'c-' . $record['gid']; $users['rooms'][$chatindex]['name'] = $record['title']; $users['rooms'][$chatindex]['status'] = 1; if (variable_get('drupalchat_user_picture', 1) == 1) { $users['rooms'][$chatindex]['p'] = $base_url . '/' . drupal_get_path('module', 'drupalchat') . '/themes/' . variable_get('drupalchat_theme', 'light') . '/images/default_room.png'; } $uids = explode(",", $record['alluids']); $names = explode(",", $record['allnames']); $status = explode(",", $record['allstatus']); $i = 0; foreach ($uids as $uid) { $users['users'][$uid]['name'] = check_plain($names[$i]); $users['users'][$uid]['status'] = $status[$i]; if (variable_get('drupalchat_user_picture', 1) == 1) { $users['users'][$uid]['p'] = drupalchat_return_pic_url_any_user(user_load($uid)); } $i++; } } return $users; */ } function opigno_chat_app_init() { if (drupalchat_verify_access()) { drupal_add_js(array('drupalchat' => array('noUsers' => '
  • array('drupalchatnousers'))) . '>' . t('No users online') . "
  • \n",)), array('type' => 'setting')); } } "
    Tim Sparrow

    Ok, I am a complete muppet!

    Ok, I am a complete muppet! Re-read my commenting out and saw I had commented out the return $users; line as well. All works as expected now. Many thanks James
    James Aparicio

    Hi Tim,

    Hi Tim,

    You commented out the return. Remove the return part from beeing commented.

    Best regards