You are here

twitter_post.install in Twitter 7.5

Install, update and uninstall functions for the twitter module.

File

twitter_post/twitter_post.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the twitter module.
 *
 */

/**
 * Implements hook_uninstall().
 */
function twitter_post_uninstall() {
  variable_del('twitter_post_types');
  variable_del('twitter_post_default_format');
  variable_del('twitter_post_default_value');
  variable_del('twitter_post_on_update');
}

/**
 * Don't default to TinyURL any more.
 */
function twitter_post_update_7300() {
  if (variable_get('twitter_post_default_format', NULL) == 'New post: !title !tinyurl') {
    variable_set('twitter_post_default_format', "New post: !title !url-alias");
  }
  return t('Twitter Post now defaults to using aliases, not TinyURL.');
}

/**
 * Implements hook_update_N().
 *
 * Increase module weight to run after pathauto.
 */
function twitter_post_update_7301() {
  db_update('system')
    ->fields(array(
    'weight' => 10,
  ))
    ->condition('name', 'twitter_post', '=')
    ->execute();
  return t('Updated system weight to 10 for Twitter Post.');
}

/**
 * Add the new "post to twitter with global account" permission to all roles
 * that have the "post to twitter" permission.
 */
function twitter_post_update_7500() {
  $roles = db_query("SELECT rid\n    FROM {role_permission}\n    WHERE permission = 'post to twitter'")
    ->fetchCol();
  foreach ($roles as $rid) {
    $record = new StdClass();
    $record->rid = $rid;
    $record->permission = 'post to twitter with global account';
    $record->module = 'twitter';
    drupal_write_record('role_permission', $record);
  }
  drupal_set_message(t('A new permission "Post a message to Twitter using a global account" as been added to all roles that already had the "Post a message to Twitter" permission. It is recommended to <a href="@url">review the permissions</a> to ensure they are appropriate for this site\'s needs.', array(
    '@url' => url('admin/people/permissions'),
  )));
}

Functions

Namesort descending Description
twitter_post_uninstall Implements hook_uninstall().
twitter_post_update_7300 Don't default to TinyURL any more.
twitter_post_update_7301 Implements hook_update_N().
twitter_post_update_7500 Add the new "post to twitter with global account" permission to all roles that have the "post to twitter" permission.