// $Id$
/**
-* Implementation of hook_install().
-*/
+ * Implementation of hook_install().
+ */
function auto_nodetitle_install() {
db_query("UPDATE {system} SET weight = 5 WHERE name = 'auto_nodetitle'");
}
/**
-* make sure hooks are invoked after cck main hooks
-*/
+ * Implementation of hook_uninstall().
+ */
+function auto_nodetitle_uninstall() {
+ foreach (node_get_types('names') as $type => $type_name) {
+ variable_del('ant_'. $type);
+ variable_del('ant_pattern_'. $type);
+ variable_del('ant_php_'. $type);
+ }
+}
+
+/**
+ * make sure hooks are invoked after cck main hooks
+ */
function auto_nodetitle_update_1() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = 5 WHERE name = 'auto_nodetitle'");
);
}
else {
- // if user doesn't have PHP permission, their submission will reset PHP evaluation
$form['auto_nodetitle']['auto_nodetitle_php'] = array(
'#type' => 'value',
- '#value' => 0,
+ '#value' => variable_get('ant_php_'. $form['#node_type']->type, ''),
);
}
}
ob_end_clean();
return $output;
}
+
+/**
+ * Implementation of hook_node_type().
+ */
+function auto_nodetitle_node_type($op, $info) {
+ switch ($op) {
+ case 'delete':
+ variable_del('ant_'. $info->type);
+ variable_del('ant_pattern_'. $info->type);
+ variable_del('ant_php_'. $info->type);
+ break;
+ case 'update':
+ if (!empty($info->old_type) && $info->old_type != $info->type) {
+ variable_set('ant_'. $info->type, auto_nodetitle_get_setting($info->old_type));
+ variable_set('ant_pattern_'. $info->type, variable_get('ant_pattern_'. $info->old_type, ''));
+ variable_set('ant_php_'. $info->type, variable_get('ant_php_'. $info->old_type, ''));
+ variable_del('ant_'. $info->old_type);
+ variable_del('ant_pattern_'. $info->old_type);
+ variable_del('ant_php_'. $info->old_type);
+ }
+ break;
+ }
+}