function flag_enable in Flag 6.2
Same name and namespace in other branches
- 5 flag.install \flag_enable()
- 7.2 flag.install \flag_enable()
Implements hook_enable().
We create the demonstration flag on enable, so hook implementations in flag module will fire correctly, as the APIs are not available on install.
File
- ./
flag.install, line 46 - Flag module install/schema/update hooks.
Code
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 (!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',
'global' => 0,
'show_on_page' => 1,
'show_on_teaser' => 1,
'show_on_form' => 1,
// The following UI labels aren't wrapped in t() because they are written
// to the DB in English. They are passed to t() later, thus allowing for
// multilingual sites.
'title' => 'Bookmarks',
'flag_short' => 'Bookmark this',
'flag_long' => 'Add this post to your bookmarks',
'flag_message' => 'This post has been added to your bookmarks',
'unflag_short' => 'Unbookmark this',
'unflag_long' => 'Remove this post from your bookmarks',
'unflag_message' => 'This post has been removed from your bookmarks',
'types' => _flag_install_get_suggested_node_types(),
);
$flag
->form_input($configuration);
$flag
->save();
}
}