Completed
Push — 1.11.x ( 4463da...cd5efc )
by José
55:32 queued 28:22
created
main/document/create_document.php 1 patch
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 $is_certificate_mode = false;
62 62
 
63 63
 if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') {
64
-	$is_certificate_mode = true;
64
+    $is_certificate_mode = true;
65 65
 }
66 66
 
67 67
 if ($is_certificate_mode) {
68
-	$nameTools = get_lang('CreateCertificate');
68
+    $nameTools = get_lang('CreateCertificate');
69 69
 } else {
70
-	$nameTools = get_lang('CreateDocument');
70
+    $nameTools = get_lang('CreateDocument');
71 71
 }
72 72
 
73 73
 /*	Constants and variables */
@@ -124,26 +124,26 @@  discard block
 block discarded – undo
124 124
 
125 125
 // Please, do not modify this dirname formatting
126 126
 if (strstr($dir, '..')) {
127
-	$dir = '/';
127
+    $dir = '/';
128 128
 }
129 129
 
130 130
 if ($dir[0] == '.') {
131
-	$dir = substr($dir, 1);
131
+    $dir = substr($dir, 1);
132 132
 }
133 133
 
134 134
 if ($dir[0] != '/') {
135
-	$dir = '/'.$dir;
135
+    $dir = '/'.$dir;
136 136
 }
137 137
 
138 138
 if ($dir[strlen($dir) - 1] != '/') {
139
-	$dir .= '/';
139
+    $dir .= '/';
140 140
 }
141 141
 
142 142
 if ($is_certificate_mode) {
143
-	$document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates');
144
-	$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
145
-	$folder_id = $document_data['id'];
146
-	$dir = '/certificates/';
143
+    $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates');
144
+    $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
145
+    $folder_id = $document_data['id'];
146
+    $dir = '/certificates/';
147 147
 }
148 148
 
149 149
 $doc_tree  = explode('/', $dir);
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
 
155 155
     // Level correction for group documents.
156 156
     if (!empty($group_properties['directory'])) {
157
-    	$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
157
+        $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
158 158
     }
159 159
 }
160 160
 $relative_url = '';
161 161
 for ($i = 0; $i < ($count_dir); $i++) {
162
-	$relative_url .= '../';
162
+    $relative_url .= '../';
163 163
 }
164 164
 
165 165
 if ($relative_url== '') {
166
-	$relative_url = '/';
166
+    $relative_url = '/';
167 167
 }
168 168
 
169 169
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
     'cols-size' => [2, 10, 0],
176 176
     'FullPage' => true,
177 177
     'InDocument' => true,
178
-	'CreateDocumentDir' => $relative_url,
179
-	'CreateDocumentWebDir' => (empty($group_properties['directory']))
180
-                        		? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
181
-                        		: api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
182
-	'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
178
+    'CreateDocumentDir' => $relative_url,
179
+    'CreateDocumentWebDir' => (empty($group_properties['directory']))
180
+                                ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
181
+                                : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
182
+    'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
183 183
 );
184 184
 
185 185
 if ($is_certificate_mode) {
@@ -191,41 +191,41 @@  discard block
 block discarded – undo
191 191
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
192 192
 
193 193
 if (!is_dir($filepath)) {
194
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
195
-	$dir = '/';
194
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
195
+    $dir = '/';
196 196
 }
197 197
 
198 198
 $to_group_id = 0;
199 199
 if (!$is_certificate_mode) {
200
-	if (api_is_in_group()) {
200
+    if (api_is_in_group()) {
201 201
         $interbreadcrumb[] = array(
202 202
             "url" => "../group/group_space.php?".api_get_cidreq(),
203 203
             "name" => get_lang('GroupSpace'),
204 204
         );
205
-		$noPHP_SELF = true;
206
-		$to_group_id = $group_properties['iid'];
207
-		$path = explode('/', $dir);
208
-		if ('/'.$path[1] != $group_properties['directory']) {
209
-			api_not_allowed(true);
210
-		}
211
-	}
205
+        $noPHP_SELF = true;
206
+        $to_group_id = $group_properties['iid'];
207
+        $path = explode('/', $dir);
208
+        if ('/'.$path[1] != $group_properties['directory']) {
209
+            api_not_allowed(true);
210
+        }
211
+    }
212 212
     $interbreadcrumb[] = array(
213 213
         "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
214 214
         "name" => get_lang('Documents'),
215 215
     );
216 216
 } else {
217
-	$interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
217
+    $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
218 218
 }
219 219
 
220 220
 if (!api_is_allowed_in_course()) {
221
-	api_not_allowed(true);
221
+    api_not_allowed(true);
222 222
 }
223 223
 
224 224
 if (!($is_allowed_to_edit ||
225 225
     $groupRights ||
226 226
     DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id()))
227 227
 ) {
228
-	api_not_allowed(true);
228
+    api_not_allowed(true);
229 229
 }
230 230
 
231 231
 /*	Header */
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 
234 234
 $display_dir = $dir;
235 235
 if (isset($group_properties)) {
236
-	$display_dir = explode('/', $dir);
237
-	unset($display_dir[0]);
238
-	unset($display_dir[1]);
239
-	$display_dir = implode('/', $display_dir);
236
+    $display_dir = explode('/', $dir);
237
+    unset($display_dir[0]);
238
+    unset($display_dir[1]);
239
+    $display_dir = implode('/', $display_dir);
240 240
 }
241 241
 
242 242
 $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null;
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 $form->addElement('header', $nameTools);
254 254
 
