| Commit | Line | Data |
|---|---|---|
| c7843b5a | 1 | <?php |
| c7843b5a | 2 | |
| acd06abd JP |
3 | /*! @ingroup ConStructModule */ |
| 4 | //@{ | |
| 5 | ||
| 6 | /*! @file conStruct.install | |
| 7 | @brief Procedures to execute when the module get installed/uninstalled | |
| 8 | ||
| 9 | @author Frederick Giasson, Structured Dynamics LLC. | |
| 10 | ||
| 11 | \n\n\n | |
| 12 | */ | |
| 13 | ||
| 14 | include_once("framework/utilities.php"); | |
| c7843b5a FG |
15 | |
| 16 | /*!@brief Instantiation of hook_install | |
| 17 | ||
| acd06abd | 18 | @author Frederick Giasson, Structured Dynamics LLC. |
| c7843b5a | 19 | |
| acd06abd | 20 | \n\n\n |
| c7843b5a | 21 | */ |
| acd06abd | 22 | function conStruct_install() |
| c7843b5a | 23 | { |
| acd06abd JP |
24 | // Create the "dataset" content type with its related additional fields. |
| 25 | import_cck_content_types(); | |
| c7843b5a | 26 | |
| acd06abd JP |
27 | // Fix the weight of the conStruct module |
| 28 | // We want conStruct to be called first (at least before OG) | |
| 29 | db_query("UPDATE {system} SET weight = -50 WHERE name = 'conStruct'"); | |
| c7843b5a | 30 | |
| acd06abd JP |
31 | // Create the default conStruct domain name where tor esolve URIs |
| 32 | global $base_url; | |
| c7843b5a | 33 | |
| 9b1b47a0 | 34 | // Normalization of the URL of the node. Here we remove the "www" to normalize it. |
| acd06abd JP |
35 | $normalized_base_url = str_replace("www.", "", $base_url); |
| 36 | ||
| 37 | variable_set("conStruct_UrisDomain", str_replace("http://", "", get_domain($normalized_base_url))); | |
| 9b1b47a0 FG |
38 | |
| 39 | // Set the default value for the WSG-Registry Drupal to $base_url | |
| 40 | variable_set("WSF-Registry", $base_url."/ws/"); | |
| c7843b5a FG |
41 | } |
| 42 | ||
| 43 | ||
| 44 | /*!@brief Instantiation of hook_uninstall | |
| 45 | ||
| acd06abd | 46 | @author Frederick Giasson, Structured Dynamics LLC. |
| c7843b5a | 47 | |
| acd06abd | 48 | @todo Improve this method to find all the variables within the varitable table instead of using a fixed count. |
| c7843b5a | 49 | |
| acd06abd | 50 | \n\n\n |
| c7843b5a | 51 | */ |
| acd06abd | 52 | function conStruct_uninstall() |
| c7843b5a | 53 | { |
| acd06abd JP |
54 | // Removing the "dataset" content type |
| 55 | node_type_delete("dataset"); | |
| 56 | ||
| 57 | // Making sure we remove all global variables we created | |
| 58 | variable_del("Linked-Dataset-Registry"); | |
| 59 | variable_del("WSF-Registry"); | |
| 60 | variable_del("SID-Registry"); | |
| 61 | variable_del("Datasets-Registry"); | |
| 62 | variable_del("conStruct_UrisDomain"); | |
| 63 | ||
| 64 | for ($i = 0; $i < 512; $i++) | |
| 65 | { | |
| 66 | variable_del("Dataset-$i-WSF"); | |
| 67 | } | |
| c7843b5a FG |
68 | } |
| 69 | ||
| f934145d FG |
70 | |
| 71 | ||
| 72 | /*!@brief Updating to version 6.1.1.8 | |
| 73 | ||
| 74 | @see http://drupal.org/node/136078 | |
| 75 | ||
| 76 | @author Frederick Giasson, Structured Dynamics LLC. | |
| 77 | ||
| 78 | ||
| 79 | \n\n\n | |
| 80 | */ | |
| 81 | function conStruct_update_6118() | |
| 82 | { | |
| 83 | // Initial version that supports upgrading. | |
| 84 | } | |
| 85 | ||
| c7843b5a FG |
86 | /*!@brief Import needed CCK content types to run conStruct |
| 87 | ||
| acd06abd | 88 | @author Frederick Giasson, Structured Dynamics LLC. |
| c7843b5a | 89 | |
| acd06abd | 90 | \n\n\n |
| c7843b5a | 91 | */ |
| acd06abd JP |
92 | function import_cck_content_types() |
| 93 | { | |
| 94 | $filename = drupal_get_path('module', 'conStruct') . "/content_types.cck"; | |
| 95 | ||
| 96 | $content = implode('', file($filename)); | |
| 97 | ||
| 98 | // Build form state | |
| 99 | $form_state = array('values' => array( | |
| 100 | 'type_name' => '<create>', | |
| 101 | 'macro' => $content, | |
| 102 | ),); | |
| 103 | ||
| 104 | drupal_execute("content_copy_import_form", $form_state); | |
| c7843b5a FG |
105 | } |
| 106 | ||
| 107 | ||
| acd06abd | 108 | //@} |