You are here

function uc_coupon_register_form_user_admin_settings_alter in Ubercart Discount Coupons 6

Implementation of hook_form_FORM_ID_alter().

File

uc_coupon_register/uc_coupon_register.module, line 6

Code

function uc_coupon_register_form_user_admin_settings_alter(&$form, &$form_state) {
  $coupons = array(
    0 => t('None'),
  );
  $result = db_query("SELECT cid, name, code FROM {uc_coupons} WHERE status = 1 ORDER BY name ASC");
  while ($coupon = db_fetch_object($result)) {
    $coupons[$coupon->cid] = $coupon->name . ' (' . $coupon->code . ')';
  }
  $form['uc_coupon_register'] = array(
    '#type' => 'fieldset',
    '#title' => t('Coupons'),
  );
  $form['uc_coupon_register']['uc_coupon_register_cid'] = array(
    '#type' => 'select',
    '#title' => t('Coupon to issue upon registration'),
    '#description' => t('If enabled, the new user will be added to the user restrictions for the selected coupon, and the code will be sent to them by email.'),
    '#default_value' => variable_get('uc_coupon_register_cid', 0),
    '#options' => $coupons,
  );
  $form['uc_coupon_register']['uc_coupon_register_mail_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Email subject'),
    '#default_value' => variable_get('uc_coupon_register_mail_subject', t('Coupon code at !site')),
    '#maxlength' => 180,
  );
  $form['uc_coupon_register']['uc_coupon_register_mail_body'] = array(
    '#type' => 'textarea',
    '#title' => t('Email body'),
    '#description' => t('Available variables are:') . ' !username, !site, !password, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri, !login_url, !coupon_code, !coupon_name.',
    '#default_value' => variable_get('uc_coupon_register_mail_body', t("!username,\n\nThank you for registering at !site.\n\nYou may use the following coupon during checkout: !coupon_code\n\nPlease ensure you are logged in to your account, or you will not be able to use the coupon.\n\n\n--  !site team")),
    '#rows' => 10,
  );
  $form['buttons']['#weight']++;
}