Test Setup Failed
Push — master ( 43640b...10eb12 )
by Angel Fernando Quiroz
158:47 queued 97:59
created
main/reports/reports.php 1 patch
Braces   +43 added lines, -31 removed lines patch added patch discarded remove patch
@@ -37,16 +37,18 @@  discard block
 block discarded – undo
37 37
 	// converting post vars to get uri
38 38
 	$params = '';
39 39
 	$kv = array();
40
-	foreach ($_POST as $key => $value)
41
-		if ($key != 'format')
40
+	foreach ($_POST as $key => $value) {
41
+			if ($key != 'format')
42 42
 			$kv[] = $key.'='.urlencode($value);
43
+	}
43 44
 	$query_string = join("&", $kv);
44 45
 	die('<a href="reports.php?format=directlink&'.$query_string.'">'.get_lang('ReportTypeLink').'</a>');
45 46
 }
46 47
 
47 48
 if ($_REQUEST['format'] == 'directlink') {
48
-	foreach (array('jquery.dataTables.min.js') as $js)
49
-		$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n";
49
+	foreach (array('jquery.dataTables.min.js') as $js) {
50
+			$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n";
51
+	}
50 52
 
51 53
 	$htmlCSSXtra[] = 'dataTable.css';
52 54
 
@@ -72,9 +74,10 @@  discard block
 block discarded – undo
72 74
 	// converting post vars to get uri
73 75
 	$params = '';
74 76
 	$kv = array();
75
-	foreach ($_POST as $key => $value)
76
-		if ($key != 'format')
77
+	foreach ($_POST as $key => $value) {
78
+			if ($key != 'format')
77 79
 			$kv[] = $key.'='.urlencode($value);
80
+	}
78 81
 	$query_string = join("&", $kv);
79 82
 	die('<a href="reports.php?format=downloadcsv&'.$query_string.'">'.get_lang('DownloadFile').'</a>');
80 83
 } else if ($_REQUEST['format'] == 'downloadcsv') {
@@ -82,8 +85,7 @@  discard block
 block discarded – undo
82 85
 		header("Pragma: must-revalidate");
83 86
 		header("Cache-Control: must-revalidate");
84 87
 		header("Content-type: application/vnd.ms-excel");
85
-	}
86
-	else {
88
+	} else {
87 89
 		header("Content-type: text/csv");
88 90
 	}
89 91
 	$date = date("Y-m-d");
@@ -96,10 +98,12 @@  discard block
 block discarded – undo
96 98
 
97 99
 if (is_array($reports_template[$_REQUEST['type']])) {
98 100
 	$query = $reports_template[$_REQUEST['type']]['getSQL']();
99
-	if (! is_array($query))
100
-		$query = array($query);
101
-	if ($_REQUEST['format'] == 'sql')
102
-		die(var_export($query, true));
101
+	if (! is_array($query)) {
102
+			$query = array($query);
103
+	}
104
+	if ($_REQUEST['format'] == 'sql') {
105
+			die(var_export($query, true));
106
+	}
103 107
 
104 108
 	$result = multiquery_query($query);
105 109
 
@@ -155,32 +159,35 @@  discard block
 block discarded – undo
155 159
 		if (substr($columns[$i], -5, 5) != '_link') {
156 160
 			$column_islink[$i] = false;
157 161
 			echo '<th>'.$columns[$i].'</th>';
158
-		} else
159
-			$columns_islink[$i] = true;
162
+		} else {
163
+					$columns_islink[$i] = true;
164
+		}
160 165
 	}
161 166
 
162 167
 	// checking resolving link column id
163 168
 	$columns_flip = array_flip($columns);
164 169
 	$columns_link = array();
165
-	for ($i=0; $i < $nfields; $i++)
166
-		if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip))
170
+	for ($i=0; $i < $nfields; $i++) {
171
+			if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip))
167 172
 			$columns_link[$i] = $columns_flip[$columns[$i].'_link'];
168
-		else
169
-			$columns_link[$i] = '';
173
+	}
174
+		else {
175
+					$columns_link[$i] = '';
176
+		}
170 177
 	echo '</tr></thead><tbody>';
171 178
 	while ($row = multiquery_fetch_row($result)) {
172 179
 		echo '<tr>';
173
-		for ($i = 0; $i<$nfields; $i++)
174
-			if (!$columns_islink[$i]){ // ignore links
180
+		for ($i = 0; $i<$nfields; $i++) {
181
+					if (!$columns_islink[$i]){ // ignore links
175 182
 				if ($columns_link[$i] != '') // link is defined
176 183
 					if (substr($columns_link[$i],0,10) == 'javascript') {
177 184
 						echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>';
178
-					}
179
-					else {
185
+		}
186
+					} else {
180 187
 						echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>';
181
-					}
182
-				else
183
-					echo '<td>'.$row[$i].'</td>';
188
+					} else {
189
+									echo '<td>'.$row[$i].'</td>';
190
+				}
184 191
 			}
185 192
 		echo "</tr>\n";
186 193
 	}
@@ -206,18 +213,23 @@  discard block
 block discarded – undo
206 213
 		if (substr($columns[$i], -5, 5) != '_link') {
207 214
 			$column_islink[$i] = false;
208 215
 			echo csv_escaping($columns[$i]).',';
209
-		} else
210
-			$columns_islink[$i] = true;
216
+		} else {
217
+					$columns_islink[$i] = true;
218
+		}
211 219
 	}
