/[drupal]/contributions/modules/multidomain/multidomain.install
ViewVC logotype

Contents of /contributions/modules/multidomain/multidomain.install

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


Revision 1.3 - (show annotations) (download) (as text)
Tue Nov 4 05:11:11 2008 UTC (12 months, 3 weeks ago) by betz
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +19 -2 lines
File MIME type: text/x-php
#319559: Added a uninstall hook
1 <?php
2 // $Id: multidomain.install,v 1.2 2008/11/04 04:28:01 betz Exp $
3
4 /**
5 * Implementation of hook_install().
6 */
7 function multidomain_install() {
8 $vid = variable_get('multidomain_vocabulary', '');
9 if (empty($vid)) {
10 // Check to see if a multiple domain vocabulary exists
11 $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module = '%s'", 'multidomain'));
12 if (!$vid) {
13 // Create the multiple domain vocabulary. Assign the vocabulary a low weight so
14 // it will appear first in node create and edit forms.
15 // Assign it all existing node types.
16 $nodes = array();
17 foreach (array_keys(node_get_types('names')) as $type) {
18 $nodes[$type] = 1;
19 }
20 $vocabulary = array('name' => 'Domain', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'multiple domain', 'weight' => -10, 'nodes' => $nodes);
21 taxonomy_save_vocabulary($vocabulary);
22 drupal_set_message('A Domain vocabulary was created. To assign content to a domain, add it to this vocabulary.');
23 $vid = $vocabulary['vid'];
24 // Add a term for the master domain if that domain is already registered.
25 if ($master_domain = variable_get('singlesignon_master_url', FALSE)) {
26 $term = array(
27 'name' => $master_domain,
28 'description' => '',
29 'vid' => $vid,
30 // Set a low weigth as this is the primary domain.
31 'weight' => -10,
32 );
33 taxonomy_save_term($term);
34 variable_set('multidomain_master_domain_tid', $term['tid']);
35 }
36 }
37 variable_set('multidomain_vocabulary', $vid);
38 }
39 }
40
41 /**
42 * Create and populate a vocabulary.
43 */
44 function multidomain_update_1() {
45 // Initialize.
46 multidomain_install();
47 // Create a term for each existing domain.
48 $vid = variable_get('multidomain_vocabulary', '');
49 $domains = variable_get('multidomain_sites', array());
50 foreach ($domains as $domain => $settings) {
51 $term = array(
52 'name' => $domain,
53 'description' => '',
54 'vid' => $vid,
55 'weight' => $settings['weight'],
56 );
57 taxonomy_save_term($term);
58 // Set the term id for this domain.
59 $domains[$domain]['tid'] = $term['tid'];
60 }
61 variable_set('multidomain_sites', $domains);
62 return array();
63 }
64
65
66 +/**
67 * Implementation of hook_uninstall.
68 */
69
70 function multidomain_uninstall() {
71 $vid = variable_get('multidomain_vocabulary', 'multidomain_vocabulary');
72 taxonomy_del_vocabulary($vid);
73 variable_del('multidomain_sites');
74 variable_del('multidomain_taxonomy_rewrite_sql');
75 variable_del('multidomain_force_default_domain');
76 variable_del('singlesignon_master_url');
77 variable_del('multidomain_master_domain_tid');
78 variable_del('multidomain_vocabulary');
79 drupal_set_message('The domain vocabulary was deleted successfully.');
80 }

  ViewVC Help
Powered by ViewVC 1.1.2