255 255
 if ($is_certificate_mode) {//added condition for certicate in gradebook
256
-	$form->addElement('hidden','certificate','true',array('id'=>'certificate'));
257
-	if (isset($_GET['selectcat'])) {
258
-		$form->addElement('hidden','selectcat', $select_cat);
256
+    $form->addElement('hidden','certificate','true',array('id'=>'certificate'));
257
+    if (isset($_GET['selectcat'])) {
258
+        $form->addElement('hidden','selectcat', $select_cat);
259 259
     }
260 260
 }
261 261
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 // new document created
315 315
 
316 316
 if (!$is_certificate_mode &&
317
-	!DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
317
+    !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
318 318
 ) {
319 319
     $folders = DocumentManager::get_all_document_folders(
320 320
         $_course,
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         array('cols-size' => [2, 10, 0])
330 330
     );
331 331
 
332
-	$folder_titles = array();
332
+    $folder_titles = array();
333 333
     if (is_array($folders)) {
334 334
         $escaped_folders = array();
335 335
         foreach ($folders as $key => & $val) {
@@ -366,22 +366,22 @@  discard block
 block discarded – undo
366 366
         }
367 367
     }
368 368
 
369
-	if (empty($group_dir)) {
370
-		$parent_select -> addOption(get_lang('HomeDirectory'), '/');
371
-		if (is_array($folders)) {
372
-			foreach ($folders as & $folder) {
373
-				//Hide some folders
374
-				if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') {
369
+    if (empty($group_dir)) {
370
+        $parent_select -> addOption(get_lang('HomeDirectory'), '/');
371
+        if (is_array($folders)) {
372
+            foreach ($folders as & $folder) {
373
+                //Hide some folders
374
+                if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') {
375 375
                     continue;
376
-				}
377
-				//Admin setting for Hide/Show the folders of all users
378
-				if (api_get_setting('show_users_folders') == 'false' &&
376
+                }
377
+                //Admin setting for Hide/Show the folders of all users
378
+                if (api_get_setting('show_users_folders') == 'false' &&
379 379
                     (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_'))
380 380
                 ){
381
-					continue;
382
-				}
383
-				//Admin setting for Hide/Show Default folders to all users
384
-				if (api_get_setting('show_default_folders') == 'false' &&
381
+                    continue;
382
+                }
383
+                //Admin setting for Hide/Show Default folders to all users
384
+                if (api_get_setting('show_default_folders') == 'false' &&
385 385
                     (
386 386
                         $folder == '/images' ||
387 387
                         $folder == '/flash' ||
@@ -391,82 +391,82 @@  discard block
 block discarded – undo
391 391
                         $folder == '/video/flv'
392 392
                     )
393 393
                 ){
394
-					continue;
395
-				}
396
-				//Admin setting for Hide/Show chat history folder
397
-				if (api_get_setting('show_chat_folder') == 'false' &&
394
+                    continue;
395
+                }
396
+                //Admin setting for Hide/Show chat history folder
397
+                if (api_get_setting('show_chat_folder') == 'false' &&
398 398
                     $folder=='/chat_files'
399 399
                 ){
400
-					continue;
401
-				}
400
+                    continue;
401
+                }
402 402
 
403
-				$selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : '';
404
-				$path_parts = explode('/', $folder);
405
-				$folder_titles[$folder] = cut($folder_titles[$folder], 80);
403
+                $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : '';
404
+                $path_parts = explode('/', $folder);
405
+                $folder_titles[$folder] = cut($folder_titles[$folder], 80);
406 406
                 $space_counter =count($path_parts) - 2;
407 407
                 if ($space_counter > 0) {
408 408
                     $label = str_repeat('&nbsp;&nbsp;&nbsp;', $space_counter).' &mdash; '.$folder_titles[$folder];
409 409
                 } else {
410 410
                     $label = ' &mdash; '.$folder_titles[$folder];
411 411
                 }
412
-				$parent_select -> addOption($label, $folder);
413
-				if ($selected != '') {
414
-					$parent_select->setSelected($folder);
415
-				}
416
-			}
417
-		}
418
-	} else {
419
-		if (is_array($folders) && !empty($folders)) {
420
-			foreach ($folders as & $folder) {
421
-				$selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
422
-				$label = $folder_titles[$folder];
423
-				if ($folder == $group_dir) {
424
-					$label = '/ (' . get_lang('HomeDirectory') . ')';
425
-				} else {
426
-					$path_parts = explode('/', str_replace($group_dir, '', $folder));
427
-					$label = cut($label, 80);
428
-					$label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2) . ' &mdash; ' . $label;
429
-				}
430
-				$parent_select->addOption($label, $folder);
431
-				if ($selected != '') {
432
-					$parent_select->setSelected($folder);
433
-				}
434
-			}
435
-		}
436
-	}
412
+                $parent_select -> addOption($label, $folder);
413
+                if ($selected != '') {
414
+                    $parent_select->setSelected($folder);
415
+                }
416
+            }
417
+        }
418
+    } else {
419
+        if (is_array($folders) && !empty($folders)) {
420
+            foreach ($folders as & $folder) {
421
+                $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
422
+                $label = $folder_titles[$folder];
423
+                if ($folder == $group_dir) {
424
+                    $label = '/ (' . get_lang('HomeDirectory') . ')';
425
+                } else {
426
+                    $path_parts = explode('/', str_replace($group_dir, '', $folder));
427
+                    $label = cut($label, 80);
428
+                    $label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2) . ' &mdash; ' . $label;
429
+                }
430
+                $parent_select->addOption($label, $folder);
431
+                if ($selected != '') {
432
+                    $parent_select->setSelected($folder);
433
+                }
434
+            }
435
+        }
436
+    }
437 437
 }
438 438
 
439 439
 $form->addHidden('dirValue', '');
440 440
 
441 441
 if ($is_certificate_mode) {
442
-	$form->addButtonCreate(get_lang('CreateCertificate'));
442
+    $form->addButtonCreate(get_lang('CreateCertificate'));
443 443
 } else {
444
-	$form->addButtonCreate(get_lang('CreateDoc'));
444
+    $form->addButtonCreate(get_lang('CreateDoc'));
445 445
 }
446 446
 
447 447
 $form->setDefaults($defaults);
448 448
 
449 449
 // If form validates -> save the new document
450 450
 if ($form->validate()) {
451
-	$values = $form->exportValues();
452
-	$readonly = isset($values['readonly']) ? 1 : 0;
453
-	$values['title'] = trim($values['title']);
451
+    $values = $form->exportValues();
452
+    $readonly = isset($values['readonly']) ? 1 : 0;
453
+    $values['title'] = trim($values['title']);
454 454
 
455 455
     if (!empty($values['dirValue'])) {
456 456
         $dir = $values['dirValue'];
457 457
     }
458 458
 
459 459
     if ($dir[strlen($dir) - 1] != '/') {
460
-		$dir .= '/';
461
-	}
460
+        $dir .= '/';
461
+    }
462 462
     $filepath = $filepath.$dir;
463 463
 
464 464
     // Setting the filename
465
-	$filename = $values['title'];
466
-	$filename = addslashes(trim($filename));
467
-	$filename = Security::remove_XSS($filename);
468
-	$filename = api_replace_dangerous_char($filename);
469
-	$filename = disable_dangerous_file($filename);
465
+    $filename = $values['title'];
466
+    $filename = addslashes(trim($filename));
467
+    $filename = Security::remove_XSS($filename);
468
+    $filename = api_replace_dangerous_char($filename);
469
+    $filename = disable_dangerous_file($filename);
470 470
     $filename .= DocumentManager::getDocumentSuffix(
471 471
         $_course,
472 472
         api_get_session_id(),
@@ -474,14 +474,14 @@  discard block
 block discarded – undo
474 474
     );
475 475
 
476 476
     // Setting the title
477
-	$title = $values['title'];
477
+    $title = $values['title'];
478 478
 
479 479
     // Setting the extension
480
-	$extension = 'html';
480
+    $extension = 'html';
481 481
 
482
-	$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
482
+    $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
483 483
 
484
-	/*if (strpos($content, '/css/frames.css') == false) {
484
+    /*if (strpos($content, '/css/frames.css') == false) {
485 485
 		$content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content);
486 486
 	}*/
487 487
 
@@ -494,21 +494,21 @@  discard block
 block discarded – undo
494 494
         exit;
495 495
     }
496 496
 
497
-	if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
497
+    if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
498 498
 
