Projet

Général

Profil

Révision b858700c

Ajouté par Assos Assos il y a environ 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/masquerade/masquerade.module
28 28
      'title' => t('Masquerade as user'),
29 29
      'description' => t('Masquerade as another user.'),
30 30
    ),
31
    'masquerade as any user' => array(
32
      'title' => t('Masquerade as any user'),
33
      'description' => t('Masquerade as any user.'),
34
      'restrict access' => TRUE,
35
    ),
31 36
    'masquerade as admin' => array(
32 37
      'title' => t('Masquerade as admin'),
33 38
      'description' => t('Masquerade as the site admin (UID 1).'),
39
      'restrict access' => TRUE,
34 40
    ),
35 41
    'administer masquerade' => array(
36 42
      'title' => t('Administer Masquerade'),
37 43
      'description' => t('Perform administration tasks and configure the Masquerade module.'),
44
      'restrict access' => TRUE,
38 45
    ),
39 46
  );
40 47
}
......
410 417
  // hidden.
411 418
  $allowed_uids = db_query("SELECT uid_to FROM {masquerade_users} WHERE uid_from = :uid_from", array(':uid_from' => $user->uid))
412 419
    ->fetchCol();
420
  $can_masquerade_as_user = in_array($account->uid, $allowed_uids) || user_access('masquerade as any user');
413 421

  
414
  if (user_access($perm) && empty($account->masquerading) && $user->uid != $account->uid && in_array($account->uid, $allowed_uids)) {
422
  if (user_access($perm) && empty($account->masquerading) && $user->uid != $account->uid && $can_masquerade_as_user) {
415 423
    $account->content['masquerade'] = array(
416 424
      '#markup' => l(t('Masquerade as !user', array('!user' => $account->name)),
417 425
        'masquerade/switch/' . $account->uid,
......
652 660
    ->execute()
653 661
    ->fetchField();
654 662
  if ($to_uid !== FALSE) {
655
    $allowed = db_select('masquerade_users', 'm')
656
      ->fields('m', array('uid_to'))
657
      ->condition('m.uid_to', $to_uid, '=')
658
      ->condition('m.uid_from', $user->uid, '=')
659
      ->execute()
660
      ->fetchField();
663
    $allowed = user_access('masquerade as any user') ||
664
               db_select('masquerade_users', 'm')
665
                  ->fields('m', array('uid_to'))
666
                  ->condition('m.uid_to', $to_uid, '=')
667
                  ->condition('m.uid_from', $user->uid, '=')
668
                  ->execute()
669
                  ->fetchField();
661 670
  }
662 671
  if (isset($_SESSION['masquerading'])) {
663 672
    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', array('query' => array('token' => drupal_get_token('masquerade/unswitch')))))));

Formats disponibles : Unified diff