The insert case in casetracker_nodeapi() determines uses the following expression to set the uid for the user who should be assigned:

$record->assign_to = is_numeric($record->assign_to) ? $record->assign_to : casetracker_get_uid($record->assign_to);

IMHO a username which contains only numbers may cause problems (for example the username 1 may set the superuser as active user).

Comments

nvahalik’s picture

Confirmed. This is definitely an issue. Steps to reproduce:

  1. Add a user named '1'
  2. Login as user '1'
  3. Create a case as '1' and assign it to '1'
  4. When case is created, it is assigned to 'Administrator'

FWIW, it seem like the "Drupal-way" would be to always make the assign_to the name of the assigned user, just like the way the node edit forms store the author. I would imagine that changing this might have other implications if other modules use assign_to and stick UID values instead of strings in here. That would remove the ambiguity, though.

KungFuLucky7’s picture

Version: master » 6.x-1.0-beta9
StatusFileSize
new5.49 KB

I created a patch to fix this issue so that casetracker will assign cases to users with numeric usernames. You can make this patch into a module if you like.

EmanueleQuinto’s picture

Version: 6.x-1.0-beta9 » master

We noticed the same issue on our Open Atrium instance at SF State as well.

Our problem comes from the fact that we are using Shibboleth as CAS and it needs the numeric SF State Id as username. We solved the issue without patching the casetracker module with a form_alter in our username feature (>6.x-1.0-alpha3) so that we use directly the UID.

If you prefer to handle in your module you can implement a form_alter hook as follow:

MYMODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id=='casetracker_basic_case_node_form') {
    // Assign to
    // Uses uid instead of user name to solve the issue:
    // "casetracker_nodeapi case insert should not use is_numeric($record->assign_to)"
    // http://drupal.org/node/923700
    if (!empty($form['casetracker']['assign_to']['#options'])) {
      $notification_team = array_flip($form['notifications']['notifications_team']['options']['#value']);
      $assign_to = $form['casetracker']['assign_to']['#options'];
      foreach ($assign_to as $key => $value) {
        if (isset($notification_team[$key])) {
          $uid = $notification_team[$key];
          unset($form['casetracker']['assign_to']['#options'][$key]);
          $form['casetracker']['assign_to']['#options'][$uid] = $value;
        }
      }
      $default_value = $form['casetracker']['assign_to']['#default_value'];
      if (isset($notification_team[$default_value])) {
        $form['casetracker']['assign_to']['#default_value'] = $notification_team[$default_value];
      }
    }
  }
KungFuLucky7’s picture

Version: master » 6.x-1.0-beta9
StatusFileSize
new1.04 KB

Follow-up with a better patch.