function flag_install in Flag 6
Same name and namespace in other branches
- 5 flag.install \flag_install()
- 6.2 flag.install \flag_install()
- 7.2 flag.install \flag_install()
Implementation of hook_install().
File
- ./
flag.install, line 11 - Flag module install/schema/update hooks.
Code
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) {
// Install a demonstration flag.
$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' => array(
'story',
'forum',
'blog',
),
);
$flag
->form_input($configuration);
$flag
->save();
}
if ($success) {
drupal_set_message(st('Flag module installed tables successfully.'));
}
else {
drupal_set_message(st('The installation of Flag module failed.'), 'error');
}
}