~ubuntu-drupal-devs/ubuntu-drupal-countdown/6.x

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// $Id$

/**
 * @file
 * Install processes for countdown module
 */

/**
 * Implementation of hook_install().
 */

function udcountdown_install() {
  udcountdown_init_cache();
}

/**
 * Implementation of hook_uninstall().
 */

function udcountdown_uninstall() {
  udcountdown_flush_vars();
  udcountdown_flush_cache();
}

/** Stuff to do **/

function udcountdown_init_cache() {
  $cache = file_directory_path() . "/countdown/";
  $pointerver = trim(file_get_contents('http://edge.launchpad.net/ubuntu-drupal-countdown/misc/release-version/+download/pointer'));
  $pointer = 'https://launchpad.net/ubuntu-drupal-countdown/banners/' . $pointerver;

  shell_exec('rm -rf ' . $cache);
  shell_exec('/usr/bin/wget -nd -m -P ' . $cache . ' ' . $pointer . '/+download/banners.tgz');
  shell_exec('cd ' . $cache . '; tar zxf banners.tgz ');
}

function udcountdown_flush_vars() {
  variable_del('udcountdown_option');
  variable_del('udcountdown_custom');
  variable_del('udcountdown_relver');
  variable_del('udcountdown_stylesheet');
}

function udcountdown_flush_cache() {
  $cache_dst = $_SERVER['DOCUMENT_ROOT'] . "/" . file_directory_path() . "/countdown";
  shell_exec('rm -rf ' . $cache_dst);
}