212 220
 
213 221
 	echo "\n";
214 222
 	while ($row = multiquery_fetch_row($result)) {
215
-		for ($i = 0; $i<$nfields; $i++)
216
-			if (!$columns_islink[$i]) // ignore links
217
-				echo csv_escaping($row[$i]).',';  // fixme
223
+		for ($i = 0; $i<$nfields; $i++) {
224
+					if (!$columns_islink[$i]) // ignore links
225
+				echo csv_escaping($row[$i]).',';
226
+		}
227
+		// fixme
218 228
 		echo "\n";
219 229
 	}
220
-} else die(get_lang('UnknownFormat'));
230
+} else {
231
+    die(get_lang('UnknownFormat'));
232
+}
221 233
 
222 234
 function csv_escaping($value, $csv_separator = ',') {
223 235
 	$value = str_replace('"','""',$value);
Please login to merge, or discard this patch.
main/mySpace/myStudents.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 
824 824
                     if ($progress === null) {
825 825
                         $progress = '0%';
826
-                    }  else {
826
+                    } else {
827 827
                         $any_result = true;
828 828
                     }
829 829
 
@@ -853,7 +853,9 @@  discard block
 block discarded – undo
853 853
                         $start_time =  '-';
854 854
                     }
855 855
 
856
-                    if (!empty($total_time)) $any_result = true;
856
+                    if (!empty($total_time)) {
857
+                        $any_result = true;
858
+                    }
857 859
 
858 860
                     // Quiz in lp
859 861
                     $score = Tracking::get_avg_student_score(
@@ -873,8 +875,11 @@  discard block
 block discarded – undo
873 875
                         true
874 876
                     );
875 877
 
876
-                    if ($i % 2 == 0) $css_class = "row_even";
877
-                    else $css_class = "row_odd";
878
+                    if ($i % 2 == 0) {
879
+                        $css_class = "row_even";
880
+                    } else {
881
+                        $css_class = "row_odd";
882
+                    }
878 883
 
879 884
                     $i++;
880 885
 
@@ -1042,9 +1047,10 @@  discard block
 block discarded – undo
1042 1047
                 $result_last_attempt = Database::query($sql);
1043 1048
                 if (Database :: num_rows($result_last_attempt) > 0) {
1044 1049
                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
1045
-                    if ($count_attempts > 0)
1046
-                        echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'">
1050
+                    if ($count_attempts > 0) {
1051
+                                            echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'">
1047 1052
                         <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" border="0" /> </a>';
1053
+                    }
1048 1054
                 }
1049 1055
                 echo '</td>';
1050 1056
 
Please login to merge, or discard this patch.
main/wiki/wiki.inc.php 1 patch
Braces   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
                 $email_body = get_lang('DearUser').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).',<br /><br />';
1879 1879
                 if($session_id==0){
1880 1880
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' - '.$group_name.'</strong><br /><br /><br />';
1881
-                }else{
1881
+                } else{
1882 1882
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' ('.api_get_session_name(api_get_session_id()).') - '.$group_name.'</strong><br /><br /><br />';
1883 1883
                 }
1884 1884
                 $email_body .= $email_user_author.' ('.$email_date_changes.')<br /><br /><br />';
@@ -2261,8 +2261,7 @@  discard block
 block discarded – undo
2261 2261
                                         s1.reflink = s2.reflink AND
2262 2262
                                         ".$groupfilter.$condition_session.")";
2263 2263
                     // warning don't use group by reflink because don't return the last version