499
-		$content = str_replace(
500
-		    api_get_path(WEB_COURSE_PATH),
499
+        $content = str_replace(
500
+            api_get_path(WEB_COURSE_PATH),
501 501
             api_get_configuration_value('url_append').api_get_path(REL_COURSE_PATH),
502 502
             $content
503 503
         );
504 504
 
505
-		fputs($fp, $content);
506
-		fclose($fp);
507
-		chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
505
+        fputs($fp, $content);
506
+        fclose($fp);
507
+        chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
508 508
 
509 509
 
510
-		$file_size = filesize($filepath.$filename.'.'.$extension);
511
-		$save_file_path = $dir.$filename.'.'.$extension;
510
+        $file_size = filesize($filepath.$filename.'.'.$extension);
511
+        $save_file_path = $dir.$filename.'.'.$extension;
512 512
 
513 513
         $document_id = add_document(
514 514
             $_course,
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
             $readonly
521 521
         );
522 522
 
523
-		if ($document_id) {
524
-			api_item_property_update(
523
+        if ($document_id) {
524
+            api_item_property_update(
525 525
                 $_course,
526 526
                 TOOL_DOCUMENT,
527 527
                 $document_id,
@@ -533,13 +533,13 @@  discard block
 block discarded – undo
533 533
                 null,
534 534
                 $current_session_id
535 535
             );
536
-			// Update parent folders
537
-			item_property_update_on_folder($_course, $dir, $userId);
538
-			$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
539
-			$new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
536
+            // Update parent folders
537
+            item_property_update_on_folder($_course, $dir, $userId);
538
+            $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
539
+            $new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
540 540
             $new_title = htmlspecialchars($new_title);
541
-			if ($new_comment || $new_title) {
542
-				$ct = '';
541
+            if ($new_comment || $new_title) {
542
+                $ct = '';
543 543
                 $params = [];
544 544
                 if ($new_comment) {
545 545
                     $params['comment'] = $new_comment;
@@ -554,39 +554,39 @@  discard block
 block discarded – undo
554 554
                         ['c_id = ? AND id = ?' => [$course_id, $document_id]]
555 555
                     );
556 556
                 }
557
-			}
558
-			$dir= substr($dir,0,-1);
559
-			$selectcat = '';
557
+            }
558
+            $dir= substr($dir,0,-1);
559
+            $selectcat = '';
560 560
             if (isset($_REQUEST['selectcat'])) {
561 561
                 $selectcat = "&selectcat=".intval($_REQUEST['selectcat']);
562 562
             }
563
-			$certificate_condition = '';
564
-			if ($is_certificate_mode) {
565
-				$df = DocumentManager::get_default_certificate_id($_course['code']);
563
+            $certificate_condition = '';
564
+            if ($is_certificate_mode) {
565
+                $df = DocumentManager::get_default_certificate_id($_course['code']);
566 566
                 if (!isset($df)) {
567 567
                     DocumentManager::attach_gradebook_certificate($_course['code'],$document_id);
568
-				}
569
-				$certificate_condition = '&certificate=true&curdirpath=/certificates';
570
-			}
568
+                }
569
+                $certificate_condition = '&certificate=true&curdirpath=/certificates';
570
+            }
571 571
             Display::addFlash(Display::return_message(get_lang('ItemAdded')));
572
-			header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
573
-			exit();
574
-		} else {
575
-			Display :: display_header($nameTools, 'Doc');
576
-			Display :: display_error_message(get_lang('Impossible'));
577
-			Display :: display_footer();
578
-		}
579
-	} else {
580
-		Display :: display_header($nameTools, 'Doc');
581
-		Display :: display_error_message(get_lang('Impossible'));
582
-		Display :: display_footer();
583
-	}
572
+            header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
573
+            exit();
574
+        } else {
575
+            Display :: display_header($nameTools, 'Doc');
576
+            Display :: display_error_message(get_lang('Impossible'));
577
+            Display :: display_footer();
578
+        }
579
+    } else {
580
+        Display :: display_header($nameTools, 'Doc');
581
+        Display :: display_error_message(get_lang('Impossible'));
582
+        Display :: display_footer();
583
+    }
584 584
 } else {
585
-	// Copied from document.php
586
-	$dir_array = explode('/', $dir);
587
-	$array_len = count($dir_array);
585
+    // Copied from document.php
586
+    $dir_array = explode('/', $dir);
587
+    $array_len = count($dir_array);
588 588
 
589
-	// Breadcrumb for the current directory root path
589
+    // Breadcrumb for the current directory root path
590 590
     if (!empty($document_data)) {
591 591
         if (empty($document_data['parents'])) {
592 592
             $interbreadcrumb[] = array(
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
         }
604 604
     }
605 605
 
606
-	Display :: display_header($nameTools, "Doc");
607
-	// actions
606
+    Display :: display_header($nameTools, "Doc");
607
+    // actions
608 608
 
609
-	// link back to the documents overview
610
-	if ($is_certificate_mode) {
609
+    // link back to the documents overview
610
+    if ($is_certificate_mode) {
611 611
             $actionsLeft =  '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.
612 612
                 Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>';
613 613
             $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.
@@ -622,19 +622,19 @@  discard block
 block discarded – undo
622 622
 
623 623
     echo $toolbar = Display::toolbarAction('actions-documents', array($actionsLeft));
624 624
 
625
-	if ($is_certificate_mode) {
625
+    if ($is_certificate_mode) {
626 626
         $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
627 627
             api_get_user_id(),
628 628
             api_get_course_id()
629 629
         );
630 630
 
631
-		$str_info = '';
632
-		foreach ($all_information_by_create_certificate[0] as $info_value) {
633
-			$str_info.=$info_value.'<br/>';
634
-		}
635
-		$create_certificate = get_lang('CreateCertificateWithTags');
636
-		Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
637
-	}
631
+        $str_info = '';
632
+        foreach ($all_information_by_create_certificate[0] as $info_value) {
633
+            $str_info.=$info_value.'<br/>';
634
+        }
635
+        $create_certificate = get_lang('CreateCertificateWithTags');
636
+        Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
637
+    }
638 638
 
639 639
     // HTML-editor
640 640
     echo '<div class="page-create">
@@ -650,5 +650,5 @@  discard block
 block discarded – undo
650 650
                 '.$form->returnForm().'
651 651
             </div>
652 652
           </div></div>';
653
-	Display :: display_footer();
653
+    Display :: display_footer();
654 654
 }
Please login to merge, or discard this patch.
main/user/subscribe_user.php 1 patch
Indentation   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 // Access restriction
29 29
 if (!api_is_allowed_to_edit()) {
30
-	 api_not_allowed(true);
30
+        api_not_allowed(true);
31 31
 }
32 32
 
33 33
 $tool_name = get_lang("SubscribeUserToCourse");
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 $courseInfo = api_get_course_info();
38 38
 
39 39
 if ($type == COURSEMANAGER) {
40
-	$tool_name = get_lang("SubscribeUserToCourseAsTeacher");
40
+    $tool_name = get_lang("SubscribeUserToCourseAsTeacher");
41 41
 }
42 42
 
43 43
 //extra entries in breadcrumb
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         "url" => "subscribe_user.php?type=".$type.'&'.api_get_cidreq(),
51 51
         "name" => $tool_name
52 52
     );
53
-	$tool_name = get_lang('SearchResults');
53
+    $tool_name = get_lang('SearchResults');
54 54
 }
55 55
 
56 56
 $sessionId = api_get_session_id();
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
 
131 131
 // Build table
132 132
 $table = new SortableTable(
133
-	'subscribe_users',
134
-	'get_number_of_users',
135
-	'get_user_data',
136
-	($is_western_name_order xor $sort_by_first_name) ? 3 : 2
133
+    'subscribe_users',
134
+    'get_number_of_users',
135
+    'get_user_data',
136
+    ($is_western_name_order xor $sort_by_first_name) ? 3 : 2
137 137
 );
138 138
 $parameters['keyword'] = $keyword;
139 139
 $parameters['type'] = $type;
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
  */
221 221
 function get_number_of_users()
