-
Notifications
You must be signed in to change notification settings - Fork 1
/
userimage.inc
70 lines (56 loc) · 1.83 KB
/
userimage.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @file
* This migrates user photos
*
*/
class NistUserImageMigration extends NistMigration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import of user images');
$fields = array(
'changed' => 'Date the page was last modified',
'id' => 'Image ID',
'authorimageurl' => 'CP Image ID'
);
$this->highwaterField = array(
'name' => 'changed', // Column to be used as highwater mark
'alias' => 'w',
);
$json_file = '';
$this->source = new MigrateSourceList(new PageListJSON($json_file),
new PageItemJSON($json_file, array()), $fields);
$this->destination = new MigrateDestinationFile();
$this->map = new MigrateSQLMap($this->machineName,
array('id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'ImageID',
)
),
MigrateDestinationFile::getKeySchema()
);
$this->addFieldMapping('value', 'authorimageurl');
$this->addFieldMapping('preserve_files')
->defaultValue(true);
$this->addFieldMapping('file_replace')
->defaultValue(MigrateFile::FILE_EXISTS_REUSE);
$this->addFieldMapping('destination_dir')
->defaultValue('public://userphotos');
$this->addUnmigratedDestinations(array('uid', 'timestamp', 'path',
'destination_file', 'source_dir', 'urlencode'
));
}
/**
* Implementation of Migration::prepareRow($row).
*/
public function prepareRow($row) {
if (parent::prepareRow($row) === FALSE) :
return FALSE;
endif;
$this->drushLog($row->authorimageurl);
// add some time (one min) to the changed value so it is forced to be updated.
//$row->changed = $this->_get_updated_time_for_force_updating( $formattedDate );
}
}