Completed
Push — gcconnex ( ee5ffc...718fe4 )
by Ilia
09:37 queued 04:29
created
mod/missions/lib/missions-searching.php 3 patches
Indentation   +890 added lines, -890 removed lines patch added patch discarded remove patch
@@ -14,83 +14,83 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function mm_search_database_for_missions($query_array, $query_operand, $limit, $mission_state_include_array = ['posted'])
16 16
 {
17
-    $options = array();
18
-    $mission_count = '';
19
-    $missions = '';
20
-
21
-    $filtered_array = array_filter($query_array);
22
-    if(empty($filtered_array)) {
23
-        register_error(elgg_echo('missions:error:no_search_values'));
24
-        return false;
25
-    }
26
-
27
-    foreach($filtered_array as $key => $array) {
28
-        $filtered_array[$key]['operand'] = htmlspecialchars_decode($array['operand']);
29
-    }
30
-
31
-    if ( strcasecmp( $query_operand, 'OR' ) === 0 ){
32
-        $options['type'] = 'object';
33
-        $options['subtype'] = 'mission';
34
-        $options['metadata_name_value_pairs_operator'] = $query_operand;
35
-        $options['metadata_case_sensitive'] = false;
36
-        $options['limit'] = $limit;
37
-
38
-        // split the search into separate queries to prevent slowdown from 10+ join queries using 'OR'
39
-        $all_missions = array();
40
-        foreach ($filtered_array as $array) {
41
-            $options['metadata_name_value_pairs'] = array($array);
42
-            $some_missions = elgg_get_entities_from_metadata($options);
43
-            $all_missions = array_merge( $all_missions, $some_missions );
44
-        }
45
-
46
-        $missions = array();
47
-        foreach ($all_missions as $mission) {
48
-            $missions[$mission->guid] = $mission;
49
-        }
50
-        // Filter opportunities based on their state.  Inclusive.
51
-        // WHY: We may only want to search for archived or open opportunities which have different states.
52
-        foreach($missions as $key => $mission) {
53
-            $include_opportunity = false;
54
-            foreach ($mission_state_include_array as $include_state) {
55
-                if ($mission->state == $include_state) {
56
-                    $include_opportunity = true;
57
-                    last;
58
-                }
59
-            }
60
-            if ($include_opportunity == false) {
61
-                unset($missions[$key]);
62
-            }
63
-        }
64
-    }
65
-    else {
66
-        // Setting options with which the query will be built.
67
-        $options['type'] = 'object';
68
-        $options['subtype'] = 'mission';
69
-        $options['metadata_name_value_pairs'] = $filtered_array;
70
-        $options['metadata_name_value_pairs_operator'] = $query_operand;
71
-        $options['metadata_case_sensitive'] = false;
72
-        $options['limit'] = $limit;
73
-        $missions = elgg_get_entities_from_metadata($options);
74
-
75
-
76
-        foreach($missions as $key => $mission) {
77
-            if($mission->state != 'posted') {
78
-                unset($missions[$key]);
79
-            }
80
-        }
81
-    }
82
-
83
-    $mission_count = count($missions);
84
-    if ($mission_count == 0) {
85
-        register_error(elgg_echo('missions:error:entity_does_not_exist'));
86
-        return false;
87
-    } else {
88
-        $_SESSION['mission_count'] = $mission_count;
89
-        $_SESSION['mission_search_set'] = $missions;
90
-        $_SESSION['mission_search_set_timestamp'] = time();
91
-
92
-        return true;
93
-    }
17
+	$options = array();
18
+	$mission_count = '';
19
+	$missions = '';
20
+
21
+	$filtered_array = array_filter($query_array);
22
+	if(empty($filtered_array)) {
23
+		register_error(elgg_echo('missions:error:no_search_values'));
24
+		return false;
25
+	}
26
+
27
+	foreach($filtered_array as $key => $array) {
28
+		$filtered_array[$key]['operand'] = htmlspecialchars_decode($array['operand']);
29
+	}
30
+
31
+	if ( strcasecmp( $query_operand, 'OR' ) === 0 ){
32
+		$options['type'] = 'object';
33
+		$options['subtype'] = 'mission';
34
+		$options['metadata_name_value_pairs_operator'] = $query_operand;
35
+		$options['metadata_case_sensitive'] = false;
36
+		$options['limit'] = $limit;
37
+
38
+		// split the search into separate queries to prevent slowdown from 10+ join queries using 'OR'
39
+		$all_missions = array();
40
+		foreach ($filtered_array as $array) {
41
+			$options['metadata_name_value_pairs'] = array($array);
42
+			$some_missions = elgg_get_entities_from_metadata($options);
43
+			$all_missions = array_merge( $all_missions, $some_missions );
44
+		}
45
+
46
+		$missions = array();
47
+		foreach ($all_missions as $mission) {
48
+			$missions[$mission->guid] = $mission;
49
+		}
50
+		// Filter opportunities based on their state.  Inclusive.
51
+		// WHY: We may only want to search for archived or open opportunities which have different states.
52
+		foreach($missions as $key => $mission) {
53
+			$include_opportunity = false;
54
+			foreach ($mission_state_include_array as $include_state) {
55
+				if ($mission->state == $include_state) {
56
+					$include_opportunity = true;
57
+					last;
58
+				}
59
+			}
60
+			if ($include_opportunity == false) {
61
+				unset($missions[$key]);
62
+			}
63
+		}
64
+	}
65
+	else {
66
+		// Setting options with which the query will be built.
67
+		$options['type'] = 'object';
68
+		$options['subtype'] = 'mission';
69
+		$options['metadata_name_value_pairs'] = $filtered_array;
70
+		$options['metadata_name_value_pairs_operator'] = $query_operand;
71
+		$options['metadata_case_sensitive'] = false;
72
+		$options['limit'] = $limit;
73
+		$missions = elgg_get_entities_from_metadata($options);
74
+
75
+
76
+		foreach($missions as $key => $mission) {
77
+			if($mission->state != 'posted') {
78
+				unset($missions[$key]);
79
+			}
80
+		}
81
+	}
82
+
83
+	$mission_count = count($missions);
84
+	if ($mission_count == 0) {
85
+		register_error(elgg_echo('missions:error:entity_does_not_exist'));
86
+		return false;
87
+	} else {
88
+		$_SESSION['mission_count'] = $mission_count;
89
+		$_SESSION['mission_search_set'] = $missions;
90
+		$_SESSION['mission_search_set_timestamp'] = time();
91
+
92
+		return true;
93
+	}
94 94
 }
95 95
 
96 96
 /*
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
  */
99 99
 function mm_compare_guid($a, $b)
100 100
 {
101
-    if ($a->guid == $b->guid) {
102
-        return 0;
103
-    }
104
-    if ($a->guid > $b->guid) {
105
-        return 1;
106
-    }
107
-    return - 1;
101
+	if ($a->guid == $b->guid) {
102
+		return 0;
103
+	}
104
+	if ($a->guid > $b->guid) {
105
+		return 1;
106
+	}
107
+	return - 1;
108 108
 }
109 109
 
110 110
 /*
@@ -113,345 +113,345 @@  discard block
 block discarded – undo
113 113
  */
114 114
 function mm_analyze_advanced_search_element($place, $array)