222 222
 {
223
-	// Database table definition
224
-	$user_table = Database::get_main_table(TABLE_MAIN_USER);
225
-	$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
226
-	$tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
227
-	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
223
+    // Database table definition
224
+    $user_table = Database::get_main_table(TABLE_MAIN_USER);
225
+    $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
226
+    $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
227
+    $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
228 228
 
229 229
     $courseCode = api_get_course_id();
230 230
     $sessionId = api_get_session_id();
231 231
 
232
-	if (isset($_REQUEST['type']) && $_REQUEST['type'] === 'teacher') {
233
-		if (api_get_session_id() != 0) {
234
-			$sql = "SELECT COUNT(u.id)
232
+    if (isset($_REQUEST['type']) && $_REQUEST['type'] === 'teacher') {
233
+        if (api_get_session_id() != 0) {
234
+            $sql = "SELECT COUNT(u.id)
235 235
 					FROM $user_table u
236 236
 					LEFT JOIN $tbl_session_rel_course_user cu
237 237
 					ON
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
     $count_user = 0;
400 400
 
401 401
     if ($res) {
402
-       $row = Database::fetch_row($res);
403
-       $count_user = $row[0];
402
+        $row = Database::fetch_row($res);
403
+        $count_user = $row[0];
404 404
     }
405 405
 
406
-	return $count_user;
406
+    return $count_user;
407 407
 }
408 408
 /**
409 409
  * Get the users to display on the current page.
@@ -413,17 +413,17 @@  discard block
 block discarded – undo
413 413
     $url_access_id = api_get_current_access_url_id();
414 414
     $course_code = api_get_course_id();
415 415
     $sessionId = api_get_session_id();
416
-	$courseId = api_get_course_int_id();
416
+    $courseId = api_get_course_int_id();
417 417
 
418
-	// Database table definitions
419
-	$user_table = Database::get_main_table(TABLE_MAIN_USER);
420
-	$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
421
-	$tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
422
-	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
418
+    // Database table definitions
419
+    $user_table = Database::get_main_table(TABLE_MAIN_USER);
420
+    $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
421
+    $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
422
+    $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
423 423
     $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
424 424
 
425 425
     // adding teachers
426
-	$is_western_name_order = api_is_western_name_order();
426
+    $is_western_name_order = api_is_western_name_order();
427 427
 
428 428
     if (api_get_setting('show_email_addresses') === 'true') {
429 429
         $select_fields = "u.id              AS col0,
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
                 u.active               AS col4,
448 448
                 u.user_id              AS col5";
449 449
     }
450
-	if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) {
451
-		// adding a teacher through a session
452
-		if (!empty($sessionId)) {
453
-			$sql = "SELECT $select_fields
450
+    if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) {
451
+        // adding a teacher through a session
452
+        if (!empty($sessionId)) {
453
+            $sql = "SELECT $select_fields
454 454
 					FROM $user_table u
455 455
 					LEFT JOIN $tbl_session_rel_course_user cu
456 456
 					ON
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
                     INNER JOIN  $tbl_url_rel_user as url_rel_user
461 461
                     ON (url_rel_user.user_id = u.user_id) ";
462 462
 
463
-			// applying the filter of the additional user profile fields
464
-			if (isset($_GET['subscribe_user_filter_value']) &&
465
-				!empty($_GET['subscribe_user_filter_value']) &&
466
-				api_get_setting('ProfilingFilterAddingUsers') == 'true'
467
-			) {
468
-				$field_identification = explode('*',$_GET['subscribe_user_filter_value']);
469
-				$sql .=	"
463
+            // applying the filter of the additional user profile fields
464
+            if (isset($_GET['subscribe_user_filter_value']) &&
465
+                !empty($_GET['subscribe_user_filter_value']) &&
466
+                api_get_setting('ProfilingFilterAddingUsers') == 'true'
467
+            ) {
468
+                $field_identification = explode('*',$_GET['subscribe_user_filter_value']);
469
+                $sql .=	"
470 470
 					LEFT JOIN $table_user_field_values field_values
471 471
 						ON field_values.item_id = u.user_id
472 472
 					WHERE
@@ -480,47 +480,47 @@  discard block
 block discarded – undo
480 480
             }
481 481
 
482 482
             $sql .=	" AND access_url_id = $url_access_id";
483
-		} else {
484
-		     // adding a teacher NOT through a session
485
-			$sql = "SELECT $select_fields
483
+        } else {
484
+                // adding a teacher NOT through a session
485
+            $sql = "SELECT $select_fields
486 486
                     FROM $user_table u
487 487
                     LEFT JOIN $course_user_table cu
488 488
                     ON u.user_id = cu.user_id AND c_id = '".$courseId."'";
489 489
 
490
-				// applying the filter of the additional user profile fields
491
-				if (isset($_GET['subscribe_user_filter_value']) &&
492
-					!empty($_GET['subscribe_user_filter_value']) &&
493
-					api_get_setting('ProfilingFilterAddingUsers') == 'true'
494
-				) {
495
-					$field_identification = explode('*',$_GET['subscribe_user_filter_value']);
496
-					$sql .=	"
490
+                // applying the filter of the additional user profile fields
491
+                if (isset($_GET['subscribe_user_filter_value']) &&
492
+                    !empty($_GET['subscribe_user_filter_value']) &&
493
+                    api_get_setting('ProfilingFilterAddingUsers') == 'true'
494
+                ) {
495
+                    $field_identification = explode('*',$_GET['subscribe_user_filter_value']);
496
+                    $sql .=	"
497 497
 						LEFT JOIN $table_user_field_values field_values
498 498
 							ON field_values.item_id = u.user_id
499 499
 						WHERE
500 500
 							cu.user_id IS NULL AND u.status<>".DRH." AND
501 501
 							field_values.field_id = '".intval($field_identification[0])."' AND
502 502
 							field_values.value = '".Database::escape_string($field_identification[1])."'";
503
-				} else	{
504
-					$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
505
-				}
506
-
507
-				// adding a teacher NOT trough a session on a portal with multiple URLs
508
-				if (api_is_multiple_url_enabled()) {
509
-					if ($url_access_id !=-1) {
510
-						$sql = "SELECT $select_fields
503
+                } else	{
504
+                    $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
505
+                }
506
+
507
+                // adding a teacher NOT trough a session on a portal with multiple URLs
508
+                if (api_is_multiple_url_enabled()) {
509
+                    if ($url_access_id !=-1) {
510
+                        $sql = "SELECT $select_fields
511 511
 						FROM $user_table u
512 512
 						LEFT JOIN $course_user_table cu
513 513
 						ON u.user_id = cu.user_id and c_id='".$courseId."'
514 514
 						INNER JOIN  $tbl_url_rel_user as url_rel_user
515 515
 						ON (url_rel_user.user_id = u.user_id) ";
516 516
 
517
-					// applying the filter of the additional user profile fields
518
-					if (isset($_GET['subscribe_user_filter_value']) &&
519
-						!empty($_GET['subscribe_user_filter_value']) &&
520
-						api_get_setting('ProfilingFilterAddingUsers') == 'true'
521
-					){
522
-						$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
523
-						$sql .=	"
517
+                    // applying the filter of the additional user profile fields
518
+                    if (isset($_GET['subscribe_user_filter_value']) &&
519
+                        !empty($_GET['subscribe_user_filter_value']) &&
520
+                        api_get_setting('ProfilingFilterAddingUsers') == 'true'
521
+                    ){
522
+                        $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
523
+                        $sql .=	"
524 524
 							LEFT JOIN $table_user_field_values field_values
525 525
 								ON field_values.item_id = u.user_id
526 526
 							WHERE
@@ -528,16 +528,16 @@  discard block
 block discarded – undo
528 528
 							 	u.status<>".DRH." AND
529 529
 							 	field_values.field_id = '".intval($field_identification[0])."' AND
530 530
 							 	field_values.value = '".Database::escape_string($field_identification[1])."'";
531
-					} else	{
532
-						$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
533
-					}
534
-				}
535
-			}
536
-		}
537
-	} else {
538
-		// adding a student
539
-		if (!empty($sessionId)) {
540
-			$sql = "SELECT $select_fields
531
+                    } else	{
532
+                        $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
533
+                    }
534
+                }
535
+            }
536
+        }
537
+    } else {
538
+        // adding a student
539
+        if (!empty($sessionId)) {
540
+            $sql = "SELECT $select_fields
541 541
                     FROM $user_table u
542 542
                     LEFT JOIN $tbl_session_rel_course_user cu
543 543
                     ON
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
                 $sql .=  "AND access_url_id = $url_access_id";
573 573
             }
574 574
 
575
-		} else {
575
+        } else {
576 576
             $sql = "SELECT $select_fields
577 577
                     FROM $user_table u
578 578
                     LEFT JOIN $course_user_table cu
@@ -580,10 +580,10 @@  discard block
 block discarded – undo
580 580
                     	u.user_id = cu.user_id AND
581 581
                     	c_id ='".$courseId."'";
582 582
 
583
-			// applying the filter of the additional user profile fields
584
-			if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])) {
585
-				$field_identification = explode('*',$_GET['subscribe_user_filter_value']);
586
-				$sql .=	"
583
+            // applying the filter of the additional user profile fields
584
+            if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])) {
585
+                $field_identification = explode('*',$_GET['subscribe_user_filter_value']);
586
+                $sql .=	"
587 587
 					LEFT JOIN $table_user_field_values field_values
588 588
 						ON field_values.item_id = u.user_id
589 589
 					WHERE
@@ -591,28 +591,28 @@  discard block
 block discarded – undo
591 591
 						u.status<>".DRH." AND
592 592
 						field_values.field_id = '".intval($field_identification[0])."' AND
593 593
 						field_values.value = '".Database::escape_string($field_identification[1])."'";
594
-			} else	{
595
-				$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
596
-			}
594
+            } else	{
595
+                $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." ";
596
+            }
597 597
 
598
-			//showing only the courses of the current Chamilo access_url_id
598
+            //showing only the courses of the current Chamilo access_url_id
599 599
 
600
-			if (api_is_multiple_url_enabled()) {
601
-				if ($url_access_id !=-1) {
602
-					$sql = "SELECT $select_fields
600
+            if (api_is_multiple_url_enabled()) {
601
+                if ($url_access_id !=-1) {
602
+                    $sql = "SELECT $select_fields
603 603
 						FROM $user_table u
604 604
 						LEFT JOIN $course_user_table cu
605 605
 						ON u.user_id = cu.user_id AND c_id='".$courseId."'
606 606
 						INNER JOIN  $tbl_url_rel_user as url_rel_user
607 607
 						ON (url_rel_user.user_id = u.user_id) ";
608 608
 
609
-					// applying the filter of the additional user profile fields
610
-					if (isset($_GET['subscribe_user_filter_value']) &&
611
-						!empty($_GET['subscribe_user_filter_value']) &&
612
-						api_get_setting('ProfilingFilterAddingUsers') == 'true'
613
-					){
614
-						$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
615
-						$sql .=	"
609
+                    // applying the filter of the additional user profile fields
610
+                    if (isset($_GET['subscribe_user_filter_value']) &&
611
+                        !empty($_GET['subscribe_user_filter_value']) &&
612
+                        api_get_setting('ProfilingFilterAddingUsers') == 'true'
613
+                    ){
614
+                        $field_identification = explode('*', $_GET['subscribe_user_filter_value']);
615
+                        $sql .=	"
616 616
 							LEFT JOIN $table_user_field_values field_values
617 617
 								ON field_values.item_id = u.user_id
618 618
 							WHERE
@@ -622,18 +622,18 @@  discard block
 block discarded – undo
622 622
 								field_values.value = '".Database::escape_string($field_identification[1])."' AND
623 623
 								access_url_id = $url_access_id
624 624
                             ";
625
-					} else	{
626
-						$sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
627
-					}
628
-				}
629
-			}
630
-		}
631
-	}
632
-
633
-	// adding additional WHERE statements to the SQL for the search functionality
634
-	if (isset($_REQUEST['keyword'])) {
635
-		$keyword = Database::escape_string(trim($_REQUEST['keyword']));
636
-		$sql .= " AND (
625
+                    } else	{
626
+                        $sql .=	"WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id ";
627
+                    }
628
+                }
629
+            }
630
+        }
631
+    }
632
+
633
+    // adding additional WHERE statements to the SQL for the search functionality
634
+    if (isset($_REQUEST['keyword'])) {
635
+        $keyword = Database::escape_string(trim($_REQUEST['keyword']));
636
+        $sql .= " AND (
637 637
 					firstname LIKE '%".$keyword."%' OR
638 638
 					lastname LIKE '%".$keyword."%' OR
639 639
 					email LIKE '%".$keyword."%' OR
@@ -642,39 +642,39 @@  discard block
 block discarded – undo
642 642
 					)
643 643
 				";
644 644
 
645
-		if (api_get_setting('ProfilingFilterAddingUsers') === 'true') {
646
-			// we also want to search for users who have something in
647
-			// their profile fields that matches the keyword
648
-			$additional_users = search_additional_profile_fields($keyword);
649
-		}
650
-
651
-		// getting all the users of the course (to make sure that we do not
652
-		// display users that are already in the course)
653
-		if (!empty($sessionId)) {
654
-			$a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $sessionId);
655
-		} else {
656
-			$a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0);
657
-	    }
658
-		foreach ($a_course_users as $user_id=>$course_user) {
659
-			$users_of_course[] = $course_user['user_id'];
660
-		}
661
-	}
662
-
663
-	$sql .=" AND u.status != ".ANONYMOUS." ";
664
-
665
-	// Sorting and pagination (used by the sortable table)
666
-	$sql .= " ORDER BY col$column $direction ";
645
+        if (api_get_setting('ProfilingFilterAddingUsers') === 'true') {
646
+            // we also want to search for users who have something in
647
+            // their profile fields that matches the keyword
648
+            $additional_users = search_additional_profile_fields($keyword);
649
+        }
650
+
651
+        // getting all the users of the course (to make sure that we do not
652
+        // display users that are already in the course)
653
+        if (!empty($sessionId)) {
654
+            $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $sessionId);
655
+        } else {
656
+            $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0);
657
+        }
658
+        foreach ($a_course_users as $user_id=>$course_user) {
659
+            $users_of_course[] = $course_user['user_id'];
660
+        }
661
+    }
662
+
663
+    $sql .=" AND u.status != ".ANONYMOUS." ";
664
+
665
+    // Sorting and pagination (used by the sortable table)
666
+    $sql .= " ORDER BY col$column $direction ";
667 667
     $from = (int) $from;
668 668
     $number_of_items = (int) $number_of_items;
669
-	$sql .= " LIMIT $from, $number_of_items";
669
+    $sql .= " LIMIT $from, $number_of_items";
670 670
 
671
-	$res = Database::query($sql);
672
-	$users = array ();
673
-	while ($user = Database::fetch_row($res)) {
674
-		$users[] = $user;
675
-	}
671
+    $res = Database::query($sql);
672
+    $users = array ();
673
+    while ($user = Database::fetch_row($res)) {
674
+        $users[] = $user;
675
+    }
676 676
 
677
-	return $users;
677
+    return $users;
678 678
 }
679 679
 /**
680 680
 * Returns a mailto-link
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 */
684 684
 function email_filter($email)
685 685
 {
686
-	return Display :: encrypted_mailto_link($email, $email);
686
+    return Display :: encrypted_mailto_link($email, $email);
687 687
 }
688 688
 /**
689 689
  * Build the reg-column of the table
@@ -699,10 +699,10 @@  discard block
 block discarded – undo
699 699
     }
700 700
     $user_id = (int) $user_id;
701 701
 
702
-	$result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?'.api_get_cidreq().'&register=yes&type='.$type.'&user_id='.$user_id.'">'.
702
+    $result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?'.api_get_cidreq().'&register=yes&type='.$type.'&user_id='.$user_id.'">'.
703 703
         get_lang("reg").'</a>';
704 704
 
705
-	return $result;
705
+    return $result;
706 706
 }
707 707
 
708 708
 /**
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
  */
717 717
 function active_filter($active, $url_params, $row)
718 718
 {
719
-	$_user = api_get_user_info();
719
+    $_user = api_get_user_info();
720 720
     if ($active == '1') {
721 721
         $action = 'AccountActive';
722 722
         $image = 'accept';
@@ -725,15 +725,15 @@  discard block
 block discarded – undo
725 725
     if ($active == '0') {
726 726
         $action = 'AccountInactive';
727 727
         $image = 'error';
728
-	}
728
+    }
729 729
     $result = '';
730 730
     if ($row['0'] <> $_user['user_id']) {
731
-	// you cannot lock yourself out otherwise you could disable all the accounts
732
-	// including your own => everybody is locked out and nobody can change it anymore.
733
-		$result = Display::return_icon($image.'.png',  get_lang(ucfirst($action)), array() , ICON_SIZE_TINY);
734
-	}
731
+    // you cannot lock yourself out otherwise you could disable all the accounts
732
+    // including your own => everybody is locked out and nobody can change it anymore.
733
+        $result = Display::return_icon($image.'.png',  get_lang(ucfirst($action)), array() , ICON_SIZE_TINY);
734
+    }
735 735
 
736
-	return $result;
736
+    return $result;
737 737
 }
738 738
 
739 739
 /**
@@ -751,30 +751,30 @@  discard block
 block discarded – undo
751 751
  */
752 752
 function search_additional_profile_fields($keyword)
753 753
 {
754
-	// database table definitions
755
-	$table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
756
-	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
754
+    // database table definitions
755
+    $table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
756
+    $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
757 757
     $tableExtraField = Database::get_main_table(TABLE_EXTRA_FIELD);
758
-	$table_user = Database::get_main_table(TABLE_MAIN_USER);
758
+    $table_user = Database::get_main_table(TABLE_MAIN_USER);
759 759
 
760 760
     $keyword = Database::escape_string($keyword);
761
-	// getting the field option text that match this keyword (for radio buttons and checkboxes)
762
-	$sql = "SELECT * FROM $table_user_field_options
761
+    // getting the field option text that match this keyword (for radio buttons and checkboxes)
762
+    $sql = "SELECT * FROM $table_user_field_options
763 763
 	        WHERE display_text LIKE '%".$keyword."%'";
764
-	$result_profiling = Database::query($sql);
765
-	while ($profiling_field_options = Database::fetch_array($result_profiling)) {
766
-		$profiling_field_options_exact_values[] = $profiling_field_options;
767
-	}
764
+    $result_profiling = Database::query($sql);
765
+    while ($profiling_field_options = Database::fetch_array($result_profiling)) {
766
+        $profiling_field_options_exact_values[] = $profiling_field_options;
767
+    }
768 768
     $profiling_field_options_exact_values_sql = '';
769
-	foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue) {
770
-		$profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') ";
771
-	}
769
+    foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue) {
770
+        $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') ";
771
+    }
772 772
 
773 773
     $extraFieldType = ExtraField::USER_FIELD_TYPE;
774 774
 
775
-	// getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword
776
-	// or all the users who have entered the keyword in a free-form field
777
-	$sql = "SELECT
775
+    // getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword
776
+    // or all the users who have entered the keyword in a free-form field
777
+    $sql = "SELECT
778 778
 	            user.user_id as col0,
779 779
 	            user.official_code as col1,
780 780
 	            user.lastname as col2,
@@ -788,13 +788,13 @@  discard block
 block discarded – undo
788 788
                 user_values.field_id = e.id AND
789 789
                 e.extra_field_type = $extraFieldType AND
790 790
                 (value LIKE '%".$keyword."%'".$profiling_field_options_exact_values_sql.")";
791
-	$result = Database::query($sql);
791
+    $result = Database::query($sql);
792 792
     $additional_users = array();
793
-	while ($profiled_users = Database::fetch_array($result)) {
794
-		$additional_users[$profiled_users['col0']] = $profiled_users;
795
-	}
793
+    while ($profiled_users = Database::fetch_array($result)) {
794
+        $additional_users[$profiled_users['col0']] = $profiled_users;
795
+    }
796 796
 
797
-	return $additional_users;
797
+    return $additional_users;
798 798
 }
799 799
 
800 800
 /**
@@ -806,44 +806,44 @@  discard block
 block discarded – undo
806 806
  */
807 807
 function display_extra_profile_fields_filter()
808 808
 {
809
-	// getting all the additional user profile fields
809
+    // getting all the additional user profile fields
810 810
     $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
811
-	$return = '<option value="">'.get_lang('SelectFilter').'</option>';
812
-
813
-	// looping through the additional user profile fields
814
-	foreach ($extra as $id => $field_details) {
815
-		// $field_details[2] contains the type of the additional user profile field
816
-		switch ($field_details[2]) {
817
-			// text fields cannot be used as a filter
818
-			case ExtraFieldModel::FIELD_TYPE_TEXT:
819
-				break;
820
-			// text area fields cannot be used as a filter
821
-			case ExtraFieldModel::FIELD_TYPE_TEXTAREA:
822
-				break;
823
-			case ExtraFieldModel::FIELD_TYPE_RADIO:
824
-			case ExtraFieldModel::FIELD_TYPE_SELECT:
825
-			case ExtraFieldModel::FIELD_TYPE_SELECT_MULTIPLE:
826
-				$return .= '<optgroup label="'.$field_details[3].'">';
827
-				foreach ($field_details[9] as $option_id => $option_details) {
828
-					if (isset($_GET['subscribe_user_filter_value']) &&
811
+    $return = '<option value="">'.get_lang('SelectFilter').'</option>';
812
+
813
+    // looping through the additional user profile fields
814
+    foreach ($extra as $id => $field_details) {
815
+        // $field_details[2] contains the type of the additional user profile field
816
+        switch ($field_details[2]) {
817
+            // text fields cannot be used as a filter
818
+            case ExtraFieldModel::FIELD_TYPE_TEXT:
819
+                break;
820
+            // text area fields cannot be used as a filter
821
+            case ExtraFieldModel::FIELD_TYPE_TEXTAREA:
822
+                break;
823
+            case ExtraFieldModel::FIELD_TYPE_RADIO:
824
+            case ExtraFieldModel::FIELD_TYPE_SELECT:
825
+            case ExtraFieldModel::FIELD_TYPE_SELECT_MULTIPLE:
826
+                $return .= '<optgroup label="'.$field_details[3].'">';
827
+                foreach ($field_details[9] as $option_id => $option_details) {
828
+                    if (isset($_GET['subscribe_user_filter_value']) &&
829 829
                         $_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1]
830 830
                     ) {
831
-						$selected = 'selected="selected"';
832
-					} else {
833
-						$selected = false;
834
-					}
835
-					$return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>';
836
-				}
837
-				$return .= '</optgroup>';
838
-				break;
839
-		}
840
-	}
841
-
842
-	$html = '<form class="form-inline" id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?'.api_get_cidreq().'">';
843
-	$html .= '<input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />';
844
-	$html .= '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>';
845
-	$html .= '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>';
846
-	$html .= '</form>';
831
+                        $selected = 'selected="selected"';
832
+                    } else {
833
+                        $selected = false;
834
+                    }
835
+                    $return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>';
836
+                }
837
+                $return .= '</optgroup>';
838
+                break;
839
+        }
840
+    }
841
+
842
+    $html = '<form class="form-inline" id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?'.api_get_cidreq().'">';
843
+    $html .= '<input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />';
844
+    $html .= '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>';
845
+    $html .= '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>';
846
+    $html .= '</form>';
847 847
 
848 848
     return $html;
849 849
 }
