socialfeed.install in Social Feed 7
Same filename and directory in other branches
Social Feeds installation functions.
File
socialfeed.installView source
<?php
/**
* @file
* Social Feeds installation functions.
*/
/**
* Implements hook_requirements().
*/
function socialfeed_requirements($phase) {
$requirements = $library = array();
// Ensure translations don't break at install time.
$t = get_t();
if ($phase == 'runtime') {
$library['facebook'] = libraries_detect('facebook');
$library['twitter'] = libraries_detect('twitter');
$library['instagram'] = libraries_detect('instagram');
foreach ($library as $key => $value) {
$error_type = isset($library[$key]['error']) ? drupal_ucfirst($library[$key]['error']) : '';
$error_message = isset($library[$key]['error message']) ? $library[$key]['error message'] : '';
}
if (!function_exists('curl_init')) {
$requirements['curl']['title'] = $t('cURL library');
$requirements['curl']['value'] = $t('Not installed');
$requirements['curl']['severity'] = REQUIREMENT_ERROR;
$requirements['curl']['description'] = $t('The cURL library is not installed. Please check the <a href="@url">PHP cURL documentation</a> for information on how to correct this.', array(
'@url' => 'http://www.php.net/manual/en/curl.setup.php',
));
}
if (!function_exists('json_decode')) {
$requirements['json']['title'] = $t('JSON extension');
$requirements['json']['value'] = $t('Not installed');
$requirements['json']['severity'] = REQUIREMENT_ERROR;
$requirements['json']['description'] = $t('The JSON library is not installed. Facebook needs the JSON PHP extension');
}
if (empty($library['facebook']['installed'])) {
$requirements['facebook'] = array(
'title' => $t('PHP SDK for Facebook APIs'),
'value' => $t('@e: At least @a', array(
'@e' => $error_type,
'@a' => SOCIALFEED_FACEBOOK_SDK_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('!error You need to download the !facebook,
place the facebook directory in the %path directory on your server
and extract the archive
.', array(
'!error' => $error_message,
'!facebook' => l($t('PHP SDK for Facebook APIs'), $library['facebook']['download url']),
'%path' => 'sites/all/libraries',
)),
);
}
elseif (version_compare($library['facebook']['version'], SOCIALFEED_FACEBOOK_SDK_MIN_PLUGIN_VERSION, '>=')) {
$requirements['facebook'] = array(
'title' => $t('PHP SDK for Facebook APIs'),
'severity' => REQUIREMENT_OK,
'value' => 'v' . $library['facebook']['version'] . ' installed',
);
}
else {
$requirements['facebook'] = array(
'title' => $t('PHP SDK for Facebook APIs'),
'value' => $t('At least @a', array(
'@a' => SOCIALFEED_FACEBOOK_SDK_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('You need to download a later version of the
!facebook and replace the old version located in the %path directory
on your server.', array(
'!facebook' => l($t('PHP SDK for Facebook APIs'), $library['facebook']['download url']),
'%path' => $library['facebook']['library path'],
)),
);
}
if (empty($library['twitter']['installed'])) {
$requirements['twitter'] = array(
'title' => $t('PHP SDK for Twitter APIs'),
'value' => $t('@e: At least @a', array(
'@e' => $error_type,
'@a' => SOCIALFEED_TWITTER_SDK_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('!error You need to download the !twitter,
place the twitter directory in the %path directory on your server
and extract the archive
.', array(
'!error' => $error_message,
'!twitter' => l($t('PHP SDK for Twitter APIs'), $library['twitter']['download url']),
'%path' => 'sites/all/libraries',
)),
);
}
elseif (version_compare($library['twitter']['version'], SOCIALFEED_TWITTER_SDK_MIN_PLUGIN_VERSION, '>=')) {
$requirements['twitter'] = array(
'title' => $t('PHP SDK for Twitter APIs'),
'severity' => REQUIREMENT_OK,
'value' => 'v' . $library['twitter']['version'] . ' installed',
);
}
else {
$requirements['twitter'] = array(
'title' => $t('PHP SDK for Twitter APIs'),
'value' => $t('At least @a', array(
'@a' => SOCIALFEED_TWITTER_SDK_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('You need to download a later version of the
!twitter and replace the old version located in the %path directory
on your server.', array(
'!twitter' => l($t('PHP SDK for Twitter APIs'), $library['twitter']['download url']),
'%path' => $library['twitter']['library path'],
)),
);
}
if (empty($library['instagram']['installed'])) {
$requirements['instagram'] = array(
'title' => $t('PHP SDK for Instagram APIs'),
'value' => $t('@e: At least @a', array(
'@e' => $error_type,
'@a' => SOCIALFEED_INSTAGRAM_SDK_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('!error You need to download the !instagram,
place the instagram directory in the %path directory on your server
and extract the archive
.', array(
'!error' => $error_message,
'!instagram' => l($t('PHP SDK for Instagram APIs'), $library['instagram']['download url']),
'%path' => 'sites/all/libraries',
)),
);
}
elseif (version_compare($library['instagram']['version'], SOCIALFEED_INSTAGRAM_SDK_MIN_PLUGIN_VERSION, '>=')) {
$requirements['instagram'] = array(
'title' => $t('PHP SDK for Instagram APIs'),
'severity' => REQUIREMENT_OK,
'value' => 'v' . $library['instagram']['version'] . ' installed',
);
}
else {
$requirements['instagram'] = array(
'title' => $t('PHP SDK for Instagram APIs'),
'value' => $t('At least @a', array(
'@a' => SOCIALFEED_INSTAGRAM_SDK_MIN_PLUGIN_VERSION,
)),
'severity' => REQUIREMENT_ERROR,
'description' => $t('You need to download a later version of the
!instagram and replace the old version located in the %path directory
on your server.', array(
'!instagram' => l($t('PHP SDK for Instagram APIs'), $library['instagram']['download url']),
'%path' => $library['instagram']['library path'],
)),
);
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function socialfeed_uninstall() {
variable_del('socialfeed_facebook_all_types');
variable_del('socialfeed_facebook_app_id');
variable_del('socialfeed_facebook_display_pic');
variable_del('socialfeed_facebook_display_video');
variable_del('socialfeed_facebook_no_feeds');
variable_del('socialfeed_facebook_page_name');
variable_del('socialfeed_facebook_post_type');
variable_del('socialfeed_facebook_secret_key');
variable_del('socialfeed_facebook_time_format');
variable_del('socialfeed_facebook_time_stamp');
variable_del('socialfeed_facebook_trim_length');
variable_del('socialfeed_instagram_api_key');
variable_del('socialfeed_instagram_api_secret');
variable_del('socialfeed_instagram_picture_count');
variable_del('socialfeed_instagram_picture_resolution');
variable_del('socialfeed_instagram_redirect_uri');
variable_del('socialfeed_instagram_user_id');
variable_del('socialfeed_twitter_access_token');
variable_del('socialfeed_twitter_access_token_secret');
variable_del('socialfeed_twitter_consumer_key');
variable_del('socialfeed_twitter_consumer_secret');
variable_del('socialfeed_twitter_time_format');
variable_del('socialfeed_twitter_time_stamp');
variable_del('socialfeed_twitter_tweets_count');
variable_del('socialfeed_twitter_username');
}
Functions
Name | Description |
---|---|
socialfeed_requirements | Implements hook_requirements(). |
socialfeed_uninstall | Implements hook_uninstall(). |