<?php
// $Id: notifications_ui.install,v 1.1.2.4.2.3 2010/03/12 13:28:09 jareyero Exp $

/**
 * Implementation of hook_install()
 * 
 * Set up some variables so basic options are enabled out of the box
 */
function notifications_ui_install() {
  variable_set('notifications_ui_user', array('page' => 'page', 'create' => 'create'));
  variable_set('notifications_ui_node', array('links' => 'links', 'teaserlinks' => 'teaserlinks', 'block' => 'block'));
  variable_set('notifications_ui_account_options', array('links' => 'links', 'block' => 'block'));
  // The most common options for notifications_content: thread, nodetype, author
  variable_set('notifications_ui_types', array('thread' => 'thread', 'nodetype' => 'nodetype', 'author' => 'author'));
}

/**
 * Implementation of hook_uninstall()
 */
function notifications_ui_uninstall() {
  // Some global variables
  variable_del('notifications_ui_per_type');
  variable_del('notifications_ui_user');
  variable_del('notifications_ui_node');
  variable_del('notifications_ui_account_options');
  // Just delete variables for subscription types and node types  
  variable_del('notifications_ui_types');
  foreach (array_keys(node_get_types()) as $type) {
    variable_del('notifications_node_ui_'. $type);
  }
}

/**
 * Update UI variables
 */
function notifications_ui_update_6000() {
  // All options will be messed up so we better do manual review
  variable_del('notifications_link_teaser');  
  drupal_set_message(t('Please, check all your Notifications UI settings and note the new options.'));
  return array();
}

/**
 * Disable cache in subscription block
 */
function notifications_ui_update_6001() {
  $ret = array();
  $ret[] = update_sql("UPDATE {blocks} SET cache = ". BLOCK_NO_CACHE ." WHERE module = 'notifications_ui'");
  $ret[] = update_sql("DELETE FROM {cache_block} WHERE cid LIKE 'notifications_ui:%'");
  return $ret;
}
