summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xauto_nodetitle.install19
-rw-r--r--auto_nodetitle.module26
2 files changed, 39 insertions, 6 deletions
diff --git a/auto_nodetitle.install b/auto_nodetitle.install
index 9b5792b..e291d6a 100755
--- a/auto_nodetitle.install
+++ b/auto_nodetitle.install
@@ -2,15 +2,26 @@
// $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'");
diff --git a/auto_nodetitle.module b/auto_nodetitle.module
index 292f504..e3886fd 100644
--- a/auto_nodetitle.module
+++ b/auto_nodetitle.module
@@ -159,10 +159,9 @@ function auto_nodetitle_node_settings_form(&$form) {
);
}
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, ''),
);
}
}
@@ -184,3 +183,26 @@ function auto_nodetitle_eval($code, $node) {
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;
+ }
+}