You are here

revenue_sharing_basic.install in Google AdSense integration 7

Install file of the revenue_sharing_basic module.

File

old/revenue_sharing_basic/revenue_sharing_basic.install
View source
<?php

/**
 * @file
 * Install file of the revenue_sharing_basic module.
 */

/**
 * Implements hook_requirements().
 */
function revenue_sharing_basic_requirements($phase) {
  $requirements = array();
  $t = get_t();
  switch ($phase) {

    // At runtime, make sure that we have a publisher ID.
    case 'runtime':
      if (variable_get('cache', 0) && variable_get('adsense_id_module', ADSENSE_ID_MODULE_DEFAULT) == 'revenue_sharing_basic_adsense') {
        $requirements['revenue_sharing_nocache'] = array(
          'title' => $t('Revenue Sharing'),
          'value' => $t('Drupal page cache is enabled.'),
          'description' => $t('This causes conflicts with revenue sharing, since the pages are stored in the cache and are not dynamically generated. If you experience issues with revenue sharing, then disable the page cache.'),
          'severity' => REQUIREMENT_WARNING,
        );
      }
      break;
  }
  return $requirements;
}

/**
 * Implements hook_uninstall().
 */
function revenue_sharing_basic_uninstall() {
  variable_del('revenue_sharing_basic_client_id_profile_field');
  variable_del('revenue_sharing_basic_percentage_author');
  variable_del('revenue_sharing_basic_percentage_refer');
  variable_del('revenue_sharing_basic_revenue_enable');
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'revenue\\_sharing\\_basic\\_percentage\\_role\\_%'");
  foreach ($settings as $variable) {
    variable_del($variable->name);
  }
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'revenue\\_sharing\\_basic\\_node\\_type\\_%'");
  foreach ($settings as $variable) {
    variable_del($variable->name);
  }
}

/**
 * Update value of the revenue_sharing_basic_client_id_profile_field variable.
 */
function revenue_sharing_basic_update_7100(&$sandbox) {
  $value = variable_get('revenue_sharing_basic_client_id_profile_field', REVENUE_SHARING_BASIC_CLIENT_ID_PROFILE_FIELD_DEFAULT);
  if ($value != REVENUE_SHARING_BASIC_CLIENT_ID_PROFILE_FIELD_DEFAULT) {

    // Value is set to something useful.
    $new_value = 'profile:' . db_query("SELECT name FROM {profile_field} WHERE fid=:fid", array(
      ':fid' => $value,
    ))
      ->fetchField();
    variable_set('revenue_sharing_basic_client_id_profile_field', $new_value);
    return t('Updated the value of revenue_sharing_basic_client_id_profile_field to %value', array(
      '%value' => $new_value,
    ));
  }
  return '';
}

Functions

Namesort descending Description
revenue_sharing_basic_requirements Implements hook_requirements().
revenue_sharing_basic_uninstall Implements hook_uninstall().
revenue_sharing_basic_update_7100 Update value of the revenue_sharing_basic_client_id_profile_field variable.