/[drupal]/contributions/modules/drawing/modules/drawing_gd/drawing_gd.install
ViewVC logotype

Diff of /contributions/modules/drawing/modules/drawing_gd/drawing_gd.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Sat May 9 05:56:28 2009 UTC revision 1.1.2.1, Sat May 9 05:56:28 2009 UTC
# Line 0  Line 1 
1    <?php
2    // $Id$
3    
4    /**
5     * @file
6     */
7    
8    /**
9     * Implementation of hook_schema().
10     */
11    function drawing_gd_schema() {
12      $schema['drawing_gd_image'] = array(
13        'fields' => array(
14          'gd_id' => array(
15            'type' => 'serial',
16            'unsigned' => TRUE,
17            'not null' => TRUE,
18          ),
19          'file' => array(
20            'type' => 'varchar',
21            'length' => 255,
22          ),
23          'data' => array(
24            'type' => 'text',
25            'not null' => TRUE,
26            'serialize' => TRUE,
27          ),
28        ),
29        'primary key' => array('gd_id'),
30      );
31    
32      return $schema;
33    }
34    
35    /**
36     * Implementation of hook_install().
37     */
38    function drawing_gd_install() {
39      drupal_install_schema('drawing_gd');
40    }
41    
42    /**
43     * Implementation of hook_uninstall().
44     */
45    function drawing_gd_uninstall() {
46      drupal_uninstall_schema('drawing_gd');
47    
48      $path = realpath(file_directory_path() .'/drawing_gd');
49      if ($path != FALSE) {
50        _drawing_gd_recursive_delete($path);
51      }
52    
53    }
54    
55    /**
56     * Recursively delete all files and folders in the specified filepath, then
57     * delete the containing folder Note that this only deletes visible files with
58     * write permission
59     *
60     * @param string $path
61     *   An absolute filepath (relative to the filesystem) to delete
62     */
63    function _drawing_gd_recursive_delete($path) {
64      $listing = $path ."/*";
65    
66      foreach (glob($listing) as $file) {
67        if (is_file($file) === TRUE) {
68          @unlink($file);
69        }
70        elseif (is_dir($file) === TRUE) {
71          _drawing_gd_recursive_delete($file);
72          @rmdir($file);
73        }
74      }
75    
76      @rmdir($path);
77    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2