115 115
 {
116
-    $returner = array();
117
-
118
-    switch(trim($array['selection_' . $place])) {
119
-        // Returns an empty array if
120
-        case '':
121
-            break;
122
-
123
-        case elgg_echo('missions:user_department'):
124
-            if (trim($array['selection_' . $place . '_element']) != '') {
125
-                $returner['name'] = 'department';
126
-                $returner['operand'] = 'LIKE';
127
-                $returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
128
-            }
129
-            break;
130
-
131
-        case elgg_echo('missions:opt_in'):
132
-            if(trim($array['selection_' . $place . '_element']) != '') {
133
-                $name_option = '';
134
-                switch($array['selection_' . $place . '_element']) {
135
-                    case elgg_echo('gcconnex_profile:opt:micro_missionseek'):
136
-                        $name_option = 'opt_in_missions';
137
-                        break;
138
-                    case elgg_echo('gcconnex_profile:opt:micro_mission'):
139
-                        $name_option = 'opt_in_missionCreate';
140
-                        break;
141
-                    case elgg_echo('gcconnex_profile:opt:assignment_deployment_seek');
142
-                        $name_option = 'opt_in_assignSeek';
143
-                        break;
144
-                    case elgg_echo('gcconnex_profile:opt:assignment_deployment_create');
145
-                        $name_option = 'opt_in_assignCreate';
146
-                        break;
147
-                    case elgg_echo('gcconnex_profile:opt:deployment_seek');
148
-                        $name_option = 'opt_in_deploySeek';
149
-                        break;
150
-                    case elgg_echo('gcconnex_profile:opt:deployment_create');
151
-                        $name_option = 'opt_in_deployCreate';
152
-                        break;
153
-                    case elgg_echo('gcconnex_profile:opt:job_swap'):
154
-                        $name_option = 'opt_in_swap';
155
-                        break;
156
-                    case elgg_echo('gcconnex_profile:opt:job_rotate');
157
-                        $name_option = 'opt_in_rotation';
158
-                        break;
159
-
160
-                    // Development
161
-
162
-                    case elgg_echo('gcconnex_profile:opt:mentored'):
163
-                        $name_option = 'opt_in_mentored';
164
-                        break;
165
-                    case elgg_echo('gcconnex_profile:opt:mentoring'):
166
-                        $name_option = 'opt_in_mentoring';
167
-                        break;
168
-                    case elgg_echo('gcconnex_profile:opt:shadowed'):
169
-                        $name_option = 'opt_in_shadowed';
170
-                        break;
171
-                    case elgg_echo('gcconnex_profile:opt:shadowing'):
172
-                        $name_option = 'opt_in_shadowing';
173
-                        break;
174
-                    case elgg_echo('gcconnex_profile:opt:job_sharing'):
175
-                        $name_option = 'opt_in_jobshare';
176
-                        break;
177
-                    case elgg_echo('gcconnex_profile:opt:peer_coached'):
178
-                        $name_option = 'opt_in_pcSeek';
179
-                        break;
180
-                    case elgg_echo('gcconnex_profile:opt:peer_coaching'):
181
-                        $name_option = 'opt_in_pcCreate';
182
-                        break;
183
-                    case elgg_echo('gcconnex_profile:opt:skill_sharing'):
184
-                        $name_option = 'opt_in_ssSeek';
185
-                        break;
186
-                    case elgg_echo('gcconnex_profile:opt:skill_sharing_create');
187
-                        $name_option = 'opt_in_ssCreate';
188
-                        break;
189
-                }
190
-                $returner['name'] = $name_option;
191
-                $returner['operand'] = '=';
192
-                $returner['value'] = 'gcconnex_profile:opt:yes';
193
-            }
194
-            break;
195
-
196
-        case elgg_echo('missions:portfolio'):
197
-            if(trim($array['selection_' . $place . '_element_value']) != '') {
198
-                $name_option = '';
199
-                $operand_option = 'LIKE';
200
-                $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
201
-                switch($array['selection_' . $place . '_element']) {
202
-                    case elgg_echo('missions:title'):
203
-                        $name_option = 'title';
204
-                        break;
205
-                    case elgg_echo('missions:publication_date'):
206
-                        $name_option = 'pubdate';
207
-                        $operand_option = $array['selection_' . $place . '_element_operand'];
208
-                        $value_option = $array['selection_' . $place . '_element_value'];
209
-                        break;
210
-                }
211
-                $returner['name'] = $name_option;
212
-                $returner['operand'] = $operand_option;
213
-                $returner['value'] = $value_option;
214
-                $returner['extra_option'] = 'portfolio';
215
-            }
216
-            break;
217
-
218
-        case elgg_echo('missions:skill'):
219
-            if(trim($array['selection_' . $place . '_element']) != '') {
220
-                $returner['name'] = 'title';
221
-                $returner['operand'] = 'LIKE';
222
-                $returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
223
-                $returner['extra_option'] = 'MySkill';
224
-            }
225
-            break;
226
-
227
-        case elgg_echo('missions:experience'):
228
-            if(trim($array['selection_' . $place . '_element_value']) != '') {
229
-                $name_option = '';
230
-                $operand_option = 'LIKE';
231
-                $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
232
-                switch($array['selection_' . $place . '_element']) {
233
-                    case elgg_echo('missions:title'):
234
-                        $name_option = 'title';
235
-                        break;
236
-                    case elgg_echo('missions:organization'):
237
-                        $name_option = 'organization';
238
-                        break;
239
-                    case elgg_echo('missions:end_year'):
240
-                        $name_option = 'endyear';
241
-                        $operand_option = $array['selection_' . $place . '_element_operand'];
242
-                        $value_option = $array['selection_' . $place . '_element_value'];
243
-                        break;
244
-                }
245
-                $returner['name'] = $name_option;
246
-                $returner['operand'] = $operand_option;
247
-                $returner['value'] = $value_option;
248
-                $returner['extra_option'] = 'experience';
249
-            }
250
-            break;
251
-
252
-        case elgg_echo('missions:education'):
253
-            if(trim($array['selection_' . $place . '_element_value']) != '') {
254
-                $name_option = '';
255
-                $operand_option = 'LIKE';
256
-                $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
257
-                switch($array['selection_' . $place . '_element']) {
258
-                    case elgg_echo('missions:title'):
259
-                        $name_option = 'title';
260
-                        break;
261
-                    case elgg_echo('missions:degree'):
262
-                        $name_option = 'degree';
263
-                        break;
264
-                    case elgg_echo('missions:field'):
265
-                        $name_option = 'field';
266
-                        break;
267
-                    case elgg_echo('missions:end_year'):
268
-                        $name_option = 'endyear';
269
-                        $operand_option = $array['selection_' . $place . '_element_operand'];
270
-                        $value_option = $array['selection_' . $place . '_element_value'];
271
-                        break;
272
-                }
273
-                $returner['name'] = $name_option;
274
-                $returner['operand'] = $operand_option;
275
-                $returner['value'] = $value_option;
276
-                $returner['extra_option'] = 'education';
277
-            }
278
-            break;
279
-
280
-        //
281
-        case elgg_echo('missions:start_time'):
282
-        case elgg_echo('missions:duration'):
283
-            if (trim($array['selection_' . $place . '_element'])) {
284
-                $name_option = '';
285
-                // Selects which day will be searched.
286
-                switch ($array['selection_' . $place . '_element_day']) {
287
-                    case elgg_echo('missions:mon'):
288
-                        $name_option = 'mon';
289
-                        break;
290
-                    case elgg_echo('missions:tue'):
291
-                        $name_option = 'tue';
292
-                        break;
293
-                    case elgg_echo('missions:wed'):
294
-                        $name_option = 'wed';
295
-                        break;
296
-                    case elgg_echo('missions:thu'):
297
-                        $name_option = 'thu';
298
-                        break;
299
-                    case elgg_echo('missions:fri'):
300
-                        $name_option = 'fri';
301
-                        break;
302
-                    case elgg_echo('missions:sat'):
303
-                        $name_option = 'sat';
304
-                        break;
305
-                    case elgg_echo('missions:sun'):
306
-                        $name_option = 'sun';
307
-                        break;
308
-                }
309
-
310
-                if($array['selection_' . $place] == elgg_echo('missions:start_time')) {
311
-                    $name_option .= '_start';
312
-                }
313
-                if($array['selection_' . $place] == elgg_echo('missions:duration')) {
314
-                     $name_option .= '_duration';
315
-                }
316
-
317
-                $operand_option = $array['selection_' . $place . '_operand'];
318
-                // Packs the input hour and time for comparison with the packed elements in the database.
319
-                $returner['name'] = $name_option;
320
-                $returner['operand'] = $array['selection_' . $place . '_operand'];
321
-                $returner['value'] = $array['selection_' . $place . '_element'];
322
-            }
323
-            break;
324
-
325
-        case elgg_echo('missions:period'):
326
-            if(trim($array['selection_' . $place . '_element']) != '') {
327
-                $returner['name'] = 'time_interval';
328
-                $returner['operand'] = '=';
329
-                $returner['value'] = $array['selection_' . $place . '_element'];
330
-            }
331
-              break;
332
-
333
-        case elgg_echo('missions:time'):
334
-            if (trim($array['selection_' . $place . '_element']) != '') {
335
-                $returner['name'] = 'time_commitment';
336
-                $returner['operand'] = $array['selection_' . $place . '_operand'];
337
-                $returner['value'] = $array['selection_' . $place . '_element'];
338
-            }
339
-            break;
340
-
341
-        // Selects language element which requires packing.
342
-        case elgg_echo('missions:language'):
343
-            if (trim($array['selection_' . $place . '_element_lwc']) != '' || trim($array['selection_' . $place . '_element_lwe']) != '' || trim($array['selection_' . $place . '_element_lop']) != '') {
344
-                $name_option = '';
345
-                // Selects which language will be searched
346
-                switch ($array['selection_' . $place . '_element']) {
347
-                    case elgg_echo('missions:english'):
348
-                        $name_option = 'english';
349
-                        break;
350
-                    case elgg_echo('missions:french'):
351
-                        $name_option = 'french';
352
-                        break;
353
-                }
354
-
355
-                $option_value = $name_option;
356
-                $language_requirement_array = array($array['selection_' . $place . '_element_lwc'], $array['selection_' . $place . '_element_lwe'], $array['selection_' . $place . '_element_lop']);
357
-                foreach($language_requirement_array as $value) {
358
-                    switch($value) {
359
-                        case 'A':
360
-                            $option_value .= '[Aa-]';
361
-                            break;
362
-                        case 'B':
363
-                            $option_value .= '[ABab-]';
364
-                            break;
365
-                        case 'C':
366
-                            $option_value .= '[ABCabc-]';
367
-                            break;
368
-                        default:
369
-                            $option_value .= '[-]';
370
-                    }
371
-                }
372
-
373
-                // Packs the input written comprehension, written expression and oral proficiency for comparison with the packed elements in the database.
374
-                //$option_value = mm_pack_language($array['selection_' . $place . '_element_lwc'], $array['selection_' . $place . '_element_lwe'], $array['selection_' . $place . '_element_lop'], $name_option);
375
-                $returner['name'] = $name_option;
376
-                $returner['operand'] = 'REGEXP';
377
-                $returner['value'] = $option_value;
378
-            }
379
-            break;
380
-
381
-        // The next 3 are select elements that require a MySQL LIKE comparison.
382
-        case elgg_echo('missions:key_skills'):
383
-            if (trim($array['selection_' . $place . '_element']) != '') {
384
-                $returner['name'] = 'key_skills';
385
-                $returner['operand'] = 'LIKE';
386
-                $returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
387
-            }
388
-            break;
389
-
390
-        case elgg_echo('missions:location'):
391
-            if (trim($array['selection_' . $place . '_element']) != '') {
392
-                $returner['name'] = 'location';
393
-                $returner['operand'] = 'LIKE';
394
-                $returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
395
-            }
396
-            break;
397
-
398
-        case elgg_echo('missions:type'):
399
-            if (trim($array['selection_' . $place . '_element']) != '') {
400
-                $returner['name'] = 'job_type';
401
-                $returner['operand'] = '=';
402
-                $returner['value'] = $array['selection_' . $place . '_element'];
403
-            }
404
-            break;
405
-
406
-        // The next 5 are selects elements that require a direct equivalence comparison.
407
-        case elgg_echo('missions:title'):
408
-            if (trim($array['selection_' . $place . '_element']) != '') {
409
-                $returner['name'] = 'job_title';
410
-                $returner['operand'] = 'LIKE';
411
-                $returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
412
-            }
413
-            break;
414
-
415
-        case elgg_echo('missions:security_clearance'):
416
-            if (trim($array['selection_' . $place . '_element']) != '') {
417
-                $returner['name'] = 'security';
418
-                $returner['operand'] = '=';
419
-                $returner['value'] = $array['selection_' . $place . '_element'];
420
-            }
421
-            break;
422
-
423
-        case elgg_echo('missions:department'):
424
-            if (trim($array['selection_' . $place . '_element']) != '') {
425
-                if(get_current_language() == 'fr') {
426
-                    $returner['name'] = 'department_path_french';
427
-                }
428
-                else {
429
-                    $returner['name'] = 'department_path_english';
430
-                }
431
-                $returner['operand'] = 'LIKE';
432
-                $returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
433
-            }
434
-            break;
435
-
436
-        case elgg_echo('missions:work_remotely'):
437
-            $returner['name'] = 'remotely';
438
-            $returner['operand'] = '=';
439
-            if($array['selection_' . $place . '_element']) {
440
-                $returner['value'] = 'on';
441
-            }
442
-            else {
443
-                $returner['value'] = 0;
444
-            }
445
-            break;
446
-
447
-        case elgg_echo('missions:program_area'):
448
-            $returner['name'] = 'program_area';
449
-            $returner['operand'] = '=';
450
-            $returner['value'] = $array['selection_' . $place . '_element'];
451
-            break;
452
-    }
453
-
454
-    return $returner;
116
+	$returner = array();
117
+
118
+	switch(trim($array['selection_' . $place])) {
119
+		// Returns an empty array if
120
+		case '':
121
+			break;
122
+
123
+		case elgg_echo('missions:user_department'):
124
+			if (trim($array['selection_' . $place . '_element']) != '') {
125
+				$returner['name'] = 'department';
126
+				$returner['operand'] = 'LIKE';
127
+				$returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
128
+			}
129
+			break;
130
+
131
+		case elgg_echo('missions:opt_in'):
132
+			if(trim($array['selection_' . $place . '_element']) != '') {
133
+				$name_option = '';
134
+				switch($array['selection_' . $place . '_element']) {
135
+					case elgg_echo('gcconnex_profile:opt:micro_missionseek'):
136
+						$name_option = 'opt_in_missions';
137
+						break;
138
+					case elgg_echo('gcconnex_profile:opt:micro_mission'):
139
+						$name_option = 'opt_in_missionCreate';
140
+						break;
141
+					case elgg_echo('gcconnex_profile:opt:assignment_deployment_seek');
142
+						$name_option = 'opt_in_assignSeek';
143
+						break;
144
+					case elgg_echo('gcconnex_profile:opt:assignment_deployment_create');
145
+						$name_option = 'opt_in_assignCreate';
146
+						break;
147
+					case elgg_echo('gcconnex_profile:opt:deployment_seek');
148
+						$name_option = 'opt_in_deploySeek';
149
+						break;
150
+					case elgg_echo('gcconnex_profile:opt:deployment_create');
151
+						$name_option = 'opt_in_deployCreate';
152
+						break;
153
+					case elgg_echo('gcconnex_profile:opt:job_swap'):
154
+						$name_option = 'opt_in_swap';
155
+						break;
156
+					case elgg_echo('gcconnex_profile:opt:job_rotate');
157
+						$name_option = 'opt_in_rotation';
158
+						break;
159
+
160
+					// Development
161
+
162
+					case elgg_echo('gcconnex_profile:opt:mentored'):
163
+						$name_option = 'opt_in_mentored';
164
+						break;
165
+					case elgg_echo('gcconnex_profile:opt:mentoring'):
166
+						$name_option = 'opt_in_mentoring';
167
+						break;
168
+					case elgg_echo('gcconnex_profile:opt:shadowed'):
169
+						$name_option = 'opt_in_shadowed';
170
+						break;
171
+					case elgg_echo('gcconnex_profile:opt:shadowing'):
172
+						$name_option = 'opt_in_shadowing';
173
+						break;
174
+					case elgg_echo('gcconnex_profile:opt:job_sharing'):
175
+						$name_option = 'opt_in_jobshare';
176
+						break;
177
+					case elgg_echo('gcconnex_profile:opt:peer_coached'):
178
+						$name_option = 'opt_in_pcSeek';
179
+						break;
180
+					case elgg_echo('gcconnex_profile:opt:peer_coaching'):
181
+						$name_option = 'opt_in_pcCreate';
182
+						break;
183
+					case elgg_echo('gcconnex_profile:opt:skill_sharing'):
184
+						$name_option = 'opt_in_ssSeek';
185
+						break;
186
+					case elgg_echo('gcconnex_profile:opt:skill_sharing_create');
187
+						$name_option = 'opt_in_ssCreate';
188
+						break;
189
+				}
190
+				$returner['name'] = $name_option;
191
+				$returner['operand'] = '=';
192
+				$returner['value'] = 'gcconnex_profile:opt:yes';
193
+			}
194
+			break;
195
+
196
+		case elgg_echo('missions:portfolio'):
197
+			if(trim($array['selection_' . $place . '_element_value']) != '') {
198
+				$name_option = '';
199
+				$operand_option = 'LIKE';
200
+				$value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
201
+				switch($array['selection_' . $place . '_element']) {
202
+					case elgg_echo('missions:title'):
203
+						$name_option = 'title';
204
+						break;
205
+					case elgg_echo('missions:publication_date'):
206
+						$name_option = 'pubdate';
207
+						$operand_option = $array['selection_' . $place . '_element_operand'];
208
+						$value_option = $array['selection_' . $place . '_element_value'];
209
+						break;
210
+				}
211
+				$returner['name'] = $name_option;
212
+				$returner['operand'] = $operand_option;
213
+				$returner['value'] = $value_option;
214
+				$returner['extra_option'] = 'portfolio';
215
+			}
216
+			break;
217
+
218
+		case elgg_echo('missions:skill'):
219
+			if(trim($array['selection_' . $place . '_element']) != '') {
220
+				$returner['name'] = 'title';
221
+				$returner['operand'] = 'LIKE';
222
+				$returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
223
+				$returner['extra_option'] = 'MySkill';
224
+			}
225
+			break;
226
+
227
+		case elgg_echo('missions:experience'):
228
+			if(trim($array['selection_' . $place . '_element_value']) != '') {
229
+				$name_option = '';
230
+				$operand_option = 'LIKE';
231
+				$value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
232
+				switch($array['selection_' . $place . '_element']) {
233
+					case elgg_echo('missions:title'):
234
+						$name_option = 'title';
235
+						break;
236
+					case elgg_echo('missions:organization'):
237
+						$name_option = 'organization';
238
+						break;
239
+					case elgg_echo('missions:end_year'):
240
+						$name_option = 'endyear';
241
+						$operand_option = $array['selection_' . $place . '_element_operand'];
242
+						$value_option = $array['selection_' . $place . '_element_value'];
243
+						break;
244
+				}
245
+				$returner['name'] = $name_option;
246
+				$returner['operand'] = $operand_option;
247
+				$returner['value'] = $value_option;
248
+				$returner['extra_option'] = 'experience';
249
+			}
250
+			break;
251
+
252
+		case elgg_echo('missions:education'):
253
+			if(trim($array['selection_' . $place . '_element_value']) != '') {
254
+				$name_option = '';
255
+				$operand_option = 'LIKE';
256
+				$value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
257
+				switch($array['selection_' . $place . '_element']) {
258
+					case elgg_echo('missions:title'):
259
+						$name_option = 'title';
260
+						break;
261
+					case elgg_echo('missions:degree'):
262
+						$name_option = 'degree';
263
+						break;
264
+					case elgg_echo('missions:field'):
265
+						$name_option = 'field';
266
+						break;
267
+					case elgg_echo('missions:end_year'):
268
+						$name_option = 'endyear';
269
+						$operand_option = $array['selection_' . $place . '_element_operand'];
270
+						$value_option = $array['selection_' . $place . '_element_value'];
271
+						break;
272
+				}
273
+				$returner['name'] = $name_option;
274
+				$returner['operand'] = $operand_option;
275
+				$returner['value'] = $value_option;
276
+				$returner['extra_option'] = 'education';
277
+			}
278
+			break;
279
+
280
+		//
281
+		case elgg_echo('missions:start_time'):
282
+		case elgg_echo('missions:duration'):
283
+			if (trim($array['selection_' . $place . '_element'])) {
284
+				$name_option = '';
285
+				// Selects which day will be searched.
286
+				switch ($array['selection_' . $place . '_element_day']) {
287
+					case elgg_echo('missions:mon'):
288
+						$name_option = 'mon';
289
+						break;
290
+					case elgg_echo('missions:tue'):
291
+						$name_option = 'tue';
292
+						break;
293
+					case elgg_echo('missions:wed'):
294
+						$name_option = 'wed';
295
+						break;
296
+					case elgg_echo('missions:thu'):
297
+						$name_option = 'thu';
298
+						break;
299
+					case elgg_echo('missions:fri'):
300
+						$name_option = 'fri';
301
+						break;
302
+					case elgg_echo('missions:sat'):
303
+						$name_option = 'sat';
304
+						break;
305
+					case elgg_echo('missions:sun'):
306
+						$name_option = 'sun';
307
+						break;
308
+				}
309
+
310
+				if($array['selection_' . $place] == elgg_echo('missions:start_time')) {
311
+					$name_option .= '_start';
312
+				}
313
+				if($array['selection_' . $place] == elgg_echo('missions:duration')) {
314
+					 $name_option .= '_duration';
315
+				}
316
+
317
+				$operand_option = $array['selection_' . $place . '_operand'];
318
+				// Packs the input hour and time for comparison with the packed elements in the database.
319
+				$returner['name'] = $name_option;
320
+				$returner['operand'] = $array['selection_' . $place . '_operand'];
321
+				$returner['value'] = $array['selection_' . $place . '_element'];
322
+			}
323
+			break;
324
+
325
+		case elgg_echo('missions:period'):
326
+			if(trim($array['selection_' . $place . '_element']) != '') {
327
+				$returner['name'] = 'time_interval';
328
+				$returner['operand'] = '=';
329
+				$returner['value'] = $array['selection_' . $place . '_element'];
330
+			}
331
+			  break;
332
+
333
+		case elgg_echo('missions:time'):
334
+			if (trim($array['selection_' . $place . '_element']) != '') {
335
+				$returner['name'] = 'time_commitment';
336
+				$returner['operand'] = $array['selection_' . $place . '_operand'];
337
+				$returner['value'] = $array['selection_' . $place . '_element'];
338
+			}
339
+			break;
340
+
341
+		// Selects language element which requires packing.
342
+		case elgg_echo('missions:language'):
343
+			if (trim($array['selection_' . $place . '_element_lwc']) != '' || trim($array['selection_' . $place . '_element_lwe']) != '' || trim($array['selection_' . $place . '_element_lop']) != '') {
344
+				$name_option = '';
345
+				// Selects which language will be searched
346
+				switch ($array['selection_' . $place . '_element']) {
347
+					case elgg_echo('missions:english'):
348
+						$name_option = 'english';
349
+						break;
350
+					case elgg_echo('missions:french'):
351
+						$name_option = 'french';
352
+						break;
353
+				}
354
+
355
+				$option_value = $name_option;
356
+				$language_requirement_array = array($array['selection_' . $place . '_element_lwc'], $array['selection_' . $place . '_element_lwe'], $array['selection_' . $place . '_element_lop']);
357
+				foreach($language_requirement_array as $value) {
358
+					switch($value) {
359
+						case 'A':
360
+							$option_value .= '[Aa-]';
361
+							break;
362
+						case 'B':
363
+							$option_value .= '[ABab-]';
364
+							break;
365
+						case 'C':
366
+							$option_value .= '[ABCabc-]';
367
+							break;
368
+						default:
369
+							$option_value .= '[-]';
370
+					}
371
+				}
372
+
373
+				// Packs the input written comprehension, written expression and oral proficiency for comparison with the packed elements in the database.
374
+				//$option_value = mm_pack_language($array['selection_' . $place . '_element_lwc'], $array['selection_' . $place . '_element_lwe'], $array['selection_' . $place . '_element_lop'], $name_option);
375
+				$returner['name'] = $name_option;
376
+				$returner['operand'] = 'REGEXP';
377
+				$returner['value'] = $option_value;
378
+			}
379
+			break;
380
+
381
+		// The next 3 are select elements that require a MySQL LIKE comparison.
382
+		case elgg_echo('missions:key_skills'):
383
+			if (trim($array['selection_' . $place . '_element']) != '') {
384
+				$returner['name'] = 'key_skills';
385
+				$returner['operand'] = 'LIKE';
386
+				$returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
387
+			}
388
+			break;
389
+
390
+		case elgg_echo('missions:location'):
391
+			if (trim($array['selection_' . $place . '_element']) != '') {
392
+				$returner['name'] = 'location';
393
+				$returner['operand'] = 'LIKE';
394
+				$returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
395
+			}
396
+			break;
397
+
398
+		case elgg_echo('missions:type'):
399
+			if (trim($array['selection_' . $place . '_element']) != '') {
400
+				$returner['name'] = 'job_type';
401
+				$returner['operand'] = '=';
402
+				$returner['value'] = $array['selection_' . $place . '_element'];
403
+			}
404
+			break;
405
+
406
+		// The next 5 are selects elements that require a direct equivalence comparison.
407
+		case elgg_echo('missions:title'):
408
+			if (trim($array['selection_' . $place . '_element']) != '') {
409
+				$returner['name'] = 'job_title';
410
+				$returner['operand'] = 'LIKE';
411
+				$returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
412
+			}
413
+			break;
414
+
415
+		case elgg_echo('missions:security_clearance'):
416
+			if (trim($array['selection_' . $place . '_element']) != '') {
417
+				$returner['name'] = 'security';
418
+				$returner['operand'] = '=';
419
+				$returner['value'] = $array['selection_' . $place . '_element'];
420
+			}
421
+			break;
422
+
423
+		case elgg_echo('missions:department'):
424
+			if (trim($array['selection_' . $place . '_element']) != '') {
425
+				if(get_current_language() == 'fr') {
426
+					$returner['name'] = 'department_path_french';
427
+				}
428
+				else {
429
+					$returner['name'] = 'department_path_english';
430
+				}
431
+				$returner['operand'] = 'LIKE';
432
+				$returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
433
+			}
434
+			break;
435
+
436
+		case elgg_echo('missions:work_remotely'):
437
+			$returner['name'] = 'remotely';
438
+			$returner['operand'] = '=';
439
+			if($array['selection_' . $place . '_element']) {
440
+				$returner['value'] = 'on';
441
+			}
442
+			else {
443
+				$returner['value'] = 0;
444
+			}
445
+			break;
446
+
447
+		case elgg_echo('missions:program_area'):
448
+			$returner['name'] = 'program_area';
449
+			$returner['operand'] = '=';
450
+			$returner['value'] = $array['selection_' . $place . '_element'];
451
+			break;
452
+	}
453
+
454
+	return $returner;
455 455
 }
