Projet

Général

Profil

Révision ec2b0e7b

Ajouté par Assos Assos il y a presque 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/feeds/plugins/FeedsUserProcessor.inc
108 108

  
109 109
    // Check when an user ID gets set or changed during processing if that user
110 110
    // ID is not already in use.
111
    $uid_is_set = FALSE;
111 112
    if (!empty($account->uid)) {
112 113
      $is_new = !empty($account->feeds_item->is_new);
113 114
      $different = !empty($account->feeds_item->entity_id) && $account->feeds_item->entity_id != $account->uid;
114 115
      if ($is_new || $different) {
116
        // Flag that an user ID is explicitly set. This will skip the
117
        // validations for existing user name and mail address defined below.
118
        $uid_is_set = TRUE;
119

  
120
        // Check if the given user ID already exists.
115 121
        $exists = entity_load_unchanged('user', $account->uid);
116 122
        if ($exists) {
117 123
          throw new FeedsValidationException(t('Could not update user ID to @uid since that ID is already in use.', array(
......
121 127
      }
122 128
    }
123 129

  
130
    // Look for other validation constraints.
131
    $errors = array();
132

  
133
    // Validate the user name.
134
    if ($error = user_validate_name($account->name)) {
135
      $errors[] = $error;
136
    }
137

  
138
    // Check for an existing user name, unless an user ID is explicitly set.
139
    if (!$uid_is_set && (bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('name', db_like($account->name), 'LIKE')->range(0, 1)->execute()->fetchField()) {
140
      $errors[] = t("The name '@name' is already taken.", array('@name' => $account->name));
141
    }
142

  
143
    // Check for an existing mail address, unless an user ID is explicitly set.
144
    if (!$uid_is_set && (bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('mail', db_like($account->mail), 'LIKE')->range(0, 1)->execute()->fetchField()) {
145
      $errors[] = t("The e-mail address '@email' is already taken.", array('@email' => $account->mail));
146
    }
147

  
124 148
    // Timezone validation.
125 149
    if (!empty($account->timezone) && !array_key_exists($account->timezone, system_time_zones())) {
126
      throw new FeedsValidationException(t("Failed importing '@name'. User's timezone is not valid.", array('@name' => $account->name)));
150
      $errors[] = t("Failed importing '@name'. User's timezone is not valid.", array('@name' => $account->name));
151
    }
152

  
153
    if (!empty($errors)) {
154
      throw new FeedsValidationException(implode("\n", $errors));
127 155
    }
128 156
  }
129 157

  

Formats disponibles : Unified diff