2264
-                }
2265
-                else {
2264
+                } else {
2266 2265
                     $sql = " SELECT * FROM ".$tbl_wiki." s1
2267 2266
                             WHERE
2268 2267
                                 s1.c_id = $course_id AND
@@ -3696,8 +3695,7 @@  discard block
 block discarded – undo
3696 3695
                 '.api_htmlentities($obj->title).'</a>';
3697 3696
                 if ($obj->user_id <>0) {
3698 3697
                     $row[] = UserManager::getUserProfileLink($userinfo);
3699
-                }
3700
-                else {
3698
+                } else {
3701 3699
                     $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
3702 3700
                 }
3703 3701
                 $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
@@ -3932,8 +3930,7 @@  discard block
 block discarded – undo
3932 3930
                         api_htmlentities($obj->title).'</a>';
3933 3931
                     if ($obj->user_id <>0) {
3934 3932
                         $row[] = UserManager::getUserProfileLink($userinfo);
3935
-                    }
3936
-                    else {
3933
+                    } else {
3937 3934
                         $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
3938 3935
                     }
3939 3936
                     $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseSelectForm.class.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -527,14 +527,15 @@
 block discarded – undo
527 527
 						// Mark folders to import which are not selected by the user to import,
528 528
 						// but in which a document was selected.
529 529
 						$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
530
-						if (!empty($resources) && is_array($resources))
531
-							foreach ($resources as $id => $obj) {
530
+						if (!empty($resources) && is_array($resources)) {
531
+													foreach ($resources as $id => $obj) {
532 532
 								if (isset($obj->file_type) && $obj->file_type == 'folder' &&
533 533
                                     !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
534 534
                                     is_array($documents)
535 535
                                 ) {
536 536
 									foreach ($documents as $id_to_check => $post_value) {
537 537
 										$obj_to_check = $resources[$id_to_check];
538
+						}
538 539
 										$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
539 540
 										if ($id_to_check != $id && $obj->path == $shared_path_part) {
540 541
 											$_POST['resource'][RESOURCE_DOCUMENT][$id] = 1;
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseRestorer.class.php 1 patch
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -512,7 +512,9 @@  discard block
 block discarded – undo
512 512
 
513 513
                                     if (in_array($file_info['extension'], array('html', 'htm'))) {
514 514
                                         $content = file_get_contents($path.$document->path);
515
-                                        if (UTF8_CONVERT) $content = utf8_encode($content);
515
+                                        if (UTF8_CONVERT) {
516
+                                            $content = utf8_encode($content);
517
+                                        }
516 518
                                         $content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
517 519
                                             $content,
518 520
                                             $this->course->code,
@@ -2240,7 +2242,11 @@  discard block
 block discarded – undo
2240 2242
 		            c_id = ".$this->destination_course_id." AND
2241 2243
 		            code='".self::DBUTF8escapestring($survey_code)."'";
2242 2244
 		$result = Database::query($sql);
2243
-		if (Database::num_rows($result) > 0) return false; else return true;
2245
+		if (Database::num_rows($result) > 0) {
2246
+		    return false;
2247
+		} else {
2248
+		    return true;
2249
+		}
2244 2250
 	}
2245 2251
 
2246 2252
 	/**
@@ -2719,8 +2725,9 @@  discard block
 block discarded – undo
2719 2725
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2720 2726
                         }*/
2721 2727
                     } elseif(is_dir($path)) {
2722
-                        if (!is_dir($dest . '/' . $file))
2723
-                        mkdir($dest . '/' . $file);
2728
+                        if (!is_dir($dest . '/' . $file)) {
2729
+                                                mkdir($dest . '/' . $file);
2730
+                        }
2724 2731
                        self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2725 2732
                     }
2726 2733
                 }
Please login to merge, or discard this patch.
main/search/search_suggestions.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,6 +104,8 @@
 block discarded – undo
104 104
 }
105 105
 
106 106
 $q = strtolower($_GET["q"]);
107
-if (!$q) return;
107
+if (!$q) {
108
+    return;
109
+}
108 110
 //echo $q . "| value\n";
109 111
 get_suggestions_from_search_engine($q);
Please login to merge, or discard this patch.
main/webservices/registration.soap.php 1 patch
Braces   +169 added lines, -62 removed lines patch added patch discarded remove patch
@@ -63,19 +63,22 @@  discard block
 block discarded – undo
63 63
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
64 64
         $ip = trim($ip1);
65 65
     }
66
-    if ($debug)
67
-        error_log("ip: $ip");
66
+    if ($debug) {
67
+            error_log("ip: $ip");
68
+    }
68 69
     // Check if a file that limits access from webservices exists and contains
69 70
     // the restraining check
70 71
     if (is_file('webservice-auth-ip.conf.php')) {
71 72
         include 'webservice-auth-ip.conf.php';
72
-        if ($debug)
73
-            error_log("webservice-auth-ip.conf.php file included");
73
+        if ($debug) {
74
+                    error_log("webservice-auth-ip.conf.php file included");
75
+        }
74 76
         if (!empty($ws_auth_ip)) {
75 77
             $check_ip = true;
76 78
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
77
-            if ($debug)
78
-                error_log("ip_matches: $ip_matches");
79
+            if ($debug) {
80
+                            error_log("ip_matches: $ip_matches");
81
+            }
79 82
         }
80 83
     }
81 84
 
@@ -92,8 +95,9 @@  discard block
 block discarded – undo
92 95
 
93 96
     $result = api_is_valid_secret_key($secret_key, $security_key);
94 97
 
95
-    if ($debug)
96
-        error_log('WSHelperVerifyKey result: '.intval($result));
98
+    if ($debug) {
99
+            error_log('WSHelperVerifyKey result: '.intval($result));
100
+    }
97 101
     return $result;
98 102
 }
99 103
 
@@ -553,7 +557,9 @@  discard block
 block discarded – undo
553 557
 
554 558
     // First check wether the login already exists
555 559
     if (!UserManager::is_username_available($loginName)) {
556
-        if ($debug) error_log("Username $loginName is not available");
560
+        if ($debug) {
561
+            error_log("Username $loginName is not available");
562
+        }
557 563
         return 0;
558 564
     }
559 565
 
@@ -1012,7 +1018,9 @@  discard block
 block discarded – undo
1012 1018
     if (empty($userId) && empty($sessionId) && empty($courseId)) {
1013 1019
         // try original values
1014 1020
 
1015
-        if ($debug) error_log('try original values');
1021
+        if ($debug) {
1022
+            error_log('try original values');
1023
+        }
1016 1024
 
1017 1025
         $userIdName = isset($params['original_user_id_name']) ? $params['original_user_id_name'] : 0;
1018 1026
         $userIdValue = isset($params['original_user_id_value']) ? $params['original_user_id_value'] : 0;
@@ -1044,9 +1052,15 @@  discard block
 block discarded – undo
1044 1052
         );
1045 1053
     }
1046 1054
 