456 456
 
457 457
 /*
@@ -460,158 +460,158 @@  discard block
 block discarded – undo
460 460
  */
461 461
 function mm_analyze_backup($place, $array)
462 462
 {
463
-    $returner = array();
464
-
465
-    $name_option = '';
466
-    $operand_option = '';
467
-    $value_option = '';
468
-    $extra_option = '';
469
-
470
-    // If the selection element has been chosen.
471
-    if (trim($array['selection_' . $place]) != '') {
472
-        // Base operand and value.
473
-        $operand_option = '=';
474
-        $value_option = $array['backup_' . $place];
475
-        // Modifies name, operand and/or value depending on which selection element was chosen.
476
-        switch ($array['selection_' . $place]) {
477
-            case elgg_echo('missions:title'):
478
-                $name_option = 'job_title';
479
-                break;
480
-
481
-            case elgg_echo('missions:type'):
482
-                $name_option = 'job_type';
483
-                $operand_option = 'LIKE';
484
-                $value_option = '%' . $array['backup_' . $place] . '%';
485
-                break;
486
-
487
-            case elgg_echo('missions:department'):
488
-                $name_option = 'department';
489
-                break;
490
-
491
-            case elgg_echo('missions:location'):
492
-                $name_option = 'location';
493
-                break;
494
-
495
-            case elgg_echo('missions:key_skills'):
496
-                $name_option = 'key_skills';
497
-                $operand_option = 'LIKE';
498
-                $value_option = '%' . $array['backup_' . $place] . '%';
499
-                break;
500
-
501
-            case elgg_echo('missions:security_clearance'):
502
-                $name_option = 'security';
503
-                break;
504
-
505
-            // In the language case, the value needs to have the format {language}{LWC}{LWE}{LOP}
506
-            case elgg_echo('missions:language'):
507
-                switch ($array['backup_' . $place]) {
508
-                    case (strpos($array['backup_' . $place], 'english') !== false):
509
-                        $name_option = 'english';
510
-                        break;
511
-                    case (strpos($array['backup_' . $place], 'french') !== false):
512
-                        $name_option = 'french';
513
-                        break;
514
-                    default:
515
-                        return array();
516
-                }
517
-                $operand_option = '=';
518
-                break;
519
-
520
-            // In the time case, the value needs to have the format {day}_{start/end}{hour}:{min}
521
-            case elgg_echo('missions:duration'):
522
-            case elgg_echo('missions:start_time'):
523
-                switch ($array['backup_' . $place]) {
524
-                    case (strpos($array['backup_' . $place], 'mon_start') !== false):
525
-                        $name_option = 'mon_start';
526
-                        break;
527
-                    case (strpos($array['backup_' . $place], 'mon_duration') !== false):
528
-                        $name_option = 'mon_duration';
529
-                        break;
530
-                    case (strpos($array['backup_' . $place], 'tue_start') !== false):
531
-                        $name_option = 'tue_start';
532
-                        break;
533
-                    case (strpos($array['backup_' . $place], 'tue_duration') !== false):
534
-                        $name_option = 'tue_duration';
535
-                        break;
536
-                    case (strpos($array['backup_' . $place], 'wed_start') !== false):
537
-                        $name_option = 'wed_start';
538
-                        break;
539
-                    case (strpos($array['backup_' . $place], 'wed_duration') !== false):
540
-                        $name_option = 'wed_duration';
541
-                        break;
542
-                    case (strpos($array['backup_' . $place], 'thu_start') !== false):
543
-                        $name_option = 'thu_start';
544
-                        break;
545
-                    case (strpos($array['backup_' . $place], 'thu_duration') !== false):
546
-                        $name_option = 'thu_duration';
547
-                        break;
548
-                    case (strpos($array['backup_' . $place], 'fri_start') !== false):
549
-                        $name_option = 'fri_start';
550
-                        break;
551
-                    case (strpos($array['backup_' . $place], 'fri_duration') !== false):
552
-                        $name_option = 'fri_duration';
553
-                        break;
554
-                    case (strpos($array['backup_' . $place], 'sat_start') !== false):
555
-                        $name_option = 'sat_start';
556
-                        break;
557
-                    case (strpos($array['backup_' . $place], 'sat_duration') !== false):
558
-                        $name_option = 'sat_duration';
559
-                        break;
560
-                    case (strpos($array['backup_' . $place], 'sun_start') !== false):
561
-                        $name_option = 'sun_start';
562
-                        break;
563
-                    case (strpos($array['backup_' . $place], 'sun_duration') !== false):
564
-                        $name_option = 'sun_duration';
565
-                        break;
566
-                    default:
567
-                        return array();
568
-                }
569
-                $operand_option = '=';
570
-                break;
571
-
572
-            case elgg_echo('missions:skill'):
573
-                $name_option = 'title';
574
-                $operand_option = 'LIKE';
575
-                $value_option = '%' . $array['selection_' . $place . '_element'] . '%';
576
-                $extra_option = 'MySkill';
577
-                break;
578
-
579
-            case elgg_echo('missions:experience'):
580
-                $name_option = 'title';
581
-                $operand_option = 'LIKE';
582
-                $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
583
-                $extra_option = 'experience';
584
-                break;
585
-
586
-            case elgg_echo('missions:education'):
587
-                $name_option = 'title';
588
-                $operand_option = 'LIKE';
589
-                $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
590
-                $extra_option = 'education';
591
-                break;
592
-
593
-            case elgg_echo('missions:portfolio'):
594
-                $name_option = 'title';
595
-                $operand_option = 'LIKE';
596
-                $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
597
-                $extra_option = 'portfolio';
598
-                break;
599
-
600
-            case elgg_echo('missions:work_remotely'):
601
-                $name_option = 'remotely';
602
-                break;
603
-
604
-            case elgg_echo('missions:program_area'):
605
-                $name_option = 'program_area';
606
-                break;
607
-        }
608
-        $returner['name'] = $name_option;
609
-        $returner['operand'] = $operand_option;
610
-        $returner['value'] = $value_option;
611
-        $returner['extra_option'] = $extra_option;
612
-    }
613
-
614
-    return $returner;
463
+	$returner = array();
464
+
465
+	$name_option = '';
466
+	$operand_option = '';
467
+	$value_option = '';
468
+	$extra_option = '';
469
+
470
+	// If the selection element has been chosen.
471
+	if (trim($array['selection_' . $place]) != '') {
472
+		// Base operand and value.
473
+		$operand_option = '=';
474
+		$value_option = $array['backup_' . $place];
475
+		// Modifies name, operand and/or value depending on which selection element was chosen.
476
+		switch ($array['selection_' . $place]) {
477
+			case elgg_echo('missions:title'):
478
+				$name_option = 'job_title';
479
+				break;
480
+
481
+			case elgg_echo('missions:type'):
482
+				$name_option = 'job_type';
483
+				$operand_option = 'LIKE';
484
+				$value_option = '%' . $array['backup_' . $place] . '%';
485
+				break;
486
+
487
+			case elgg_echo('missions:department'):
488
+				$name_option = 'department';
489
+				break;
490
+
491
+			case elgg_echo('missions:location'):
492
+				$name_option = 'location';
493
+				break;
494
+
495
+			case elgg_echo('missions:key_skills'):
496
+				$name_option = 'key_skills';
497
+				$operand_option = 'LIKE';
498
+				$value_option = '%' . $array['backup_' . $place] . '%';
499
+				break;
500
+
501
+			case elgg_echo('missions:security_clearance'):
502
+				$name_option = 'security';
503
+				break;
504
+
505
+			// In the language case, the value needs to have the format {language}{LWC}{LWE}{LOP}
506
+			case elgg_echo('missions:language'):
507
+				switch ($array['backup_' . $place]) {
508
+					case (strpos($array['backup_' . $place], 'english') !== false):
509
+						$name_option = 'english';
510
+						break;
511
+					case (strpos($array['backup_' . $place], 'french') !== false):
512
+						$name_option = 'french';
513
+						break;
514
+					default:
515
+						return array();
516
+				}
517
+				$operand_option = '=';
518
+				break;
519
+
520
+			// In the time case, the value needs to have the format {day}_{start/end}{hour}:{min}
521
+			case elgg_echo('missions:duration'):
522
+			case elgg_echo('missions:start_time'):
523
+				switch ($array['backup_' . $place]) {
524
+					case (strpos($array['backup_' . $place], 'mon_start') !== false):
525
+						$name_option = 'mon_start';
526
+						break;
527
+					case (strpos($array['backup_' . $place], 'mon_duration') !== false):
528
+						$name_option = 'mon_duration';
529
+						break;
530
+					case (strpos($array['backup_' . $place], 'tue_start') !== false):
531
+						$name_option = 'tue_start';
532
+						break;
533
+					case (strpos($array['backup_' . $place], 'tue_duration') !== false):
534
+						$name_option = 'tue_duration';
535
+						break;
536
+					case (strpos($array['backup_' . $place], 'wed_start') !== false):
537
+						$name_option = 'wed_start';
538
+						break;
539
+					case (strpos($array['backup_' . $place], 'wed_duration') !== false):
540
+						$name_option = 'wed_duration';
541
+						break;
542
+					case (strpos($array['backup_' . $place], 'thu_start') !== false):
543
+						$name_option = 'thu_start';
544
+						break;
545
+					case (strpos($array['backup_' . $place], 'thu_duration') !== false):
546
+						$name_option = 'thu_duration';
547
+						break;
548
+					case (strpos($array['backup_' . $place], 'fri_start') !== false):
549
+						$name_option = 'fri_start';
550
+						break;
551
+					case (strpos($array['backup_' . $place], 'fri_duration') !== false):
552
+						$name_option = 'fri_duration';
553
+						break;
554
+					case (strpos($array['backup_' . $place], 'sat_start') !== false):
555
+						$name_option = 'sat_start';
556
+						break;
557
+					case (strpos($array['backup_' . $place], 'sat_duration') !== false):
558
+						$name_option = 'sat_duration';
559
+						break;
560
+					case (strpos($array['backup_' . $place], 'sun_start') !== false):
561
+						$name_option = 'sun_start';
562
+						break;
563
+					case (strpos($array['backup_' . $place], 'sun_duration') !== false):
564
+						$name_option = 'sun_duration';
565
+						break;
566
+					default:
567
+						return array();
568
+				}
569
+				$operand_option = '=';
570
+				break;
571
+
572
+			case elgg_echo('missions:skill'):
573
+				$name_option = 'title';
574
+				$operand_option = 'LIKE';
575
+				$value_option = '%' . $array['selection_' . $place . '_element'] . '%';
576
+				$extra_option = 'MySkill';
577
+				break;
578
+
579
+			case elgg_echo('missions:experience'):
580
+				$name_option = 'title';
581
+				$operand_option = 'LIKE';
582
+				$value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
583
+				$extra_option = 'experience';
584
+				break;
585
+
586
+			case elgg_echo('missions:education'):
587
+				$name_option = 'title';
588
+				$operand_option = 'LIKE';
589
+				$value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
590
+				$extra_option = 'education';
591
+				break;
592
+
593
+			case elgg_echo('missions:portfolio'):
594
+				$name_option = 'title';
595
+				$operand_option = 'LIKE';
596
+				$value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
597
+				$extra_option = 'portfolio';
598
+				break;
599
+
600
+			case elgg_echo('missions:work_remotely'):
601
+				$name_option = 'remotely';
602
+				break;
603
+
604
+			case elgg_echo('missions:program_area'):
605
+				$name_option = 'program_area';
606
+				break;
607
+		}
608
+		$returner['name'] = $name_option;
609
+		$returner['operand'] = $operand_option;
610
+		$returner['value'] = $value_option;
611
+		$returner['extra_option'] = $extra_option;
612
+	}
613
+
614
+	return $returner;
615 615
 }
