-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvals_soc.install
More file actions
112 lines (107 loc) · 3.19 KB
/
vals_soc.install
File metadata and controls
112 lines (107 loc) · 3.19 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* Implements Drupal hook_install().
*/
function vals_soc_install(){
module_load_include('inc', 'vals_soc', 'includes/install/vals_soc.roles');
drupal_install_schema('soc_projects');
drupal_install_schema('soc_codes');
drupal_install_schema('soc_institutes');
drupal_install_schema('soc_organisations');
drupal_install_schema('soc_user_membership');
drupal_install_schema('soc_groups');
create_roles();
create_codes();
}
/**
* Implements hook_uninstall().
*/
function vals_soc_uninstall() {
$stored_vars = array(
'vals_timeline_program_active',
'vals_timeline_program_start_date',
'vals_timeline_program_end_date',
'vals_timeline_org_app_start_date',
'vals_timeline_org_app_end_date',
'vals_timeline_accepted_org_announced_date',
'vals_timeline_student_signup_start_date',
'vals_timeline_student_signup_end_date',
'vals_timeline_org_review_student_applications_date',
'vals_timeline_students_matched_to_mentors_deadline_date',
'vals_timeline_accepted_students_announced_deadline_date',
'vals_timeline_students_start_submit_forms_date');
foreach ($stored_vars as $var){
variable_del($var);
}
// Delete tables.
$tables = array(
'soc_projects',
'soc_groups',
'soc_codes',
'soc_organisations',
'soc_institutes',
'soc_user_membership'
);
foreach ($tables as $table) {
if (db_table_exists($table)) {
db_drop_table($table);
}
}
//TODO - remove all custom roles in the drupal rols table
menu_cache_clear_all();
}
/**
* Implements Drupal hook_schema()
* We create a schema which can be read by drupal's schema_install and used by drupal's create_tables
*
* @return multitype:string NULL
*/
function vals_soc_schema() {
module_load_include('inc', 'vals_soc', 'includes/install/vals_soc.schema');
return vals_soc_schema_handler();
}
/**
* Create new database table {soc_groups}.
*/
function vals_soc_update_7101() {
$schema['soc_groups'] = array(
'description' => 'The students will be divided in groups, each teacher probably having one or more groups',
'fields' => array(
'group_id' => array(
'description' => 'Group id.',
'type' => 'serial',
'length' => 'small',
'not null' => TRUE,
),
'name' => array(
'description' => 'The name of the group to remind.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'description' => array(
'description' => 'Some description or comment',
'type' => 'varchar',
'length' => 512,
'not null' => FALSE,
'default' => '',
),
'teacher' => array(
'description' => 'The id of the teacher',
'type' => 'int',
'length' => 'medium',
'not null' => TRUE,
),
),
'primary key' => array('group_id'),
);
db_create_table('soc_groups', $schema['soc_groups']);
}
function vals_soc_update_7102() {
$new_field = array(
'description' => 'The description of the project.',
'type' => 'text',
'not null' => FALSE,
);
db_change_field('soc_projects', 'description', 'description', $new_field);
}