Index: flag.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/flag/Attic/flag.install,v retrieving revision 1.2.2.32.2.3 diff -u -p -r1.2.2.32.2.3 flag.install --- flag.install 28 Sep 2009 18:56:49 -0000 1.2.2.32.2.3 +++ flag.install 19 Oct 2009 08:11:07 -0000 @@ -7,25 +7,19 @@ */ /** - * Implementation of hook_install(). + * Implementation of hook_enable(). + * + * We create the demonstration flag on enable, so hook implementation in flag + * module will be used. */ -function flag_install() { - // Load the flag API in case we want to use it when installing. +function flag_enable() { + // Load the flag API in case we want to use it when enabling. include_once(drupal_get_path('module', 'flag') .'/flag.module'); - // If Views Bookmark is available, skip the install and do an upgrade instead. - if (strpos($GLOBALS['db_type'], 'mysql') === 0) { - include_once(drupal_get_path('module', 'flag') .'/includes/flag.views_bookmark.inc'); - if (flag_views_bookmark_update_needed()) { - flag_views_bookmark_update(); - return; - } - } - - $success = drupal_install_schema('flag'); - - if ($success) { - // Install a demonstration flag. + if (!flag_get_flags()) { + // Install a demonstration flag only if no flag exists. This is to prevent + // a case where a disables and enables the module, and the demonstration + // flag is overwritten or re-created. $flag = flag_flag::factory_by_content_type('node'); $configuration = array( 'name' => 'bookmarks', @@ -48,6 +42,25 @@ function flag_install() { $flag->form_input($configuration); $flag->save(); } +} + +/** + * Implementation of hook_install(). + */ +function flag_install() { + // Load the flag API in case we want to use it when installing. + include_once(drupal_get_path('module', 'flag') .'/flag.module'); + + // If Views Bookmark is available, skip the install and do an upgrade instead. + if (strpos($GLOBALS['db_type'], 'mysql') === 0) { + include_once(drupal_get_path('module', 'flag') .'/includes/flag.views_bookmark.inc'); + if (flag_views_bookmark_update_needed()) { + flag_views_bookmark_update(); + return; + } + } + + $success = drupal_install_schema('flag'); if ($success) { drupal_set_message(st('Flag module installed tables successfully.'));