616 616
 
617 617
 /*
@@ -621,95 +621,95 @@  discard block
 block discarded – undo
621 621
 function mm_simple_search_database_for_candidates($query_array, $limit, $offset=0)
622 622
 {
623 623
 
624
-    $filtered_array = array_filter($query_array);
625
-    if (empty($filtered_array)) {
626
-        register_error(elgg_echo('missions:error:no_search_values'));
627
-        return false;
628
-    }
629
-
630
-    if (function_exists('\NRC\EUS\get') && \NRC\EUS\ready()) {
631
-      $MemberSearch = \NRC\EUS\get();
632
-      $term = '';
633
-      foreach ($query_array as $t) {
634
-        $term .= "{$t}* ";
635
-      }
636
-      $term = trim($term);
637
-      $results = $MemberSearch->search($term, $limit, $offset);
638
-
639
-      $candidate_count = $results['total'];
640
-
641
-
642
-      $search_feedback = array();
643
-      $pairs = array();
644
-      foreach ($results['users'] as $user) {
645
-
646
-        $pairs[] = array(
647
-            'name' => 'guid',
648
-            'value' => $user['user_guid'],
649
-            'operand' => '='
650
-        );
651
-
652
-        if (!isset($search_feedback[$user['user_guid']])) {
653
-            $search_feedback[$user['user_guid']] = '';
654
-        }
655
-        if ($user['matched_using']['education'] == 1) {
656
-          $search_feedback[$user['user_guid']] .= elgg_echo('missions:school_name') . ': ' . $user['education'] . ',';
657
-        }
658
-        if ($user['matched_using']['experience'] == 1) {
659
-            $search_feedback[$user['user_guid']] .= elgg_echo('missions:job_title') . ': ' . $user['experience'] . ',';
660
-        }
661
-        if ($user['matched_using']['gc_skills'] == 1) {
662
-            $search_feedback[$user['user_guid']] .= elgg_echo('missions:skill') . ': ' . $user['gc_skills'] . ',';
663
-        }
664
-        if ($user['matched_using']['portfolio'] == 1) {
665
-            $search_feedback[$user['user_guid']] .= elgg_echo('missions:portfolio') . ': ' . $user['portfolio'] . ',';
666
-        }
667
-        if ($user['matched_using']['name'] == 1) {
668
-            $search_feedback[$user['user_guid']] .= elgg_echo('missions:name') . ': ' . $user['name'] . ',';
669
-        }
670
-        if ($user['matched_using']['contactemail'] == 1) {
671
-            $search_feedback[$user['user_guid']] .= elgg_echo('missions:email') . ': ' . $user['contactemail'] . ',';
672
-        }
673
-      }
674
-
675
-      if ($candidate_count > 0) {
676
-        $unique_owners_entity = elgg_get_entities_from_attributes(array(
677
-            'type' => 'user', 'limit' => 0,
678
-            'attribute_name_value_pairs' => $pairs,
679
-            'attribute_name_value_pairs_operator' => 'OR'
680
-        ));
681
-
682
-        // SORT ORDER LOST, resort results based on initial query.
683
-        $sorted = array();
684
-        foreach ($unique_owners_entity as $owner) {
685
-            $sorted[] = array_search($owner->guid, array_keys($search_feedback));
686
-        }
687
-
688
-        array_multisort($sorted, $unique_owners_entity);
689
-      }
690
-    } else {
691
-
692
-      $dbprefix = elgg_get_config("dbprefix");
693
-      $only_opt_in = false; // Only include members who have opted-in to the platform
694
-      $opt_in_sql = '';
695
-
696
-      // TODO: Later versions of ELGG support parameterized queries... DO THAT.
697
-      $ms_search = array(); $s_search = array(); $u_search = array();
698
-      foreach ($query_array as $term) {
699
-          $t = mysql_escape_string(trim($term)) . '*';
700
-          $ms_search[] = "(MATCH(a.string) AGAINST(\"$t\" IN BOOLEAN MODE))";
701
-          $s_search[] = "(MATCH(eoe.title) AGAINST(\"$t\" IN BOOLEAN MODE))";
702
-          $u_search[] = "(MATCH(a.name) AGAINST(\"$t\" IN BOOLEAN MODE))";
703
-      }
704
-
705
-      $metadata_search = implode(' AND ', $ms_search);
706
-      $metadata_relevance = implode(' + ', $ms_search) . ' + 0';
707
-      $skill_search = implode(' AND ', $s_search);
708
-      $skill_relevance = implode(' + ', $s_search) . ' + 0';
709
-      $user_search = implode(' AND ', $u_search);
710
-      $user_relevance = implode(' + ', $u_search) . ' + 0';
711
-
712
-      $search_query_metadata = "
624
+	$filtered_array = array_filter($query_array);
625
+	if (empty($filtered_array)) {
626
+		register_error(elgg_echo('missions:error:no_search_values'));
627
+		return false;
628
+	}
629
+
630
+	if (function_exists('\NRC\EUS\get') && \NRC\EUS\ready()) {
631
+	  $MemberSearch = \NRC\EUS\get();
632
+	  $term = '';
633
+	  foreach ($query_array as $t) {
634
+		$term .= "{$t}* ";
635
+	  }
636
+	  $term = trim($term);
637
+	  $results = $MemberSearch->search($term, $limit, $offset);
638
+
639
+	  $candidate_count = $results['total'];
640
+
641
+
642
+	  $search_feedback = array();
643
+	  $pairs = array();
644
+	  foreach ($results['users'] as $user) {
645
+
646
+		$pairs[] = array(
647
+			'name' => 'guid',
648
+			'value' => $user['user_guid'],
649
+			'operand' => '='
650
+		);
651
+
652
+		if (!isset($search_feedback[$user['user_guid']])) {
653
+			$search_feedback[$user['user_guid']] = '';
654
+		}
655
+		if ($user['matched_using']['education'] == 1) {
656
+		  $search_feedback[$user['user_guid']] .= elgg_echo('missions:school_name') . ': ' . $user['education'] . ',';
657
+		}
658
+		if ($user['matched_using']['experience'] == 1) {
659
+			$search_feedback[$user['user_guid']] .= elgg_echo('missions:job_title') . ': ' . $user['experience'] . ',';
660
+		}
661
+		if ($user['matched_using']['gc_skills'] == 1) {
662
+			$search_feedback[$user['user_guid']] .= elgg_echo('missions:skill') . ': ' . $user['gc_skills'] . ',';
663
+		}
664
+		if ($user['matched_using']['portfolio'] == 1) {
665
+			$search_feedback[$user['user_guid']] .= elgg_echo('missions:portfolio') . ': ' . $user['portfolio'] . ',';
666
+		}
667
+		if ($user['matched_using']['name'] == 1) {
668
+			$search_feedback[$user['user_guid']] .= elgg_echo('missions:name') . ': ' . $user['name'] . ',';
669
+		}
670
+		if ($user['matched_using']['contactemail'] == 1) {
671
+			$search_feedback[$user['user_guid']] .= elgg_echo('missions:email') . ': ' . $user['contactemail'] . ',';
672
+		}
673
+	  }
674
+
675
+	  if ($candidate_count > 0) {
676
+		$unique_owners_entity = elgg_get_entities_from_attributes(array(
677
+			'type' => 'user', 'limit' => 0,
678
+			'attribute_name_value_pairs' => $pairs,
679
+			'attribute_name_value_pairs_operator' => 'OR'
680
+		));
681
+
682
+		// SORT ORDER LOST, resort results based on initial query.
683
+		$sorted = array();
684
+		foreach ($unique_owners_entity as $owner) {
685
+			$sorted[] = array_search($owner->guid, array_keys($search_feedback));
686
+		}
687
+
688
+		array_multisort($sorted, $unique_owners_entity);
689
+	  }
690
+	} else {
691
+
692
+	  $dbprefix = elgg_get_config("dbprefix");
693
+	  $only_opt_in = false; // Only include members who have opted-in to the platform
694
+	  $opt_in_sql = '';
695
+
696
+	  // TODO: Later versions of ELGG support parameterized queries... DO THAT.
697
+	  $ms_search = array(); $s_search = array(); $u_search = array();
698
+	  foreach ($query_array as $term) {
699
+		  $t = mysql_escape_string(trim($term)) . '*';
700
+		  $ms_search[] = "(MATCH(a.string) AGAINST(\"$t\" IN BOOLEAN MODE))";
701
+		  $s_search[] = "(MATCH(eoe.title) AGAINST(\"$t\" IN BOOLEAN MODE))";
702
+		  $u_search[] = "(MATCH(a.name) AGAINST(\"$t\" IN BOOLEAN MODE))";
703
+	  }
704
+
705
+	  $metadata_search = implode(' AND ', $ms_search);
706
+	  $metadata_relevance = implode(' + ', $ms_search) . ' + 0';
707
+	  $skill_search = implode(' AND ', $s_search);
708
+	  $skill_relevance = implode(' + ', $s_search) . ' + 0';
709
+	  $user_search = implode(' AND ', $u_search);
710
+	  $user_relevance = implode(' + ', $u_search) . ' + 0';
711
+
712
+	  $search_query_metadata = "
713 713
           SELECT
714 714
               c.guid AS user_guid,
715 715
               CONCAT(d.string, ':::::', a.string) AS field,
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
               AND d.string IN ('contactemail')
725 725
               AND ($metadata_search)
726 726
       ";
727
-      $search_user_name = "
727
+	  $search_user_name = "
728 728
           SELECT
729 729
               a.guid as user_guid,
730 730
               CONCAT('name:::::', a.name) as field,
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
           WHERE
735 735
               ($user_search)
736 736
       ";
737
-      $search_query_subtypes = "
737
+	  $search_query_subtypes = "
738 738
           SELECT
739 739
               eue.guid as user_guid,
740 740
               CONCAT(es.subtype, ':::::', eoe.title) as field,
@@ -753,18 +753,18 @@  discard block
 block discarded – undo
753 753
               AND ($skill_search)
754 754
       ";
755 755
 
756
-      $search_wrapper = "
756
+	  $search_wrapper = "
757 757
       SELECT SQL_CALC_FOUND_ROWS
758 758
           user_guid,
759 759
           GROUP_CONCAT(DISTINCT field SEPARATOR '!!!!!') as reason,
760 760
           SUM(relevance) as relevance
761 761
       FROM (";
762
-      $search_wrapper .= $search_user_name;
763
-      $search_wrapper .= "\nUNION\n" . $search_query_metadata;
764
-      $search_wrapper .= "\nUNION\n" . $search_query_subtypes;
765
-      $search_wrapper .= "\n) matches\n";
766
-      if ($only_opt_in) {
767
-          $search_wrapper .= "
762
+	  $search_wrapper .= $search_user_name;
763
+	  $search_wrapper .= "\nUNION\n" . $search_query_metadata;
764
+	  $search_wrapper .= "\nUNION\n" . $search_query_subtypes;
765
+	  $search_wrapper .= "\n) matches\n";
766
+	  if ($only_opt_in) {
767
+		  $search_wrapper .= "
768 768
               LEFT JOIN {$dbprefix}metadata b ON b.owner_guid = user_guid
769 769
               LEFT JOIN {$dbprefix}metastrings a ON a.id = b.name_id
770 770
               LEFT JOIN {$dbprefix}metastrings c ON c.id = b.value_id
@@ -772,84 +772,84 @@  discard block
 block discarded – undo
772 772
               match(a.string) against ('opt_in_*' IN BOOLEAN MODE)
773 773
               AND c.string = 'gcconnex_profile:opt:yes'
774 774
           ";
775
-      }
776
-      $search_wrapper .= "GROUP BY user_guid ORDER BY relevance DESC, reason LIMIT $offset, $limit;";
777
-      $results = get_data($search_wrapper);
778
-      $total_users = get_data('SELECT FOUND_ROWS() as total_users;')[0]->total_users;
779
-
780
-      $candidate_count = min(elgg_get_plugin_setting('search_limit', 'missions'), $total_users);
781
-
782
-      if (count($results) > 0) {
783
-          $search_feedback = array();
784
-          foreach($results as $result) {
785
-              $reasons = array();
786
-              $reason_values = array();
787
-              $reasons_tmp = explode('!!!!!', $result->reason);
788
-              foreach ($reasons_tmp as $rt) {
789
-                  $sp = explode(':::::', $rt);
790
-                  $reasons[] = $sp[0];
791
-                  $reason_values[$sp[0]] = $sp[1];
792
-              }
793
-              if (!isset($search_feedback[$result->user_guid])) {
794
-                  $search_feedback[$result->user_guid] = '';
795
-              }
796
-              if (in_array('education', $reasons)) {
797
-                  $search_feedback[$result->user_guid] .= elgg_echo('missions:school_name') . ': ' . $reason_values['education'] . ',';
798
-              }
799
-              if (in_array('experience', $reasons)) {
800
-                  $search_feedback[$result->user_guid] .= elgg_echo('missions:job_title') . ': ' . $reason_values['experience'] . ',';
801
-              }
802
-              if (in_array('MySkill', $reasons)) {
803
-                  $search_feedback[$result->user_guid] .= elgg_echo('missions:skill') . ': ' . $reason_values['MySkill'] . ',';
804
-              }
805
-              if (in_array('portfolio', $reasons)) {
806
-                  $search_feedback[$result->user_guid] .= elgg_echo('missions:portfolio') . ': ' . $reason_values['portfolio'] . ',';
807
-              }
808
-              if (in_array('name', $reasons)) {
809
-                  $search_feedback[$result->user_guid] .= elgg_echo('missions:name') . ': ' . $reason_values['name'] . ',';
810
-              }
811
-              if (in_array('contactemail', $reasons)) {
812
-                  $search_feedback[$result->user_guid] .= elgg_echo('missions:email') . ': ' . $reason_values['contactemail'] . ',';
813
-              }
814
-          }
815
-
816
-          $pairs = array();
817
-          foreach(array_keys($search_feedback) as $guid) {
818
-              $pairs[] = array(
819
-                  'name' => 'guid',
820
-                  'value' => $guid,
821
-                  'operand' => '='
822
-              );
823
-          }
824
-          $unique_owners_entity = elgg_get_entities_from_attributes(array(
825
-              'type' => 'user', 'limit' => 0,
826
-              'attribute_name_value_pairs' => $pairs,
827
-              'attribute_name_value_pairs_operator' => 'OR'
828
-          ));
829
-
830
-          // SORT ORDER LOST, resort results based on initial query.
831
-          $sorted = array();
832
-          foreach ($unique_owners_entity as $owner) {
833
-              $sorted[] = array_search($owner->guid, array_keys($search_feedback));
834
-          }
835
-
836
-          array_multisort($sorted, $unique_owners_entity);
837
-      }
838
-    }
839
-
840
-    if ($candidate_count == 0) {
841
-        register_error(elgg_echo('missions:error:candidate_does_not_exist'));
842
-        return false;
843
-    } else {
844
-        $_SESSION['candidate_count'] = $candidate_count;
845
-        $_SESSION['candidate_search_set'] = $unique_owners_entity;
846
-        $_SESSION['candidate_search_set_timestamp'] = time();
847
-        $_SESSION['candidate_search_feedback'] = $search_feedback;
848
-        $_SESSION['candidate_search_feedback_timestamp'] = time();
849
-        $_SESSION['candidate_search_query_array'] = $query_array;
850
-
851
-        return true;
852
-    }
775
+	  }
776
+	  $search_wrapper .= "GROUP BY user_guid ORDER BY relevance DESC, reason LIMIT $offset, $limit;";
777
+	  $results = get_data($search_wrapper);
778
+	  $total_users = get_data('SELECT FOUND_ROWS() as total_users;')[0]->total_users;
779
+
780
+	  $candidate_count = min(elgg_get_plugin_setting('search_limit', 'missions'), $total_users);
781
+
782
+	  if (count($results) > 0) {
783
+		  $search_feedback = array();
784
+		  foreach($results as $result) {
785
+			  $reasons = array();
786
+			  $reason_values = array();
787
+			  $reasons_tmp = explode('!!!!!', $result->reason);
788
+			  foreach ($reasons_tmp as $rt) {
789
+				  $sp = explode(':::::', $rt);
790
+				  $reasons[] = $sp[0];
791
+				  $reason_values[$sp[0]] = $sp[1];
792
+			  }
793
+			  if (!isset($search_feedback[$result->user_guid])) {
794
+				  $search_feedback[$result->user_guid] = '';
795
+			  }
796
+			  if (in_array('education', $reasons)) {
797
+				  $search_feedback[$result->user_guid] .= elgg_echo('missions:school_name') . ': ' . $reason_values['education'] . ',';
798
+			  }
799
+			  if (in_array('experience', $reasons)) {
800
+				  $search_feedback[$result->user_guid] .= elgg_echo('missions:job_title') . ': ' . $reason_values['experience'] . ',';
801
+			  }
802
+			  if (in_array('MySkill', $reasons)) {
803
+				  $search_feedback[$result->user_guid] .= elgg_echo('missions:skill') . ': ' . $reason_values['MySkill'] . ',';
804
+			  }
805
+			  if (in_array('portfolio', $reasons)) {
806
+				  $search_feedback[$result->user_guid] .= elgg_echo('missions:portfolio') . ': ' . $reason_values['portfolio'] . ',';
807
+			  }
808
+			  if (in_array('name', $reasons)) {
809
+				  $search_feedback[$result->user_guid] .= elgg_echo('missions:name') . ': ' . $reason_values['name'] . ',';
810
+			  }
811
+			  if (in_array('contactemail', $reasons)) {
812
+				  $search_feedback[$result->user_guid] .= elgg_echo('missions:email') . ': ' . $reason_values['contactemail'] . ',';
813
+			  }
814
+		  }
815
+
816
+		  $pairs = array();
817
+		  foreach(array_keys($search_feedback) as $guid) {
818
+			  $pairs[] = array(
819
+				  'name' => 'guid',
820
+				  'value' => $guid,
821
+				  'operand' => '='
822
+			  );
823
+		  }
824
+		  $unique_owners_entity = elgg_get_entities_from_attributes(array(
825
+			  'type' => 'user', 'limit' => 0,
826
+			  'attribute_name_value_pairs' => $pairs,
827
+			  'attribute_name_value_pairs_operator' => 'OR'
828
+		  ));
829
+
830
+		  // SORT ORDER LOST, resort results based on initial query.
831
+		  $sorted = array();
832
+		  foreach ($unique_owners_entity as $owner) {
833
+			  $sorted[] = array_search($owner->guid, array_keys($search_feedback));
834
+		  }
835
+
836
+		  array_multisort($sorted, $unique_owners_entity);
837
+	  }
838
+	}
839
+
840
+	if ($candidate_count == 0) {
841
+		register_error(elgg_echo('missions:error:candidate_does_not_exist'));
842
+		return false;
843
+	} else {
844
+		$_SESSION['candidate_count'] = $candidate_count;
845
+		$_SESSION['candidate_search_set'] = $unique_owners_entity;
846
+		$_SESSION['candidate_search_set_timestamp'] = time();
847
+		$_SESSION['candidate_search_feedback'] = $search_feedback;
848
+		$_SESSION['candidate_search_feedback_timestamp'] = time();
849
+		$_SESSION['candidate_search_query_array'] = $query_array;
850
+
851
+		return true;
852
+	}
853 853
 }
854 854
 
855 855
 /*
@@ -857,149 +857,149 @@  discard block
 block discarded – undo
857 857
  * Checks education, experience and skill attributes and metadata from user profiles.
858 858
  */
