-
Notifications
You must be signed in to change notification settings - Fork 0
/
eduerp.install
562 lines (529 loc) · 15.8 KB
/
eduerp.install
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
<?php
include('fixtures.inc');
include_once('permissions_api.module');
/**
* initialize the permissions for roles in this module
*/
function eduerp_perms_initialize() {
$permissions = array(
'Administrator' => array(
'create profile content',
'delete any profile content',
'edit any profile content',
'edit field_profile_country_name',
'edit field_profile_dob',
'edit field_profile_first_name',
'edit field_profile_maiden_name',
'edit field_profile_gender',
'edit field_profile_last_name',
'edit field_profile_lga_name',
'edit field_profile_marital_status',
'edit field_profile_middle_name',
'edit field_profile_mobile_number',
'edit field_profile_permanent_address',
'edit field_profile_permanent_city',
'edit field_profile_permanent_state',
'edit field_profile_photograph',
'edit field_profile_religion',
'edit field_profile_signature',
'edit field_profile_state_name_origin',
'edit field_profile_title_name',
'view field_profile_country_name',
'view field_profile_department_id',
'view field_profile_dob',
'view field_profile_first_name',
'view field_profile_maiden_name',
'view field_profile_gender',
'view field_profile_last_name',
'view field_profile_lga_name',
'view field_profile_marital_status',
'view field_profile_middle_name',
'view field_profile_mobile_number',
'view field_profile_permanent_address',
'view field_profile_permanent_city',
'view field_profile_permanent_state',
'view field_profile_photograph',
'view field_profile_religion',
'view field_profile_signature',
'view field_profile_state_name_origin',
'view field_profile_title_name',
),
'authenticated user' => array(
'create profile content',
'edit own profile content',
'edit field_profile_country_name',
'edit field_profile_dob',
'edit field_profile_first_name',
'edit field_profile_maiden_name',
'edit field_profile_gender',
'edit field_profile_last_name',
'edit field_profile_lga_name',
'edit field_profile_marital_status',
'edit field_profile_middle_name',
'edit field_profile_mobile_number',
'edit field_profile_permanent_address',
'edit field_profile_permanent_city',
'edit field_profile_permanent_state',
'edit field_profile_photograph',
'edit field_profile_religion',
'edit field_profile_signature',
'edit field_profile_state_name_origin',
'edit field_profile_title_name',
'view field_profile_country_name',
'view field_profile_department_id',
'view field_profile_dob',
'view field_profile_first_name',
'view field_profile_maiden_name',
'view field_profile_gender',
'view field_profile_last_name',
'view field_profile_lga_name',
'view field_profile_marital_status',
'view field_profile_middle_name',
'view field_profile_mobile_number',
'view field_profile_permanent_address',
'view field_profile_permanent_city',
'view field_profile_permanent_state',
'view field_profile_photograph',
'view field_profile_religion',
'view field_profile_signature',
'view field_profile_state_name_origin',
'view field_profile_title_name',
),
'anonymous user' => array(
'create profile content',
'edit field_profile_country_name',
'edit field_profile_dob',
'edit field_profile_first_name',
'edit field_profile_maiden_name',
'edit field_profile_gender',
'edit field_profile_last_name',
'edit field_profile_lga_name',
'edit field_profile_marital_status',
'edit field_profile_middle_name',
'edit field_profile_mobile_number',
'edit field_profile_permanent_address',
'edit field_profile_permanent_city',
'edit field_profile_permanent_state',
'edit field_profile_photograph',
'edit field_profile_religion',
'edit field_profile_signature',
'edit field_profile_state_name_origin',
'edit field_profile_title_name',
),
);
return $permissions;
}
function eduerp_install(){
// Install the schemas
drupal_install_schema('eduerp');
// Load fixtures
$fixtures_path = dirname(__FILE__) . "/fixtures/";
load_fixtures('eduerp_states', $fixtures_path . "states.csv", true);
load_fixtures('eduerp_lgas', $fixtures_path . "lgas.csv", true);
load_fixtures('eduerp_countries', $fixtures_path . "countries.csv", true);
// Run raw queries
db_query('INSERT INTO {course_grade_weightings} VALUES (0, 4, 0, 10, 10, 10, 10, 60, 0, 0, 0, 0, 0)');
// Install the content types
$profile_content_type = file_get_contents(dirname(__FILE__) . '/cck/cck_profile.txt');
$profile_info = content_types('profile');
$form_state = array(
'values' => array(
// Updates the content type if it's existent, if not, creates it.
'type_name' => (is_array($profile_info) && array_key_exists('type', $profile_info)) ? 'profile' : '<create>',
'macro' => $profile_content_type,
),
);
drupal_execute('content_copy_import_form', $form_state);
content_clear_type_cache();
drupal_set_message('eduerp module installed');
}
function eduerp_enable() {
// set content type permissions
$perms = eduerp_perms_initialize();
foreach ($perms as $role => $permissions) {
permissions_grant_permissions($role, $permissions);
}
}
function eduerp_disable() {
// remove content type permissions
$perms = eduerp_perms_initialize();
foreach ($perms as $role => $permissions) {
permissions_revoke_permissions($role, $permissions);
}
}
function eduerp_uninstall(){
// uninstall the schemas
drupal_uninstall_schema('eduerp');
drupal_set_message('eduerp module uninstalled');
}
function eduerp_schema() {
$schema['session'] = array(
'description' => t('Table for storing school session data'),
'fields' => array(
'session_id' => array(
'description' => t('Session ID'),
'type' => 'serial',
'not null' => TRUE,
),
'sess_name' => array(
'description' => t('Session Name e.g. 2009/2010'),
'type' => 'varchar',
'length' => '30',
'not null' => TRUE,
),
),
'primary key' => array('session_id'),
);
$schema['eduerp_lgas'] = array(
'description' => t('This table stores Local Government Areas of a state'),
'fields' => array(
'lga_id' => array(
'description' => t('Primary Key ID'),
'type' => 'int',
'not null' => TRUE,
),
'lga_rel' => array(
'description' => t('Foreign Key to the States table'),
'type' => 'int',
'not null' => TRUE,
),
'lga_name' => array(
'description' => t('The name of the LGA'),
'type' => 'varchar',
'length' => '100',
'not null' => TRUE,
),
),
);
$schema['eduerp_countries'] = array(
'description' => t('Stores a list of countries'),
'fields' => array(
'country_id' => array(
'description' => t('Primary Key ID'),
'type' => 'int',
'not null' => TRUE,
),
'country_name' => array(
'description' => t('The name of the country'),
'type' => 'varchar',
'length' => '100',
'not null' => TRUE,
),
),
);
$schema['eduerp_states'] = array(
'description' => t('Table for storing the states in a country'),
'fields' => array(
'state_id' => array(
'description' => t('State ID'),
'type' => 'int',
'not null' => TRUE,
),
'state_name' => array(
'description' => t('State Name'),
'type' => 'varchar',
'length' => '100',
'not null' => TRUE,
),
),
);
$schema['program_level_semester'] = array(
'description' => t('Program Level Semester'),
'fields' => array(
'programme_id' => array(
'description' => t('Programme ID'),
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'level' => array(
'description' => t('Level'),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'semester' => array(
'description' => t('Semester'),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'min_credit_load' => array(
'description' => t('Minimum Credit Load'),
'type' => 'int',
'not null' => TRUE,
),
'max_credit_load' => array(
'description' => t('Maximum Credit Load'),
'type' => 'int',
'not null' => TRUE,
),
'open_for_registrations' => array(
'description' => t('Open for registration'),
'type' => 'int',
'not null' => TRUE,
),
),
'indexes' => array(
'programme_id' => array('programme_id'),
),
);
$schema['program_course'] = array(
'description' => t('Program Course'),
'fields' => array(
'program_course_id' => array(
'description' => t('Program Course ID'),
'type' => 'serial',
'not null' => TRUE,
),
'course_id' => array(
'description' => t('Course ID'),
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'programme_id' => array(
'description' => t('Programme'),
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'level' => array(
'description' => t('Level'),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'semester' => array(
'description' => t('Semester'),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'course_type' => array(
'description' => t('Course Type - 1 is core and 2 is elective'),
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
),
'lecturer_id' => array(
'description' => t('Lecturer'),
'type' => 'int',
'unsigned' => TRUE,
),
'historical' => array(
'description' => t('Historical - 0 is active and 1 is not to be used for new selections'),
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
),
'credit_load' => array(
'description' => t('Credit Load for this Course in this Program'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('program_course_id'),
'indexes' => array(
'programme_id' => array('programme_id'),
'course_id' => array('course_id'),
),
);
$schema['program_course_instance'] = array(
'description' => t('Program Course Instance'),
'fields' => array(
'course_instance_id' => array(
'description' => t('Course Instance ID'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'programme_id' => array(
'description' => t('Programme ID'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'session' => array(
'description' => t('Session'),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'semester' => array(
'description' => t('Semester'),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
),
'indexes' => array(
'programme_id' => array('programme_id')
)
);
$schema['course_grade_weightings'] = array(
'description' => t('Course Grade Weightings'),
'fields' => array(
'course_id' => array(
'description' => t('Course ID'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'number_of_ca' => array(
'description' => t('Number of CAs'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'ca_approved_onebyone' => array(
'description' => t('CA approved One by One'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'max_mark_ca1' => array(
'description' => t('Maximum mark for CA1'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'max_mark_ca2' => array(
'description' => t('Maximum mark for CA2'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'max_mark_ca3' => array(
'description' => t('Maxmimum mark for CA3'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'max_mark_ca4' => array(
'description' => t('Maximum mark for CA4'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'max_mark_exam' => array(
'description' => t('Maximum mark for exam'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'weight_ca1' => array(
'description' => t('Weighting for CA1'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'weight_ca2' => array(
'description' => t('Weighting for CA2'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'weight_ca3' => array(
'description' => t('Weighting for CA3'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'weight_ca4' => array(
'description' => t('Weighting for CA4'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'weight_exam' => array(
'description' => t('Weighting for exam'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'indexes' => array(
'course_id' => array('course_id')
)
);
$schema['eduerp_roles'] = array(
'description' => t('EduERP roles'),
'fields' => array(
'eduerp_role_id' => array(
'description' => t('EduERP Role ID'),
'type' => 'serial',
'size' => 'big',
'not null' => TRUE,
),
'uid' => array(
'description' => t('User ID'),
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'department_id' => array(
'description' => t('Department ID'),
'type' => 'int',
'default' => 0,
'not null' => TRUE,
'unsigned' => TRUE,
),
'college_id' => array(
'description' => t('College ID'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'unsigned' => TRUE,
),
'role' => array(
'description' => t('Role'),
'type' => 'varchar',
'length' => '100',
'not null' => TRUE,
),
),
'primary key' => array('eduerp_role_id'),
'indexes' => array(
'uid' => array('uid'),
'department_id' => array('department_id'),
'college_id' => array('college_id'),
'role' => array('role')
)
);
$schema['cron_notification'] = array(
'description' => t('CRON notifications'),
'fields' => array(
'approver_uid' => array(
'description' => t('Approver UID'),
'type' => 'int',
'default' => 0,
),
'student_uid' => array(
'description' => t('Student UID'),
'type' => 'int',
'not null' => TRUE,
),
'gradestext' => array(
'description' => t('Grades text'),
'type' => 'varchar',
'length' => '255',
'default' => '',
),
'programme' => array(
'description' => t('Programme'),
'type' => 'varchar',
'length' => '255',
'default' => '',
),
'instruction' => array(
'description' => t('Instruction'),
'type' => 'int',
'not null' => TRUE,
),
),
);
return $schema;
}
?>