fb_autopost.install in Facebook Autopost 7
Install file to support fb_autopost.module
File
fb_autopost.installView source
<?php
/**
* @file
* Install file to support fb_autopost.module
*/
/**
* Implements hook_requirements().
*/
function fb_autopost_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time.
$t = get_t();
// Disable these checks at install time, because failure then causes more
// problems due to module dependencies and Drupal's poor handling of
// requirement errors.
if ($phase != 'runtime') {
return $requirements;
}
// Check for the presence of facebook-php-sdk library
// given that we are in the runtime phase we can assume that
// drupal has been fully loaded and we can use libraries helpers.
$machine = 'facebook-php-sdk';
$requirements[$machine] = array(
'title' => $t('Facebook PHP SDK'),
);
$lib_path = libraries_get_path($machine);
if (file_exists($lib_path . '/src/facebook.php')) {
// Inform that the library has been found and what is the version of it
// If there is no such file or we cannot find the version.
$warning_data = array(
'description' => $t('The Facebook PHP SDK library has been found but we could not verify the version.'),
'severity' => REQUIREMENT_WARNING,
);
if (!file_exists($lib_path . '/src/base_facebook.php')) {
$requirements[$machine] += $warning_data;
}
else {
require_once $lib_path . '/src/base_facebook.php';
// The file has been found, now check the version of it.
$matches = array();
// Facebook PHP SDK contains a constant in base_facebook.php with the
// version.
$version = BaseFacebook::VERSION;
if (!empty($version)) {
// Set the requirement OK.
$requirements[$machine] += array(
'value' => $version,
'severity' => REQUIREMENT_OK,
);
}
else {
// If there is no information about the version return a warning.
$requirements += $warning_data;
}
}
}
else {
// Set a requirement error.
$requirements[$machine] += array(
'severity' => REQUIREMENT_ERROR,
'description' => $t('The Facebook PHP SDK library has not been installed. Please clone the git repository or download the library in the common library paths from !link.', array(
'!link' => l($t('here'), 'https://github.com/facebook/facebook-php-sdk'),
)),
);
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function fb_autopost_uninstall() {
variable_del('fb_autopost_app_id');
variable_del('fb_autopost_app_secret');
variable_del('fb_autopost_account_id');
variable_del('fb_autopost_page');
variable_del('fb_autopost_pages_access_tokens');
variable_del('fb_autopost_token');
}
/**
* Implements hook_update_N().
*/
function fb_autopost_update_7100(&$sandbox) {
// Fixes typo in variable name.
variable_set('fb_autopost_app_id', variable_get('fb_autopos_app_id', ''));
variable_set('fb_autopost_app_secret', variable_get('fb_autopos_app_secret', ''));
variable_del('fb_autopos_app_id');
variable_del('fb_autopos_app_secret');
}
/**
* Enable the new dependency.
*/
function fb_autopost_update_7101(&$sandbox) {
module_enable(array(
'fb_permissions',
));
}
Functions
Name | Description |
---|---|
fb_autopost_requirements | Implements hook_requirements(). |
fb_autopost_uninstall | Implements hook_uninstall(). |
fb_autopost_update_7100 | Implements hook_update_N(). |
fb_autopost_update_7101 | Enable the new dependency. |