1047
-    if ($debug) error_log('$userId found: '. $userId);
1048
-    if ($debug) error_log('$courseId found: '. $courseId);
1049
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1055
+    if ($debug) {
1056
+        error_log('$userId found: '. $userId);
1057
+    }
1058
+    if ($debug) {
1059
+        error_log('$courseId found: '. $courseId);
1060
+    }
1061
+    if ($debug) {
1062
+        error_log('$sessionId found: '. $sessionId);
1063
+    }
1050 1064
 
1051 1065
     return [
1052 1066
         'user_id' => $userId,
@@ -1076,13 +1090,17 @@  discard block
 block discarded – undo
1076 1090
 {
1077 1091
     global $debug;
1078 1092
 
1079
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1093
+    if ($debug) {
1094
+        error_log('WSSubscribeTeacherToSessionCourse');
1095
+    }
1080 1096
 
1081 1097
     if (!WSHelperVerifyKey($params)) {
1082 1098
         return returnError(WS_ERROR_SECRET_KEY);
1083 1099
     }
1084 1100
 
1085
-    if ($debug) error_log('Params '. print_r($params, 1));
1101
+    if ($debug) {
1102
+        error_log('Params '. print_r($params, 1));
1103
+    }
1086 1104
 
1087 1105
     $params = parseCourseSessionUserParams($params);
1088 1106
 
@@ -1095,13 +1113,17 @@  discard block
 block discarded – undo
1095 1113
     $result = 0;
1096 1114
 
1097 1115
     if (!empty($coaches)) {
1098
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1116
+        if ($debug) {
1117
+            error_log('Coaches:  '. print_r($coaches, 1));
1118
+        }
1099 1119
         if (in_array($userId, $coaches)) {
1100 1120
             $result = 1;
1101 1121
         }
1102 1122
     }
1103 1123
 
1104
-    if ($debug) error_log('Result:  '. $result);
1124
+    if ($debug) {
1125
+        error_log('Result:  '. $result);
1126
+    }
1105 1127
 
1106 1128
     return $result;
1107 1129
 }
@@ -1127,13 +1149,17 @@  discard block
 block discarded – undo
1127 1149
 {
1128 1150
     global $debug;
1129 1151
 
1130
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1152
+    if ($debug) {
1153
+        error_log('WSSubscribeTeacherToSessionCourse');
1154
+    }
1131 1155
 
1132 1156
     if (!WSHelperVerifyKey($params)) {
1133 1157
         return returnError(WS_ERROR_SECRET_KEY);
1134 1158
     }
1135 1159
 
1136
-    if ($debug) error_log('Params '. print_r($params, 1));
1160
+    if ($debug) {
1161
+        error_log('Params '. print_r($params, 1));
1162
+    }
1137 1163
 
1138 1164
     $params = parseCourseSessionUserParams($params);
1139 1165
 
@@ -1147,7 +1173,9 @@  discard block
 block discarded – undo
1147 1173
     $result = 0;
1148 1174
 
1149 1175
     if (!empty($coaches)) {
1150
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1176
+        if ($debug) {
1177
+            error_log('Coaches:  ' . print_r($coaches, 1));
1178
+        }
1151 1179
         if (!in_array($userId, $coaches)) {
1152 1180
             $result = 1;
1153 1181
         }
@@ -1155,7 +1183,9 @@  discard block
 block discarded – undo
1155 1183
         $result = 1;
1156 1184
     }
1157 1185
 
1158
-    if ($debug) error_log('Final Result: '. $result);
1186
+    if ($debug) {
1187
+        error_log('Final Result: '. $result);
1188
+    }
1159 1189
 
1160 1190
     return $result;
1161 1191
 }
@@ -1207,8 +1237,12 @@  discard block
 block discarded – undo
1207 1237
 {
1208 1238
     global $_user, $_configuration, $debug;
1209 1239
     $debug = 1;
1210
-    if ($debug) error_log('WSCreateUserPasswordCrypted');
1211
-    if ($debug) error_log(print_r($params,1));
1240
+    if ($debug) {
1241
+        error_log('WSCreateUserPasswordCrypted');
1242
+    }
1243
+    if ($debug) {
1244
+        error_log(print_r($params,1));
1245
+    }
1212 1246
 
1213 1247
     if (!WSHelperVerifyKey($params)) {
1214 1248
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1244,22 +1278,30 @@  discard block
 block discarded – undo
1244 1278
         if ($_configuration['password_encryption'] === $encrypt_method ) {
1245 1279
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1246 1280
                 $msg = "Encryption $encrypt_method is invalid";
1247
-                if ($debug) error_log($msg);
1281
+                if ($debug) {
1282
+                    error_log($msg);
1283
+                }
1248 1284
                 return $msg;
1249 1285
 
1250 1286
             } else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
1251 1287
                 $msg = "Encryption $encrypt_method is invalid";
1252
-                if ($debug) error_log($msg);
1288
+                if ($debug) {
1289
+                    error_log($msg);
1290
+                }
1253 1291
                 return $msg;
1254 1292
             }
1255 1293
         } else {
1256 1294
             $msg = "This encryption $encrypt_method is not configured";
1257
-            if ($debug) error_log($msg);
1295
+            if ($debug) {
1296
+                error_log($msg);
1297
+            }
1258 1298
             return $msg;
1259 1299
         }
1260 1300
     } else {
1261 1301
         $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured';
1262
-        if ($debug) error_log($msg);
1302
+        if ($debug) {
1303
+            error_log($msg);
1304
+        }
1263 1305
         return $msg;
1264 1306
     }
