You are here

function revenue_sharing_by_role_settings in Google AdSense integration 5.2

1 call to revenue_sharing_by_role_settings()
revenue_sharing_by_role_adsense in contrib/revenue_sharing_by_role/revenue_sharing_by_role.module

File

contrib/revenue_sharing_by_role/revenue_sharing_by_role.module, line 38

Code

function revenue_sharing_by_role_settings() {
  $form = array();
  $module = 'revenue_sharing_by_role';
  include_once drupal_get_path('module', $module) . '/' . $module . '_help.inc';
  $form['help'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Help and instructions'),
  );
  $help_function = $module . '_help_text';
  $form['help']['help'] = array(
    '#type' => 'markup',
    '#value' => $help_function(),
  );
  $form['required'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t('Required parameters'),
  );
  $form['required'][REVENUE_SHARING_BY_ROLE_CLIENT_ID_PROFILE_FIELD] = array(
    '#type' => 'select',
    '#title' => t('Google AdSense client ID profile field'),
    '#default_value' => variable_get(REVENUE_SHARING_BY_ROLE_CLIENT_ID_PROFILE_FIELD, 0),
    '#options' => revenue_sharing_by_role_get_profile_fields(),
    '#required' => TRUE,
    '#description' => t('This is the profile field that holds the AdSense Client ID for the site owner as well as (optionally) for site users who participate in revenue sharing. You must enabled the profile module and create a new field for this.'),
  );
  $error_flag = revenue_sharing_by_role_adsense('status');
  if ($error_flag) {
    return $form;
  }
  $form['revenue'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Revenue sharing options'),
  );
  $form['revenue'][REVENUE_SHARING_BY_ROLE_ENABLE] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable revenue sharing'),
    '#return_value' => 1,
    '#default_value' => variable_get(REVENUE_SHARING_BY_ROLE_ENABLE, 0),
    '#description' => t('Note that enabling this will disable AdSense code caching, which can cause more resource usage for busy sites. The referral feature requires the referral module to be installed.'),
  );
  foreach (user_roles(true) as $key => $item) {
    $form['revenue']['revenue_sharing_by_role_percentage_author_' . $key] = array(
      '#type' => 'select',
      '#title' => t('Percentage of node views going to author with role ' . $item),
      '#default_value' => variable_get(REVENUE_SHARING_BY_ROLE_PERCENTAGE_AUTHOR . $key, 0),
      '#options' => drupal_map_assoc(array(
        0,
        5,
        10,
        15,
        20,
        25,
        30,
        40,
        50,
        60,
        70,
        75,
        80,
        90,
        100,
      )),
    );
  }
  if (module_exists('referral')) {
    $list = drupal_map_assoc(array(
      0,
      5,
      10,
      15,
      20,
      25,
      30,
      40,
      50,
      60,
      70,
      75,
      80,
      90,
      100,
    ));
    $form['revenue'][REVENUE_SHARING_BY_ROLE_PERCENTAGE_REFER] = array(
      '#type' => 'select',
      '#title' => t('Percentage of node views going to user who referred the author'),
      '#default_value' => variable_get(REVENUE_SHARING_BY_ROLE_PERCENTAGE_REFER, 0),
      '#options' => $list,
      '#description' => t('This feature requires the referral module to be installed.'),
    );
  }
  $form['revenue']['content'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Content types'),
    '#description' => t('Content types that have revenue sharing enabled.'),
  );
  foreach (node_get_types() as $type => $name) {
    $form['revenue']['content'][REVENUE_SHARING_BY_ROLE_NODE_TYPE . $type] = array(
      '#type' => 'checkbox',
      '#title' => $name->name,
      '#return_value' => 1,
      '#default_value' => variable_get(REVENUE_SHARING_BY_ROLE_NODE_TYPE . $type, 0),
    );
  }
  return $form;
}