home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (calendar_ical.install)

This example Drupal source code file (calendar_ical.install) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, cache_views, database, db_query, delete, directory, displays, file, from, function, ical, php, sql, where

The calendar_ical.install Drupal example source code

<?php
// $Id: calendar_ical.install,v 1.1.2.6 2010/02/28 14:23:48 karens Exp $

/**
 * Implementation of hook_install().
 */
function calendar_ical_install() {
  db_query("UPDATE {system} SET weight = 1 WHERE name = 'calendar_ical'");
}

/**
 * Make sure handlers for disabled Calendar iCal module don't get saved in the view.
 */
function calendar_ical_uninstall() {
  $displays = array(
    'ical', 
    );
  db_query("DELETE FROM {views_display} WHERE display_plugin IN ('". implode("','", $displays) ."')");
  db_query("DELETE FROM {cache_views}");
}

function calendar_ical_enable() {
  db_query("DELETE FROM {cache_views}");
}

/**
 * Make sure handlers for disabled Calendar iCal module don't get saved in the view.
 */
function calendar_ical_disable() {
  db_query("DELETE FROM {cache_views}");
}

function calendar_ical_update_last_removed() {
  return 1;
}

function calendar_ical_update_6000() {
  $ret = array();
  $result = db_query("SELECT * FROM {views_display} d LEFT JOIN {views_view} v ON d.vid = v.vid");
  drupal_load('module', 'views');
  while ($row = db_fetch_array($result)) {
    if ($row['display_plugin'] == 'ical') {
      $options = unserialize($row['display_options']);
      $options['displays'] = array('calendar_1' => 'calendar_1', 'default' => 0, 'calendar_block_1' => 'calendar_block_1');
      $row['display_plugin'] = 'calendar_period';
      $row['display_options'] = serialize($options);
      db_query("UPDATE {views_display} SET id='%s', display_plugin='%s', display_options='%s' WHERE id='%s'", 'calendar_ical_1', 'calendar_ical', $row['display_options'], $row['id']);
      db_query("DELETE FROM {views_object_cache} WHERE name = '%s'", $row['name']);
    }
  }
  $ret[] = array('success' => TRUE, 'query' => 'Updated calendar ical displays to use new handlers and ids.');
  views_invalidate_cache();
  return $ret;
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal calendar_ical.install source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.