1265 1307
 
@@ -1279,10 +1321,14 @@  discard block
 block discarded – undo
1279 1321
         $original_user_id_name
1280 1322
     );
1281 1323
 
1282
-    if ($debug) error_log('Ready to create user');
1324
+    if ($debug) {
1325
+        error_log('Ready to create user');
1326
+    }
1283 1327
 
1284 1328
     if ($user_id > 0) {
1285
-        if ($debug) error_log('User found with id: '.$user_id);
1329
+        if ($debug) {
1330
+            error_log('User found with id: '.$user_id);
1331
+        }
1286 1332
 
1287 1333
         // Check whether user is not active
1288 1334
         //@todo why this condition exists??
@@ -1293,7 +1339,9 @@  discard block
 block discarded – undo
1293 1339
         $count_check_user = Database::num_rows($resu);
1294 1340
         if ($count_check_user > 0) {
1295 1341
 
1296
-            if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1342
+            if ($debug) {
1343
+                error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1344
+            }
1297 1345
 
1298 1346
             $sql = "UPDATE $table_user SET
1299 1347
                     lastname='".Database::escape_string($lastName)."',
@@ -1313,7 +1361,9 @@  discard block
 block discarded – undo
1313 1361
                     active='1',
1314 1362
                     hr_dept_id=".intval($hr_dept_id);
1315 1363
             $sql .=    " WHERE user_id='".$r_check_user[0]."'";
1316
-            if ($debug) error_log($sql);
1364
+            if ($debug) {
1365
+                error_log($sql);
1366
+            }
1317 1367
             Database::query($sql);
1318 1368
 
1319 1369
             if (is_array($extra_list) && count($extra_list) > 0) {
@@ -1330,11 +1380,15 @@  discard block
 block discarded – undo
1330 1380
             }
1331 1381
             return $r_check_user[0];
1332 1382
         } else {
1333
-            if ($debug) error_log('User exists but is active. Cant be updated');
1383
+            if ($debug) {
1384
+                error_log('User exists but is active. Cant be updated');
1385
+            }
1334 1386
             return 0;
1335 1387
         }
1336 1388
     } else {
1337
-        if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1389
+        if ($debug) {
1390
+            error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1391
+        }
1338 1392
     }
1339 1393
 
1340 1394
     // Default language.
@@ -1350,7 +1404,9 @@  discard block
 block discarded – undo
1350 1404
 
1351 1405
     // First check wether the login already exists
1352 1406
     if (!UserManager::is_username_available($loginName)) {
1353
-        if ($debug) error_log("Username $loginName is not available");
1407
+        if ($debug) {
1408
+            error_log("Username $loginName is not available");
1409
+        }
1354 1410
         return 0;
1355 1411
     }
1356 1412
 
@@ -1372,7 +1428,9 @@  discard block
 block discarded – undo
1372 1428
             expiration_date     = '".Database::escape_string($expiration_date)."',
1373 1429
             hr_dept_id          = '".Database::escape_string($hr_dept_id)."',
1374 1430
             active              = '".Database::escape_string($active)."'";
1375
-    if ($debug) error_log($sql);
1431
+    if ($debug) {
1432
+        error_log($sql);
1433
+    }
1376 1434
 
1377 1435
     Database::query($sql);
1378 1436
     $return = Database::insert_id();
@@ -1384,7 +1442,9 @@  discard block
 block discarded – undo
1384 1442
 
1385 1443
         $url_id = api_get_current_access_url_id();
1386 1444
         UrlManager::add_user_to_url($return, $url_id);
1387
-        if ($debug) error_log("Adding user_id = $return to URL id $url_id ");
1445
+        if ($debug) {
1446
+            error_log("Adding user_id = $return to URL id $url_id ");
1447
+        }
1388 1448
 
1389 1449
         // Create extra field for the original_user_id_name
1390 1450
         UserManager::create_extra_field(
@@ -1421,7 +1481,9 @@  discard block
 block discarded – undo
1421 1481
             }
1422 1482
         }
1423 1483
     } else {
1424
-        if ($debug) error_log('Error while inserting a user');
1484
+        if ($debug) {
1485
+            error_log('Error while inserting a user');
1486
+        }
1425 1487
         return 0;
1426 1488
     }
1427 1489
 
@@ -4480,7 +4542,9 @@  discard block
 block discarded – undo
4480 4542
     if (!WSHelperVerifyKey($params)) {
4481 4543
         return returnError(WS_ERROR_SECRET_KEY);
4482 4544
     }
4483
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4545
+    if ($debug) {
4546
+        error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4547
+    }
4484 4548
 
4485 4549
     $results = array();
4486 4550
     $userscourses = $params['userscourses'];
@@ -4499,7 +4563,9 @@  discard block
 block discarded – undo
4499 4563
             $original_user_id['original_user_id_value'],
4500 4564
             $original_user_id['original_user_id_name']
4501 4565
         );
4502
-        if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4566
+        if ($debug) {
4567
+            error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4568
+        }
4503 4569
 
4504 4570
         if ($user_id == 0) {
4505 4571
             // If user was not found, there was a problem
@@ -4517,13 +4583,19 @@  discard block
 block discarded – undo
4517 4583
                 // Course was not found
4518 4584
                 $resultValue = 0;
4519 4585
             } else {
4520
-                if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4586
+                if ($debug) {
4587
+                    error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4588
+                }
4521 4589
                 $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false);
