You are here

function uc_addresses_install in Ubercart Addresses 7

Same name and namespace in other branches
  1. 5.2 uc_addresses.install \uc_addresses_install()
  2. 5 uc_addresses.install \uc_addresses_install()
  3. 6.2 uc_addresses.install \uc_addresses_install()
  4. 6 uc_addresses.install \uc_addresses_install()

Implements hook_install().

File

./uc_addresses.install, line 141
Install file for Ubercart Addresses.

Code

function uc_addresses_install() {
  $t = get_t();

  // Setup default permissions. Authenticated users will automatically
  // be granted with permissions to manage their own addresses.
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'view own addresses',
    'add/edit own addresses',
    'delete own addresses',
  ));

  // Increase the weight of uc_addresses relative
  // to uc_quote by an addition of 1 so that
  // uc_addresses module can undo some of the actions
  // done by uc_quote's form alter, which causes the
  // delivery address form to disapear on checkout.
  //
  // See also http://drupal.org/node/1421720.
  $weight = db_select('system', 's')
    ->fields('s', array(
    'weight',
  ))
    ->condition('name', 'uc_quote', '=')
    ->execute()
    ->fetchField();
  db_update('system')
    ->fields(array(
    'weight' => $weight + 1,
  ))
    ->condition('name', 'uc_addresses', '=')
    ->execute();
  drupal_set_message($t("Ubercart Addresses is installed. The authenticated user automatically was granted the permissions %view_own, %edit_own and %delete_own.", array(
    '%view_own' => $t('view own addresses'),
    '%edit_own' => $t('add/edit own addresses'),
    '%delete_own' => $t('delete own addresses'),
  )), 'status');
}