likebtn.install in Like Button 7
Same filename and directory in other branches
Install, update and uninstall functions for the LikeBtn module.
File
likebtn.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the LikeBtn module.
*/
/**
* Implements hook_install().
*/
function likebtn_install() {
$t = get_t();
drupal_set_message($t("LikeBtn settings are available under !link", array(
'!link' => l($t('Administration > Web services > LikeBtn configuration'), 'admin/config/services/likebtn'),
)));
}
/**
* Implements hook_uninstall().
*/
function likebtn_uninstall() {
variable_del('likebtn_nodetypes');
variable_del('likebtn_comments_nodetypes');
variable_del('likebtn_view_modes');
variable_del('likebtn_weight');
variable_del('likebtn_plan');
variable_del('likebtn_account_data_email');
variable_del('likebtn_account_data_api_key');
variable_del('likebtn_sync_inerval');
variable_del('likebtn_html_before');
variable_del('likebtn_html_after');
variable_del('likebtn_alignment');
variable_del('likebtn_user_logged_in');
variable_del('likebtn_settings_local_domain');
variable_del('likebtn_settings_subdirectory');
require_once dirname(__FILE__) . '/likebtn.module';
$settings = unserialize(LIKEBTN_SETTINGS);
foreach ($settings as $option_name => $option_info) {
variable_del('likebtn_settings_' . $option_name);
}
variable_del('likebtn_last_sync_time');
variable_del('likebtn_last_successfull_sync_time');
variable_del('likebtn_last_locale_sync_time');
variable_del('likebtn_last_style_sync_time');
variable_del('likebtn_locales');
variable_del('likebtn_styles');
// Delete dynamically named variables.
db_delete('variable')
->condition('name', 'likebtn_comments_sort_enabled_%', 'LIKE')
->execute();
db_delete('variable')
->condition('name', 'likebtn_comments_sort_by_%', 'LIKE')
->execute();
db_delete('variable')
->condition('name', 'likebtn_comments_sort_order_%', 'LIKE')
->execute();
cache_clear_all('variables', 'cache_bootstrap');
}
/**
* Implements hook_field_schema().
*/
function likebtn_field_schema($field) {
return array(
'columns' => array(
'likebtn_likes' => array(
'type' => 'int',
'size' => 'normal',
'not null' => FALSE,
'sortable' => TRUE,
'default' => 0,
'description' => 'Likes count',
),
'likebtn_dislikes' => array(
'type' => 'int',
'size' => 'normal',
'not null' => FALSE,
'sortable' => TRUE,
'default' => 0,
'description' => 'Dislikes count',
),
'likebtn_likes_minus_dislikes' => array(
'type' => 'int',
'size' => 'normal',
'not null' => FALSE,
'sortable' => TRUE,
'default' => 0,
'description' => 'Likes minus dislikes',
),
),
);
}
/**
* Populate vote_source field in votingapi_vote table with like or dislike.
*/
function likebtn_update_7100() {
db_query("UPDATE {votingapi_vote} SET vote_source = 'like' WHERE vote_source = '' and uid = 0 and value_type = 'points' and value >= 0");
db_query("UPDATE {votingapi_vote} SET vote_source = 'dislike' WHERE vote_source = '' and uid = 0 and value_type = 'points' and value < 0");
}
/**
* Move tag data to vote_source. Set tag to likebtn.
*
* Change vote_source 'vote' to 'entity'.
*/
function likebtn_update_7101() {
db_query("UPDATE {votingapi_vote} SET vote_source = tag, tag = '" . LIKEBTN_VOTING_TAG . "' WHERE vote_source in ('like', 'dislike')");
db_query("UPDATE {votingapi_vote} SET vote_source = '" . LIKEBTN_VOTING_VOTE_SOURCE . "' WHERE vote_source = 'vote' and tag = '" . LIKEBTN_VOTING_TAG . "'");
}
Functions
Name![]() |
Description |
---|---|
likebtn_field_schema | Implements hook_field_schema(). |
likebtn_install | Implements hook_install(). |
likebtn_uninstall | Implements hook_uninstall(). |
likebtn_update_7100 | Populate vote_source field in votingapi_vote table with like or dislike. |
likebtn_update_7101 | Move tag data to vote_source. Set tag to likebtn. |