4522 4590
                 if ($result) {
4523 4591
                     $resultValue = 1;
4524
-                    if ($debug) error_log('WSSubscribeUserToCourse subscribed');
4592
+                    if ($debug) {
4593
+                        error_log('WSSubscribeUserToCourse subscribed');
4594
+                    }
4525 4595
                 } else {
4526
-                    if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: ');
4596
+                    if ($debug) {
4597
+                        error_log('WSSubscribeUserToCourse NOT subscribed: ');
4598
+                    }
4527 4599
                 }
4528 4600
             }
4529 4601
         }
@@ -4581,8 +4653,12 @@  discard block
 block discarded – undo
4581 4653
 function WSSubscribeUserToCourseSimple($params) {
4582 4654
     global $debug;
4583 4655
 
4584
-    if ($debug) error_log('WSSubscribeUserToCourseSimple');
4585
-    if ($debug) error_log('Params '. print_r($params, 1));
4656
+    if ($debug) {
4657
+        error_log('WSSubscribeUserToCourseSimple');
4658
+    }
4659
+    if ($debug) {
4660
+        error_log('Params '. print_r($params, 1));
4661
+    }
4586 4662
     if (!WSHelperVerifyKey($params)) {
4587 4663
         return returnError(WS_ERROR_SECRET_KEY);
4588 4664
     }
@@ -4597,7 +4673,9 @@  discard block
 block discarded – undo
4597 4673
     if (empty($user_data)) {
4598 4674
         // If user was not found, there was a problem
4599 4675
         $result = "User $user_id does not exist";
4600
-        if ($debug) error_log($result);
4676
+        if ($debug) {
4677
+            error_log($result);
4678
+        }
4601 4679
         return $result;
4602 4680
     }
4603 4681
     if (!empty($course_code)) {
@@ -4605,14 +4683,22 @@  discard block
 block discarded – undo
4605 4683
         if (empty($course_data)) {
4606 4684
             // Course was not found
4607 4685
             $result = "Course $course_code does not exist in the platform ";
4608
-            if ($debug) error_log($result);
4686
+            if ($debug) {
4687
+                error_log($result);
4688
+            }
4609 4689
         } else {
4610
-            if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4690
+            if ($debug) {
4691
+                error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4692
+            }
4611 4693
             if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) {
4612 4694
                 $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions ';
4613
-                if ($debug) error_log($result);
4695
+                if ($debug) {
4696
+                    error_log($result);
4697
+                }
4614 4698
             } else {
4615
-                if ($debug) error_log('User registered to the course: '.$course_data['code']);
4699
+                if ($debug) {
4700
+                    error_log('User registered to the course: '.$course_data['code']);
4701
+                }
4616 4702
                 $result = 1;
4617 4703
             }
4618 4704
         }
@@ -4664,8 +4750,12 @@  discard block
 block discarded – undo
4664 4750
 // define the method WSGetUser
4665 4751
 function WSGetUser($params) {
4666 4752
     global $debug;
4667
-    if ($debug) error_log('WSGetUser');
4668
-    if ($debug) error_log('$params: '.print_r($params, 1));
4753
+    if ($debug) {
4754
+        error_log('WSGetUser');
4755
+    }
4756
+    if ($debug) {
4757
+        error_log('$params: '.print_r($params, 1));
4758
+    }
4669 4759
 
4670 4760
     if (!WSHelperVerifyKey($params)) {
4671 4761
         return returnError(WS_ERROR_SECRET_KEY);
@@ -4718,8 +4808,12 @@  discard block
 block discarded – undo
4718 4808
 // define the method WSGetUserFromUsername
4719 4809
 function WSGetUserFromUsername($params) {
4720 4810
     global $debug;
4721
-    if ($debug) error_log('WSGetUserFromUsername');
4722
-    if ($debug) error_log('$params: '.print_r($params, 1));
4811
+    if ($debug) {
4812
+        error_log('WSGetUserFromUsername');
4813
+    }
4814
+    if ($debug) {
4815
+        error_log('$params: '.print_r($params, 1));
4816
+    }
4723 4817
 
4724 4818
     if (!WSHelperVerifyKey($params)) {
4725 4819
         return returnError(WS_ERROR_SECRET_KEY);
@@ -5169,7 +5263,9 @@  discard block
 block discarded – undo
5169 5263
                 $orig_session_id_value[] = $original_session_id_value;
5170 5264
                 $results[] = 1;
5171 5265
 
5172
-                if ($debug) error_log("subscribe user:$user_id to session $sessionId");
5266
+                if ($debug) {
5267
+                    error_log("subscribe user:$user_id to session $sessionId");
5268
+                }
5173 5269
             }
5174 5270
         }
5175 5271
     } // end principal foreach
@@ -5253,7 +5349,9 @@  discard block
 block discarded – undo
5253 5349
                 SESSION_VISIBLE_READ_ONLY,
5254 5350
                 false
5255 5351
             );
5256
-            if ($debug) error_log('User registered to the course: '.$session_id);
5352
+            if ($debug) {
5353
+                error_log('User registered to the course: '.$session_id);
5354
+            }
5257 5355
             $result = 1;
5258 5356
         }
5259 5357
     }
