summaryrefslogtreecommitdiff
path: root/esim_workshop_form.module
blob: 141902d161093dfdc09921f1caeb6866213ae1d7 (plain)
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
<?php
global $base_url;
/**
 * Implements hook_menu().
 */
function esim_workshop_form_menu()
{
	$items = array();
	// Form page. 
	/***********************************************************/
	$items['esim-workshop/form'] = array(
		'title' => t('eSim Workshop Form'),
		'page callback' => 'esim_workshop_form_page',
		'page arguments' => array(),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	$items['esim-workshop/form/step1'] = array(
		'title' => t('eSim Workshop Form'),
		'page callback' => 'esim_workshop_form_page',
		'page arguments' => array(),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	$items['esim-workshop/form/step2'] = array(
		'title' => t('Important Instructions for Participants'),
		'page callback' => 'drupal_get_form',
		'page arguments' => array(
			'esim_workshop_step2_form'
		),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	$items['esim-workshop/form/step3'] = array(
		'title' => t('Schematic Creation'),
		'page callback' => 'drupal_get_form',
		'page arguments' => array(
			'esim_workshop_step3_form'
		),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	$items['esim-workshop/form/step4'] = array(
		'title' => t('Simulation and Hardware'),
		'page callback' => 'drupal_get_form',
		'page arguments' => array(
			'esim_workshop_step4_form'
		),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	$items['esim-workshop/form/step5'] = array(
		'title' => t('PCB designing'),
		'page callback' => 'drupal_get_form',
		'page arguments' => array(
			'esim_workshop_step5_form'
		),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	$items['esim-workshop/form/step6'] = array(
		'title' => t('Documentation and Submission'),
		'page callback' => 'drupal_get_form',
		'page arguments' => array(
			'esim_workshop_step6_form'
		),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	$items['admin/settings/esim-workshop'] = array(
		'title' => 'eSim Workshop Settings',
		'description' => 'eSim Workshop Settings',
		'page callback' => 'drupal_get_form',
		'page arguments' => array(
			'esim_workshop_settings_form'
		),
		'access arguments' => array(
			'administer esim workshop settings'
		),
		'type' => MENU_NORMAL_ITEM,
		'file' => 'settings.inc'
	);
	$items['esim-workshop/download/project-file'] = array(
		'title' => 'eSim download project file',
		'description' => 'eSim download project file',
		'page callback' => 'drupal_get_form',
		'page arguments' => array(
			'esim_download_project_file'
		),
		'access arguments' => array(
			'download project file'
		),
		'type' => MENU_NORMAL_ITEM,
		'file' => 'download.inc'
	);
	// Delete the comment
	$items['esim-workshop/delete'] = array(
		'title' => t('eSim Workshop Form successful!'),
		'page callback' => 'esim_workshop_delete_comment',
		'page arguments' => array(),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	// Success page.
	$items['esim-workshop/success'] = array(
		'title' => t('eSim Workshop Form successful!'),
		'page callback' => 'esim_workshop_success',
		'page arguments' => array(),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	// Result page
	$items['esim-workshop/form/result'] = array(
		'title' => t('eSim Workshop Form'),
		'page callback' => 'esim_workshop_result_page',
		'page arguments' => array(),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	$items['esim-workshop/form/result/download'] = array(
		'title' => t('eSim Workshop Form'),
		'page callback' => 'esim_workshop_result_generate_csv',
		'page arguments' => array(),
		'access arguments' => array(
			'access esim workshop form'
		),
		'file' => 'esim_workshop_form_2019.inc'
	);
	return $items;
}
function esim_workshop_form_permission()
{
	return array(
		"access esim workshop form" => array(
			"title" => t("esim workshop form"),
			"description" => t("Allows users to view esim workshop form")
		),
		"administer esim workshop settings" => array(
			"title" => t("Administer eSim Workshop settings"),
			"description" => t("Allows users to administer esim workshop settings")
		),
		"download project file" => array(
			"title" => t("Download Project file"),
			"description" => t("Allows users to download uploaded project file")
		),
	);
}
function _field_sentence_case($string)
{
	$string = ucwords(strtolower($string));
	foreach (array(
		'-',
		'\''
	) as $delimiter)
	{
		if (strpos($string, $delimiter) !== false)
		{
			$string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
		} //strpos($string, $delimiter) !== false
	} //array( '-', '\'' ) as $delimiter
	return $string;
}

function esim_workshop_file_path()
{
	return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'esim_uploads/esim_workshop_uploads/july2019/';
}

function workshop_project_file_check_valid_filename($file_name)
{
	if (!preg_match('/^[0-9]{4}/', $file_name))
		return FALSE;
	else if (substr_count($file_name, ".") > 1)
		return FALSE;
	else
		return TRUE;
}