function uc_recurring_subscription_enable in UC Recurring Payments and Subscriptions 7.2
Same name and namespace in other branches
- 6.2 modules/uc_recurring_subscription/uc_recurring_subscription.install \uc_recurring_subscription_enable()
Implements hook_enable().
File
- modules/
uc_recurring_subscription/ uc_recurring_subscription.install, line 84 - Installs the Recurring Subscription module.
Code
function uc_recurring_subscription_enable() {
$pcid = 'uc_recurring_subscription';
if (db_query("SELECT COUNT(*) FROM {uc_product_classes} WHERE pcid = :pcid", array(
':pcid' => $pcid,
))
->fetchField() < 1) {
db_insert('uc_product_classes')
->fields(array(
'pcid' => $pcid,
'name' => 'Recurring Subscription',
'description' => 'A recurring subscription product used by the recurring subscription ui module to manage your subscription products',
))
->execute();
uc_product_node_info(TRUE);
node_types_rebuild();
menu_rebuild();
}
variable_set('node_options_' . $pcid, variable_get('node_options_product', array(
'status',
'promote',
)));
variable_set('uc_recurring_subscription_product_class', $pcid);
$attribute = new stdClass();
//@todo. There is something incorrect here because if you uninstall and reinstall, you get duplicate entries in the db.
$attribute->name = 'uc_recurring_subscription_payment_options';
$attribute->label = 'Payment Option';
$attribute->ordering = 0;
$attribute->required = 1;
$attribute->display = 1;
$attribute->description = 'The subscription payment options';
uc_attribute_save($attribute);
uc_attribute_subject_save($attribute, 'class', 'uc_recurring_subscription');
variable_set('uc_recurring_subscription_attribute', $attribute->aid);
}