You are here

flickrapi.install in Flickr API 7

Same filename and directory in other branches
  1. 6 flickrapi.install
  2. 7.2 flickrapi.install

Update functions for the FlickrAPI module.

File

flickrapi.install
View source
<?php

/**
 * @file
 * Update functions for the FlickrAPI module.
 */

/**
 * Use the string 'configure flickr api' instead of
 * configure_flickr_api for permissions.
 */
function flickrapi_update_7000() {
  db_update('role_permission')
    ->fields(array(
    'permission' => 'configure flickr api',
  ))
    ->condition('permission', 'configure_flickr_api')
    ->execute();
}

/**
 * Rename the variable 'flickrcachepath' to 'flickrapi_cache_path'
 */
function flickrapi_update_7001() {
  variable_set('flickrapi_cache_path', variable_get('flickrcachepath', '/tmp'));
  variable_del('flickrcachepath');
}

/**
 * Implements hook_uninstall().
 * Clean up old variables.
 */
function flickrapi_uninstall() {
  variable_del('flickrapi_cache');
  variable_del('flickrapi_cache_path');
  variable_del('flickrapi_api_key');
  variable_del('flickrapi_api_secret');
  variable_del('flickrapi_cache_duration');
  variable_del('flickrapi_default_nsid');
  variable_del('flickrapi_access_permissions');

  // flickrapi is disabled so we have to load it manually to use its functions.
  module_load_include('module', 'flickrapi', 'flickrapi');
  _flickrapi_oauth_clear();
}

/**
 * Implements hook_requirements().
 */
function flickrapi_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();
  $requirements['phpflickr_library']['title'] = $t('phpFlickr library');
  if ($phase !== 'install') {

    // Check if the required library is installed.
    $library = libraries_detect('phpFlickr');
    if (!empty($library) && $library['installed'] === TRUE) {
      $requirements['phpflickr_library']['value'] = $t('phpFlickr library installed');
    }
    else {

      // Set an error stating the required library is not properly installed.
      $requirements['phpflickr_library']['value'] = $t('Not installed!');
      $requirements['phpflickr_library']['description'] = $t('The phpFlickr library is not installed properly.');
      $requirements['phpflickr_library']['severity'] = REQUIREMENT_ERROR;
    }
  }
  return $requirements;
}

Functions

Namesort descending Description
flickrapi_requirements Implements hook_requirements().
flickrapi_uninstall Implements hook_uninstall(). Clean up old variables.
flickrapi_update_7000 Use the string 'configure flickr api' instead of configure_flickr_api for permissions.
flickrapi_update_7001 Rename the variable 'flickrcachepath' to 'flickrapi_cache_path'