Projet

Général

Profil

Révision 41cc1b08

Ajouté par Assos Assos il y a presque 9 ans

Update feeds 7.x-2.0-alpha9 -> 7.x-2.0-beta1

Install lib simplepie 1.3.1

Voir les différences:

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

  
3 3
/**
4 4
 * @file
5
 * FeedsUserProcessor class.
5
 * Contains FeedsUserProcessor.
6 6
 */
7 7

  
8
/**
9
 * Option to block users not found in the feed.
10
 *
11
 * @var string
12
 */
13
define('FEEDS_BLOCK_NON_EXISTENT', 'block');
14

  
8 15
/**
9 16
 * Feeds processor plugin. Create users from feed items.
10 17
 */
11 18
class FeedsUserProcessor extends FeedsProcessor {
19

  
12 20
  /**
13 21
   * Define entity type.
14 22
   */
......
132 140
      '#description' => t('This appends _test to all imported e-mail addresses to ensure they cannot be used as recipients.'),
133 141
      '#default_value' => $this->config['defuse_mail'],
134 142
    );
143
    $form['update_non_existent']['#options'][FEEDS_BLOCK_NON_EXISTENT] = t('Block non-existent users');
135 144
    return $form;
136 145
  }
137 146

  
......
193 202
       );
194 203
    }
195 204

  
196
    // Let other modules expose mapping targets.
197
    self::loadMappers();
198
    $entity_type = $this->entityType();
199
    $bundle = $this->bundle();
200
    drupal_alter('feeds_processor_targets', $targets, $entity_type, $bundle);
205
    $this->getHookTargets($targets);
201 206

  
202 207
    return $targets;
203 208
  }
......
231 236
    }
232 237
    return 0;
233 238
  }
239

  
240
  /**
241
   * Overrides FeedsProcessor::clean().
242
   *
243
   * Block users instead of deleting them.
244
   *
245
   * @param FeedsState $state
246
   *   The FeedsState object for the given stage.
247
   */
248
  protected function clean(FeedsState $state) {
249
    // Delegate to parent if not blocking or option not set.
250
    if (!isset($this->config['update_non_existent']) || $this->config['update_non_existent'] !== FEEDS_BLOCK_NON_EXISTENT) {
251
      return parent::clean($state);
252
    }
253

  
254
    if (!empty($state->removeList)) {
255
      // @see user_user_operations_block().
256
      // The following foreach is copied from above function but with an added
257
      // counter to count blocked users.
258
      foreach (user_load_multiple($state->removeList) as $account) {
259
        $this->loadItemInfo($account);
260
        $account->feeds_item->hash = $this->config['update_non_existent'];
261
        // For efficiency manually save the original account before applying any
262
        // changes.
263
        $account->original = clone $account;
264
        user_save($account, array('status' => 0));
265
        $state->blocked++;
266
      }
267
    }
268
  }
269

  
234 270
}

Formats disponibles : Unified diff