View source
<?php
function google_adwords_install() {
$created = drupal_install_schema('google_adwords');
if ($created) {
drupal_set_message(t('Google AdWords module installed successfully. You must set <a href="/admin/user/permissions#module-google_adwords">permissions</a> and <a href="/admin/settings/google_adwords">configure</a> the module. '));
}
else {
drupal_set_message(t('Table installation for the Google AdWords module was unsuccessful. The tables may need to be installed by hand. See google_adwords.install file for a list of the installation queries.'), 'error');
}
return;
}
function google_adwords_uninstall() {
db_query('DELETE FROM {variable} WHERE name LIKE "google_adwords_%"');
$deleted = drupal_uninstall_schema('google_adwords');
if ($deleted) {
drupal_set_message(t('Google AdWords module has been uninstalled successfully.'));
}
else {
drupal_set_message(t('Table removal for the Google AdWords module was unsuccessful. The tables may need to be uninstalled by hand. See google_adwords.install file for a list of the uninstall queries.'), 'error');
}
return;
}
function google_adwords_schema() {
$schema['google_adwords'] = array(
'description' => t('Stores Google AdWords for nodes.'),
'primary key' => array(
'vid',
),
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => t('The {node}.nid to associated with the Google AdWords.'),
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => t('Primary Key: The {node}.vid associated with the Google AdWords.'),
),
'enabled' => array(
'type' => 'int',
'description' => t('Useful to turn on and off Google AdWords on a per node basis.'),
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'label' => array(
'type' => 'varchar',
'default' => '',
'length' => 255,
),
'format' => array(
'type' => 'varchar',
'default' => '',
'length' => 10,
),
),
);
return $schema;
}
function google_adwords_update_6001() {
$ret = array();
db_add_field($ret, 'google_adwords', 'format', array(
'type' => 'varchar',
'length' => 10,
));
db_add_field($ret, 'google_adwords', 'color', array(
'type' => 'varchar',
'length' => 10,
));
return $ret;
}
function google_adwords_update_6102() {
$roles = user_roles();
foreach ($roles as $rid => $name) {
$old_key = 'google_adwords_track_' . str_replace(' ', '_', $name);
$new_key = 'google_adwords_track_' . $rid;
variable_set($new_key, variable_get($old_key, FALSE));
variable_del($old_key);
}
return array();
}