@@ -5399,7 +5497,9 @@  discard block
 block discarded – undo
5399 5497
                 $orig_session_id_value[] = $original_session_id_value;
5400 5498
                 $results[] = 1;
5401 5499
 
5402
-                if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session");
5500
+                if ($debug) {
5501
+                    error_log("Unsubscribe user:$user_id to session:$id_session");
5502
+                }
5403 5503
             }
5404 5504
         }
5405 5505
     } // end principal foreach
@@ -5546,7 +5646,9 @@  discard block
 block discarded – undo
5546 5646
         return returnError(WS_ERROR_SECRET_KEY);
5547 5647
     }
5548 5648
 
5549
-    if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5649
+    if ($debug) {
5650
+        error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5651
+    }
5550 5652
 
5551 5653
     $coursessessions_params = $params['coursessessions'];
5552 5654
     $results = array();
@@ -5584,7 +5686,9 @@  discard block
 block discarded – undo
5584 5686
                     array($courseInfo['real_id']),
5585 5687
                     false
5586 5688
                 );
5587
-                if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5689
+                if ($debug) {
5690
+                    error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5691
+                }
5588 5692
 
5589 5693
                 $results[] = 1;
5590 5694
                 $orig_course_id_value[] = $original_session_id_value;
@@ -5935,8 +6039,7 @@  discard block
 block discarded – undo
5935 6039
             UserManager::create_extra_field($params['original_user_id_name'], 1, $params['original_user_id_name'], '');
5936 6040
             // Save the external system's id into user_field_value table.
5937 6041
             UserManager::update_extra_field_value($user_id, $params['original_user_id_name'], $params['original_user_id_value']);
5938
-        }
5939
-        else {
6042
+        } else {
5940 6043
             return 0;
5941 6044
         }
5942 6045
     }
@@ -6086,8 +6189,12 @@  discard block
 block discarded – undo
6086 6189
 {
6087 6190
     global $debug;
6088 6191
 
6089
-    if ($debug) error_log('WSUserSubscribedInCourse');
6090
-    if ($debug) error_log('Params '. print_r($params, 1));
6192
+    if ($debug) {
6193
+        error_log('WSUserSubscribedInCourse');
6194
+    }
6195
+    if ($debug) {
6196
+        error_log('Params '. print_r($params, 1));
6197
+    }
6091 6198
     if (!WSHelperVerifyKey($params)) {
6092 6199
 
6093 6200
         return returnError(WS_ERROR_SECRET_KEY);
Please login to merge, or discard this patch.
main/webservices/access_url.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,19 +58,22 @@  discard block
 block discarded – undo
58 58
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
59 59
         $ip = trim($ip1);
60 60
     }
61
-    if ($debug)
62
-        error_log("ip: $ip");
61
+    if ($debug) {
62
+            error_log("ip: $ip");
63
+    }
63 64
     // Check if a file that limits access from webservices exists and contains
64 65
     // the restraining check
65 66
     if (is_file('webservice-auth-ip.conf.php')) {
66 67
         include 'webservice-auth-ip.conf.php';
67
-        if ($debug)
68
-            error_log("webservice-auth-ip.conf.php file included");
68
+        if ($debug) {
69
+                    error_log("webservice-auth-ip.conf.php file included");
70
+        }
69 71
         if (!empty($ws_auth_ip)) {
70 72
             $check_ip = true;
71 73
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
72
-            if ($debug)
73
-                error_log("ip_matches: $ip_matches");
74
+            if ($debug) {
75
+                            error_log("ip_matches: $ip_matches");
76
+            }
74 77
         }
75 78
     }
76 79
 
@@ -87,8 +90,9 @@  discard block
 block discarded – undo
87 90
 
88 91
     $result = api_is_valid_secret_key($secret_key, $security_key);
89 92
     //error_log($secret_key.'-'.$security_key);
90
-    if ($debug)
91
-        error_log('WSHelperVerifyKey result: '.intval($result));
93
+    if ($debug) {
94
+            error_log('WSHelperVerifyKey result: '.intval($result));
95
+    }
92 96
     return $result;
93 97
 }
94 98
 
Please login to merge, or discard this patch.
main/webservices/lp.php 1 patch
Braces   +48 added lines, -20 removed lines patch added patch discarded remove patch
@@ -48,19 +48,22 @@  discard block
 block discarded – undo
48 48
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
49 49
         $ip = trim($ip1);
50 50
     }
51
-    if ($debug)
52
-        error_log("ip: $ip");
51
+    if ($debug) {
52
+            error_log("ip: $ip");
53
+    }
53 54
     // Check if a file that limits access from webservices exists and contains
54 55
     // the restraining check
55 56
     if (is_file('webservice-auth-ip.conf.php')) {
56 57
         include 'webservice-auth-ip.conf.php';
57
-        if ($debug)
58
-            error_log("webservice-auth-ip.conf.php file included");
58
+        if ($debug) {
59
+                    error_log("webservice-auth-ip.conf.php file included");
60
+        }
59 61
         if (!empty($ws_auth_ip)) {
60 62
             $check_ip = true;
61 63
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
62
-            if ($debug)
63
-                error_log("ip_matches: $ip_matches");
64
+            if ($debug) {
65
+                            error_log("ip_matches: $ip_matches");
66
+            }
64 67
         }
65 68
     }
66 69
 
