When a user has been inactive for more than X minutes they are deemed not present. The IM drop down user selection block then shows zero elements.

I suspect that this is at least one cause of the intermittent log entry:

Location /caa/
Message warning: Invalid argument supplied for foreach() in /home/james/public_html/drupal/includes/common.inc on line 1352.

However I have not done exhaustive testing on this hypothesis and I am unfamiliar with both drupal and PHP.

I hacked my im.module to include:


            }
          }
+        if (count($items) > 1) {
            $form = form_textfield(t('Message'), 'message', $edit['message'], 20, 255);
            $form .= form_select(t('Select user'), 'receiver', '', $items);
            $form .= form_hidden('destination', $_GET['q']);
            $form .= form_submit(t('Go!'));
+        } else {
+          $form = t('No other user online');
+        }
          $block['content'] = form($form, 'post', url('im/send'));
        }

and the intermittent error I was getting seems to have gone away. I have also discovered it has another benefit in that I now don't get tempted to send messages to myself.

Comments

cubano’s picture

Hi. I remixed your hack to:

while ($uid = db_fetch_object($users)) {
+ if ($user->uid != $uid->uid)
$items[] = array($uid->uid => $uid->name);
}
}
// next line was exchanged with
+ if (count($items) >= 1) {

so I really cannot send messages to myself.

killes@www.drop.org’s picture

Thanks, fixed in cvs.

Anonymous’s picture