/[drupal]/contributions/modules/masquerade/masquerade.module
ViewVC logotype

Diff of /contributions/modules/masquerade/masquerade.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.16.2.27, Thu Sep 10 20:13:15 2009 UTC revision 1.16.2.28, Thu Sep 10 20:58:21 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: masquerade.module,v 1.16.2.26 2009/09/04 17:07:21 deviantintegral Exp $  // $Id: masquerade.module,v 1.16.2.27 2009/09/10 20:13:15 deviantintegral Exp $
3    
4  /**  /**
5   * @file masquerade.module   * @file masquerade.module
# Line 427  function masquerade_block_1($record) { Line 427  function masquerade_block_1($record) {
427   * Masquerade block form validation.   * Masquerade block form validation.
428   */   */
429  function masquerade_block_1_validate($form, &$form_state) {  function masquerade_block_1_validate($form, &$form_state) {
430      global $user;
431    unset($form);    unset($form);
432    $name = $form_state['values']['masquerade_user_field'];    $name = $form_state['values']['masquerade_user_field'];
433    if ($name == variable_get('anonymous', t('Anonymous'))) {    if ($name == variable_get('anonymous', t('Anonymous'))) {
# Line 435  function masquerade_block_1_validate($fo Line 436  function masquerade_block_1_validate($fo
436    if ($_SESSION['masquerading']) {    if ($_SESSION['masquerading']) {
437      form_set_error('masquerade_user_field', t('You are already masquerading. Please <a href="@unswitch">switch back</a> to your account to masquerade as another user.', array('@unswitch' => url('masquerade/unswitch'))));      form_set_error('masquerade_user_field', t('You are already masquerading. Please <a href="@unswitch">switch back</a> to your account to masquerade as another user.', array('@unswitch' => url('masquerade/unswitch'))));
438    }    }
439    global $user;    if (module_exists('alt_login')) {
440    $masq_user = user_load(array('name' => $form_state['values']['masquerade_user_field']));      $alt_login = db_fetch_object(db_query("SELECT u.name FROM {users} u INNER JOIN {alt_login} al ON u.uid = al.uid WHERE al.alt_login = '%s'", $name));
441        if ($alt_login->name) {
442          $name = $alt_login->name;
443        }
444      }
445      $masq_user = user_load(array('name' => $name));
446    if (!$masq_user) {    if (!$masq_user) {
447      form_set_error('masquerade_user_field', t('User %masq_as does not exist. Please enter a valid username.', array('%masq_as' => $form_state['values']['masquerade_user_field'])));      form_set_error('masquerade_user_field', t('User %masq_as does not exist. Please enter a valid username.', array('%masq_as' => $form_state['values']['masquerade_user_field'])));
448    }    }
# Line 469  function masquerade_autocomplete($string Line 475  function masquerade_autocomplete($string
475    while ($user = db_fetch_object($result)) {    while ($user = db_fetch_object($result)) {
476      $matches[$user->name] = check_plain($user->name);      $matches[$user->name] = check_plain($user->name);
477    }    }
478    $matches[variable_get('anonymous', t('Anonymous'))] = variable_get('anonymous', t('Anonymous'));    if (stripos(variable_get('anonymous', t('Anonymous')), $string) === 0) {
479        $matches[variable_get('anonymous', t('Anonymous'))] = variable_get('anonymous', t('Anonymous'));
480      }
481    if (module_exists('devel')) {    if (module_exists('devel')) {
482      $GLOBALS['devel_shutdown'] = FALSE;      $GLOBALS['devel_shutdown'] = FALSE;
483    }    }
# Line 494  function masquerade_autocomplete_multipl Line 502  function masquerade_autocomplete_multipl
502    while ($user = db_fetch_object($result)) {    while ($user = db_fetch_object($result)) {
503      $matches[$prefix . $user->name] = check_plain($user->name);      $matches[$prefix . $user->name] = check_plain($user->name);
504    }    }
505      if (module_exists('alt_login')) {
506        $result = db_query_range("SELECT alt_login FROM {alt_login} u WHERE LOWER(alt_login) LIKE LOWER('%s%%')", $string, 0, 10);
507        while ($user = db_fetch_object($result)) {
508          $matches[$user->alt_login] = check_plain($user->alt_login);
509        }
510      }
511    if (module_exists('devel')) {    if (module_exists('devel')) {
512      $GLOBALS['devel_shutdown'] = FALSE;      $GLOBALS['devel_shutdown'] = FALSE;
513    }    }

Legend:
Removed from v.1.16.2.27  
changed lines
  Added in v.1.16.2.28

  ViewVC Help
Powered by ViewVC 1.1.2