You are here

panopoly_users.install in Panopoly 7

An installation file for Panopoly Users

File

modules/panopoly/panopoly_users/panopoly_users.install
View source
<?php

/**
 * @file
 * An installation file for Panopoly Users
 */

/**
 * Implements hook_update_dependencies().
 */
function panopoly_users_update_dependencies() {
  $deps = array();
  $deps['panopoly_users'][7001] = array(
    'panopoly_core' => 7002,
  );
  return $deps;
}

/**
 * Enable user_picture_field and copy from field_user_picture to users.picture.
 */
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');
}

Functions

Namesort descending Description
panopoly_users_update_7001 Enable user_picture_field and copy from field_user_picture to users.picture.
panopoly_users_update_dependencies Implements hook_update_dependencies().