Please login to merge, or discard this patch.
main/exercise/fill_blanks.class.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
         }
566 566
 
567 567
         return $items;*/
568
-         $listChoises = api_preg_split("/\|/", $correctAnswer);
568
+            $listChoises = api_preg_split("/\|/", $correctAnswer);
569 569
         if ($displayForStudent) {
570 570
             shuffle($listChoises);
571 571
         }
@@ -789,29 +789,29 @@  discard block
 block discarded – undo
789 789
     }
790 790
 
791 791
     /**
792
-    * Return an array of student state answers for fill the blank questions
793
-    * for each students that answered the question
794
-    * -2  : didn't answer
795
-    * -1  : student answer is wrong
796
-    *  0  : student answer is correct
797
-    * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
798
-    *
799
-    * @param integer $testId
800
-    * @param integer $questionId
801
-    * @param $studentsIdList
802
-    * @param string $startDate
803
-    * @param string $endDate
804
-    * @param bool $useLastAnswerredAttempt
805
-    * @return array
806
-    * (
807
-    *     [student_id] => Array
808
-    *         (
809
-    *             [first fill the blank for question] => -1
810
-    *             [second fill the blank for question] => 2
811
-    *             [third fill the blank for question] => -1
812
-    *         )
813
-    * )
814
-    */
792
+     * Return an array of student state answers for fill the blank questions
793
+     * for each students that answered the question
794
+     * -2  : didn't answer
795
+     * -1  : student answer is wrong
796
+     *  0  : student answer is correct
797
+     * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
798
+     *
799
+     * @param integer $testId
800
+     * @param integer $questionId
801
+     * @param $studentsIdList
802
+     * @param string $startDate
803
+     * @param string $endDate
804
+     * @param bool $useLastAnswerredAttempt
805
+     * @return array
806
+     * (
807
+     *     [student_id] => Array
808
+     *         (
809
+     *             [first fill the blank for question] => -1
810
+     *             [second fill the blank for question] => 2
811
+     *             [third fill the blank for question] => -1
812
+     *         )
813
+     * )
814
+     */
815 815
     public static function getFillTheBlankTabResult(
816 816
         $testId,
817 817
         $questionId,
Please login to merge, or discard this patch.
plugin/buycourses/src/Requests/Response/Headers.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -11,88 +11,88 @@
 block discarded – undo
11 11
  * @package Requests
12 12
  */
13 13
 class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictionary {
14
-	/**
15
-	 * Get the given header
16
-	 *
17
-	 * Unlike {@see self::getValues()}, this returns a string. If there are
18
-	 * multiple values, it concatenates them with a comma as per RFC2616.
19
-	 *
20
-	 * Avoid using this where commas may be used unquoted in values, such as
21
-	 * Set-Cookie headers.
22
-	 *
23
-	 * @param string $key
24
-	 * @return string Header value
25
-	 */
26
-	public function offsetGet($key) {
27
-		$key = strtolower($key);
28
-		if (!isset($this->data[$key])) {
29
-			return null;
30
-		}
14
+    /**
15
+     * Get the given header
16
+     *
17
+     * Unlike {@see self::getValues()}, this returns a string. If there are
18
+     * multiple values, it concatenates them with a comma as per RFC2616.
19
+     *
20
+     * Avoid using this where commas may be used unquoted in values, such as
21
+     * Set-Cookie headers.
22
+     *
23
+     * @param string $key
24
+     * @return string Header value
25
+     */
26
+    public function offsetGet($key) {
27
+        $key = strtolower($key);
28
+        if (!isset($this->data[$key])) {
29
+            return null;
30
+        }
31 31
 
32
-		return $this->flatten($this->data[$key]);
33
-	}
32
+        return $this->flatten($this->data[$key]);
33
+    }
34 34
 
35
-	/**
36
-	 * Set the given item
37
-	 *
38
-	 * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`)
39
-	 *
40
-	 * @param string $key Item name
41
-	 * @param string $value Item value
42
-	 */
43
-	public function offsetSet($key, $value) {
44
-		if ($key === null) {
45
-			throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
46
-		}
35
+    /**
36
+     * Set the given item
37
+     *
38
+     * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`)
39
+     *
40
+     * @param string $key Item name
41
+     * @param string $value Item value
42
+     */
43
+    public function offsetSet($key, $value) {
44
+        if ($key === null) {
45
+            throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
46
+        }
47 47
 
48
-		$key = strtolower($key);
48
+        $key = strtolower($key);
49 49
 
50
-		if (!isset($this->data[$key])) {
51
-			$this->data[$key] = array();
52
-		}
50
+        if (!isset($this->data[$key])) {
51
+            $this->data[$key] = array();
52
+        }
53 53
 
54
-		$this->data[$key][] = $value;
55
-	}
54
+        $this->data[$key][] = $value;
55
+    }
56 56
 
57
-	/**
58
-	 * Get all values for a given header
59
-	 *
60
-	 * @param string $key
61
-	 * @return array Header values
62
-	 */
63
-	public function getValues($key) {
64
-		$key = strtolower($key);
65
-		if (!isset($this->data[$key])) {
66
-			return null;
67
-		}
57
+    /**
58
+     * Get all values for a given header
59
+     *
60
+     * @param string $key
61
+     * @return array Header values
62
+     */
63
+    public function getValues($key) {
64
+        $key = strtolower($key);
65
+        if (!isset($this->data[$key])) {
66
+            return null;
67
+        }
68 68
 
69
-		return $this->data[$key];
70
-	}
69
+        return $this->data[$key];
70
+    }
71 71
 
72
-	/**
73
-	 * Flattens a value into a string
74
-	 *
75
-	 * Converts an array into a string by imploding values with a comma, as per
76
-	 * RFC2616's rules for folding headers.
77
-	 *
78
-	 * @param string|array $value Value to flatten
79
-	 * @return string Flattened value
80
-	 */
81
-	public function flatten($value) {
82
-		if (is_array($value)) {
83
-			$value = implode(',', $value);
84
-		}
72
+    /**
73
+     * Flattens a value into a string
74
+     *
75
+     * Converts an array into a string by imploding values with a comma, as per
76
+     * RFC2616's rules for folding headers.
77
+     *
78
+     * @param string|array $value Value to flatten
79
+     * @return string Flattened value
80
+     */
81
+    public function flatten($value) {
82
+        if (is_array($value)) {
83
+            $value = implode(',', $value);
84
+        }
85 85
 
86
-		return $value;
87
-	}
86
+        return $value;
87
+    }
88 88
 
89
-	/**
90
-	 * Get an iterator for the data
91
-	 *
92
-	 * Converts the internal
93
-	 * @return ArrayIterator
94
-	 */
95
-	public function getIterator() {
96
-		return new Requests_Utility_FilteredIterator($this->data, array($this, 'flatten'));
97
-	}
89
+    /**
90
+     * Get an iterator for the data
91
+     *
92
+     * Converts the internal
93
+     * @return ArrayIterator
94
+     */
95
+    public function getIterator() {
96
+        return new Requests_Utility_FilteredIterator($this->data, array($this, 'flatten'));
97
+    }
98 98
 }
Please login to merge, or discard this patch.
plugin/buycourses/src/Requests/Utility/FilteredIterator.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -13,33 +13,33 @@
 block discarded – undo
13 13
  * @subpackage Utilities
14 14
  */
15 15
 class Requests_Utility_FilteredIterator extends ArrayIterator {
16
-	/**
17
-	 * Callback to run as a filter
18
-	 *
19
-	 * @var callable
20
-	 */
21
-	protected $callback;
16
+    /**
17
+     * Callback to run as a filter
18
+     *
19
+     * @var callable
20
+     */
21
+    protected $callback;
22 22
 
23
-	/**
24
-	 * Create a new iterator
25
-	 *
26
-	 * @param array $data
27
-	 * @param callable $callback Callback to be called on each value
28
-	 */
29
-	public function __construct($data, $callback) {
30
-		parent::__construct($data);
23
+    /**
24
+     * Create a new iterator
25
+     *
26
+     * @param array $data
27
+     * @param callable $callback Callback to be called on each value
28
+     */
29
+    public function __construct($data, $callback) {
30
+        parent::__construct($data);
31 31
 
32
-		$this->callback = $callback;
33
-	}
32
+        $this->callback = $callback;
33
+    }
34 34
 
35
-	/**
36
-	 * Get the current item's value after filtering
37
-	 *
38
-	 * @return string
39
-	 */
40
-	public function current() {
41
-		$value = parent::current();
42
-		$value = call_user_func($this->callback, $value);
43
-		return $value;
44
-	}
35
+    /**
36
+     * Get the current item's value after filtering
37
+     *
38
+     * @return string
39
+     */
40
+    public function current() {
41
+        $value = parent::current();
42
+        $value = call_user_func($this->callback, $value);
43
+        return $value;
44
+    }
45 45
 }
Please login to merge, or discard this patch.
plugin/buycourses/src/Requests/Utility/CaseInsensitiveDictionary.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -13,91 +13,91 @@
 block discarded – undo
13 13
  * @subpackage Utilities
14 14
  */
15 15
 class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate {
16
-	/**
17
-	 * Actual item data
18
-	 *
19
-	 * @var array
20
-	 */
21
-	protected $data = array();
16
+    /**
17
+     * Actual item data
18
+     *
19
+     * @var array
20
+     */
21
+    protected $data = array();
22 22
 
23
-	/**
24
-	 * Creates a case insensitive dictionary.
25
-	 *
26
-	 * @param array $data Dictionary/map to convert to case-insensitive
27
-	 */
28
-	public function __construct(array $data = array()) {
29
-		foreach ($data as $key => $value) {
30
-			$this->offsetSet($key, $value);
31
-		}
32
-	}
23
+    /**
24
+     * Creates a case insensitive dictionary.
25
+     *
26
+     * @param array $data Dictionary/map to convert to case-insensitive
27
+     */
28
+    public function __construct(array $data = array()) {
29
+        foreach ($data as $key => $value) {
30
+            $this->offsetSet($key, $value);
31
+        }
32
+    }
33 33
 
34
-	/**
35
-	 * Check if the given item exists
36
-	 *
37
-	 * @param string $key Item key
38
-	 * @return boolean Does the item exist?
39
-	 */
40
-	public function offsetExists($key) {
41
-		$key = strtolower($key);
42
-		return isset($this->data[$key]);
43
-	}
34
+    /**
35
+     * Check if the given item exists
36
+     *
37
+     * @param string $key Item key
38
+     * @return boolean Does the item exist?
39
+     */
40
+    public function offsetExists($key) {
41
+        $key = strtolower($key);
42
+        return isset($this->data[$key]);
43
+    }
44 44
 
45
-	/**
46
-	 * Get the value for the item
47
-	 *
48
-	 * @param string $key Item key
49
-	 * @return string Item value
50
-	 */
51
-	public function offsetGet($key) {
52
-		$key = strtolower($key);
53
-		if (!isset($this->data[$key])) {
54
-			return null;
55
-		}
45
+    /**
46
+     * Get the value for the item
47
+     *
48
+     * @param string $key Item key
49
+     * @return string Item value
50
+     */
51
+    public function offsetGet($key) {
52
+        $key = strtolower($key);
53
+        if (!isset($this->data[$key])) {
54
+            return null;
55
+        }
56 56
 
57
-		return $this->data[$key];
58
-	}
57
+        return $this->data[$key];
58
+    }
59 59
 
60
-	/**
61
-	 * Set the given item
62
-	 *
63
-	 * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`)
64
-	 *
65
-	 * @param string $key Item name
66
-	 * @param string $value Item value
67
-	 */
68
-	public function offsetSet($key, $value) {
69
-		if ($key === null) {
70
-			throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
71
-		}
60
+    /**
61
+     * Set the given item
62
+     *
63
+     * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`)
64
+     *
65
+     * @param string $key Item name
66
+     * @param string $value Item value
67
+     */
68
+    public function offsetSet($key, $value) {
69
+        if ($key === null) {
70
+            throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
71
+        }
72 72
 
73
-		$key = strtolower($key);
74
-		$this->data[$key] = $value;
75
-	}
73
+        $key = strtolower($key);
74
+        $this->data[$key] = $value;
75
+    }
76 76
 
77
-	/**
78
-	 * Unset the given header
79
-	 *
80
-	 * @param string $key
81
-	 */
82
-	public function offsetUnset($key) {
83
-		unset($this->data[strtolower($key)]);
84
-	}
77
+    /**
78
+     * Unset the given header
79
+     *
80
+     * @param string $key
81
+     */
82
+    public function offsetUnset($key) {
83
+        unset($this->data[strtolower($key)]);
84
+    }
85 85
 
86
-	/**
87
-	 * Get an iterator for the data
88
-	 *
89
-	 * @return ArrayIterator
90
-	 */
91
-	public function getIterator() {
92
-		return new ArrayIterator($this->data);
93
-	}
86
+    /**
87
+     * Get an iterator for the data
88
+     *
89
+     * @return ArrayIterator
90
+     */
91
+    public function getIterator() {
92
+        return new ArrayIterator($this->data);
93
+    }
94 94
 
95
-	/**
96
-	 * Get the headers as an array
97
-	 *
98
-	 * @return array Header data
99
-	 */
100
-	public function getAll() {
101
-		return $this->data;
102
-	}
95
+    /**
96
+     * Get the headers as an array
97
+     *
98
+     * @return array Header data
99
+     */
100
+    public function getAll() {
101
+        return $this->data;
102
+    }
103 103
 }
Please login to merge, or discard this patch.
plugin/buycourses/src/Requests/Hooker.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@
 block discarded – undo
13 13
  * @subpackage Utilities
14 14
  */
15 15
 interface Requests_Hooker {
16
-	/**
17
-	 * Register a callback for a hook
18
-	 *
19
-	 * @param string $hook Hook name
20
-	 * @param callback $callback Function/method to call on event
21
-	 * @param int $priority Priority number. <0 is executed earlier, >0 is executed later
22
-	 */
23
-	public function register($hook, $callback, $priority = 0);
16
+    /**
17
+     * Register a callback for a hook
18
+     *
19
+     * @param string $hook Hook name
20
+     * @param callback $callback Function/method to call on event
21
+     * @param int $priority Priority number. <0 is executed earlier, >0 is executed later
22
+     */
23
+    public function register($hook, $callback, $priority = 0);
24 24
 
25
-	/**
26
-	 * Dispatch a message
27
-	 *
28
-	 * @param string $hook Hook name
29
-	 * @param array $parameters Parameters to pass to callbacks
30
-	 * @return boolean Successfulness
31
-	 */
32
-	public function dispatch($hook, $parameters = array());
25
+    /**
26
+     * Dispatch a message
27
+     *
28
+     * @param string $hook Hook name
29
+     * @param array $parameters Parameters to pass to callbacks
30
+     * @return boolean Successfulness
31
+     */
32
+    public function dispatch($hook, $parameters = array());
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
plugin/buycourses/src/Requests/Exception/HTTP/431.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@
 block discarded – undo
13 13
  * @package Requests
14 14
  */
15 15
 class Requests_Exception_HTTP_431 extends Requests_Exception_HTTP {
16
-	/**
17
-	 * HTTP status code
18
-	 *
19
-	 * @var integer
20
-	 */
21
-	protected $code = 431;
16
+    /**
17
+     * HTTP status code
18
+     *
19
+     * @var integer
20
+     */
21
+    protected $code = 431;
22 22
 
23
-	/**
24
-	 * Reason phrase
25
-	 *
26
-	 * @var string
27
-	 */
28
-	protected $reason = 'Request Header Fields Too Large';
23
+    /**
24
+     * Reason phrase
25
+     *
26
+     * @var string
27
+     */
28
+    protected $reason = 'Request Header Fields Too Large';
29 29
 }
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
plugin/buycourses/src/Requests/Exception/HTTP/415.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@
 block discarded – undo
11 11
  * @package Requests
12 12
  */
13 13
 class Requests_Exception_HTTP_415 extends Requests_Exception_HTTP {
14
-	/**
15
-	 * HTTP status code
16
-	 *
17
-	 * @var integer
18
-	 */
19
-	protected $code = 415;
14
+    /**
15
+     * HTTP status code
16
+     *
17
+     * @var integer
18
+     */
19
+    protected $code = 415;
20 20
 
21
-	/**
22
-	 * Reason phrase
23
-	 *
24
-	 * @var string
25
-	 */
26
-	protected $reason = 'Unsupported Media Type';
21
+    /**
22
+     * Reason phrase
23
+     *
24
+     * @var string
25
+     */
26
+    protected $reason = 'Unsupported Media Type';
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.