function panopoly_users_update_7001 in Panopoly 7
Enable user_picture_field and copy from field_user_picture to users.picture.
File
- modules/
panopoly/ panopoly_users/ panopoly_users.install, line 22 - An installation file for Panopoly Users
Code
function panopoly_users_update_7001() {
module_enable(array(
'user_picture_field',
));
// When updating from REALLY old versions of Panopoly, the user picture field
// may not even exist on the user entity. It'll get created by Features later
// but there's no sense in trying to migrate data if it isn't around.
if (db_table_exists('field_data_field_user_picture')) {
$result = db_query("SELECT entity_id, field_user_picture_fid FROM {field_data_field_user_picture} WHERE entity_type = 'user'");
foreach ($result as $record) {
db_query("UPDATE {users} SET picture = :picture WHERE uid = :uid", array(
':picture' => $record->field_user_picture_fid,
':uid' => $record->entity_id,
));
}
}
// Set the variables that would be set via defaultconfig.
variable_set('user_pictures', 1);
variable_set('user_picture_style', 'panopoly_image_thumbnail');
}