859 859
 function mm_advanced_search_database_for_candidates($query_array, $query_operand, $limit) {
860
-    $users_returned_by_attribute = array();
861
-    $users_returned_by_metadata = array();
862
-    $is_attribute_searched = false;
863
-    $is_metadata_searched = false;
864
-    $candidates = array();
865
-
866
-    $filtered_array = array_filter($query_array);
867
-    if (empty($filtered_array)) {
868
-        register_error(elgg_echo('missions:error:no_search_values'));
869
-        return false;
870
-    }
871
-
872
-    // Handles each query individually.
873
-    foreach($filtered_array as $array) {
874
-        // Sets up an education and experience array search for title (not metadata).
875
-        if($array['name'] == 'title') {
876
-            $options_attribute['type'] = 'object';
877
-            $options_attribute['subtypes'] = $array['extra_option'];
878
-            $options_attribute['joins'] = array('INNER JOIN ' . elgg_get_config('dbprefix') . 'objects_entity g ON (g.guid = e.guid)');
879
-            $options_attribute['wheres'] = array("g." . $array['name'] . " " . $array['operand'] . " '" . $array['value'] . "'");
880
-            $options_attribute['limit'] = $limit;
881
-            $entities = elgg_get_entities($options_attribute);
882
-
883
-            $entity_owners = array();
884
-            $count = 0;
885
-            foreach($entities as $entity) {
886
-                $entity_owners[$count] = $entity->owner_guid;
887
-                $count++;
888
-            }
889
-
890
-            // Adds the results of the query to a pool of results.
891
-            if(empty($users_returned_by_attribute)) {
892
-                $users_returned_by_attribute = array_unique($entity_owners);
893
-            }
894
-            else {
895
-                $users_returned_by_attribute = array_unique(array_intersect($users_returned_by_attribute, $entity_owners));
896
-            }
897
-            // Notes that attributes have been searched during this function call.
898
-            $is_attribute_searched = true;
899
-        }
900
-
901
-        else if(strpos($array['name'], 'opt_in') !== false || strpos($array['name'], 'department') !== false) {
902
-            $options_attribute['type'] = 'user';
903
-            $options_metadata['metadata_name_value_pairs'] = array(array('name' => $array['name'], 'operand' => $array['operand'], 'value' => $array['value']));
904
-            $options_metadata['limit'] = $limit;
905
-            $options_metadata['metadata_case_sensitive'] = false;
906
-            $entities = elgg_get_entities_from_metadata($options_metadata);
907
-
908
-            $entity_owners = array();
909
-            $count = 0;
910
-            foreach($entities as $entity) {
911
-                $entity_owners[$count] = $entity->guid;
912
-                $count++;
913
-            }
914
-
915
-            // Adds the results of the query to a pool of results.
916
-            if(empty($users_returned_by_metadata)) {
917
-                $users_returned_by_metadata = array_unique($entity_owners);
918
-            }
919
-            else {
920
-                $users_returned_by_metadata = array_unique(array_intersect($users_returned_by_metadata, $entity_owners));
921
-            }
922
-            // Notes that metadata have been searched during this function call.
923
-            $is_metadata_searched = true;
924
-        }
925
-
926
-        // Sets up metadata serach.
927
-        else {
928
-            $operand_temp = htmlspecialchars_decode($array['operand']);
929
-
930
-            $options_metadata['type'] = 'object';
931
-            $options_metadata['subtypes'] = $array['extra_option'];
932
-            $options_metadata['metadata_name_value_pairs'] = array(array('name' => $array['name'], 'operand' => $operand_temp, 'value' => $array['value']));
933
-            $options_metadata['limit'] = $limit;
934
-            $options_metadata['metadata_case_sensitive'] = false;
935
-            $entities = elgg_get_entities_from_metadata($options_metadata);
936
-
937
-            $entity_owners = array();
938
-            $count = 0;
939
-            foreach($entities as $entity) {
940
-                $entity_owners[$count] = $entity->owner_guid;
941
-                $count++;
942
-            }
943
-
944
-            // Adds the results of the query to a pool of results.
945
-            if(empty($users_returned_by_metadata)) {
946
-                $users_returned_by_metadata = array_unique($entity_owners);
947
-            }
948
-            else {
949
-                $users_returned_by_metadata = array_unique(array_intersect($users_returned_by_metadata, $entity_owners));
950
-            }
951
-            // Notes that metadata have been searched during this function call.
952
-            $is_metadata_searched = true;
953
-        }
954
-    }
955
-
956
-    // Intersects the results into a single pool.
957
-    if($is_attribute_searched && $is_metadata_searched) {
958
-        $candidates = array_intersect($users_returned_by_attribute, $users_returned_by_metadata);
959
-    }
960
-    // If only metadata or only attributes have been searched then intersection is unecessary.
961
-    if($is_attribute_searched && !$is_metadata_searched) {
962
-        $candidates = $users_returned_by_attribute;
963
-    }
964
-    if(!$is_attribute_searched && $is_metadata_searched) {
965
-        $candidates = $users_returned_by_metadata;
966
-    }
967
-
968
-    $final_users = mm_guids_to_entities_with_opt(array_slice($candidates, 0, $limit));
969
-    $final_count = count($final_users);
970
-
971
-    if ($final_count == 0) {
972
-        register_error(elgg_echo('missions:error:candidate_does_not_exist'));
973
-        return false;
974
-    } else {
975
-        $_SESSION['candidate_count'] = $final_count;
976
-        $_SESSION['candidate_search_set'] = $final_users;
977
-        $_SESSION['candidate_search_set_timestamp'] = time();
978
-        unset($_SESSION['candidate_search_feedback']);
979
-
980
-        return true;
981
-    }
860
+	$users_returned_by_attribute = array();
861
+	$users_returned_by_metadata = array();
862
+	$is_attribute_searched = false;
863
+	$is_metadata_searched = false;
864
+	$candidates = array();
865
+
866
+	$filtered_array = array_filter($query_array);
867
+	if (empty($filtered_array)) {
868
+		register_error(elgg_echo('missions:error:no_search_values'));
869
+		return false;
870
+	}
871
+
872
+	// Handles each query individually.
873
+	foreach($filtered_array as $array) {
874
+		// Sets up an education and experience array search for title (not metadata).
875
+		if($array['name'] == 'title') {
876
+			$options_attribute['type'] = 'object';
877
+			$options_attribute['subtypes'] = $array['extra_option'];
878
+			$options_attribute['joins'] = array('INNER JOIN ' . elgg_get_config('dbprefix') . 'objects_entity g ON (g.guid = e.guid)');
879
+			$options_attribute['wheres'] = array("g." . $array['name'] . " " . $array['operand'] . " '" . $array['value'] . "'");
880
+			$options_attribute['limit'] = $limit;
881
+			$entities = elgg_get_entities($options_attribute);
882
+
883
+			$entity_owners = array();
884
+			$count = 0;
885
+			foreach($entities as $entity) {
886
+				$entity_owners[$count] = $entity->owner_guid;
887
+				$count++;
888
+			}
889
+
890
+			// Adds the results of the query to a pool of results.
891
+			if(empty($users_returned_by_attribute)) {
892
+				$users_returned_by_attribute = array_unique($entity_owners);
893
+			}
894
+			else {
895
+				$users_returned_by_attribute = array_unique(array_intersect($users_returned_by_attribute, $entity_owners));
896
+			}
897
+			// Notes that attributes have been searched during this function call.
898
+			$is_attribute_searched = true;
899
+		}
900
+
901
+		else if(strpos($array['name'], 'opt_in') !== false || strpos($array['name'], 'department') !== false) {
902
+			$options_attribute['type'] = 'user';
903
+			$options_metadata['metadata_name_value_pairs'] = array(array('name' => $array['name'], 'operand' => $array['operand'], 'value' => $array['value']));
904
+			$options_metadata['limit'] = $limit;
905
+			$options_metadata['metadata_case_sensitive'] = false;
906
+			$entities = elgg_get_entities_from_metadata($options_metadata);
907
+
908
+			$entity_owners = array();
909
+			$count = 0;
910
+			foreach($entities as $entity) {
911
+				$entity_owners[$count] = $entity->guid;
912
+				$count++;
913
+			}
914
+
915
+			// Adds the results of the query to a pool of results.
916
+			if(empty($users_returned_by_metadata)) {
917
+				$users_returned_by_metadata = array_unique($entity_owners);
918
+			}
919
+			else {
920
+				$users_returned_by_metadata = array_unique(array_intersect($users_returned_by_metadata, $entity_owners));
921
+			}
922
+			// Notes that metadata have been searched during this function call.
923
+			$is_metadata_searched = true;
924
+		}
925
+
926
+		// Sets up metadata serach.
927
+		else {
928
+			$operand_temp = htmlspecialchars_decode($array['operand']);
929
+
930
+			$options_metadata['type'] = 'object';
931
+			$options_metadata['subtypes'] = $array['extra_option'];
932
+			$options_metadata['metadata_name_value_pairs'] = array(array('name' => $array['name'], 'operand' => $operand_temp, 'value' => $array['value']));
933
+			$options_metadata['limit'] = $limit;
934
+			$options_metadata['metadata_case_sensitive'] = false;
935
+			$entities = elgg_get_entities_from_metadata($options_metadata);
936
+
937
+			$entity_owners = array();
938
+			$count = 0;
939
+			foreach($entities as $entity) {
940
+				$entity_owners[$count] = $entity->owner_guid;
941
+				$count++;
942
+			}
943
+
944
+			// Adds the results of the query to a pool of results.
945
+			if(empty($users_returned_by_metadata)) {
946
+				$users_returned_by_metadata = array_unique($entity_owners);
947
+			}
948
+			else {
949
+				$users_returned_by_metadata = array_unique(array_intersect($users_returned_by_metadata, $entity_owners));
950
+			}
951
+			// Notes that metadata have been searched during this function call.
952
+			$is_metadata_searched = true;
953
+		}
954
+	}
955
+
956
+	// Intersects the results into a single pool.
957
+	if($is_attribute_searched && $is_metadata_searched) {
958
+		$candidates = array_intersect($users_returned_by_attribute, $users_returned_by_metadata);
959
+	}
960
+	// If only metadata or only attributes have been searched then intersection is unecessary.
961
+	if($is_attribute_searched && !$is_metadata_searched) {
962
+		$candidates = $users_returned_by_attribute;
963
+	}
964
+	if(!$is_attribute_searched && $is_metadata_searched) {
965
+		$candidates = $users_returned_by_metadata;
966
+	}
967
+
968
+	$final_users = mm_guids_to_entities_with_opt(array_slice($candidates, 0, $limit));
969
+	$final_count = count($final_users);
970
+
971
+	if ($final_count == 0) {
972
+		register_error(elgg_echo('missions:error:candidate_does_not_exist'));
973
+		return false;
974
+	} else {
975
+		$_SESSION['candidate_count'] = $final_count;
976
+		$_SESSION['candidate_search_set'] = $final_users;
977
+		$_SESSION['candidate_search_set_timestamp'] = time();
978
+		unset($_SESSION['candidate_search_feedback']);
979
+
980
+		return true;
981
+	}
982 982
 }
