| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function democracy_forum_install() {
|
| 8 |
switch ($GLOBALS['db_type']) {
|
| 9 |
case 'mysql':
|
| 10 |
case 'mysqli':
|
| 11 |
db_query("CREATE TABLE {democracy_forum_council} (
|
| 12 |
nid int(10) unsigned NOT NULL default '0',
|
| 13 |
result tinyint unsigned NOT NULL,
|
| 14 |
link text,
|
| 15 |
PRIMARY KEY (nid)
|
| 16 |
) /*!40100 DEFAULT CHARACTER SET utf8 */");
|
| 17 |
break;
|
| 18 |
}
|
| 19 |
|
| 20 |
// Create proposal content type
|
| 21 |
$type = array(
|
| 22 |
'type' => 'proposal',
|
| 23 |
'name' => t('Proposal'),
|
| 24 |
'module' => 'node',
|
| 25 |
'description' => t('A proposal is used to send in propsals that can be commented and improved by other users.'),
|
| 26 |
'custom' => TRUE,
|
| 27 |
'modified' => TRUE,
|
| 28 |
'locked' => FALSE,
|
| 29 |
);
|
| 30 |
$type = (object) _node_type_set_defaults($type);
|
| 31 |
$status = node_type_save($type);
|
| 32 |
|
| 33 |
// Enable revisions, don't promote, disable comments, enable procon arguments
|
| 34 |
variable_set('node_options_'. $type->type, array('status', 'revision'));
|
| 35 |
variable_set('comment_'. $type->type, COMMENT_NODE_DISABLED);
|
| 36 |
variable_set('procon_enabled_'. $type->type, 1);
|
| 37 |
|
| 38 |
if ($status == SAVED_UPDATED) {
|
| 39 |
drupal_set_message(t('The content type %name has been updated.', array('%name' => $type->name)));
|
| 40 |
}
|
| 41 |
elseif ($status == SAVED_NEW) {
|
| 42 |
drupal_set_message(t('The content type %name has been added.', array('%name' => $type->name)));
|
| 43 |
}
|
| 44 |
|
| 45 |
// Create the council vocabulary.
|
| 46 |
$vocabulary = array(
|
| 47 |
'name' => t('Council meeting date'),
|
| 48 |
'help' => t('Enter the date of the council meeting. Example: <em>2007-11-30</em>.'),
|
| 49 |
'multiple' => 0,
|
| 50 |
'required' => 1,
|
| 51 |
'hierarchy' => 0,
|
| 52 |
'relations' => 0,
|
| 53 |
'tags' => 1,
|
| 54 |
'module' => 'democracy_forum',
|
| 55 |
'nodes' => array('advpoll_binary' => 1, 'advpoll_ranking' => 1),
|
| 56 |
);
|
| 57 |
taxonomy_save_vocabulary($vocabulary);
|
| 58 |
variable_set('democracy_forum_council_vocabulary', $vocabulary['vid']);
|
| 59 |
|
| 60 |
// Create the proposal status vocabulary.
|
| 61 |
$vocabulary = array(
|
| 62 |
'name' => t('Proposal status'),
|
| 63 |
'multiple' => 0,
|
| 64 |
'required' => 1,
|
| 65 |
'hierarchy' => 1,
|
| 66 |
'relations' => 0,
|
| 67 |
'module' => 'democracy_forum',
|
| 68 |
'nodes' => array('proposal' => 1),
|
| 69 |
);
|
| 70 |
taxonomy_save_vocabulary($vocabulary);
|
| 71 |
variable_set('democracy_forum_proposal_vocabulary', $vocabulary['vid']);
|
| 72 |
|
| 73 |
// Define some terms to categorize news items.
|
| 74 |
$terms = array(
|
| 75 |
t('Draft'),
|
| 76 |
t('Sent to council'),
|
| 77 |
t('Back from council'),
|
| 78 |
t('Archived - accepted'),
|
| 79 |
t('Archived - rejected'),
|
| 80 |
);
|
| 81 |
// Submit the "Add term" form programmatically for each term. Give the terms
|
| 82 |
// a weight that represents how they are listed above.
|
| 83 |
$i = 0;
|
| 84 |
foreach ($terms as $name) {
|
| 85 |
drupal_execute('taxonomy_form_term', array('name' => $name, 'weight' => $i++), $vocabulary['vid']);
|
| 86 |
}
|
| 87 |
}
|
| 88 |
|
| 89 |
/**
|
| 90 |
* Implementation of hook_uninstall().
|
| 91 |
*/
|
| 92 |
function democracy_forum_uninstall() {
|
| 93 |
db_query('DROP TABLE {democracy_forum_council}');
|
| 94 |
// Delete the vocabularies created by this module
|
| 95 |
taxonomy_del_vocabulary(variable_get('democracy_forum_council_vocabulary', ''));
|
| 96 |
taxonomy_del_vocabulary(variable_get('democracy_forum_proposal_vocabulary', ''));
|
| 97 |
}
|