-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.inc
52 lines (36 loc) · 1.35 KB
/
user.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
class TripUserMigration extends DrupalUser6Migration {
public function __construct(array $arguments) {
parent::__construct($arguments);
$this->addFieldMapping('field_user_image', 'filename');
$this->addFieldMapping('field_user_image:source_dir')
->defaultValue('http://trip.ee/files/imagecache/trip_picture_big/pictures');
$this->addFieldMapping('field_user_image:file_replace')
->defaultValue(FILE_EXISTS_REPLACE);
}
public function userQuery() {
// Do not attempt to migrate the anonymous or admin user rows.
$query = Database::getConnection('default', $this->sourceConnection)
->select('users', 'u')
->fields('u')
->condition('uid', 1, '>');
$query->orderby('uid', 'ASC');
return $query;
}
public function prepareRow($row) {
if (parent::prepareRow($row) === FALSE) {
return FALSE;
}
$row->filename = basename($row->picture);
}
public function complete($user, stdClass $row) {
$user_styles = array('user_tiny', 'user_small', 'user_medium', 'user_big');
$styles = image_styles();
foreach ($styles as $key => $style) {
if (in_array($key, $user_styles)) {
$file = file_load($user->field_user_image[LANGUAGE_NONE][0]['fid']);
image_style_create_derivative($styles[$key], $file->uri, image_style_path($key, $file->uri));
}
}
}
}