983 983
 
984 984
 /*
985 985
  * Turns an array of guids into an array of entities.
986 986
  */
987 987
 function mm_guids_to_entities_with_opt($candidates) {
988
-    $count_c = 0;
989
-    $count_p = 0;
990
-    $candidates_users = array();
991
-    $potentials_users = array();
992
-    foreach($candidates as $candidate) {
993
-        $user_temp = get_user($candidate);
994
-        if(check_if_opted_in($user_temp)) {
995
-            $candidates_users[$count_c] = $user_temp;
996
-            $count_c++;
997
-        }
998
-        else {
999
-            $potentials_users[$count_p] = $user_temp;
1000
-            $count_p++;
1001
-        }
1002
-    }
1003
-
1004
-    return array_merge($candidates_users, $potentials_users);
988
+	$count_c = 0;
989
+	$count_p = 0;
990
+	$candidates_users = array();
991
+	$potentials_users = array();
992
+	foreach($candidates as $candidate) {
993
+		$user_temp = get_user($candidate);
994
+		if(check_if_opted_in($user_temp)) {
995
+			$candidates_users[$count_c] = $user_temp;
996
+			$count_c++;
997
+		}
998
+		else {
999
+			$potentials_users[$count_p] = $user_temp;
1000
+			$count_p++;
1001
+		}
1002
+	}
1003
+
1004
+	return array_merge($candidates_users, $potentials_users);
1005 1005
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
     $missions = '';
20 20
 
21 21
     $filtered_array = array_filter($query_array);
22
-    if(empty($filtered_array)) {
22
+    if (empty($filtered_array)) {
23 23
         register_error(elgg_echo('missions:error:no_search_values'));
24 24
         return false;
25 25
     }
26 26
 
27
-    foreach($filtered_array as $key => $array) {
27
+    foreach ($filtered_array as $key => $array) {
28 28
         $filtered_array[$key]['operand'] = htmlspecialchars_decode($array['operand']);
29 29
     }
30 30
 
31
-    if ( strcasecmp( $query_operand, 'OR' ) === 0 ){
31
+    if (strcasecmp($query_operand, 'OR') === 0) {
32 32
         $options['type'] = 'object';
33 33
         $options['subtype'] = 'mission';
34 34
         $options['metadata_name_value_pairs_operator'] = $query_operand;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         foreach ($filtered_array as $array) {
41 41
             $options['metadata_name_value_pairs'] = array($array);
42 42
             $some_missions = elgg_get_entities_from_metadata($options);
43
-            $all_missions = array_merge( $all_missions, $some_missions );
43
+            $all_missions = array_merge($all_missions, $some_missions);
44 44
         }
45 45
 
46 46
         $missions = array();
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         }
50 50
         // Filter opportunities based on their state.  Inclusive.
51 51
         // WHY: We may only want to search for archived or open opportunities which have different states.
52
-        foreach($missions as $key => $mission) {
52
+        foreach ($missions as $key => $mission) {
53 53
             $include_opportunity = false;
54 54
             foreach ($mission_state_include_array as $include_state) {
55 55
                 if ($mission->state == $include_state) {
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
         $missions = elgg_get_entities_from_metadata($options);
74 74
 
75 75
 
76
-        foreach($missions as $key => $mission) {
77
-            if($mission->state != 'posted') {
76
+        foreach ($missions as $key => $mission) {
77
+            if ($mission->state != 'posted') {
78 78
                 unset($missions[$key]);
79 79
             }
80 80
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     if ($a->guid > $b->guid) {
105 105
         return 1;
106 106
     }
107
-    return - 1;
107
+    return -1;
108 108
 }
109 109
 
110 110
 /*
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 {
116 116
     $returner = array();
117 117
 
118
-    switch(trim($array['selection_' . $place])) {
118
+    switch (trim($array['selection_' . $place])) {
119 119
         // Returns an empty array if
120 120
         case '':
121 121
             break;
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
             break;
130 130
 
131 131
         case elgg_echo('missions:opt_in'):
132
-            if(trim($array['selection_' . $place . '_element']) != '') {
132
+            if (trim($array['selection_' . $place . '_element']) != '') {
133 133
                 $name_option = '';
134
-                switch($array['selection_' . $place . '_element']) {
134
+                switch ($array['selection_' . $place . '_element']) {
135 135
                     case elgg_echo('gcconnex_profile:opt:micro_missionseek'):
136 136
                         $name_option = 'opt_in_missions';
137 137
                         break;
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
             break;
195 195
 
196 196
         case elgg_echo('missions:portfolio'):
197
-            if(trim($array['selection_' . $place . '_element_value']) != '') {
197
+            if (trim($array['selection_' . $place . '_element_value']) != '') {
198 198
                 $name_option = '';
199 199
                 $operand_option = 'LIKE';
200 200
                 $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
201
-                switch($array['selection_' . $place . '_element']) {
201
+                switch ($array['selection_' . $place . '_element']) {
202 202
                     case elgg_echo('missions:title'):
203 203
                         $name_option = 'title';
204 204
                         break;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             break;
217 217
 
218 218
         case elgg_echo('missions:skill'):
219
-            if(trim($array['selection_' . $place . '_element']) != '') {
219
+            if (trim($array['selection_' . $place . '_element']) != '') {
220 220
                 $returner['name'] = 'title';
221 221
                 $returner['operand'] = 'LIKE';
222 222
                 $returner['value'] = '%' . $array['selection_' . $place . '_element'] . '%';
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
             break;
226 226
 
227 227
         case elgg_echo('missions:experience'):
228
-            if(trim($array['selection_' . $place . '_element_value']) != '') {
228
+            if (trim($array['selection_' . $place . '_element_value']) != '') {
229 229
                 $name_option = '';
230 230
                 $operand_option = 'LIKE';
231 231
                 $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
232
-                switch($array['selection_' . $place . '_element']) {
232
+                switch ($array['selection_' . $place . '_element']) {
233 233
                     case elgg_echo('missions:title'):
234 234
                         $name_option = 'title';
235 235
                         break;
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
             break;
251 251
 
252 252
         case elgg_echo('missions:education'):
253
-            if(trim($array['selection_' . $place . '_element_value']) != '') {
253
+            if (trim($array['selection_' . $place . '_element_value']) != '') {
254 254
                 $name_option = '';
255 255
                 $operand_option = 'LIKE';
256 256
                 $value_option = '%' . $array['selection_' . $place . '_element_value'] . '%';
257
-                switch($array['selection_' . $place . '_element']) {
257
+                switch ($array['selection_' . $place . '_element']) {
258 258
                     case elgg_echo('missions:title'):
259 259
                         $name_option = 'title';
260 260
                         break;
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
                         break;
308 308
                 }
309 309
 
310
-                if($array['selection_' . $place] == elgg_echo('missions:start_time')) {
310
+                if ($array['selection_' . $place] == elgg_echo('missions:start_time')) {
311 311
                     $name_option .= '_start';
312 312
                 }
313
-                if($array['selection_' . $place] == elgg_echo('missions:duration')) {
313
+                if ($array['selection_' . $place] == elgg_echo('missions:duration')) {
314 314
                      $name_option .= '_duration';
315 315
                 }
316 316
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
             break;
324 324
 
325 325
         case elgg_echo('missions:period'):
326
-            if(trim($array['selection_' . $place . '_element']) != '') {
326
+            if (trim($array['selection_' . $place . '_element']) != '') {
327 327
                 $returner['name'] = 'time_interval';
328 328
                 $returner['operand'] = '=';
329 329
                 $returner['value'] = $array['selection_' . $place . '_element'];
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 
355 355
                 $option_value = $name_option;
356 356
                 $language_requirement_array = array($array['selection_' . $place . '_element_lwc'], $array['selection_' . $place . '_element_lwe'], $array['selection_' . $place . '_element_lop']);
357
-                foreach($language_requirement_array as $value) {
358
-                    switch($value) {
357
+                foreach ($language_requirement_array as $value) {
358
+                    switch ($value) {
359 359
                         case 'A':
360 360
                             $option_value .= '[Aa-]';
361 361
                             break;
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 
423 423
         case elgg_echo('missions:department'):
424 424
             if (trim($array['selection_' . $place . '_element']) != '') {
425
-                if(get_current_language() == 'fr') {
425
+                if (get_current_language() == 'fr') {
426 426
                     $returner['name'] = 'department_path_french';
427 427
                 }
428 428
                 else {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
         case elgg_echo('missions:work_remotely'):
437 437
             $returner['name'] = 'remotely';
438 438
             $returner['operand'] = '=';
439
-            if($array['selection_' . $place . '_element']) {
439
+            if ($array['selection_' . $place . '_element']) {
440 440
                 $returner['value'] = 'on';
441 441
             }
442 442
             else {
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
  * Basic search functionality for candidate searching.
619 619
  * Checks education, experience and skill attributes from user profiles.
620 620
  */
621
-function mm_simple_search_database_for_candidates($query_array, $limit, $offset=0)
621
+function mm_simple_search_database_for_candidates($query_array, $limit, $offset = 0)
622 622
 {
623 623
 
624 624
     $filtered_array = array_filter($query_array);
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 
782 782
       if (count($results) > 0) {
783 783
           $search_feedback = array();
784
-          foreach($results as $result) {
784
+          foreach ($results as $result) {
785 785
               $reasons = array();
786 786
               $reason_values = array();
787 787
               $reasons_tmp = explode('!!!!!', $result->reason);
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
           }
815 815
 
816 816
           $pairs = array();
817
-          foreach(array_keys($search_feedback) as $guid) {
817
+          foreach (array_keys($search_feedback) as $guid) {
818 818
               $pairs[] = array(
819 819
                   'name' => 'guid',
820 820
                   'value' => $guid,
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
     }
871 871
 
872 872
     // Handles each query individually.
873
-    foreach($filtered_array as $array) {
873
+    foreach ($filtered_array as $array) {
874 874
         // Sets up an education and experience array search for title (not metadata).
875
-        if($array['name'] == 'title') {
875
+        if ($array['name'] == 'title') {
876 876
             $options_attribute['type'] = 'object';
877 877
             $options_attribute['subtypes'] = $array['extra_option'];
878 878
             $options_attribute['joins'] = array('INNER JOIN ' . elgg_get_config('dbprefix') . 'objects_entity g ON (g.guid = e.guid)');
@@ -882,13 +882,13 @@  discard block
 block discarded – undo
882 882
 
883 883
             $entity_owners = array();
884 884
             $count = 0;
885
-            foreach($entities as $entity) {
885
+            foreach ($entities as $entity) {
886 886
                 $entity_owners[$count] = $entity->owner_guid;
887 887
                 $count++;
888 888
             }
889 889
 
890 890
             // Adds the results of the query to a pool of results.
891
-            if(empty($users_returned_by_attribute)) {
891
+            if (empty($users_returned_by_attribute)) {
892 892
                 $users_returned_by_attribute = array_unique($entity_owners);
893 893
             }
894 894
             else {
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
             $is_attribute_searched = true;
899 899
         }
900 900
 
901
-        else if(strpos($array['name'], 'opt_in') !== false || strpos($array['name'], 'department') !== false) {
901
+        else if (strpos($array['name'], 'opt_in') !== false || strpos($array['name'], 'department') !== false) {
902 902
             $options_attribute['type'] = 'user';
903 903
             $options_metadata['metadata_name_value_pairs'] = array(array('name' => $array['name'], 'operand' => $array['operand'], 'value' => $array['value']));
904 904
             $options_metadata['limit'] = $limit;
@@ -907,13 +907,13 @@  discard block
 block discarded – undo
907 907
 
908 908
             $entity_owners = array();
909 909
             $count = 0;
910
-            foreach($entities as $entity) {
910
+            foreach ($entities as $entity) {
911 911
                 $entity_owners[$count] = $entity->guid;
912 912
                 $count++;
913 913
             }
914 914
 
915 915
             // Adds the results of the query to a pool of results.
916
-            if(empty($users_returned_by_metadata)) {
916
+            if (empty($users_returned_by_metadata)) {
917 917
                 $users_returned_by_metadata = array_unique($entity_owners);
918 918
             }
919 919
             else {
@@ -936,13 +936,13 @@  discard block
 block discarded – undo
936 936
 
937 937
             $entity_owners = array();
938 938
             $count = 0;
939
-            foreach($entities as $entity) {
939
+            foreach ($entities as $entity) {
940 940
                 $entity_owners[$count] = $entity->owner_guid;
941 941
                 $count++;
942 942
             }
943 943
 
944 944
             // Adds the results of the query to a pool of results.
945
-            if(empty($users_returned_by_metadata)) {
945
+            if (empty($users_returned_by_metadata)) {
946 946
                 $users_returned_by_metadata = array_unique($entity_owners);
947 947
             }
948 948
             else {
@@ -954,14 +954,14 @@  discard block
 block discarded – undo
954 954
     }
955 955
 
956 956
     // Intersects the results into a single pool.
957
-    if($is_attribute_searched && $is_metadata_searched) {
957
+    if ($is_attribute_searched && $is_metadata_searched) {
958 958
         $candidates = array_intersect($users_returned_by_attribute, $users_returned_by_metadata);
959 959
     }
960 960
     // If only metadata or only attributes have been searched then intersection is unecessary.
961
-    if($is_attribute_searched && !$is_metadata_searched) {
961
+    if ($is_attribute_searched && !$is_metadata_searched) {
962 962
         $candidates = $users_returned_by_attribute;
963 963
     }
964
-    if(!$is_attribute_searched && $is_metadata_searched) {
964
+    if (!$is_attribute_searched && $is_metadata_searched) {
965 965
         $candidates = $users_returned_by_metadata;
966 966
     }
967 967
 
@@ -989,9 +989,9 @@  discard block
 block discarded – undo
989 989
     $count_p = 0;
990 990
     $candidates_users = array();
991 991
     $potentials_users = array();
992
-    foreach($candidates as $candidate) {
992
+    foreach ($candidates as $candidate) {
993 993
         $user_temp = get_user($candidate);
994
-        if(check_if_opted_in($user_temp)) {
994
+        if (check_if_opted_in($user_temp)) {
995 995
             $candidates_users[$count_c] = $user_temp;
996 996
             $count_c++;
997 997
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -17 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@  discard block
 block discarded – undo
61 61
                 unset($missions[$key]);
62 62
             }
63 63
         }
64
-    }
65
-    else {
64
+    } else {
66 65
         // Setting options with which the query will be built.
67 66
         $options['type'] = 'object';
68 67
         $options['subtype'] = 'mission';
@@ -424,8 +423,7 @@  discard block
 block discarded – undo
424 423
             if (trim($array['selection_' . $place . '_element']) != '') {
425 424
                 if(get_current_language() == 'fr') {
426 425
                     $returner['name'] = 'department_path_french';
427
-                }
428
-                else {
426
+                } else {
429 427
                     $returner['name'] = 'department_path_english';
430 428
                 }
431 429
                 $returner['operand'] = 'LIKE';
@@ -438,8 +436,7 @@  discard block
 block discarded – undo
438 436
             $returner['operand'] = '=';
439 437
             if($array['selection_' . $place . '_element']) {
440 438
                 $returner['value'] = 'on';
441
-            }
442
-            else {
439
+            } else {
443 440
                 $returner['value'] = 0;
444 441
             }
445 442
             break;
@@ -890,15 +887,12 @@  discard block
 block discarded – undo
890 887
             // Adds the results of the query to a pool of results.
891 888
             if(empty($users_returned_by_attribute)) {
892 889
                 $users_returned_by_attribute = array_unique($entity_owners);
893
-            }
894
-            else {
890
+            } else {
895 891
                 $users_returned_by_attribute = array_unique(array_intersect($users_returned_by_attribute, $entity_owners));
896 892
             }
897 893
             // Notes that attributes have been searched during this function call.
898 894
             $is_attribute_searched = true;
899
-        }
900
-
901
-        else if(strpos($array['name'], 'opt_in') !== false || strpos($array['name'], 'department') !== false) {
895
+        } else if(strpos($array['name'], 'opt_in') !== false || strpos($array['name'], 'department') !== false) {
902 896
             $options_attribute['type'] = 'user';
903 897
             $options_metadata['metadata_name_value_pairs'] = array(array('name' => $array['name'], 'operand' => $array['operand'], 'value' => $array['value']));
904 898
             $options_metadata['limit'] = $limit;
@@ -915,8 +909,7 @@  discard block
 block discarded – undo
915 909
             // Adds the results of the query to a pool of results.
916 910
             if(empty($users_returned_by_metadata)) {
917 911
                 $users_returned_by_metadata = array_unique($entity_owners);
918
-            }
919
-            else {
912
+            } else {
920 913
                 $users_returned_by_metadata = array_unique(array_intersect($users_returned_by_metadata, $entity_owners));
921 914
             }
922 915
             // Notes that metadata have been searched during this function call.
@@ -944,8 +937,7 @@  discard block
 block discarded – undo
944 937
             // Adds the results of the query to a pool of results.
945 938
             if(empty($users_returned_by_metadata)) {
946 939
                 $users_returned_by_metadata = array_unique($entity_owners);
947
-            }
948
-            else {
940
+            } else {
949 941
                 $users_returned_by_metadata = array_unique(array_intersect($users_returned_by_metadata, $entity_owners));
950 942
             }
951 943
             // Notes that metadata have been searched during this function call.
@@ -994,8 +986,7 @@  discard block
 block discarded – undo
994 986
         if(check_if_opted_in($user_temp)) {
995 987
             $candidates_users[$count_c] = $user_temp;
996 988
             $count_c++;
997
-        }
998
-        else {
989
+        } else {
999 990
             $potentials_users[$count_p] = $user_temp;
1000 991
             $count_p++;
1001 992
         }
Please login to merge, or discard this patch.
mod/questions/lib/hooks.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -493,7 +493,7 @@
 block discarded – undo
493 493
 		unset($question_options['order_by_metadata']);
494 494
 		$question_options['wheres'] = [
495 495
 			$container_where,
496
-			'(e.time_created > ' . ($time - (24 * 60 *60)) . ')'
496
+			'(e.time_created > ' . ($time - (24 * 60 * 60)) . ')'
497 497
 		];
498 498
 		$questions = elgg_get_entities_from_metadata($question_options);
499 499
 		if (!empty($questions)) {
Please login to merge, or discard this patch.
mod/mentions/start.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 					$link = $object->getURL();
173 173
 					$type_key = "mentions:notification_types:$type:$subtype";
174 174
 
175
-                    $type_str = array();
175
+					$type_str = array();
176 176
 
177 177
 					$type_str[0] = elgg_echo($type_key, array(), 'en');
178
-                    $type_str[1] = elgg_echo($type_key, array(), 'fr');
178
+					$type_str[1] = elgg_echo($type_key, array(), 'fr');
179 179
 					if ($type_str == $type_key) {
180 180
 						// plugins can add to the list of mention objects by defining
181 181
 						// the language string 'mentions:notification_types:<type>:<subtype>'
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 					}
184 184
 					$subject = elgg_echo('mentions:notification:subject', array($owner->name, $type_str[0]), 'en');
185 185
 
186
-                    $subject .= ' / ' . elgg_echo('mentions:notification:subject', array($owner->name, $type_str[1]), 'fr');
186
+					$subject .= ' / ' . elgg_echo('mentions:notification:subject', array($owner->name, $type_str[1]), 'fr');
187 187
 
188 188
 					$body = elgg_echo('mentions:notification:body', array(
189 189
 						$owner->name,
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 						$link,
192 192
 					), 'en');
193 193
 
194
-                    $body .= elgg_echo('mentions:notification:body', array(
194
+					$body .= elgg_echo('mentions:notification:body', array(
195 195
 						$owner->name,
196 196
 						$type_str[1],
197 197
 						$link,
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 function mentions_rewrite($hook, $entity_type, $returnvalue, $params) {
59 59
 
60 60
 	$regexp = mentions_get_regex();
61
-	$returnvalue =  preg_replace_callback($regexp, 'mentions_preg_callback', $returnvalue);
61
+	$returnvalue = preg_replace_callback($regexp, 'mentions_preg_callback', $returnvalue);
62 62
 
63 63
 	return $returnvalue;
64 64
 }
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 
205 205
 					// cyu - trigger the hook (we are re-routing the mentions to cp_notifications if it is activated)
206 206
 					// please don't trigger if subtype is thewire
207
-					if (elgg_is_active_plugin('cp_notifications') && strcmp($object->getSubtype(),'thewire') != 0) {
207
+					if (elgg_is_active_plugin('cp_notifications') && strcmp($object->getSubtype(), 'thewire') != 0) {
208 208
 
209
-						if (strcmp($object->getSubtype(),'comment') == 0 || strcmp($object->getSubtype(),'thewire') == 0 || strcmp($object->getSubtype(),'discussion_reply') == 0)
209
+						if (strcmp($object->getSubtype(), 'comment') == 0 || strcmp($object->getSubtype(), 'thewire') == 0 || strcmp($object->getSubtype(), 'discussion_reply') == 0)
210 210
 							$container = $object->getContainerEntity();
211 211
 						else
212 212
 							$container = $object;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 							'cp_to_user' => $user,
220 220
 							'cp_content_desc' => $object->description,
221 221
 						);
222
-						elgg_trigger_plugin_hook('cp_overwrite_notification','all',$message);
222
+						elgg_trigger_plugin_hook('cp_overwrite_notification', 'all', $message);
223 223
 					} else {
224 224
 
225 225
 						notify_user($user->getGUID(), $owner->getGUID(), utf8_encode($subject), utf8_encode($body), $params);
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -206,10 +206,11 @@
 block discarded – undo
206 206
 					// please don't trigger if subtype is thewire
207 207
 					if (elgg_is_active_plugin('cp_notifications') && strcmp($object->getSubtype(),'thewire') != 0) {
208 208
 
209
-						if (strcmp($object->getSubtype(),'comment') == 0 || strcmp($object->getSubtype(),'thewire') == 0 || strcmp($object->getSubtype(),'discussion_reply') == 0)
210
-							$container = $object->getContainerEntity();
211
-						else
212
-							$container = $object;
209
+						if (strcmp($object->getSubtype(),'comment') == 0 || strcmp($object->getSubtype(),'thewire') == 0 || strcmp($object->getSubtype(),'discussion_reply') == 0) {
210
+													$container = $object->getContainerEntity();
211
+						} else {
212
+													$container = $object;
213
+						}
213 214
 
214 215
 						$message = array(
215 216
 							'cp_author' => $owner->name,
Please login to merge, or discard this patch.
mod/pages/languages/fr.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@
 block discarded – undo
35 35
 	'pages:none' => 'Aucune page créée pour le moment',
36 36
 
37 37
 	/**
38
-	* River
39
-	**/	
38
+	 * River
39
+	 **/	
40 40
 
41 41
 	'river:create:object:page' => '%s a créé une page %s',
42 42
 	'river:create:object:page_top' => '%s a créé une page %s',
Please login to merge, or discard this patch.
mod/pages/actions/pages/edit.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
 	}
19 19
 }
20 20
 
21
-$input['title'] = gc_implode_translation($input['title'],$input['title2']);
22
-$input['description'] = gc_implode_translation($input['description'],$input['description2']);
21
+$input['title'] = gc_implode_translation($input['title'], $input['title2']);
22
+$input['description'] = gc_implode_translation($input['description'], $input['description2']);
23 23
 
24 24
 
25 25
 // Get guids
26
-$page_guid = (int)get_input('page_guid');
27
-$container_guid = (int)get_input('container_guid');
28
-$parent_guid = (int)get_input('parent_guid');
26
+$page_guid = (int) get_input('page_guid');
27
+$container_guid = (int) get_input('container_guid');
28
+$parent_guid = (int) get_input('parent_guid');
29 29
 
30 30
 elgg_make_sticky_form('page');
31 31
 
Please login to merge, or discard this patch.
mod/pages/actions/pages/delete.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 ]);
31 31
 
32 32
 $db_prefix = elgg_get_config('dbprefix');
33
-$subtype_id = (int)get_subtype_id('object', 'page_top');
33
+$subtype_id = (int) get_subtype_id('object', 'page_top');
34 34
 $newentity_cache = is_memcache_available() ? new ElggMemcache('new_entity_cache') : null;
35 35
 
36 36
 foreach ($children as $child) {
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	}
41 41
 
42 42
 	// If no parent, we need to transform $child to a page_top
43
-	$child_guid = (int)$child->guid;
43
+	$child_guid = (int) $child->guid;
44 44
 
45 45
 	update_data("
46 46
 		UPDATE {$db_prefix}entities
Please login to merge, or discard this patch.
mod/pages/pages/pages/view.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
 
26 26
 	$title = gc_explode_translation($page->title, $lang);
27 27
 
28
-if(!$container->title){
28
+if (!$container->title) {
29 29
 	$group_title = gc_explode_translation($container->name, $lang);
30 30
 
31
-}else{
31
+} else {
32 32
 	$group_title = gc_explode_translation($container->title, $lang);
33 33
 
34 34
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 if(!$container->title){
29 29
 	$group_title = gc_explode_translation($container->name, $lang);
30 30
 
31
-}else{
31
+} else{
32 32
 	$group_title = gc_explode_translation($container->title, $lang);
33 33
 
34 34
 }
Please login to merge, or discard this patch.
mod/pages/pages/pages/edit.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 elgg_gatekeeper();
9 9
 
10 10
 $lang = get_current_language();
11
-$page_guid = (int)get_input('guid');
12
-$revision = (int)get_input('annotation_id');
11
+$page_guid = (int) get_input('guid');
12
+$revision = (int) get_input('annotation_id');
13 13
 $page = get_entity($page_guid);
14 14
 if (!pages_is_page($page)) {
15 15
 	register_error(elgg_echo('noaccess'));
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 elgg_set_page_owner_guid($container->getGUID());
26 26
 
27
-	elgg_push_breadcrumb(gc_explode_translation($page->title,$lang), $page->getURL());
27
+	elgg_push_breadcrumb(gc_explode_translation($page->title, $lang), $page->getURL());
28 28
 
29 29
 
30 30
 elgg_push_breadcrumb(elgg_echo('edit'));
Please login to merge, or discard this patch.
mod/pages/views/default/river/object/page/create.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 
10 10
 $object = $item->getObjectEntity();
11 11
 
12
-	$description = gc_explode_translation($object->description,$lang);
12
+	$description = gc_explode_translation($object->description, $lang);
13 13
 
14 14
 $excerpt = strip_tags($description);
15 15
 $excerpt = elgg_get_excerpt($excerpt);
Please login to merge, or discard this patch.