@@ -76,8 +79,9 @@  discard block
 block discarded – undo
76 79
     }
77 80
     $result = api_is_valid_secret_key($secret_key, $security_key);
78 81
     //error_log($secret_key.'-'.$security_key);
79
-    if ($debug)
80
-        error_log('WSHelperVerifyKey result: '.intval($result));
82
+    if ($debug) {
83
+            error_log('WSHelperVerifyKey result: '.intval($result));
84
+    }
81 85
     return $result;
82 86
 }
83 87
 
@@ -140,7 +144,9 @@  discard block
 block discarded – undo
140 144
     if (!WSHelperVerifyKey($params)) {
141 145
         return return_error(WS_ERROR_SECRET_KEY);
142 146
     }
143
-    if ($debug) error_log('WSImportLP');
147
+    if ($debug) {
148
+        error_log('WSImportLP');
149
+    }
144 150
 
145 151
     $courseIdName = $params['course_id_name'];
146 152
     $courseIdValue = $params['course_id_value'];
@@ -156,7 +162,9 @@  discard block
 block discarded – undo
156 162
     $courseId = $courseInfo['real_id'];
157 163
 
158 164
     if (empty($courseInfo)) {
159
-        if ($debug) error_log('Course not found');
165
+        if ($debug) {
166
+            error_log('Course not found');
167
+        }
160 168
         return 'Course not found';
161 169
     }
162 170
 
@@ -169,7 +177,9 @@  discard block
 block discarded – undo
169 177
 
170 178
         if (empty($sessionId)) {
171 179
 
172
-            if ($debug) error_log('Session not found');
180
+            if ($debug) {
181
+                error_log('Session not found');
182
+            }
173 183
             return 'Session not found';
174 184
         }
175 185
     }
@@ -196,7 +206,9 @@  discard block
 block discarded – undo
196 206
     $manifest = $oScorm->import_package($fileInfo, '', $courseInfo);
197 207
 
198 208
     if (!$manifest) {
199
-        if ($debug) error_log('manifest.xml file not found');
209
+        if ($debug) {
210
+            error_log('manifest.xml file not found');
211
+        }
200 212
         //if api_set_failure
201 213
         return 'manifest.xml file not found';
202 214
     }
@@ -215,10 +227,14 @@  discard block
 block discarded – undo
215 227
         $oScorm->set_maker($maker, $courseId);
216 228
         //$oScorm->set_jslib('scorm_api.php');
217 229
 
218
-        if ($debug) error_log('scorm was added');
230
+        if ($debug) {
231
+            error_log('scorm was added');
232
+        }
219 233
         return 1;
220 234
     } else {
221
-        if ($debug) error_log('manifest data empty');
235
+        if ($debug) {
236
+            error_log('manifest data empty');
237
+        }
222 238
         return 'manifest data empty';
223 239
     }
224 240
 }
@@ -311,7 +327,9 @@  discard block
 block discarded – undo
311 327
     );
312 328
 
313 329
     if (empty($courseInfo)) {
314
-        if ($debug) error_log("Course not found: $courseIdName : $courseIdValue");
330
+        if ($debug) {
331
+            error_log("Course not found: $courseIdName : $courseIdValue");
332
+        }
315 333
         return 'Course not found';
316 334
     }
317 335
 
@@ -326,7 +344,9 @@  discard block
 block discarded – undo
326 344
 
327 345
         if (empty($sessionId)) {
328 346
 
329
-            if ($debug) error_log('Session not found');
347
+            if ($debug) {
348
+                error_log('Session not found');
349
+            }
330 350
             return 'Session not found';
331 351
         }
332 352
     }
@@ -407,7 +427,9 @@  discard block
 block discarded – undo
407 427
     );
408 428
 
409 429
     if (empty($courseInfo)) {
410
-        if ($debug) error_log("Course not found: $courseIdName : $courseIdValue");
430
+        if ($debug) {
431
+            error_log("Course not found: $courseIdName : $courseIdValue");
432
+        }
411 433
         return 'Course not found';
412 434
     }
413 435
     $courseId = $courseInfo['real_id'];
@@ -432,7 +454,9 @@  discard block
 block discarded – undo
432 454
 
433 455
     $lp = new learnpath($courseCode, $lpId, null);
434 456
     if ($lp) {
435
-        if ($debug) error_log("LP deleted $lpId");
457
+        if ($debug) {
458
+            error_log("LP deleted $lpId");
459
+        }
436 460
 
437 461
         $course_dir = $courseInfo['directory'] . '/document';
438 462
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
@@ -448,7 +472,9 @@  discard block
 block discarded – undo
448 472
                 if ($item) {
449 473
                     $documentId = $item->get_path();
450 474
 
451
-                    if ($debug) error_log("lp item id found #$itemId");
475
+                    if ($debug) {
476
+                        error_log("lp item id found #$itemId");
477
+                    }
452 478
 
453 479
                     $documentInfo = DocumentManager::get_document_data_by_id(
454 480
                         $documentId,
@@ -474,7 +500,9 @@  discard block
 block discarded – undo
474 500
                         }
475 501
                     }
476 502
                 } else {
477
-                    if ($debug) error_log("Document not found #$itemId");
503
+                    if ($debug) {
504
+                        error_log("Document not found #$itemId");
505
+                    }
478 506
                 }
479 507
             }
480 508
         }
Please login to merge, or discard this patch.