-
Notifications
You must be signed in to change notification settings - Fork 4
/
lab_migration.module
executable file
·1021 lines (974 loc) · 38.7 KB
/
lab_migration.module
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// $Id$
require_once('general_deletion.inc');
require_once('email.inc');
/**
* Implementation of hook_menu().
*/
function lab_migration_menu()
{
$items = array();
/* PROPOSAL */
$items['lab_migration/proposal'] = array(
'title' => 'Lab Migration Proposal',
'description' => 'Lab Migration Proposal',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_proposal_form'),
'access arguments' => array('lab migration create proposal'),
'type' => MENU_NORMAL_ITEM,
'file' => 'proposal.inc',
);
$items['lab_migration/manage_proposal'] = array(
'title' => 'LM Manage Lab Proposals',
'description' => 'Manage Lab Migration Proposals',
'page callback' => 'lab_migration_proposal_pending',
'access callback' => 'user_access',
'access arguments' => array('lab migration manage proposal'),
'file' => 'manage_proposal.inc',
);
$items['lab_migration/manage_proposal/pending'] = array(
'title' => 'Pending Proposals',
'description' => 'Pending Lab Migration Proposals Queue',
'page callback' => 'lab_migration_proposal_pending',
'access callback' => 'user_access',
'access arguments' => array('lab migration manage proposal'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
'file' => 'manage_proposal.inc',
);
$items['lab_migration/manage_proposal/pending_solution_proposal'] = array(
'title' => 'Pending Solution Proposals',
'description' => 'Pending Lab Migration Solution Proposals Queue',
'page callback' => 'lab_migration_solution_proposal_pending',
'access callback' => 'user_access',
'access arguments' => array('lab migration manage proposal'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'file' => 'manage_solution_proposal.inc',
);
$items['lab_migration/manage_proposal/pending_solution'] = array(
'title' => 'Pending Solution',
'description' => 'Pending Lab Migration Solution',
'page callback' => 'lab_migration_proposal_pending_solution',
'access callback' => 'user_access',
'access arguments' => array('lab migration manage proposal'),
'type' => MENU_LOCAL_TASK,
'weight' => 3,
'file' => 'manage_proposal.inc',
);
$items['lab_migration/manage_proposal/all'] = array(
'title' => 'All Proposals',
'description' => 'All Proposals',
'page callback' => 'lab_migration_proposal_all',
'access callback' => 'user_access',
'access arguments' => array('lab migration manage proposal'),
'type' => MENU_LOCAL_TASK,
'weight' => 4,
'file' => 'manage_proposal.inc',
);
$items['lab_migration/manage_proposal/category'] = array(
'title' => 'Category',
'description' => 'Category',
'page callback' => 'lab_migration_category_all',
'access callback' => 'user_access',
'access arguments' => array('lab migration manage proposal'),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
'file' => 'manage_proposal.inc',
);
$items['lab_migration/manage_proposal/category/edit'] = array(
'title' => 'Edit Category',
'description' => 'Edit category',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_category_edit_form'),
'access arguments' => array('lab migration edit proposal'),
'type' => MENU_CALLBACK,
'file' => 'manage_proposal.inc',
);
$items['lab_migration/manage_proposal/approve'] = array(
'title' => 'Approve Proposal',
'description' => 'Approve Proposal',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_proposal_approval_form'),
'access arguments' => array('lab migration manage proposal'),
'type' => MENU_CALLBACK,
'file' => 'manage_proposal.inc',
);
$items['lab_migration/manage_proposal/solution_proposal_approve'] = array(
'title' => 'Approve Solution Proposal',
'description' => 'Approve Solution Proposal',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_solution_proposal_approval_form'),
'access arguments' => array('lab migration manage proposal'),
'type' => MENU_CALLBACK,
'file' => 'manage_solution_proposal.inc',
);
$items['lab_migration/manage_proposal/edit'] = array(
'title' => 'Edit Proposal',
'description' => 'Edit Proposal',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_proposal_edit_form'),
'access arguments' => array('lab migration manage proposal'),
'type' => MENU_CALLBACK,
'file' => 'manage_proposal.inc',
);
$items['lab_migration/manage_proposal/status'] = array(
'title' => 'Proposal Status',
'description' => 'Proposal Status',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_proposal_status_form'),
'access arguments' => array('lab migration approve proposal'),
'type' => MENU_CALLBACK,
'file' => 'manage_proposal.inc',
);
/* SOLUTION PROPOSAL */
$items['lab_migration/open_proposal'] = array(
'title' => 'Lab Migration Solve',
'description' => 'Lab Migration Proposal Open For Solution',
'page callback' => 'lab_migration_proposal_open',
'access arguments' => array('lab migration propose solution'),
'type' => MENU_NORMAL_ITEM,
'file' => 'solution_proposal.inc',
);
$items['lab_migration/show_proposal'] = array(
'title' => 'Lab Migration Solution Proposal',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_solution_proposal_form'),
'access arguments' => array('lab migration propose solution'),
'type' => MENU_CALLBACK,
'file' => 'solution_proposal.inc',
);
/* CODE REVIEW */
$items['lab_migration/code_approval'] = array(
'title' => 'LM Manage Code Approval',
'description' => 'Manage Code Approval',
'page callback' => 'lab_migration_code_approval',
'access arguments' => array('lab migration approve code'),
'type' => MENU_NORMAL_ITEM,
'file' => 'code_approval.inc',
);
$items['lab_migration/code_approval/approve'] = array(
'title' => 'Code Approval',
'description' => 'Code Approval',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_code_approval_form'),
'access arguments' => array('lab migration approve code'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
'file' => 'code_approval.inc',
);
$items['lab_migration/code_approval/bulk'] = array(
'title' => 'Bulk Manage',
'description' => 'Bulk Mangage',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_bulk_approval_form'),
'access arguments' => array('lab migration bulk manage code'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'file' => 'bulk_approval.inc',
);
$items['lab_migration/code_approval/bulk'] = array(
'title' => 'Bulk Manage',
'description' => 'Bulk Mangage',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_bulk_approval_form'),
'access arguments' => array('lab migration bulk manage code'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'file' => 'bulk_approval.inc',
);
/*$items['lab_migration/code_approval/dependency'] = array(
'title' => 'Dependency',
'description' => 'Dependency Mangage',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_dependency_approval_form'),
'access arguments' => array('lab migration bulk manage code'),
'type' => MENU_LOCAL_TASK,
'weight' => 3,
'file' => 'dependency_approval.inc',
);*/
$items['lab_migration/code_approval/upload'] = array(
'title' => 'Upload Code',
'description' => 'Admin Upload',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_bulk_upload_code_form'),
'access arguments' => array('lab migration bulk manage code'),
'type' => MENU_CALLBACK,
'weight' => 4,
'file' => 'bulk_upload_code.inc',
);
$items['lab_migration/code_approval/notes'] = array(
'title' => 'Notes for Reviewers',
'description' => 'Notes for Reviewers',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_lab_notes_form'),
'access arguments' => array('lab migration bulk manage code'),
'type' => MENU_CALLBACK,
'weight' => 4,
'file' => 'notes.inc',
);
/* CODE UPLOAD */
$items['lab_migration/code'] = array(
'title' => 'Code Submission',
'description' => 'Code Submission',
'page callback' => 'lab_migration_list_experiments',
'access callback' => 'user_access',
'access arguments' => array('lab migration upload code'),
'file' => 'upload_code.inc',
);
$items['lab_migration/code/list_experiments'] = array(
'title' => 'List Experiments',
'description' => 'List Experiments',
'page callback' => 'lab_migration_list_experiments',
'access arguments' => array('lab migration upload code'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'file' => 'upload_code.inc',
'weight' => 1,
);
$items['lab_migration/code/upload'] = array(
'title' => 'Code Submission',
'description' => 'Code Submission',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_upload_code_form'),
'access arguments' => array('lab migration upload code'),
'type' => MENU_LOCAL_TASK,
'file' => 'upload_code.inc',
'weight' => 2,
);
/* $items['lab_migration/code/upload_dep'] = array(
'title' => 'Upload Dependency',
'description' => 'Upload Dependency Files',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_upload_dependency_form'),
'access arguments' => array('lab migration upload code'),
'type' => MENU_LOCAL_TASK,
'file' => 'dependency.inc',
'weight' => 3,
);*/
$items['lab_migration/code/delete'] = array(
'title' => 'Delete Solution',
'description' => 'Delete Solution',
'page callback' => 'lab_migration_upload_code_delete',
'access arguments' => array('lab migration upload code'),
'type' => MENU_CALLBACK,
'file' => 'upload_code_delete.inc',
);
/* CODE DOWNLOADS */
$items['lab_migration/download/file'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
'page callback' => 'lab_migration_download_solution_file',
'access arguments' => array('lab migration download code'),
'type' => MENU_CALLBACK,
'file' => 'download.inc',
);
$items['lab_migration/download/pdf'] = array(
'title' => 'PDF Download',
'description' => 'PDF Download',
'page callback' => 'lab_migration_download_pdf_file',
'access arguments' => array('lab migration download code'),
'type' => MENU_CALLBACK,
'file' => 'download.inc',
);
/*$items['lab_migration/download/dependency'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
'page callback' => 'lab_migration_download_dependency_file',
'access arguments' => array('lab migration download code'),
'type' => MENU_CALLBACK,
'file' => 'download.inc',
);*/
$items['lab_migration/download/samplecode'] = array(
'title' => 'Sample Code Download',
'description' => 'Sample Code Download',
'page callback' => 'lab_migration_download_sample_code',
'access arguments' => array('lab migration download code'),
'type' => MENU_CALLBACK,
'file' => 'download.inc',
);
$items['lab_migration/download/solution'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
'page callback' => 'lab_migration_download_solution',
'access arguments' => array('lab migration download code'),
'type' => MENU_CALLBACK,
'file' => 'download.inc',
);
$items['lab_migration/download/experiment'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
'page callback' => 'lab_migration_download_experiment',
'access arguments' => array('lab migration download code'),
'type' => MENU_CALLBACK,
'file' => 'download.inc',
);
$items['lab_migration/download/lab'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
'page callback' => 'lab_migration_download_lab',
'access arguments' => array('lab migration download code'),
'type' => MENU_CALLBACK,
'file' => 'download.inc',
);
$items['lab_migration/full_download/experiment'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
'page callback' => 'lab_migration_download_full_experiment',
'access arguments' => array('lab migration approve code'),
'type' => MENU_CALLBACK,
'file' => 'full_download.inc',
);
$items['lab_migration/full_download/lab'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
'page callback' => 'lab_migration_download_full_lab',
'access arguments' => array('lab migration approve code'),
'type' => MENU_CALLBACK,
'file' => 'full_download.inc',
);
/* COMPLETED LAB MIGRATIONS */
$items['lab_migration/completed_labs'] = array(
'title' => 'Completed Labs',
'page callback' => 'lab_migration_completed_labs_all',
'access arguments' => array('lab migration download code'),
'file' => 'lab_details.inc',
);
/* LABS IN PROGRESS */
$items['lab_migration/labs_progress'] = array(
'title' => 'Labs in Progress',
'page callback' => 'lab_migration_labs_progress_all',
'access arguments' => array('lab migration download code'),
'file' => 'lab_details.inc',
);
/* DOWNLOAD FOR EVERYONE */
$items['lab_migration_run'] = array(
'title' => 'Download Codes',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_run_form'),
'access arguments' => array('lab migration download code'),
'type' => MENU_NORMAL_ITEM,
'file' => 'run.inc',
);
/*$items['lab_migration_run'] = array(
'title' => 'Download Codes',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_run_form_ajax'),
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'file' => 'run.inc',
);
$items['lab_migration_run_ajax'] = array(
'page callback' => 'lab_migration_run_ajax',
'access callback' => TRUE,
'file' => 'run.inc',
);
$items['download_codes'] = array(
'title' => 'Download Codes',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_run_form_ajax'),
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'file' => 'run.inc',
);*/
/* LATEX SCRIPT */
$items['lab_migration/generate_lab'] = array(
'title' => 'Generate Lab',
'description' => 'Generate Lab From Latex Script',
'page callback' => 'lab_migration_download_lab_pdf',
'access arguments' => array('lab migration generate lab'),
'type' => MENU_CALLBACK,
'file' => 'latex.inc',
);
$items['lab_migration/delete_lab'] = array(
'title' => 'Delete Lab PDF',
'description' => 'Delete Lab PDF',
'page callback' => 'lab_migration_delete_lab_pdf',
'access arguments' => array('lab migration approve code'),
'type' => MENU_CALLBACK,
'file' => 'latex.inc',
);
/* ADMIN SETTINGS */
$items['admin/settings/lab_migration'] = array(
'title' => 'Lab Migration Settings',
'description' => 'Lab Migration Settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('lab_migration_settings_form'),
'access arguments' => array('administer lab migration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'settings.inc',
);
/* AJAX REQUEST */
$items["lab_bulk_manage_exp/ajax"] = array(
"title" => "Ajax callbacks",
"page callback" => "lab_bulk_manage_exp_ajax",
"access arguments" => array("lab migration bulk manage code"),
"type" => MENU_CALLBACK,
'file' => 'bulk_approval.inc',
);
/* $items["lab_migration/code_approval/dependency/ajax"] = array(
"title" => "Ajax callbacks",
"page callback" => "lab_migration_dependency_approval_ajax",
"access arguments" => array("lab migration bulk manage code"),
"type" => MENU_CALLBACK,
'file' => 'dependency_approval.inc',
);*/
$items['lab_migration/certificates'] = array(
'title' => 'List of Lab Migration Certificates',
'description' => 'List of Lab Migration Certificates',
'page callback' => '_list_lab_migration_certificates',
'access arguments' => array(
'list Lab Migration certificates',
),
'file' => 'pdf/list_lab_migration_certificate.inc',
);
$items['lab_migration/certificate'] = array(
'title' => 'List Of All Certificates LM',
'description' => 'List of all available lab migration certificates',
'page callback' => '_list_all_lm_certificates',
'access arguments' => array(
'Create custom Certificate'
)
);
$items['lab_migration/certificates/generate-pdf'] = array(
'title' => 'Download Certificate',
'description' => 'Download Certificate',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'generate_pdf',
),
'type' => MENU_CALLBACK,
'access arguments' => array(
'generate pdf',
),
'file' => 'pdf/cert_new.inc',
);
$items['lab_migration/certificate/generate-pdf'] = array(
'title' => 'Download Certificate',
'description' => 'Download Certificate',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'generate_lm_pdf'
),
'access arguments' => array(
'Create custom Certificate'
),
'file' => 'pdf/generate_pdf.inc'
);
/*$items['lab_migration/certificates-custom'] = array(
'title'=> 'List of Case Study Custom Certificates',
'description'=> 'List of Case Study Custom Certificates',
'page callback'=> '_list_cfd_lab_migration_custom_certificates',
'access arguments'=> array(
'list Case Study custom certificates'
),
'file'=> 'pdf/list_mentor_certificates.inc'
);
$items['lab_migration/certificates-custom/pdf'] = array(
'title'=> 'Download Certificate',
'description'=> 'Download Certificate',
'page callback'=> 'drupal_get_form',
'page arguments'=> array(
'generate_pdf'
),
'type'=> MENU_CALLBACK,
'access arguments'=> array(
'generate pdf'
),
'file'=> 'pdf/mentor_cert_pdf.inc'
); */
$items['lab_migration/certificate/lm-participation/form'] = array(
'title' => 'Create Certificates for Participation',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'lab_migration_certificate_participation_form'
),
'access arguments' => array(
'Create custom Certificate'
)
);
$items['lab_migration/certificate/lm-participation/form/edit'] = array(
'title' => 'Edit Certificates for Participation',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'lab_migration_certificate_participation_edit_form'
),
'access arguments' => array(
'Create custom Certificate'
)
);
$items['lab_migration/certificates/verify'] = array(
"title" => "Certificate Verification",
"page callback" => "verify_certificates",
'page arguments' => array(
'verify_certificates',
),
"access arguments" => array(
"verify certificates",
),
'type' => MENU_CALLBACK,
'file' => 'pdf/verify_certificates.inc',
);
$items["lab_migration/certificate/verify"] = array(
"title" => "Lab Migration Certificate Verification",
"page callback" => "verify_lab_migration_certificates",
'page arguments' => array(
'verify_lab_migration_certificates',
),
"access arguments" => array(
"Verify custom Certificate of lab"
),
'file' => 'pdf/verify_lab_migration_certificates.inc'
);
return $items;
}
/**
* Implementation of hook_perm().
*/
function lab_migration_permission() {
return array(
'lab migration create proposal' => array(
'title' => t('lab migration create proposal'),
'restrict access' => TRUE,
),
'lab migration manage proposal' => array(
'title' => t('lab migration manage proposal'),
'restrict access' => TRUE,
),
'lab migration edit proposal' => array(
'title' => t('lab migration edit proposal'),
'restrict access' => TRUE,
),
'lab migration approve proposal' => array(
'title' => t('lab migration approve proposal'),
'restrict access' => TRUE,
),
'lab migration propose solution' => array(
'title' => t('lab migration propose solution'),
'restrict access' => TRUE,
),
'lab migration approve code' => array(
'title' => t('lab migration approve code'),
'restrict access' => TRUE,
),
'lab migration bulk manage code' => array(
'title' => t('lab migration bulk manage code'),
'restrict access' => TRUE,
),
'lab migration bulk delete code' => array(
'title' => t('lab migration bulk delete code'),
'restrict access' => TRUE,
),
'lab migration upload code' => array(
'title' => t('lab migration upload code'),
'restrict access' => TRUE,
),
'lab migration download code' => array(
'title' => t('lab migration download code'),
'restrict access' => TRUE,
),
'administer lab migration' => array(
'title' => t('administer lab migration'),
'restrict access' => TRUE,
),
'lab migration generate lab' => array(
'title' => t('lab migration generate lab'),
'restrict access' => TRUE,
),
"list Lab Migration certificates" => array(
"title" => t("list the certificates"),
"description" => t("list the certificates"),
'restrict access' => true,
),
"list Lab Migration custom certificates" => array(
"title" => t("list the mentor certificates"),
"description" => t("list the mentor certificates"),
'restrict access' => true,
),
"verify certificates" => array(
"title" => t("verify the certificates"),
"description" => t("verify the certificates"),
'restrict access' => true,
),
"generate pdf" => array(
"title" => t("Generate pdf"),
"description" => t("Allows users to Generate pdf.")
),
"Create custom Certificate" => array(
"title" => t("create custom certificate "),
"description" => t("Create custom Certificate")
),
"Verify custom Certificate of lab" => array(
"title" => t("Verify custom Certificate of lab"),
"description" => t("Verify custom Certificate of lab")
)
);
// return array('lab migration create proposal', 'lab migration manage proposal', 'lab migration edit proposal', 'lab migration approve proposal', 'lab migration propose solution', 'lab migration approve code', 'lab migration bulk manage code', 'lab migration bulk delete code', 'lab migration upload code', 'lab migration download code', 'administer lab migration', 'lab migration generate lab');
}
/* AJAX CALLS */
function lab_migration_ajax()
{
$query_type = arg(2);
if ($query_type == 'chapter_title')
{
$chapter_number = arg(3);
$preference_id = arg(4);
//$chapter_q = db_query("SELECT * FROM {lab_migration_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id);
$query = db_select('lab_migration_chapter');
$query->fields('lab_migration_chapter');
$query->condition('number', $chapter_number);
$query->condition('preference_id', $preference_id);
$query->range(0, 1);
$chapter_q = $query->execute();
if ($chapter_data = $chapter_q->fetchObject())
{
echo $chapter_data->name;
return;
}
} else if ($query_type == 'example_exists') {
$chapter_number = arg(3);
$preference_id = arg(4);
$example_number = arg(5);
$chapter_id = 0;
$query = db_select('lab_migration_chapter');
$query->fields('lab_migration_chapter');
$query->condition('number', $chapter_number);
$query->condition('preference_id', $preference_id);
$query->range(0, 1);
$chapter_q = $query->execute();
if (!$chapter_data = $chapter_q->fetchObject())
{
echo '';
return;
} else {
$chapter_id = $chapter_data->id;
}
$query = db_select('lab_migration_example');
$query->fields('lab_migration_example');
$query->condition('chapter_id', $chapter_id);
$query->condition('number', $example_number);
$query->range(0, 1);
$example_q = $query->execute();
if ($example_data = $example_q->fetchObject())
{
if ($example_data->approval_status == 1)
echo 'Warning! Solution already approved. You cannot upload the same solution again.';
else
echo 'Warning! Solution already uploaded. Delete the solution and reupload it.';
return;
}
}
echo '';
}
/*************************** VALIDATION FUNCTIONS *****************************/
function lab_migration_check_valid_filename($file_name) {
if (!preg_match('/^[0-9a-zA-Z\.]+$/', $file_name))
return FALSE;
else
if (substr_count($file_name, ".") > 1)
return FALSE;
else
return TRUE;
}
function lab_migration_check_name($name = '') {
if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
return FALSE;
else
return TRUE;
}
function lab_migration_check_code_number($number = '') {
if (!preg_match('/^[0-9]+$/', $number))
return FALSE;
else
return TRUE;
}
function lab_migration_path() {
return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'lab_migration_uploads/';
}
function lab_migration_samplecode_path() {
return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'lm_sample_code/';
}
/************************* USER VERIFICATION FUNCTIONS ************************/
function lab_migration_get_proposal() {
global $user;
//$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1");
$query = db_select('lab_migration_proposal');
$query->fields('lab_migration_proposal');
$query->condition('solution_provider_uid', $user->uid);
$query->condition('solution_status', 2);
$query->orderBy('id', 'DESC');
$query->range(0, 1);
$proposal_q= $query->execute();
$proposal_data = $proposal_q->fetchObject();
if (!$proposal_data)
{
drupal_set_message("You do not have any approved Lab migraion solution proposal. Please check the " . l('available', 'lab_migration/open_proposal') . " Lab migration proposal.", 'error');
drupal_goto('');
}
switch ($proposal_data->approval_status)
{
case 0:
drupal_set_message(t('Proposal is awaiting approval.'), 'status');
return FALSE;
case 1:
return $proposal_data;
case 2:
drupal_set_message(t('Proposal has been dis-approved.'), 'error');
return FALSE;
case 3:
drupal_set_message(t('Proposal has been marked as completed.'), 'status');
return FALSE;
default:
drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
return FALSE;
}
return FALSE;
}
/***************************** GENERAL FUNCTIONS ******************************/
function lab_migration_get_category_name($category_id) {
$category_data = '';
switch ($category_id)
{
case 0: $category_data = 'Not Selected'; break;
case 1: $category_data = 'Fluid Mechanics'; break;
case 2: $category_data = 'Control Theory & Control Systems'; break;
case 3: $category_data = 'Chemical Engineering'; break;
case 4: $category_data = 'Thermodynamics'; break;
case 5: $category_data = 'Mechanical Engineering'; break;
case 6: $category_data = 'Signal Processing'; break;
case 7: $category_data = 'Digital Communications'; break;
case 8: $category_data = 'Electrical Technology'; break;
case 9: $category_data = 'Mathematics & Pure Science'; break;
case 10: $category_data = 'Analog Electronics'; break;
case 11: $category_data = 'Digital Electronics'; break;
case 12: $category_data = 'Computer Programming'; break;
case 13: $category_data = 'Others'; break;
default: $category_data = 'Unknown'; break;
}
return $category_data;
}
/*function lab_migration_init() {
drupal_add_js(drupal_get_path('module', 'lab_migration') . '/js/lab_migration_ajax.js', array ('scope' => 'footer'));
}*/
/***************** Functions for certificates ************************/
function _list_all_lm_certificates()
{
$query = db_query("SELECT * FROM lab_migration_certificate");
$search_rows = array();
$output = '';
$details_list = $query->fetchAll();
foreach ($details_list as $details)
{
$search_rows[] = array(
$details->lab_name,
$details->institute_name,
$details->name,
l('Download Certificate', 'lab_migration/certificate/generate-pdf/' . $details->proposal_id . '/' . $details->id),
l('Edit Certificate', 'lab_migration/certificate/lm-participation/form/edit/' . $details->proposal_id . '/' . $details->id)
);
}
$search_header = array(
'Lab Name',
'Institute name',
'Name',
'Download Certificates',
'Edit Certificates'
);
$output .= theme('table', array(
'header' => $search_header,
'rows' => $search_rows
));
return $output;
}
function lab_migration_certificate_participation_form($form, $form_state)
{
$form['name_title'] = array(
'#type' => 'select',
'#title' => t('Title'),
'#options' => array(
'Dr.' => 'Dr.',
'Prof.' => 'Prof.',
'Mr.' => 'Mr.',
'Mrs.' => 'Mrs.',
'Ms.' => 'Ms.'
),
'#required' => TRUE
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name of Participant'),
'#maxlength' => 50,
'#required' => TRUE
);
$form['email_id'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#size' => 50,
'#default_value' => 'Not availbale'
);
$form['institute_name'] = array(
'#type' => 'textfield',
'#title' => t('Collage / Institue Name'),
'#required' => TRUE
);
$form['institute_address'] = array(
'#type' => 'textfield',
'#title' => t('Collage / Institue address'),
'#required' => TRUE
);
$form['lab_name'] = array(
'#type' => 'textfield',
'#title' => t('Lab name'),
'#required' => TRUE
);
$form['department'] = array(
'#type' => 'textfield',
'#title' => t('Department'),
'#required' => TRUE
);
$form['proposal_id'] = array(
'#type' => 'textfield',
'#title' => t('Lab Proposal Id'),
'#description' => 'Note: You can find the respective Lab Proposal Id from the url for the completed lab. For example: The Lab Proposal Id is 64 for this completed lab. ( Url - scilab.in/lab_migration_run/64)',
'#required' => TRUE
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
return $form;
}
function lab_migration_certificate_participation_form_submit($form, &$form_state)
{
global $user;
$v = $form_state["values"];
$result = "INSERT INTO {lab_migration_certificate}
(uid, name_title, name, email_id, institute_name, institute_address, lab_name, department, proposal_id,creation_date) VALUES
(:uid, :name_title, :name, :email_id, :institute_name, :institute_address, :lab_name, :department, :proposal_id,:creation_date)";
$args = array(
":uid" => $user->uid,
":name_title" => trim($v['name_title']),
":name" => trim($v['name']),
":email_id" => trim($v['email_id']),
":institute_name" => trim($v['institute_name']),
":institute_address" => trim($v['institute_address']),
":lab_name" => trim($v['lab_name']),
":department" => trim($v['department']),
":proposal_id" => $v['proposal_id'],
":creation_date" => time()
);
$proposal_id = db_query($result, $args);
drupal_goto('lab_migration/certificate');
}
function lab_migration_certificate_participation_edit_form($form, $form_state)
{
$action = arg(4);
$proposal_id = arg(5);
$certi_id = arg(6);
if ($action == "edit")
{
$query = db_query("SELECT * FROM lab_migration_certificate WHERE proposal_id=:prop_id AND id=:certi_id", array(
":prop_id" => $proposal_id,
":certi_id" => $certi_id
));
$details_list = $query->fetchobject();
$form['name_title'] = array(
'#type' => 'select',
'#title' => t('Title'),
'#options' => array(
'Dr.' => 'Dr.',
'Prof.' => 'Prof.',
'Mr.' => 'Mr.',
'Mrs.' => 'Mrs.',
'Ms.'=> 'Ms.'
),
'#default_value' => $details_list->name_title
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name of Participant'),
'#maxlength' => 50,
'#default_value' => $details_list->name
);
$form['email_id'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#size' => 50,
'#default_value' => $details_list->email_id
);
$form['institute_name'] = array(
'#type' => 'textfield',
'#title' => t('Collage / Institue Name'),
'#default_value' => $details_list->institute_name
);
$form['institute_address'] = array(
'#type' => 'textfield',
'#title' => t('Collage / Institue address'),
'#default_value' => $details_list->institute_address
);
$form['lab_name'] = array(
'#type' => 'textfield',
'#title' => t('Lab name'),
'#default_value' => $details_list->lab_name
);
$form['department'] = array(
'#type' => 'textfield',
'#title' => t('Department'),
'#default_value' => $details_list->department
);
$form['proposal_id'] = array(
'#type' => 'textfield',
'#title' => t('Lab Proposal Id'),
'#description' => 'Note: You can find the respective Lab Proposal Id from the url for the completed lab. For example: The Lab Proposal Id is 64 for this completed lab. ( Url - scilab.in/lab_migration_run/64)',
'#default_value' => $details_list->proposal_id
);
$form['certi_id'] = array(
'#type' => 'hidden',
'#default_value' => $details_list->id
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
} //$type == "lm_participation" && $action == "edit"
else
{
$form['err_message'] = array(
'#type' => 'item',
'#title' => t('Message'),
'#markup' => 'Invalid information'
);
}
return $form;
}
function lab_migration_certificate_participation_edit_form_submit($form, &$form_state)
{
global $user;
$v = $form_state["values"];
$result = "UPDATE lab_migration_certificate SET
uid=:uid,
name_title=:name_title,
name=:name,
email_id=:email_id,
institute_name=:institute_name,
institute_address=:institute_address,