Test Failed
Branch develop (86e751)
by Laurent
34:11
created
htdocs/core/filemanagerdol/connectors/php/io.php 4 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function GetParentFolder($folderPath)
133 133
 {
134
-    $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
135
-    return preg_replace($sPattern, '', $folderPath);
134
+	$sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
135
+	return preg_replace($sPattern, '', $folderPath);
136 136
 }
137 137
 
138 138
 /**
@@ -214,41 +214,41 @@  discard block
 block discarded – undo
214 214
  */
215 215
 function GetRootPath()
216 216
 {
217
-    if (!isset($_SERVER)) {
218
-        global $_SERVER;
219
-    }
220
-    $sRealPath = realpath('./');
221
-    // #2124 ensure that no slash is at the end
222
-    $sRealPath = rtrim($sRealPath,"\\/");
217
+	if (!isset($_SERVER)) {
218
+		global $_SERVER;
219
+	}
220
+	$sRealPath = realpath('./');
221
+	// #2124 ensure that no slash is at the end
222
+	$sRealPath = rtrim($sRealPath,"\\/");
223 223
 
224
-    $sSelfPath = $_SERVER['PHP_SELF'] ;
225
-    $sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
224
+	$sSelfPath = $_SERVER['PHP_SELF'] ;
225
+	$sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
226 226
 
227
-    $sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath);
227
+	$sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath);
228 228
 
229
-    $position = strpos($sRealPath, $sSelfPath);
229
+	$position = strpos($sRealPath, $sSelfPath);
230 230
 
231
-    // This can check only that this script isn't run from a virtual dir
232
-    // But it avoids the problems that arise if it isn't checked
233
-    if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) )
234
-        SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
231
+	// This can check only that this script isn't run from a virtual dir
232
+	// But it avoids the problems that arise if it isn't checked
233
+	if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) )
234
+		SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
235 235
 
236
-    return substr($sRealPath, 0, $position);
236
+	return substr($sRealPath, 0, $position);
237 237
 }
238 238
 
239 239
 // Emulate the asp Server.mapPath function.
240 240
 // given an url path return the physical directory that it corresponds to
241 241
 function Server_MapPath( $path )
242 242
 {
243
-    // This function is available only for Apache
244
-    if (function_exists('apache_lookup_uri')) {
245
-        $info = apache_lookup_uri($path);
246
-        return $info->filename . $info->path_info ;
247
-    }
248
-
249
-    // This isn't correct but for the moment there's no other solution
250
-    // If this script is under a virtual directory or symlink it will detect the problem and stop
251
-    return GetRootPath() . $path ;
243
+	// This function is available only for Apache
244
+	if (function_exists('apache_lookup_uri')) {
245
+		$info = apache_lookup_uri($path);
246
+		return $info->filename . $info->path_info ;
247
+	}
248
+
249
+	// This isn't correct but for the moment there's no other solution
250
+	// If this script is under a virtual directory or symlink it will detect the problem and stop
251
+	return GetRootPath() . $path ;
252 252
 }
253 253
 
254 254
 /**
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
  * @param   string $sFolder       sFolder
30 30
  * @return  string                Combined path
31 31
  */
32
-function CombinePaths( $sBasePath, $sFolder )
32
+function CombinePaths($sBasePath, $sFolder)
33 33
 {
34
-	return RemoveFromEnd($sBasePath, '/') . '/' . RemoveFromStart($sFolder, '/');
34
+	return RemoveFromEnd($sBasePath, '/').'/'.RemoveFromStart($sFolder, '/');
35 35
 }
36 36
 /**
37 37
  * GetResourceTypePath
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
  */
43 43
 function GetResourceTypePath($resourceType, $sCommand)
44 44
 {
45
-	global $Config ;
45
+	global $Config;
46 46
 
47 47
 	if ($sCommand == "QuickUpload")
48
-		return $Config['QuickUploadPath'][$resourceType] ;
48
+		return $Config['QuickUploadPath'][$resourceType];
49 49
 	else
50
-		return $Config['FileTypesPath'][$resourceType] ;
50
+		return $Config['FileTypesPath'][$resourceType];
51 51
 }
52 52
 
53 53
 /**
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function GetResourceTypeDirectory($resourceType, $sCommand)
61 61
 {
62
-	global $Config ;
62
+	global $Config;
63 63
 	if ($sCommand == "QuickUpload")
64 64
 	{
65
-		if ( strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0)
66
-			return $Config['QuickUploadAbsolutePath'][$resourceType] ;
65
+		if (strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0)
66
+			return $Config['QuickUploadAbsolutePath'][$resourceType];
67 67
 
68 68
 		// Map the "UserFiles" path to a local directory.
69 69
 		return Server_MapPath($Config['QuickUploadPath'][$resourceType]);
70 70
 	}
71 71
 	else
72 72
 	{
73
-		if ( strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0)
74
-			return $Config['FileTypesAbsolutePath'][$resourceType] ;
73
+		if (strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0)
74
+			return $Config['FileTypesAbsolutePath'][$resourceType];
75 75
 
76 76
 		// Map the "UserFiles" path to a local directory.
77 77
 		return Server_MapPath($Config['FileTypesPath'][$resourceType]);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
 	// Ensure that the directory exists.
118 118
 	$sErrorMsg = CreateServerFolder($sResourceTypePath);
119
-	if ( $sErrorMsg != '' )
119
+	if ($sErrorMsg != '')
120 120
 		SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})");
121 121
 
122 122
 	// Return the resource type directory combined with the required path.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function GetParentFolder($folderPath)
133 133
 {
134
-    $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
134
+    $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-";
135 135
     return preg_replace($sPattern, '', $folderPath);
136 136
 }
137 137
 
@@ -144,50 +144,50 @@  discard block
 block discarded – undo
144 144
  */
145 145
 function CreateServerFolder($folderPath, $lastFolder = null)
146 146
 {
147
-	global $Config ;
147
+	global $Config;
148 148
 	$sParent = GetParentFolder($folderPath);
149 149
 
150 150
 	// Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms
151
-	while ( strpos($folderPath, '//') !== false )
151
+	while (strpos($folderPath, '//') !== false)
152 152
 	{
153 153
 		$folderPath = str_replace('//', '/', $folderPath);
154 154
 	}
155 155
 
156 156
 	// Check if the parent exists, or create it.
157
-	if ( !empty($sParent) && !file_exists($sParent))
157
+	if (!empty($sParent) && !file_exists($sParent))
158 158
 	{
159 159
 		//prevents agains infinite loop when we can't create root folder
160
-		if ( !is_null($lastFolder) && $lastFolder === $sParent) {
161
-			return "Can't create $folderPath directory" ;
160
+		if (!is_null($lastFolder) && $lastFolder === $sParent) {
161
+			return "Can't create $folderPath directory";
162 162
 		}
163 163
 
164 164
 		$sErrorMsg = CreateServerFolder($sParent, $folderPath);
165
-		if ( $sErrorMsg != '' )
166
-			return $sErrorMsg ;
165
+		if ($sErrorMsg != '')
166
+			return $sErrorMsg;
167 167
 	}
168 168
 
169
-	if ( !file_exists($folderPath))
169
+	if (!file_exists($folderPath))
170 170
 	{
171 171
 		// Turn off all error reporting.
172 172
 		error_reporting(0);
173 173
 
174
-		$php_errormsg = '' ;
174
+		$php_errormsg = '';
175 175
 		// Enable error tracking to catch the error.
176 176
 		ini_set('track_errors', '1');
177 177
 
178
-		if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] )
178
+		if (isset($Config['ChmodOnFolderCreate']) && !$Config['ChmodOnFolderCreate'])
179 179
 		{
180 180
 			mkdir($folderPath);
181 181
 		}
182 182
 		else
183 183
 		{
184 184
 			$permissions = '0777';
185
-			if ( isset( $Config['ChmodOnFolderCreate'] ) && $Config['ChmodOnFolderCreate'])
185
+			if (isset($Config['ChmodOnFolderCreate']) && $Config['ChmodOnFolderCreate'])
186 186
 			{
187 187
 				$permissions = (string) $Config['ChmodOnFolderCreate'];
188 188
 			}
189 189
 			$permissionsdec = octdec($permissions);
190
-			$permissionsdec |= octdec('0111');  // Set x bit required for directories
190
+			$permissionsdec |= octdec('0111'); // Set x bit required for directories
191 191
 			dol_syslog("io.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec));
192 192
 			// To create the folder with 0777 permissions, we need to set umask to zero.
193 193
 			$oldumask = umask(0);
@@ -195,16 +195,16 @@  discard block
 block discarded – undo
195 195
 			umask($oldumask);
196 196
 		}
197 197
 
198
-		$sErrorMsg = $php_errormsg ;
198
+		$sErrorMsg = $php_errormsg;
199 199
 
200 200
 		// Restore the configurations.
201 201
 		ini_restore('track_errors');
202 202
 		ini_restore('error_reporting');
203 203
 
204
-		return $sErrorMsg ;
204
+		return $sErrorMsg;
205 205
 	}
206 206
 	else
207
-		return '' ;
207
+		return '';
208 208
 }
209 209
 
210 210
 /**
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
     }
220 220
     $sRealPath = realpath('./');
221 221
     // #2124 ensure that no slash is at the end
222
-    $sRealPath = rtrim($sRealPath,"\\/");
222
+    $sRealPath = rtrim($sRealPath, "\\/");
223 223
 
224
-    $sSelfPath = $_SERVER['PHP_SELF'] ;
224
+    $sSelfPath = $_SERVER['PHP_SELF'];
225 225
     $sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
226 226
 
227 227
     $sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
     // This can check only that this script isn't run from a virtual dir
232 232
     // But it avoids the problems that arise if it isn't checked
233
-    if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) )
233
+    if ($position === false || $position <> strlen($sRealPath) - strlen($sSelfPath))
234 234
         SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
235 235
 
236 236
     return substr($sRealPath, 0, $position);
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
 
239 239
 // Emulate the asp Server.mapPath function.
240 240
 // given an url path return the physical directory that it corresponds to
241
-function Server_MapPath( $path )
241
+function Server_MapPath($path)
242 242
 {
243 243
     // This function is available only for Apache
244 244
     if (function_exists('apache_lookup_uri')) {
245 245
         $info = apache_lookup_uri($path);
246
-        return $info->filename . $info->path_info ;
246
+        return $info->filename.$info->path_info;
247 247
     }
248 248
 
249 249
     // This isn't correct but for the moment there's no other solution
250 250
     // If this script is under a virtual directory or symlink it will detect the problem and stop
251
-    return GetRootPath() . $path ;
251
+    return GetRootPath().$path;
252 252
 }
253 253
 
254 254
 /**
@@ -260,18 +260,18 @@  discard block
 block discarded – undo
260 260
  */
261 261
 function IsAllowedExt($sExtension, $resourceType)
262 262
 {
263
-	global $Config ;
263
+	global $Config;
264 264
 	// Get the allowed and denied extensions arrays.
265
-	$arAllowed	= $Config['AllowedExtensions'][$resourceType] ;
266
-	$arDenied	= $Config['DeniedExtensions'][$resourceType] ;
265
+	$arAllowed = $Config['AllowedExtensions'][$resourceType];
266
+	$arDenied = $Config['DeniedExtensions'][$resourceType];
267 267
 
268
-	if ( count($arAllowed) > 0 && !in_array($sExtension, $arAllowed))
269
-		return false ;
268
+	if (count($arAllowed) > 0 && !in_array($sExtension, $arAllowed))
269
+		return false;
270 270
 
271
-	if ( count($arDenied) > 0 && in_array($sExtension, $arDenied))
272
-		return false ;
271
+	if (count($arDenied) > 0 && in_array($sExtension, $arDenied))
272
+		return false;
273 273
 
274
-	return true ;
274
+	return true;
275 275
 }
276 276
 
277 277
 /**
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
  */
283 283
 function IsAllowedType($resourceType)
284 284
 {
285
-	global $Config ;
286
-	if ( !in_array($resourceType, $Config['ConfigAllowedTypes']))
287
-		return false ;
285
+	global $Config;
286
+	if (!in_array($resourceType, $Config['ConfigAllowedTypes']))
287
+		return false;
288 288
 
289
-	return true ;
289
+	return true;
290 290
 }
291 291
 
292 292
 /**
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
  */
298 298
 function IsAllowedCommand($sCommand)
299 299
 {
300
-	global $Config ;
300
+	global $Config;
301 301
 
302
-	if (! in_array($sCommand, $Config['ConfigAllowedCommands']))
303
-		return false ;
302
+	if (!in_array($sCommand, $Config['ConfigAllowedCommands']))
303
+		return false;
304 304
 
305
-	return true ;
305
+	return true;
306 306
 }
307 307
 
308 308
 /**
@@ -315,59 +315,59 @@  discard block
 block discarded – undo
315 315
 	if (!isset($_GET)) {
316 316
 		global $_GET;
317 317
 	}
318
-	$sCurrentFolder	= isset( $_GET['CurrentFolder'] ) ? GETPOST('CurrentFolder', '', 1) : '/' ;
318
+	$sCurrentFolder = isset($_GET['CurrentFolder']) ? GETPOST('CurrentFolder', '', 1) : '/';
319 319
 
320 320
 	// Check the current folder syntax (must begin and start with a slash).
321 321
 	if (!preg_match('|/$|', $sCurrentFolder))
322
-		$sCurrentFolder .= '/' ;
322
+		$sCurrentFolder .= '/';
323 323
 	if (strpos($sCurrentFolder, '/') !== 0)
324
-		$sCurrentFolder = '/' . $sCurrentFolder ;
324
+		$sCurrentFolder = '/'.$sCurrentFolder;
325 325
 
326 326
 	// Ensure the folder path has no double-slashes
327
-	while ( strpos($sCurrentFolder, '//') !== false ) {
327
+	while (strpos($sCurrentFolder, '//') !== false) {
328 328
 		$sCurrentFolder = str_replace('//', '/', $sCurrentFolder);
329 329
 	}
330 330
 
331 331
 	// Check for invalid folder paths (..)
332
-	if ( strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\"))
332
+	if (strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\"))
333 333
 		SendError(102, '');
334 334
 
335
-	if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder))
335
+	if (preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder))
336 336
 		SendError(102, '');
337 337
 
338
-	return $sCurrentFolder ;
338
+	return $sCurrentFolder;
339 339
 }
340 340
 
341 341
 // Do a cleanup of the folder name to avoid possible problems
342
-function SanitizeFolderName( $sNewFolderName )
342
+function SanitizeFolderName($sNewFolderName)
343 343
 {
344 344
 	$sNewFolderName = stripslashes($sNewFolderName);
345 345
 
346 346
 	// Remove . \ / | : ? * " < >
347 347
 	$sNewFolderName = preg_replace('/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName);
348 348
 
349
-	return $sNewFolderName ;
349
+	return $sNewFolderName;
350 350
 }
351 351
 
352 352
 // Do a cleanup of the file name to avoid possible problems
353
-function SanitizeFileName( $sNewFileName )
353
+function SanitizeFileName($sNewFileName)
354 354
 {
355
-	global $Config ;
355
+	global $Config;
356 356
 
357 357
 	$sNewFileName = stripslashes($sNewFileName);
358 358
 
359 359
 	// Replace dots in the name with underscores (only one dot can be there... security issue).
360
-	if ( $Config['ForceSingleExtension'] )
360
+	if ($Config['ForceSingleExtension'])
361 361
 		$sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName);
362 362
 
363 363
 	// Remove \ / | : ? * " < >
364 364
 	$sNewFileName = preg_replace('/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName);
365 365
 
366
-	return $sNewFileName ;
366
+	return $sNewFileName;
367 367
 }
368 368
 
369 369
 // This is the function that sends the results of the uploading process.
370
-function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' )
370
+function SendUploadResults($errorNumber, $fileUrl = '', $fileName = '', $customMsg = '')
371 371
 {
372 372
 	// Minified version of the document.domain automatic fix script (#1919).
373 373
 	// The original script can be found at _dev/domain_fix_template.js
@@ -381,10 +381,10 @@  discard block
 block discarded – undo
381 381
 		$fileName = "";
382 382
 	}
383 383
 
384
-	$rpl = array( '\\' => '\\\\', '"' => '\\"' );
385
-	echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr($fileUrl, $rpl) . '","' . strtr($fileName, $rpl) . '", "' . strtr($customMsg, $rpl) . '");' ;
386
-	echo '</script>' ;
387
-	exit ;
384
+	$rpl = array('\\' => '\\\\', '"' => '\\"');
385
+	echo 'window.parent.OnUploadCompleted('.$errorNumber.',"'.strtr($fileUrl, $rpl).'","'.strtr($fileName, $rpl).'", "'.strtr($customMsg, $rpl).'");';
386
+	echo '</script>';
387
+	exit;
388 388
 }
389 389
 
390 390
 
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
  * @param   string  $customMsg      customMsg
400 400
  * @return  void
401 401
  */
402
-function SendCKEditorResults ($callback, $sFileUrl, $customMsg = '')
402
+function SendCKEditorResults($callback, $sFileUrl, $customMsg = '')
403 403
 {
404 404
   echo '<script type="text/javascript">';
405 405
 
406
-  $rpl = array( '\\' => '\\\\', '"' => '\\"' );
406
+  $rpl = array('\\' => '\\\\', '"' => '\\"');
407 407
 
408
-  echo 'window.parent.CKEDITOR.tools.callFunction("'. $callback. '","'. strtr($sFileUrl, $rpl). '", "'. strtr($customMsg, $rpl). '");' ;
408
+  echo 'window.parent.CKEDITOR.tools.callFunction("'.$callback.'","'.strtr($sFileUrl, $rpl).'", "'.strtr($customMsg, $rpl).'");';
409 409
 
410 410
   echo '</script>';
411 411
 }
Please login to merge, or discard this patch.
Braces   +53 added lines, -40 removed lines patch added patch discarded remove patch
@@ -44,11 +44,12 @@  discard block
 block discarded – undo
44 44
 {
45 45
 	global $Config ;
46 46
 
47
-	if ($sCommand == "QuickUpload")
48
-		return $Config['QuickUploadPath'][$resourceType] ;
49
-	else
50
-		return $Config['FileTypesPath'][$resourceType] ;
51
-}
47
+	if ($sCommand == "QuickUpload") {
48
+			return $Config['QuickUploadPath'][$resourceType] ;
49
+	} else {
50
+			return $Config['FileTypesPath'][$resourceType] ;
51
+	}
52
+	}
52 53
 
53 54
 /**
54 55
  * GetResourceTypeDirectory
@@ -62,16 +63,17 @@  discard block
 block discarded – undo
62 63
 	global $Config ;
63 64
 	if ($sCommand == "QuickUpload")
64 65
 	{
65
-		if ( strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0)
66
-			return $Config['QuickUploadAbsolutePath'][$resourceType] ;
66
+		if ( strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0) {
67
+					return $Config['QuickUploadAbsolutePath'][$resourceType] ;
68
+		}
67 69
 
68 70
 		// Map the "UserFiles" path to a local directory.
69 71
 		return Server_MapPath($Config['QuickUploadPath'][$resourceType]);
70
-	}
71
-	else
72
+	} else
72 73
 	{
73
-		if ( strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0)
74
-			return $Config['FileTypesAbsolutePath'][$resourceType] ;
74
+		if ( strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0) {
75
+					return $Config['FileTypesAbsolutePath'][$resourceType] ;
76
+		}
75 77
 
76 78
 		// Map the "UserFiles" path to a local directory.
77 79
 		return Server_MapPath($Config['FileTypesPath'][$resourceType]);
@@ -116,8 +118,9 @@  discard block
 block discarded – undo
116 118
 
117 119
 	// Ensure that the directory exists.
118 120
 	$sErrorMsg = CreateServerFolder($sResourceTypePath);
119
-	if ( $sErrorMsg != '' )
120
-		SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})");
121
+	if ( $sErrorMsg != '' ) {
122
+			SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})");
123
+	}
121 124
 
122 125
 	// Return the resource type directory combined with the required path.
123 126
 	return CombinePaths($sResourceTypePath, $folderPath);
@@ -162,8 +165,9 @@  discard block
 block discarded – undo
162 165
 		}
163 166
 
164 167
 		$sErrorMsg = CreateServerFolder($sParent, $folderPath);
165
-		if ( $sErrorMsg != '' )
166
-			return $sErrorMsg ;
168
+		if ( $sErrorMsg != '' ) {
169
+					return $sErrorMsg ;
170
+		}
167 171
 	}
168 172
 
169 173
 	if ( !file_exists($folderPath))
@@ -178,8 +182,7 @@  discard block
 block discarded – undo
178 182
 		if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] )
179 183
 		{
180 184
 			mkdir($folderPath);
181
-		}
182
-		else
185
+		} else
183 186
 		{
184 187
 			$permissions = '0777';
185 188
 			if ( isset( $Config['ChmodOnFolderCreate'] ) && $Config['ChmodOnFolderCreate'])
@@ -202,10 +205,10 @@  discard block
 block discarded – undo
202 205
 		ini_restore('error_reporting');
203 206
 
204 207
 		return $sErrorMsg ;
208
+	} else {
209
+			return '' ;
210
+	}
205 211
 	}
206
-	else
207
-		return '' ;
208
-}
209 212
 
210 213
 /**
211 214
  * Get Root Path
@@ -230,8 +233,9 @@  discard block
 block discarded – undo
230 233
 
231 234
     // This can check only that this script isn't run from a virtual dir
232 235
     // But it avoids the problems that arise if it isn't checked
233
-    if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) )
234
-        SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
236
+    if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) ) {
237
+            SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
238
+    }
235 239
 
236 240
     return substr($sRealPath, 0, $position);
237 241
 }
@@ -265,11 +269,13 @@  discard block
 block discarded – undo
265 269
 	$arAllowed	= $Config['AllowedExtensions'][$resourceType] ;
266 270
 	$arDenied	= $Config['DeniedExtensions'][$resourceType] ;
267 271
 
268
-	if ( count($arAllowed) > 0 && !in_array($sExtension, $arAllowed))
269
-		return false ;
272
+	if ( count($arAllowed) > 0 && !in_array($sExtension, $arAllowed)) {
273
+			return false ;
274
+	}
270 275
 
271
-	if ( count($arDenied) > 0 && in_array($sExtension, $arDenied))
272
-		return false ;
276
+	if ( count($arDenied) > 0 && in_array($sExtension, $arDenied)) {
277
+			return false ;
278
+	}
273 279
 
274 280
 	return true ;
275 281
 }
@@ -283,8 +289,9 @@  discard block
 block discarded – undo
283 289
 function IsAllowedType($resourceType)
284 290
 {
285 291
 	global $Config ;
286
-	if ( !in_array($resourceType, $Config['ConfigAllowedTypes']))
287
-		return false ;
292
+	if ( !in_array($resourceType, $Config['ConfigAllowedTypes'])) {
293
+			return false ;
294
+	}
288 295
 
289 296
 	return true ;
290 297
 }
@@ -299,8 +306,9 @@  discard block
 block discarded – undo
299 306
 {
300 307
 	global $Config ;
301 308
 
302
-	if (! in_array($sCommand, $Config['ConfigAllowedCommands']))
303
-		return false ;
309
+	if (! in_array($sCommand, $Config['ConfigAllowedCommands'])) {
310
+			return false ;
311
+	}
304 312
 
305 313
 	return true ;
306 314
 }
@@ -318,10 +326,12 @@  discard block
 block discarded – undo
318 326
 	$sCurrentFolder	= isset( $_GET['CurrentFolder'] ) ? GETPOST('CurrentFolder', '', 1) : '/' ;
319 327
 
320 328
 	// Check the current folder syntax (must begin and start with a slash).
321
-	if (!preg_match('|/$|', $sCurrentFolder))
322
-		$sCurrentFolder .= '/' ;
323
-	if (strpos($sCurrentFolder, '/') !== 0)
324
-		$sCurrentFolder = '/' . $sCurrentFolder ;
329
+	if (!preg_match('|/$|', $sCurrentFolder)) {
330
+			$sCurrentFolder .= '/' ;
331
+	}
332
+	if (strpos($sCurrentFolder, '/') !== 0) {
333
+			$sCurrentFolder = '/' . $sCurrentFolder ;
334
+	}
325 335
 
326 336
 	// Ensure the folder path has no double-slashes
327 337
 	while ( strpos($sCurrentFolder, '//') !== false ) {
@@ -329,11 +339,13 @@  discard block
 block discarded – undo
329 339
 	}
330 340
 
331 341
 	// Check for invalid folder paths (..)
332
-	if ( strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\"))
333
-		SendError(102, '');
342
+	if ( strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\")) {
343
+			SendError(102, '');
344
+	}
334 345
 
335
-	if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder))
336
-		SendError(102, '');
346
+	if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) {
347
+			SendError(102, '');
348
+	}
337 349
 
338 350
 	return $sCurrentFolder ;
339 351
 }
@@ -357,8 +369,9 @@  discard block
 block discarded – undo
357 369
 	$sNewFileName = stripslashes($sNewFileName);
358 370
 
359 371
 	// Replace dots in the name with underscores (only one dot can be there... security issue).
360
-	if ( $Config['ForceSingleExtension'] )
361
-		$sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName);
372
+	if ( $Config['ForceSingleExtension'] ) {
373
+			$sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName);
374
+	}
362 375
 
363 376
 	// Remove \ / | : ? * " < >
364 377
 	$sNewFileName = preg_replace('/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -374,7 +374,7 @@
 block discarded – undo
374 374
 	echo <<<EOF
375 375
 <script type="text/javascript">
376 376
 (function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();
377
-EOF;
377
+eof;
378 378
 
379 379
 	if ($errorNumber && $errorNumber != 201) {
380 380
 		$fileUrl = "";
Please login to merge, or discard this patch.
htdocs/core/filemanagerdol/connectors/php/basexml.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	// Date in the past
37 37
 	header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
38 38
 	// always modified
39
-	header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
39
+	header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
40 40
 	// HTTP/1.1
41 41
 	header('Cache-Control: no-store, no-cache, must-revalidate');
42 42
 	header('Cache-Control: post-check=0, pre-check=0', false);
@@ -55,20 +55,20 @@  discard block
 block discarded – undo
55 55
  * @param string	$currentFolder	Current folder
56 56
  * @return void
57 57
  */
58
-function CreateXmlHeader( $command, $resourceType, $currentFolder )
58
+function CreateXmlHeader($command, $resourceType, $currentFolder)
59 59
 {
60 60
 	SetXmlHeaders();
61 61
 
62 62
 	// Create the XML document header.
63
-	echo '<?xml version="1.0" encoding="utf-8" ?>' ;
63
+	echo '<?xml version="1.0" encoding="utf-8" ?>';
64 64
 
65 65
 	// Create the main "Connector" node.
66
-	echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">' ;
66
+	echo '<Connector command="'.$command.'" resourceType="'.$resourceType.'">';
67 67
 
68 68
 	// Add the current folder node.
69
-	echo '<CurrentFolder path="' . ConvertToXmlAttribute($currentFolder) . '" url="' . ConvertToXmlAttribute(GetUrlFromPath($resourceType, $currentFolder, $command)) . '" />' ;
69
+	echo '<CurrentFolder path="'.ConvertToXmlAttribute($currentFolder).'" url="'.ConvertToXmlAttribute(GetUrlFromPath($resourceType, $currentFolder, $command)).'" />';
70 70
 
71
-	$GLOBALS['HeaderSent'] = true ;
71
+	$GLOBALS['HeaderSent'] = true;
72 72
 }
73 73
 
74 74
 /**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
  */
79 79
 function CreateXmlFooter()
80 80
 {
81
-	echo '</Connector>' ;
81
+	echo '</Connector>';
82 82
 }
83 83
 
84 84
 /**
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
  */
91 91
 function SendError($number, $text)
92 92
 {
93
-	if ( $_GET['Command'] == 'FileUpload' )
93
+	if ($_GET['Command'] == 'FileUpload')
94 94
 		SendUploadResults($number, "", "", $text);
95 95
 
96
-	if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] )
96
+	if (isset($GLOBALS['HeaderSent']) && $GLOBALS['HeaderSent'])
97 97
 	{
98 98
 		SendErrorNode($number, $text);
99 99
 		CreateXmlFooter();
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
 		dol_syslog('Error: '.$number.' '.$text, LOG_ERR);
106 106
 		
107 107
 		// Create the XML document header
108
-		echo '<?xml version="1.0" encoding="utf-8" ?>' ;
108
+		echo '<?xml version="1.0" encoding="utf-8" ?>';
109 109
 
110
-		echo '<Connector>' ;
110
+		echo '<Connector>';
111 111
 
112 112
 		SendErrorNode($number, $text);
113 113
 
114
-		echo '</Connector>' ;
114
+		echo '</Connector>';
115 115
 	}
116
-	exit ;
116
+	exit;
117 117
 }
118 118
 
119 119
 /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 function SendErrorNode($number, $text)
127 127
 {
128 128
 	if ($text)
129
-		echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ;
129
+		echo '<Error number="'.$number.'" text="'.htmlspecialchars($text).'" />';
130 130
 	else
131
-		echo '<Error number="' . $number . '" />' ;
131
+		echo '<Error number="'.$number.'" />';
132 132
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -9 removed lines patch added patch discarded remove patch
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
  */
91 91
 function SendError($number, $text)
92 92
 {
93
-	if ( $_GET['Command'] == 'FileUpload' )
94
-		SendUploadResults($number, "", "", $text);
93
+	if ( $_GET['Command'] == 'FileUpload' ) {
94
+			SendUploadResults($number, "", "", $text);
95
+	}
95 96
 
96 97
 	if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] )
97 98
 	{
98 99
 		SendErrorNode($number, $text);
99 100
 		CreateXmlFooter();
100
-	}
101
-	else
101
+	} else
102 102
 	{
103 103
 		SetXmlHeaders();
104 104
 
@@ -125,8 +125,9 @@  discard block
 block discarded – undo
125 125
  */
126 126
 function SendErrorNode($number, $text)
127 127
 {
128
-	if ($text)
129
-		echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ;
130
-	else
131
-		echo '<Error number="' . $number . '" />' ;
132
-}
128
+	if ($text) {
129
+			echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ;
130
+	} else {
131
+			echo '<Error number="' . $number . '" />' ;
132
+	}
133
+	}
Please login to merge, or discard this patch.
htdocs/core/filemanagerdol/connectors/php/commands.php 3 patches
Braces   +32 added lines, -28 removed lines patch added patch discarded remove patch
@@ -43,8 +43,9 @@  discard block
 block discarded – undo
43 43
 	{
44 44
 		while ( $sFile = readdir($oCurrentFolder) )
45 45
 		{
46
-			if ( $sFile != '.' && $sFile != '..' && is_dir($sServerDir . $sFile) )
47
-				$aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ;
46
+			if ( $sFile != '.' && $sFile != '..' && is_dir($sServerDir . $sFile) ) {
47
+							$aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ;
48
+			}
48 49
 		}
49 50
 		closedir($oCurrentFolder);
50 51
 	}
@@ -53,8 +54,9 @@  discard block
 block discarded – undo
53 54
 	echo "<Folders>" ;
54 55
 
55 56
 	natcasesort($aFolders);
56
-	foreach ( $aFolders as $sFolder )
57
-		echo $sFolder ;
57
+	foreach ( $aFolders as $sFolder ) {
58
+			echo $sFolder ;
59
+	}
58 60
 
59 61
 	// Close the "Folders" node.
60 62
 	echo "</Folders>" ;
@@ -84,9 +86,9 @@  discard block
 block discarded – undo
84 86
 		{
85 87
 			if ( $sFile != '.' && $sFile != '..' )
86 88
 			{
87
-				if ( is_dir($sServerDir . $sFile) )
88
-					$aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ;
89
-				else
89
+				if ( is_dir($sServerDir . $sFile) ) {
90
+									$aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ;
91
+				} else
90 92
 				{
91 93
 					$iFileSize = @filesize($sServerDir . $sFile);
92 94
 					if ( !$iFileSize ) {
@@ -95,8 +97,9 @@  discard block
 block discarded – undo
95 97
 					if ( $iFileSize > 0 )
96 98
 					{
97 99
 						$iFileSize = round($iFileSize / 1024);
98
-						if ( $iFileSize < 1 )
99
-							$iFileSize = 1 ;
100
+						if ( $iFileSize < 1 ) {
101
+													$iFileSize = 1 ;
102
+						}
100 103
 					}
101 104
 
102 105
 					$aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />' ;
@@ -110,8 +113,9 @@  discard block
 block discarded – undo
110 113
 	natcasesort($aFolders);
111 114
 	echo '<Folders>' ;
112 115
 
113
-	foreach ( $aFolders as $sFolder )
114
-		echo $sFolder ;
116
+	foreach ( $aFolders as $sFolder ) {
117
+			echo $sFolder ;
118
+	}
115 119
 
116 120
 	echo '</Folders>' ;
117 121
 
@@ -119,8 +123,9 @@  discard block
 block discarded – undo
119 123
 	natcasesort($aFiles);
120 124
 	echo '<Files>' ;
121 125
 
122
-	foreach ( $aFiles as $sFiles )
123
-		echo $sFiles ;
126
+	foreach ( $aFiles as $sFiles ) {
127
+			echo $sFiles ;
128
+	}
124 129
 
125 130
 	echo '</Files>' ;
126 131
 }
@@ -145,8 +150,10 @@  discard block
 block discarded – undo
145 150
 		$sNewFolderName = $_GET['NewFolderName'] ;
146 151
 		$sNewFolderName = SanitizeFolderName($sNewFolderName);
147 152
 
148
-		if (strpos($sNewFolderName, '..') !== FALSE)
149
-			$sErrorNumber = '102' ;		// Invalid folder name.
153
+		if (strpos($sNewFolderName, '..') !== FALSE) {
154
+					$sErrorNumber = '102' ;
155
+		}
156
+		// Invalid folder name.
150 157
 		else
151 158
 		{
152 159
 			// Map the virtual path to the local server path of the current folder.
@@ -171,13 +178,13 @@  discard block
 block discarded – undo
171 178
 						$sErrorNumber = '110' ;
172 179
 						break ;
173 180
 				}
181
+			} else {
182
+							$sErrorNumber = '103' ;
174 183
 			}
175
-			else
176
-				$sErrorNumber = '103' ;
177 184
 		}
185
+	} else {
186
+			$sErrorNumber = '102' ;
178 187
 	}
179
-	else
180
-		$sErrorNumber = '102' ;
181 188
 
182 189
 	// Create the "Error" node.
183 190
 	echo '<Error number="' . $sErrorNumber . '" />' ;
@@ -254,8 +261,7 @@  discard block
 block discarded – undo
254 261
 					$iCounter++ ;
255 262
 					$sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension ;
256 263
 					$sErrorNumber = '201' ;
257
-				}
258
-				else
264
+				} else
259 265
 				{
260 266
 					move_uploaded_file($oFile['tmp_name'], $sFilePath);
261 267
 
@@ -289,19 +295,18 @@  discard block
 block discarded – undo
289 295
 				{
290 296
 					@unlink($sFilePath);
291 297
 					$sErrorNumber = '202' ;
292
-				}
293
-				else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml($sFilePath) === true )
298
+				} else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml($sFilePath) === true )
294 299
 				{
295 300
 					@unlink($sFilePath);
296 301
 					$sErrorNumber = '202' ;
297 302
 				}
298 303
 			}
304
+		} else {
305
+					$sErrorNumber = '202' ;
299 306
 		}
300
-		else
307
+	} else {
301 308
 			$sErrorNumber = '202' ;
302 309
 	}
303
-	else
304
-		$sErrorNumber = '202' ;
305 310
 
306 311
 
307 312
 	$sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder);
@@ -314,8 +319,7 @@  discard block
 block discarded – undo
314 319
     {
315 320
         // this line already exists so wrap the if block around it
316 321
         SendUploadResults($sErrorNumber, $sFileUrl, $sFileName);
317
-    }
318
-    else
322
+    } else
319 323
 	{
320 324
 	    //issue the CKEditor Callback
321 325
 		SendCKEditorResults(
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	$sFileName = '' ;
204 204
 
205 205
 	if ( isset( $_FILES['NewFile'] ) && !is_null($_FILES['NewFile']['tmp_name'])
206
-       // This is for the QuickUpload tab box
207
-        or (isset($_FILES['upload']) && !is_null($_FILES['upload']['tmp_name'])))
206
+	   // This is for the QuickUpload tab box
207
+		or (isset($_FILES['upload']) && !is_null($_FILES['upload']['tmp_name'])))
208 208
 	{
209 209
 		global $Config ;
210 210
 
@@ -311,18 +311,18 @@  discard block
 block discarded – undo
311 311
 	// @CHANGE
312 312
 	//SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName );
313 313
 	if($CKEcallback == '')
314
-    {
315
-        // this line already exists so wrap the if block around it
316
-        SendUploadResults($sErrorNumber, $sFileUrl, $sFileName);
317
-    }
318
-    else
319 314
 	{
320
-	    //issue the CKEditor Callback
315
+		// this line already exists so wrap the if block around it
316
+		SendUploadResults($sErrorNumber, $sFileUrl, $sFileName);
317
+	}
318
+	else
319
+	{
320
+		//issue the CKEditor Callback
321 321
 		SendCKEditorResults(
322 322
 			$CKEcallback,
323 323
 			$sFileUrl,
324 324
 			($sErrorNumber != 0 ? 'Error '. $sErrorNumber. ' upload failed.' : 'Upload Successful')
325
-    	);
325
+		);
326 326
 	}
327 327
 
328 328
 	exit;
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -35,29 +35,29 @@  discard block
 block discarded – undo
35 35
 	$sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFolders');
36 36
 
37 37
 	// Array that will hold the folders names.
38
-	$aFolders	= array();
38
+	$aFolders = array();
39 39
 
40 40
 	$oCurrentFolder = @opendir($sServerDir);
41 41
 
42 42
 	if ($oCurrentFolder !== false)
43 43
 	{
44
-		while ( $sFile = readdir($oCurrentFolder) )
44
+		while ($sFile = readdir($oCurrentFolder))
45 45
 		{
46
-			if ( $sFile != '.' && $sFile != '..' && is_dir($sServerDir . $sFile) )
47
-				$aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ;
46
+			if ($sFile != '.' && $sFile != '..' && is_dir($sServerDir.$sFile))
47
+				$aFolders[] = '<Folder name="'.ConvertToXmlAttribute($sFile).'" />';
48 48
 		}
49 49
 		closedir($oCurrentFolder);
50 50
 	}
51 51
 
52 52
 	// Open the "Folders" node.
53
-	echo "<Folders>" ;
53
+	echo "<Folders>";
54 54
 
55 55
 	natcasesort($aFolders);
56
-	foreach ( $aFolders as $sFolder )
57
-		echo $sFolder ;
56
+	foreach ($aFolders as $sFolder)
57
+		echo $sFolder;
58 58
 
59 59
 	// Close the "Folders" node.
60
-	echo "</Folders>" ;
60
+	echo "</Folders>";
61 61
 }
62 62
 
63 63
 /**
@@ -67,39 +67,39 @@  discard block
 block discarded – undo
67 67
  * @param	string	$currentFolder	Current folder
68 68
  * @return void
69 69
  */
70
-function GetFoldersAndFiles( $resourceType, $currentFolder )
70
+function GetFoldersAndFiles($resourceType, $currentFolder)
71 71
 {
72 72
 	// Map the virtual path to the local server path.
73 73
 	$sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFoldersAndFiles');
74 74
 
75 75
 	// Arrays that will hold the folders and files names.
76
-	$aFolders	= array();
77
-	$aFiles		= array();
76
+	$aFolders = array();
77
+	$aFiles = array();
78 78
 
79 79
 	$oCurrentFolder = @opendir($sServerDir);
80 80
 
81 81
 	if ($oCurrentFolder !== false)
82 82
 	{
83
-		while ( $sFile = readdir($oCurrentFolder) )
83
+		while ($sFile = readdir($oCurrentFolder))
84 84
 		{
85
-			if ( $sFile != '.' && $sFile != '..' )
85
+			if ($sFile != '.' && $sFile != '..')
86 86
 			{
87
-				if ( is_dir($sServerDir . $sFile) )
88
-					$aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ;
87
+				if (is_dir($sServerDir.$sFile))
88
+					$aFolders[] = '<Folder name="'.ConvertToXmlAttribute($sFile).'" />';
89 89
 				else
90 90
 				{
91
-					$iFileSize = @filesize($sServerDir . $sFile);
92
-					if ( !$iFileSize ) {
93
-						$iFileSize = 0 ;
91
+					$iFileSize = @filesize($sServerDir.$sFile);
92
+					if (!$iFileSize) {
93
+						$iFileSize = 0;
94 94
 					}
95
-					if ( $iFileSize > 0 )
95
+					if ($iFileSize > 0)
96 96
 					{
97 97
 						$iFileSize = round($iFileSize / 1024);
98
-						if ( $iFileSize < 1 )
99
-							$iFileSize = 1 ;
98
+						if ($iFileSize < 1)
99
+							$iFileSize = 1;
100 100
 					}
101 101
 
102
-					$aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />' ;
102
+					$aFiles[] = '<File name="'.ConvertToXmlAttribute($sFile).'" size="'.$iFileSize.'" />';
103 103
 				}
104 104
 			}
105 105
 		}
@@ -108,21 +108,21 @@  discard block
 block discarded – undo
108 108
 
109 109
 	// Send the folders
110 110
 	natcasesort($aFolders);
111
-	echo '<Folders>' ;
111
+	echo '<Folders>';
112 112
 
113
-	foreach ( $aFolders as $sFolder )
114
-		echo $sFolder ;
113
+	foreach ($aFolders as $sFolder)
114
+		echo $sFolder;
115 115
 
116
-	echo '</Folders>' ;
116
+	echo '</Folders>';
117 117
 
118 118
 	// Send the files
119 119
 	natcasesort($aFiles);
120
-	echo '<Files>' ;
120
+	echo '<Files>';
121 121
 
122
-	foreach ( $aFiles as $sFiles )
123
-		echo $sFiles ;
122
+	foreach ($aFiles as $sFiles)
123
+		echo $sFiles;
124 124
 
125
-	echo '</Files>' ;
125
+	echo '</Files>';
126 126
 }
127 127
 
128 128
 /**
@@ -132,55 +132,55 @@  discard block
 block discarded – undo
132 132
  * @param   string $currentFolder   Current folder
133 133
  * @return void
134 134
  */
135
-function CreateFolder( $resourceType, $currentFolder )
135
+function CreateFolder($resourceType, $currentFolder)
136 136
 {
137 137
 	if (!isset($_GET)) {
138 138
 		global $_GET;
139 139
 	}
140
-	$sErrorNumber	= '0' ;
141
-	$sErrorMsg		= '' ;
140
+	$sErrorNumber = '0';
141
+	$sErrorMsg = '';
142 142
 
143
-	if ( isset( $_GET['NewFolderName'] ) )
143
+	if (isset($_GET['NewFolderName']))
144 144
 	{
145
-		$sNewFolderName = $_GET['NewFolderName'] ;
145
+		$sNewFolderName = $_GET['NewFolderName'];
146 146
 		$sNewFolderName = SanitizeFolderName($sNewFolderName);
147 147
 
148 148
 		if (strpos($sNewFolderName, '..') !== FALSE)
149
-			$sErrorNumber = '102' ;		// Invalid folder name.
149
+			$sErrorNumber = '102'; // Invalid folder name.
150 150
 		else
151 151
 		{
152 152
 			// Map the virtual path to the local server path of the current folder.
153 153
 			$sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder');
154 154
 
155
-			if ( is_writable($sServerDir) )
155
+			if (is_writable($sServerDir))
156 156
 			{
157
-				$sServerDir .= $sNewFolderName ;
157
+				$sServerDir .= $sNewFolderName;
158 158
 
159 159
 				$sErrorMsg = CreateServerFolder($sServerDir);
160 160
 
161
-				switch ( $sErrorMsg )
161
+				switch ($sErrorMsg)
162 162
 				{
163 163
 					case '':
164
-						$sErrorNumber = '0' ;
164
+						$sErrorNumber = '0';
165 165
 						break;
166 166
 					case 'Invalid argument' :
167 167
 					case 'No such file or directory' :
168
-						$sErrorNumber = '102' ;		// Path too long.
169
-						break ;
168
+						$sErrorNumber = '102'; // Path too long.
169
+						break;
170 170
 					default:
171
-						$sErrorNumber = '110' ;
172
-						break ;
171
+						$sErrorNumber = '110';
172
+						break;
173 173
 				}
174 174
 			}
175 175
 			else
176
-				$sErrorNumber = '103' ;
176
+				$sErrorNumber = '103';
177 177
 		}
178 178
 	}
179 179
 	else
180
-		$sErrorNumber = '102' ;
180
+		$sErrorNumber = '102';
181 181
 
182 182
 	// Create the "Error" node.
183
-	echo '<Error number="' . $sErrorNumber . '" />' ;
183
+	echo '<Error number="'.$sErrorNumber.'" />';
184 184
 }
185 185
 
186 186
 // @CHANGE
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	if (!isset($_FILES)) {
200 200
 		global $_FILES;
201 201
 	}
202
-	$sErrorNumber = '0' ;
203
-	$sFileName = '' ;
202
+	$sErrorNumber = '0';
203
+	$sFileName = '';
204 204
 
205
-	if ( isset( $_FILES['NewFile'] ) && !is_null($_FILES['NewFile']['tmp_name'])
205
+	if (isset($_FILES['NewFile']) && !is_null($_FILES['NewFile']['tmp_name'])
206 206
        // This is for the QuickUpload tab box
207 207
         or (isset($_FILES['upload']) && !is_null($_FILES['upload']['tmp_name'])))
208 208
 	{
209
-		global $Config ;
209
+		global $Config;
210 210
 
211 211
 		$oFile = isset($_FILES['NewFile']) ? $_FILES['NewFile'] : $_FILES['upload'];
212 212
 
@@ -214,62 +214,62 @@  discard block
 block discarded – undo
214 214
 		$sServerDir = ServerMapFolder($resourceType, $currentFolder, $sCommand);
215 215
 
216 216
 		// Get the uploaded file name.
217
-		$sFileName = $oFile['name'] ;
217
+		$sFileName = $oFile['name'];
218 218
 		$sFileName = SanitizeFileName($sFileName);
219 219
 
220
-		$sOriginalFileName = $sFileName ;
220
+		$sOriginalFileName = $sFileName;
221 221
 
222 222
 		// Get the extension.
223 223
 		$sExtension = substr($sFileName, (strrpos($sFileName, '.') + 1));
224 224
 		$sExtension = strtolower($sExtension);
225 225
 
226
-		if ( isset( $Config['SecureImageUploads'] ) )
226
+		if (isset($Config['SecureImageUploads']))
227 227
 		{
228
-			if ( ( $isImageValid = IsImageValid($oFile['tmp_name'], $sExtension) ) === false )
228
+			if (($isImageValid = IsImageValid($oFile['tmp_name'], $sExtension)) === false)
229 229
 			{
230
-				$sErrorNumber = '202' ;
230
+				$sErrorNumber = '202';
231 231
 			}
232 232
 		}
233 233
 
234
-		if ( isset( $Config['HtmlExtensions'] ) )
234
+		if (isset($Config['HtmlExtensions']))
235 235
 		{
236 236
 			if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) &&
237 237
 				($detectHtml = DetectHtml($oFile['tmp_name'])) === true)
238 238
 			{
239
-				$sErrorNumber = '202' ;
239
+				$sErrorNumber = '202';
240 240
 			}
241 241
 		}
242 242
 
243 243
 		// Check if it is an allowed extension.
244
-		if ( !$sErrorNumber && IsAllowedExt($sExtension, $resourceType) )
244
+		if (!$sErrorNumber && IsAllowedExt($sExtension, $resourceType))
245 245
 		{
246
-			$iCounter = 0 ;
246
+			$iCounter = 0;
247 247
 
248
-			while ( true )
248
+			while (true)
249 249
 			{
250
-				$sFilePath = $sServerDir . $sFileName ;
250
+				$sFilePath = $sServerDir.$sFileName;
251 251
 
252
-				if ( is_file($sFilePath) )
252
+				if (is_file($sFilePath))
253 253
 				{
254
-					$iCounter++ ;
255
-					$sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension ;
256
-					$sErrorNumber = '201' ;
254
+					$iCounter++;
255
+					$sFileName = RemoveExtension($sOriginalFileName).'('.$iCounter.').'.$sExtension;
256
+					$sErrorNumber = '201';
257 257
 				}
258 258
 				else
259 259
 				{
260 260
 					move_uploaded_file($oFile['tmp_name'], $sFilePath);
261 261
 
262
-					if ( is_file($sFilePath) )
262
+					if (is_file($sFilePath))
263 263
 					{
264
-						if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] )
264
+						if (isset($Config['ChmodOnUpload']) && !$Config['ChmodOnUpload'])
265 265
 						{
266
-							break ;
266
+							break;
267 267
 						}
268 268
 
269 269
 						$permissions = '0777';
270
-						if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] )
270
+						if (isset($Config['ChmodOnUpload']) && $Config['ChmodOnUpload'])
271 271
 						{
272
-							$permissions = (string) $Config['ChmodOnUpload'] ;
272
+							$permissions = (string) $Config['ChmodOnUpload'];
273 273
 						}
274 274
 						$permissionsdec = octdec($permissions);
275 275
 						dol_syslog("commands.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec));
@@ -278,30 +278,30 @@  discard block
 block discarded – undo
278 278
 						umask($oldumask);
279 279
 					}
280 280
 
281
-					break ;
281
+					break;
282 282
 				}
283 283
 			}
284 284
 
285
-			if ( file_exists($sFilePath) )
285
+			if (file_exists($sFilePath))
286 286
 			{
287 287
 				//previous checks failed, try once again
288
-				if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false )
288
+				if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false)
289 289
 				{
290 290
 					@unlink($sFilePath);
291
-					$sErrorNumber = '202' ;
291
+					$sErrorNumber = '202';
292 292
 				}
293
-				else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml($sFilePath) === true )
293
+				else if (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true)
294 294
 				{
295 295
 					@unlink($sFilePath);
296
-					$sErrorNumber = '202' ;
296
+					$sErrorNumber = '202';
297 297
 				}
298 298
 			}
299 299
 		}
300 300
 		else
301
-			$sErrorNumber = '202' ;
301
+			$sErrorNumber = '202';
302 302
 	}
303 303
 	else
304
-		$sErrorNumber = '202' ;
304
+		$sErrorNumber = '202';
305 305
 
306 306
 
307 307
 	$sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder);
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 	// @CHANGE
312 312
 	//SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName );
313
-	if($CKEcallback == '')
313
+	if ($CKEcallback == '')
314 314
     {
315 315
         // this line already exists so wrap the if block around it
316 316
         SendUploadResults($sErrorNumber, $sFileUrl, $sFileName);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		SendCKEditorResults(
322 322
 			$CKEcallback,
323 323
 			$sFileUrl,
324
-			($sErrorNumber != 0 ? 'Error '. $sErrorNumber. ' upload failed.' : 'Upload Successful')
324
+			($sErrorNumber != 0 ? 'Error '.$sErrorNumber.' upload failed.' : 'Upload Successful')
325 325
     	);
326 326
 	}
327 327
 
Please login to merge, or discard this patch.
htdocs/core/filemanagerdol/connectors/php/connector.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@
 block discarded – undo
42 42
  */
43 43
 function DoResponse()
44 44
 {
45
-    if (!isset($_GET)) {
46
-        global $_GET;
47
-    }
45
+	if (!isset($_GET)) {
46
+		global $_GET;
47
+	}
48 48
 	if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
49 49
 		return;
50 50
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 require 'basexml.php';
31 31
 require 'commands.php';
32 32
 
33
-if ( !$Config['Enabled'] )
33
+if (!$Config['Enabled'])
34 34
 	SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file');
35 35
 
36 36
 DoResponse();
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
     if (!isset($_GET)) {
46 46
         global $_GET;
47 47
     }
48
-	if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
48
+	if (!isset($_GET['Command']) || !isset($_GET['Type']) || !isset($_GET['CurrentFolder']))
49 49
 		return;
50 50
 
51 51
 	// Get the main request informaiton.
52
-	$sCommand		= $_GET['Command'] ;
53
-	$sResourceType	= $_GET['Type'] ;
54
-	$sCurrentFolder	= GetCurrentFolder();
52
+	$sCommand = $_GET['Command'];
53
+	$sResourceType = $_GET['Type'];
54
+	$sCurrentFolder = GetCurrentFolder();
55 55
 
56 56
 	// Check if it is an allowed command
57
-	if (! IsAllowedCommand($sCommand))
57
+	if (!IsAllowedCommand($sCommand))
58 58
 	{
59
-		SendError(1, 'The "' . $sCommand . '" command isn\'t allowed');
59
+		SendError(1, 'The "'.$sCommand.'" command isn\'t allowed');
60 60
 	}
61 61
 	// Check if it is an allowed type.
62
-	if (! IsAllowedType($sResourceType))
62
+	if (!IsAllowedType($sResourceType))
63 63
 		SendError(1, 'Invalid type specified');
64 64
 
65 65
 	// File Upload doesn't have to Return XML, so it must be intercepted before anything.
66
-	if ( $sCommand == 'FileUpload' )
66
+	if ($sCommand == 'FileUpload')
67 67
 	{
68 68
 		FileUpload($sResourceType, $sCurrentFolder, $sCommand);
69 69
 		return;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder);
73 73
 
74 74
 	// Execute the required command.
75
-	switch ( $sCommand )
75
+	switch ($sCommand)
76 76
 	{
77 77
 		case 'GetFolders' :
78 78
 			GetFolders($sResourceType, $sCurrentFolder);
Please login to merge, or discard this patch.
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
 require 'basexml.php';
31 31
 require 'commands.php';
32 32
 
33
-if ( !$Config['Enabled'] )
33
+if ( !$Config['Enabled'] ) {
34 34
 	SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file');
35
+}
35 36
 
36 37
 DoResponse();
37 38
 
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
     if (!isset($_GET)) {
46 47
         global $_GET;
47 48
     }
48
-	if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
49
-		return;
49
+	if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) ) {
50
+			return;
51
+	}
50 52
 
51 53
 	// Get the main request informaiton.
52 54
 	$sCommand		= $_GET['Command'] ;
@@ -59,8 +61,9 @@  discard block
 block discarded – undo
59 61
 		SendError(1, 'The "' . $sCommand . '" command isn\'t allowed');
60 62
 	}
61 63
 	// Check if it is an allowed type.
62
-	if (! IsAllowedType($sResourceType))
63
-		SendError(1, 'Invalid type specified');
64
+	if (! IsAllowedType($sResourceType)) {
65
+			SendError(1, 'Invalid type specified');
66
+	}
64 67
 
65 68
 	// File Upload doesn't have to Return XML, so it must be intercepted before anything.
66 69
 	if ( $sCommand == 'FileUpload' )
Please login to merge, or discard this patch.
htdocs/core/filemanagerdol/connectors/php/config.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,44 +22,44 @@  discard block
 block discarded – undo
22 22
  * Configuration file for the File Manager Connector for PHP.
23 23
  */
24 24
 
25
-global $Config ;
25
+global $Config;
26 26
 global $website;
27 27
 
28
-define('NOTOKENRENEWAL',1); // Disables token renewal
28
+define('NOTOKENRENEWAL', 1); // Disables token renewal
29 29
 
30 30
 // We must include the main because this page is
31 31
 // a web page that require security controls and
32 32
 // is a security hole if anybody can access without
33 33
 // being an authenticated user.
34 34
 require_once '../../../../main.inc.php';
35
-$uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root);
36
-$pos = strstr($uri, '/');       // $pos contient alors url sans nom domaine
37
-if ($pos == '/') $pos = '';     // si $pos vaut /, on le met a ''
35
+$uri = preg_replace('/^http(s?):\/\//i', '', $dolibarr_main_url_root);
36
+$pos = strstr($uri, '/'); // $pos contient alors url sans nom domaine
37
+if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a ''
38 38
 define('DOL_URL_ROOT', $pos);
39 39
 $entity = ((!empty($_SESSION['dol_entity']) && $_SESSION['dol_entity'] > 1) ? $_SESSION['dol_entity'] : null);
40 40
 
41 41
 // SECURITY: You must explicitly enable this "connector". (Set it to "true").
42 42
 // WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only
43 43
 //		authenticated users can access this file or use some kind of session checking.
44
-$Config['Enabled'] = true ;
44
+$Config['Enabled'] = true;
45 45
 
46 46
 
47 47
 // Path to user files relative to the document root.
48
-$extEntity=(empty($entity) ? 1 : $entity); // For multicompany with external access
48
+$extEntity = (empty($entity) ? 1 : $entity); // For multicompany with external access
49 49
 
50
-$Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=medias'.(empty($website)?'':'_'.$website).'&entity='.$extEntity.'&file=' ;
51
-$Config['UserFilesAbsolutePathRelative'] = (empty($website) ? ((!empty($entity) ? '/' . $entity : '') . '/medias/') : ('/websites/'.$website));
50
+$Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=medias'.(empty($website) ? '' : '_'.$website).'&entity='.$extEntity.'&file=';
51
+$Config['UserFilesAbsolutePathRelative'] = (empty($website) ? ((!empty($entity) ? '/'.$entity : '').'/medias/') : ('/websites/'.$website));
52 52
 
53 53
 
54 54
 // Fill the following value it you prefer to specify the absolute path for the
55 55
 // user files directory. Useful if you are using a virtual directory, symbolic
56 56
 // link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
57 57
 // Attention: The above 'UserFilesPath' must point to the same directory.
58
-$Config['UserFilesAbsolutePath'] = $dolibarr_main_data_root . $Config['UserFilesAbsolutePathRelative'];
58
+$Config['UserFilesAbsolutePath'] = $dolibarr_main_data_root.$Config['UserFilesAbsolutePathRelative'];
59 59
 
60 60
 // Due to security issues with Apache modules, it is recommended to leave the
61 61
 // following setting enabled.
62
-$Config['ForceSingleExtension'] = true ;
62
+$Config['ForceSingleExtension'] = true;
63 63
 
64 64
 // Perform additional checks for image files.
65 65
 // If set to true, validate image size (using getimagesize).
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 // Set to 0 to disable this feature.
82 82
 // Note: not needed on Windows-based servers.
83 83
 $newmask = '0644';
84
-if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
84
+if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK;
85 85
 $Config['ChmodOnUpload'] = $newmask;
86 86
 
87 87
 // See comments above.
88 88
 // Used when creating folders that does not exist.
89 89
 $newmask = '0755';
90
-$dirmaskdec=octdec($newmask);
91
-if (! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
92
-$dirmaskdec |= octdec('0200');  // Set w bit required to be able to create content for recursive subdirs files
90
+$dirmaskdec = octdec($newmask);
91
+if (!empty($conf->global->MAIN_UMASK)) $dirmaskdec = octdec($conf->global->MAIN_UMASK);
92
+$dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
93 93
 $newmask = decoct($dirmaskdec);
94 94
 
95 95
 $Config['ChmodOnFolderCreate'] = $newmask;
@@ -148,29 +148,29 @@  discard block
 block discarded – undo
148 148
 
149 149
 $Config['AllowedExtensions']['File']	= array('7z', 'aiff', 'asf', 'avi', 'bmp', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip');
150 150
 $Config['DeniedExtensions']['File']		= array();
151
-$Config['FileTypesPath']['File']		= $Config['UserFilesPath'] . 'file/' ;
152
-$Config['FileTypesAbsolutePath']['File']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'file/' ;
153
-$Config['QuickUploadPath']['File']		= $Config['UserFilesPath'] ;
154
-$Config['QuickUploadAbsolutePath']['File']= $Config['UserFilesAbsolutePath'] ;
151
+$Config['FileTypesPath']['File'] = $Config['UserFilesPath'].'file/';
152
+$Config['FileTypesAbsolutePath']['File'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'file/';
153
+$Config['QuickUploadPath']['File'] = $Config['UserFilesPath'];
154
+$Config['QuickUploadAbsolutePath']['File'] = $Config['UserFilesAbsolutePath'];
155 155
 
156
-$Config['AllowedExtensions']['Image']	= array('bmp','gif','jpeg','jpg','png');
156
+$Config['AllowedExtensions']['Image'] = array('bmp', 'gif', 'jpeg', 'jpg', 'png');
157 157
 $Config['DeniedExtensions']['Image']	= array();
158
-$Config['FileTypesPath']['Image']		= $Config['UserFilesPath'] . 'image/' ;
159
-$Config['FileTypesAbsolutePath']['Image']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'image/' ;
160
-$Config['QuickUploadPath']['Image']		= $Config['UserFilesPath'] ;
161
-$Config['QuickUploadAbsolutePath']['Image']= $Config['UserFilesAbsolutePath'] ;
158
+$Config['FileTypesPath']['Image'] = $Config['UserFilesPath'].'image/';
159
+$Config['FileTypesAbsolutePath']['Image'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'image/';
160
+$Config['QuickUploadPath']['Image']		= $Config['UserFilesPath'];
161
+$Config['QuickUploadAbsolutePath']['Image'] = $Config['UserFilesAbsolutePath'];
162 162
 
163
-$Config['AllowedExtensions']['Flash']	= array('swf','flv');
163
+$Config['AllowedExtensions']['Flash'] = array('swf', 'flv');
164 164
 $Config['DeniedExtensions']['Flash']	= array();
165
-$Config['FileTypesPath']['Flash']		= $Config['UserFilesPath'] . 'flash/' ;
166
-$Config['FileTypesAbsolutePath']['Flash']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'flash/' ;
167
-$Config['QuickUploadPath']['Flash']		= $Config['UserFilesPath'] ;
168
-$Config['QuickUploadAbsolutePath']['Flash']= $Config['UserFilesAbsolutePath'] ;
165
+$Config['FileTypesPath']['Flash'] = $Config['UserFilesPath'].'flash/';
166
+$Config['FileTypesAbsolutePath']['Flash'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'flash/';
167
+$Config['QuickUploadPath']['Flash']		= $Config['UserFilesPath'];
168
+$Config['QuickUploadAbsolutePath']['Flash'] = $Config['UserFilesAbsolutePath'];
169 169
 
170
-$Config['AllowedExtensions']['Media']	= array('aiff', 'asf', 'avi', 'bmp', 'fla', 'flv', 'gif', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'png', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'swf', 'tif', 'tiff', 'wav', 'wma', 'wmv');
170
+$Config['AllowedExtensions']['Media'] = array('aiff', 'asf', 'avi', 'bmp', 'fla', 'flv', 'gif', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'png', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'swf', 'tif', 'tiff', 'wav', 'wma', 'wmv');
171 171
 $Config['DeniedExtensions']['Media']	= array();
172
-$Config['FileTypesPath']['Media']		= $Config['UserFilesPath'] . 'media/' ;
173
-$Config['FileTypesAbsolutePath']['Media']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'media/' ;
174
-$Config['QuickUploadPath']['Media']		= $Config['UserFilesPath'] ;
175
-$Config['QuickUploadAbsolutePath']['Media']= $Config['UserFilesAbsolutePath'] ;
172
+$Config['FileTypesPath']['Media'] = $Config['UserFilesPath'].'media/';
173
+$Config['FileTypesAbsolutePath']['Media'] = ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'media/';
174
+$Config['QuickUploadPath']['Media']		= $Config['UserFilesPath'];
175
+$Config['QuickUploadAbsolutePath']['Media'] = $Config['UserFilesAbsolutePath'];
176 176
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,10 @@  discard block
 block discarded – undo
34 34
 require_once '../../../../main.inc.php';
35 35
 $uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root);
36 36
 $pos = strstr($uri, '/');       // $pos contient alors url sans nom domaine
37
-if ($pos == '/') $pos = '';     // si $pos vaut /, on le met a ''
37
+if ($pos == '/') {
38
+	$pos = '';
39
+}
40
+// si $pos vaut /, on le met a ''
38 41
 define('DOL_URL_ROOT', $pos);
39 42
 $entity = ((!empty($_SESSION['dol_entity']) && $_SESSION['dol_entity'] > 1) ? $_SESSION['dol_entity'] : null);
40 43
 
@@ -81,14 +84,18 @@  discard block
 block discarded – undo
81 84
 // Set to 0 to disable this feature.
82 85
 // Note: not needed on Windows-based servers.
83 86
 $newmask = '0644';
84
-if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
87
+if (! empty($conf->global->MAIN_UMASK)) {
88
+	$newmask=$conf->global->MAIN_UMASK;
89
+}
85 90
 $Config['ChmodOnUpload'] = $newmask;
86 91
 
87 92
 // See comments above.
88 93
 // Used when creating folders that does not exist.
89 94
 $newmask = '0755';
90 95
 $dirmaskdec=octdec($newmask);
91
-if (! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
96
+if (! empty($conf->global->MAIN_UMASK)) {
97
+	$dirmaskdec=octdec($conf->global->MAIN_UMASK);
98
+}
92 99
 $dirmaskdec |= octdec('0200');  // Set w bit required to be able to create content for recursive subdirs files
93 100
 $newmask = decoct($dirmaskdec);
94 101
 
Please login to merge, or discard this patch.
htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
48 48
 	{
49
-        if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
49
+		if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
50 50
 
51 51
 		if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
52 52
 				|| $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') {
@@ -87,6 +87,6 @@  discard block
 block discarded – undo
87 87
 		}
88 88
 
89 89
 
90
-    }
90
+	}
91 91
 
92 92
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,38 +46,38 @@
 block discarded – undo
46 46
 	 */
47 47
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
48 48
 	{
49
-        if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
49
+        if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing
50 50
 
51
-		if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
51
+		if ($action === 'BILL_VALIDATE' || $action === 'BILL_PAYED' || $action === 'BILL_UNPAYED'
52 52
 				|| $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') {
53
-			$amounts=  (double) $object->total_ttc;
53
+			$amounts = (double) $object->total_ttc;
54 54
 		}
55
-		else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') {
55
+		else if ($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') {
56 56
 			$amounts = 0;
57
-			if(!empty($object->amounts)) {
58
-				foreach($object->amounts as $amount) {
59
-					$amounts+= price2num($amount);
57
+			if (!empty($object->amounts)) {
58
+				foreach ($object->amounts as $amount) {
59
+					$amounts += price2num($amount);
60 60
 				}
61 61
 			}
62 62
 
63 63
 
64 64
 		}
65
-		else if(strpos($action,'PAYMENT')!==false) {
66
-			$amounts= (double) $object->amount;
65
+		else if (strpos($action, 'PAYMENT') !== false) {
66
+			$amounts = (double) $object->amount;
67 67
 		}
68 68
 		else {
69 69
 			return 0; // not implemented action log
70 70
 		}
71 71
 
72
-		$b=new BlockedLog($this->db);
72
+		$b = new BlockedLog($this->db);
73 73
 		$b->action = $action;
74
-		$b->amounts= $amounts;
74
+		$b->amounts = $amounts;
75 75
 		$b->setObjectData($object);
76 76
 
77 77
 		$res = $b->create($user);
78 78
 
79
-		if($res<0) {
80
-			setEventMessage($b->error,'errors');
79
+		if ($res < 0) {
80
+			setEventMessage($b->error, 'errors');
81 81
 
82 82
 			return -1;
83 83
 		}
Please login to merge, or discard this patch.
Braces   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -46,13 +46,15 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
48 48
 	{
49
-        if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
49
+        if (empty($conf->blockedlog->enabled)) {
50
+        	return 0;
51
+        }
52
+        // Module not active, we do nothing
50 53
 
51 54
 		if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
52 55
 				|| $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') {
53 56
 			$amounts=  (double) $object->total_ttc;
54
-		}
55
-		else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') {
57
+		} else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') {
56 58
 			$amounts = 0;
57 59
 			if(!empty($object->amounts)) {
58 60
 				foreach($object->amounts as $amount) {
@@ -61,11 +63,9 @@  discard block
 block discarded – undo
61 63
 			}
62 64
 
63 65
 
64
-		}
65
-		else if(strpos($action,'PAYMENT')!==false) {
66
+		} else if(strpos($action,'PAYMENT')!==false) {
66 67
 			$amounts= (double) $object->amount;
67
-		}
68
-		else {
68
+		} else {
69 69
 			return 0; // not implemented action log
70 70
 		}
71 71
 
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
 			setEventMessage($b->error,'errors');
81 81
 
82 82
 			return -1;
83
-		}
84
-		else {
83
+		} else {
85 84
 
86 85
 			return 1;
87 86
 		}
Please login to merge, or discard this patch.
htdocs/core/triggers/interface_20_all_Logevents.class.php 3 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -48,78 +48,78 @@  discard block
 block discarded – undo
48 48
 	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
49 49
 	 */
50 50
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
51
-    {
52
-    	if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0;	// Log events is disabled (hidden features)
51
+	{
52
+		if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0;	// Log events is disabled (hidden features)
53 53
 
54
-    	$key='MAIN_LOGEVENTS_'.$action;
55
-    	//dol_syslog("xxxxxxxxxxx".$key);
56
-    	if (empty($conf->global->$key)) return 0;				// Log events not enabled for this action
54
+		$key='MAIN_LOGEVENTS_'.$action;
55
+		//dol_syslog("xxxxxxxxxxx".$key);
56
+		if (empty($conf->global->$key)) return 0;				// Log events not enabled for this action
57 57
 
58
-    	if (empty($conf->entity)) $conf->entity = $entity;  // forcing of the entity if it's not defined (ex: in login form)
58
+		if (empty($conf->entity)) $conf->entity = $entity;  // forcing of the entity if it's not defined (ex: in login form)
59 59
 
60
-        $date = dol_now();
60
+		$date = dol_now();
61 61
 
62
-        // Actions
63
-        if ($action == 'USER_LOGIN')
64
-        {
65
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
62
+		// Actions
63
+		if ($action == 'USER_LOGIN')
64
+		{
65
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
66 66
             
67
-            $langs->load("users");
68
-            // Initialisation donnees (date,duree,texte,desc)
69
-            $text="(UserLogged,".$object->login.")";
70
-            $text.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg);
71
-            $desc="(UserLogged,".$object->login.")";
72
-            $desc.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg);
73
-        }
74
-        if ($action == 'USER_LOGIN_FAILED')
75
-        {
76
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
77
-
78
-            // Initialisation donnees (date,duree,texte,desc)
79
-            $text=$object->trigger_mesg;	// Message direct
80
-            $desc=$object->trigger_mesg;	// Message direct
81
-        }
82
-        if ($action == 'USER_LOGOUT')
83
-        {
84
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
85
-
86
-            $langs->load("users");
87
-            // Initialisation donnees (date,duree,texte,desc)
88
-            $text="(UserLogoff,".$object->login.")";
89
-            $desc="(UserLogoff,".$object->login.")";
90
-        }
91
-        if ($action == 'USER_CREATE')
92
-        {
93
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
94
-            $langs->load("users");
95
-
96
-            // Initialisation donnees (date,duree,texte,desc)
97
-            $text=$langs->transnoentities("NewUserCreated",$object->login);
98
-            $desc=$langs->transnoentities("NewUserCreated",$object->login);
67
+			$langs->load("users");
68
+			// Initialisation donnees (date,duree,texte,desc)
69
+			$text="(UserLogged,".$object->login.")";
70
+			$text.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg);
71
+			$desc="(UserLogged,".$object->login.")";
72
+			$desc.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg);
99 73
 		}
100
-        elseif ($action == 'USER_MODIFY')
101
-        {
102
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
103
-            $langs->load("users");
104
-
105
-            // Initialisation donnees (date,duree,texte,desc)
106
-            $text=$langs->transnoentities("EventUserModified",$object->login);
107
-            $desc=$langs->transnoentities("EventUserModified",$object->login);
108
-        }
109
-        elseif ($action == 'USER_NEW_PASSWORD')
110
-        {
111
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
112
-            $langs->load("users");
74
+		if ($action == 'USER_LOGIN_FAILED')
75
+		{
76
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
113 77
 
114
-            // Initialisation donnees (date,duree,texte,desc)
115
-            $text=$langs->transnoentities("NewUserPassword",$object->login);
116
-            $desc=$langs->transnoentities("NewUserPassword",$object->login);
117
-        }
118
-        elseif ($action == 'USER_ENABLEDISABLE')
119
-        {
120
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
121
-            $langs->load("users");
122
-            // Initialisation donnees (date,duree,texte,desc)
78
+			// Initialisation donnees (date,duree,texte,desc)
79
+			$text=$object->trigger_mesg;	// Message direct
80
+			$desc=$object->trigger_mesg;	// Message direct
81
+		}
82
+		if ($action == 'USER_LOGOUT')
83
+		{
84
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
85
+
86
+			$langs->load("users");
87
+			// Initialisation donnees (date,duree,texte,desc)
88
+			$text="(UserLogoff,".$object->login.")";
89
+			$desc="(UserLogoff,".$object->login.")";
90
+		}
91
+		if ($action == 'USER_CREATE')
92
+		{
93
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
94
+			$langs->load("users");
95
+
96
+			// Initialisation donnees (date,duree,texte,desc)
97
+			$text=$langs->transnoentities("NewUserCreated",$object->login);
98
+			$desc=$langs->transnoentities("NewUserCreated",$object->login);
99
+		}
100
+		elseif ($action == 'USER_MODIFY')
101
+		{
102
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
103
+			$langs->load("users");
104
+
105
+			// Initialisation donnees (date,duree,texte,desc)
106
+			$text=$langs->transnoentities("EventUserModified",$object->login);
107
+			$desc=$langs->transnoentities("EventUserModified",$object->login);
108
+		}
109
+		elseif ($action == 'USER_NEW_PASSWORD')
110
+		{
111
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
112
+			$langs->load("users");
113
+
114
+			// Initialisation donnees (date,duree,texte,desc)
115
+			$text=$langs->transnoentities("NewUserPassword",$object->login);
116
+			$desc=$langs->transnoentities("NewUserPassword",$object->login);
117
+		}
118
+		elseif ($action == 'USER_ENABLEDISABLE')
119
+		{
120
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
121
+			$langs->load("users");
122
+			// Initialisation donnees (date,duree,texte,desc)
123 123
 			if ($object->statut == 0)
124 124
 			{
125 125
 				$text=$langs->transnoentities("UserEnabled",$object->login);
@@ -130,40 +130,40 @@  discard block
 block discarded – undo
130 130
 				$text=$langs->transnoentities("UserDisabled",$object->login);
131 131
 				$desc=$langs->transnoentities("UserDisabled",$object->login);
132 132
 			}
133
-        }
134
-        elseif ($action == 'USER_DELETE')
135
-        {
136
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137
-            $langs->load("users");
138
-            // Initialisation donnees (date,duree,texte,desc)
139
-            $text=$langs->transnoentities("UserDeleted",$object->login);
140
-            $desc=$langs->transnoentities("UserDeleted",$object->login);
141
-        }
133
+		}
134
+		elseif ($action == 'USER_DELETE')
135
+		{
136
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137
+			$langs->load("users");
138
+			// Initialisation donnees (date,duree,texte,desc)
139
+			$text=$langs->transnoentities("UserDeleted",$object->login);
140
+			$desc=$langs->transnoentities("UserDeleted",$object->login);
141
+		}
142 142
 
143 143
 		// Groupes
144
-        elseif ($action == 'GROUP_CREATE')
145
-        {
146
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
147
-            $langs->load("users");
148
-            // Initialisation donnees (date,duree,texte,desc)
149
-            $text=$langs->transnoentities("NewGroupCreated",$object->name);
150
-            $desc=$langs->transnoentities("NewGroupCreated",$object->name);
144
+		elseif ($action == 'GROUP_CREATE')
145
+		{
146
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
147
+			$langs->load("users");
148
+			// Initialisation donnees (date,duree,texte,desc)
149
+			$text=$langs->transnoentities("NewGroupCreated",$object->name);
150
+			$desc=$langs->transnoentities("NewGroupCreated",$object->name);
151 151
 		}
152
-        elseif ($action == 'GROUP_MODIFY')
153
-        {
154
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
155
-            $langs->load("users");
156
-            // Initialisation donnees (date,duree,texte,desc)
157
-            $text=$langs->transnoentities("GroupModified",$object->name);
158
-            $desc=$langs->transnoentities("GroupModified",$object->name);
152
+		elseif ($action == 'GROUP_MODIFY')
153
+		{
154
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
155
+			$langs->load("users");
156
+			// Initialisation donnees (date,duree,texte,desc)
157
+			$text=$langs->transnoentities("GroupModified",$object->name);
158
+			$desc=$langs->transnoentities("GroupModified",$object->name);
159 159
 		}
160
-        elseif ($action == 'GROUP_DELETE')
161
-        {
162
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
163
-            $langs->load("users");
164
-            // Initialisation donnees (date,duree,texte,desc)
165
-            $text=$langs->transnoentities("GroupDeleted",$object->name);
166
-            $desc=$langs->transnoentities("GroupDeleted",$object->name);
160
+		elseif ($action == 'GROUP_DELETE')
161
+		{
162
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
163
+			$langs->load("users");
164
+			// Initialisation donnees (date,duree,texte,desc)
165
+			$text=$langs->transnoentities("GroupDeleted",$object->name);
166
+			$desc=$langs->transnoentities("GroupDeleted",$object->name);
167 167
 		}
168 168
 
169 169
 		// If not found
@@ -178,29 +178,29 @@  discard block
 block discarded – undo
178 178
 		// Add more information into desc from the context property
179 179
 		if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
180 180
 		
181
-        // Add entry in event table
181
+		// Add entry in event table
182 182
 		include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
183 183
 
184 184
 		$event=new Events($this->db);
185
-        $event->type=$action;
186
-        $event->dateevent=$date;
187
-        $event->label=$text;
188
-        $event->description=$desc;
185
+		$event->type=$action;
186
+		$event->dateevent=$date;
187
+		$event->label=$text;
188
+		$event->description=$desc;
189 189
 		$event->user_agent=$_SERVER["HTTP_USER_AGENT"];
190 190
 
191
-        $result=$event->create($user);
192
-        if ($result > 0)
193
-        {
194
-            return 1;
195
-        }
196
-        else
197
-        {
198
-            $error ="Failed to insert security event: ".$event->error;
199
-            $this->error=$error;
191
+		$result=$event->create($user);
192
+		if ($result > 0)
193
+		{
194
+			return 1;
195
+		}
196
+		else
197
+		{
198
+			$error ="Failed to insert security event: ".$event->error;
199
+			$this->error=$error;
200 200
 
201
-            dol_syslog(get_class($this).": ".$this->error, LOG_ERR);
202
-            return -1;
203
-        }
204
-    }
201
+			dol_syslog(get_class($this).": ".$this->error, LOG_ERR);
202
+			return -1;
203
+		}
204
+	}
205 205
 
206 206
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
51 51
     {
52
-    	if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0;	// Log events is disabled (hidden features)
52
+    	if (!empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features)
53 53
 
54
-    	$key='MAIN_LOGEVENTS_'.$action;
54
+    	$key = 'MAIN_LOGEVENTS_'.$action;
55 55
     	//dol_syslog("xxxxxxxxxxx".$key);
56
-    	if (empty($conf->global->$key)) return 0;				// Log events not enabled for this action
56
+    	if (empty($conf->global->$key)) return 0; // Log events not enabled for this action
57 57
 
58
-    	if (empty($conf->entity)) $conf->entity = $entity;  // forcing of the entity if it's not defined (ex: in login form)
58
+    	if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form)
59 59
 
60 60
         $date = dol_now();
61 61
 
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
             
67 67
             $langs->load("users");
68 68
             // Initialisation donnees (date,duree,texte,desc)
69
-            $text="(UserLogged,".$object->login.")";
70
-            $text.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg);
71
-            $desc="(UserLogged,".$object->login.")";
72
-            $desc.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg);
69
+            $text = "(UserLogged,".$object->login.")";
70
+            $text .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg);
71
+            $desc = "(UserLogged,".$object->login.")";
72
+            $desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg);
73 73
         }
74 74
         if ($action == 'USER_LOGIN_FAILED')
75 75
         {
76 76
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
77 77
 
78 78
             // Initialisation donnees (date,duree,texte,desc)
79
-            $text=$object->trigger_mesg;	// Message direct
80
-            $desc=$object->trigger_mesg;	// Message direct
79
+            $text = $object->trigger_mesg; // Message direct
80
+            $desc = $object->trigger_mesg; // Message direct
81 81
         }
82 82
         if ($action == 'USER_LOGOUT')
83 83
         {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 
86 86
             $langs->load("users");
87 87
             // Initialisation donnees (date,duree,texte,desc)
88
-            $text="(UserLogoff,".$object->login.")";
89
-            $desc="(UserLogoff,".$object->login.")";
88
+            $text = "(UserLogoff,".$object->login.")";
89
+            $desc = "(UserLogoff,".$object->login.")";
90 90
         }
91 91
         if ($action == 'USER_CREATE')
92 92
         {
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
             $langs->load("users");
95 95
 
96 96
             // Initialisation donnees (date,duree,texte,desc)
97
-            $text=$langs->transnoentities("NewUserCreated",$object->login);
98
-            $desc=$langs->transnoentities("NewUserCreated",$object->login);
97
+            $text = $langs->transnoentities("NewUserCreated", $object->login);
98
+            $desc = $langs->transnoentities("NewUserCreated", $object->login);
99 99
 		}
100 100
         elseif ($action == 'USER_MODIFY')
101 101
         {
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
             $langs->load("users");
104 104
 
105 105
             // Initialisation donnees (date,duree,texte,desc)
106
-            $text=$langs->transnoentities("EventUserModified",$object->login);
107
-            $desc=$langs->transnoentities("EventUserModified",$object->login);
106
+            $text = $langs->transnoentities("EventUserModified", $object->login);
107
+            $desc = $langs->transnoentities("EventUserModified", $object->login);
108 108
         }
109 109
         elseif ($action == 'USER_NEW_PASSWORD')
110 110
         {
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
             $langs->load("users");
113 113
 
114 114
             // Initialisation donnees (date,duree,texte,desc)
115
-            $text=$langs->transnoentities("NewUserPassword",$object->login);
116
-            $desc=$langs->transnoentities("NewUserPassword",$object->login);
115
+            $text = $langs->transnoentities("NewUserPassword", $object->login);
116
+            $desc = $langs->transnoentities("NewUserPassword", $object->login);
117 117
         }
118 118
         elseif ($action == 'USER_ENABLEDISABLE')
119 119
         {
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
             // Initialisation donnees (date,duree,texte,desc)
123 123
 			if ($object->statut == 0)
124 124
 			{
125
-				$text=$langs->transnoentities("UserEnabled",$object->login);
126
-				$desc=$langs->transnoentities("UserEnabled",$object->login);
125
+				$text = $langs->transnoentities("UserEnabled", $object->login);
126
+				$desc = $langs->transnoentities("UserEnabled", $object->login);
127 127
 			}
128 128
 			if ($object->statut == 1)
129 129
 			{
130
-				$text=$langs->transnoentities("UserDisabled",$object->login);
131
-				$desc=$langs->transnoentities("UserDisabled",$object->login);
130
+				$text = $langs->transnoentities("UserDisabled", $object->login);
131
+				$desc = $langs->transnoentities("UserDisabled", $object->login);
132 132
 			}
133 133
         }
134 134
         elseif ($action == 'USER_DELETE')
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137 137
             $langs->load("users");
138 138
             // Initialisation donnees (date,duree,texte,desc)
139
-            $text=$langs->transnoentities("UserDeleted",$object->login);
140
-            $desc=$langs->transnoentities("UserDeleted",$object->login);
139
+            $text = $langs->transnoentities("UserDeleted", $object->login);
140
+            $desc = $langs->transnoentities("UserDeleted", $object->login);
141 141
         }
142 142
 
143 143
 		// Groupes
@@ -146,24 +146,24 @@  discard block
 block discarded – undo
146 146
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
147 147
             $langs->load("users");
148 148
             // Initialisation donnees (date,duree,texte,desc)
149
-            $text=$langs->transnoentities("NewGroupCreated",$object->name);
150
-            $desc=$langs->transnoentities("NewGroupCreated",$object->name);
149
+            $text = $langs->transnoentities("NewGroupCreated", $object->name);
150
+            $desc = $langs->transnoentities("NewGroupCreated", $object->name);
151 151
 		}
152 152
         elseif ($action == 'GROUP_MODIFY')
153 153
         {
154 154
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
155 155
             $langs->load("users");
156 156
             // Initialisation donnees (date,duree,texte,desc)
157
-            $text=$langs->transnoentities("GroupModified",$object->name);
158
-            $desc=$langs->transnoentities("GroupModified",$object->name);
157
+            $text = $langs->transnoentities("GroupModified", $object->name);
158
+            $desc = $langs->transnoentities("GroupModified", $object->name);
159 159
 		}
160 160
         elseif ($action == 'GROUP_DELETE')
161 161
         {
162 162
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
163 163
             $langs->load("users");
164 164
             // Initialisation donnees (date,duree,texte,desc)
165
-            $text=$langs->transnoentities("GroupDeleted",$object->name);
166
-            $desc=$langs->transnoentities("GroupDeleted",$object->name);
165
+            $text = $langs->transnoentities("GroupDeleted", $object->name);
166
+            $desc = $langs->transnoentities("GroupDeleted", $object->name);
167 167
 		}
168 168
 
169 169
 		// If not found
@@ -176,27 +176,27 @@  discard block
 block discarded – undo
176 176
 */
177 177
 
178 178
 		// Add more information into desc from the context property
179
-		if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
179
+		if (!empty($desc) && !empty($object->context['audit'])) $desc .= ' - '.$object->context['audit'];
180 180
 		
181 181
         // Add entry in event table
182 182
 		include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
183 183
 
184
-		$event=new Events($this->db);
185
-        $event->type=$action;
186
-        $event->dateevent=$date;
187
-        $event->label=$text;
188
-        $event->description=$desc;
189
-		$event->user_agent=$_SERVER["HTTP_USER_AGENT"];
184
+		$event = new Events($this->db);
185
+        $event->type = $action;
186
+        $event->dateevent = $date;
187
+        $event->label = $text;
188
+        $event->description = $desc;
189
+		$event->user_agent = $_SERVER["HTTP_USER_AGENT"];
190 190
 
191
-        $result=$event->create($user);
191
+        $result = $event->create($user);
192 192
         if ($result > 0)
193 193
         {
194 194
             return 1;
195 195
         }
196 196
         else
197 197
         {
198
-            $error ="Failed to insert security event: ".$event->error;
199
-            $this->error=$error;
198
+            $error = "Failed to insert security event: ".$event->error;
199
+            $this->error = $error;
200 200
 
201 201
             dol_syslog(get_class($this).": ".$this->error, LOG_ERR);
202 202
             return -1;
Please login to merge, or discard this patch.
Braces   +22 added lines, -18 removed lines patch added patch discarded remove patch
@@ -49,13 +49,22 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
51 51
     {
52
-    	if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0;	// Log events is disabled (hidden features)
52
+    	if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) {
53
+    		return 0;
54
+    	}
55
+    	// Log events is disabled (hidden features)
53 56
 
54 57
     	$key='MAIN_LOGEVENTS_'.$action;
55 58
     	//dol_syslog("xxxxxxxxxxx".$key);
56
-    	if (empty($conf->global->$key)) return 0;				// Log events not enabled for this action
59
+    	if (empty($conf->global->$key)) {
60
+    		return 0;
61
+    	}
62
+    	// Log events not enabled for this action
57 63
 
58
-    	if (empty($conf->entity)) $conf->entity = $entity;  // forcing of the entity if it's not defined (ex: in login form)
64
+    	if (empty($conf->entity)) {
65
+    		$conf->entity = $entity;
66
+    	}
67
+    	// forcing of the entity if it's not defined (ex: in login form)
59 68
 
60 69
         $date = dol_now();
61 70
 
@@ -96,8 +105,7 @@  discard block
 block discarded – undo
96 105
             // Initialisation donnees (date,duree,texte,desc)
97 106
             $text=$langs->transnoentities("NewUserCreated",$object->login);
98 107
             $desc=$langs->transnoentities("NewUserCreated",$object->login);
99
-		}
100
-        elseif ($action == 'USER_MODIFY')
108
+		} elseif ($action == 'USER_MODIFY')
101 109
         {
102 110
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
103 111
             $langs->load("users");
@@ -105,8 +113,7 @@  discard block
 block discarded – undo
105 113
             // Initialisation donnees (date,duree,texte,desc)
106 114
             $text=$langs->transnoentities("EventUserModified",$object->login);
107 115
             $desc=$langs->transnoentities("EventUserModified",$object->login);
108
-        }
109
-        elseif ($action == 'USER_NEW_PASSWORD')
116
+        } elseif ($action == 'USER_NEW_PASSWORD')
110 117
         {
111 118
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
112 119
             $langs->load("users");
@@ -114,8 +121,7 @@  discard block
 block discarded – undo
114 121
             // Initialisation donnees (date,duree,texte,desc)
115 122
             $text=$langs->transnoentities("NewUserPassword",$object->login);
116 123
             $desc=$langs->transnoentities("NewUserPassword",$object->login);
117
-        }
118
-        elseif ($action == 'USER_ENABLEDISABLE')
124
+        } elseif ($action == 'USER_ENABLEDISABLE')
119 125
         {
120 126
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
121 127
             $langs->load("users");
@@ -130,8 +136,7 @@  discard block
 block discarded – undo
130 136
 				$text=$langs->transnoentities("UserDisabled",$object->login);
131 137
 				$desc=$langs->transnoentities("UserDisabled",$object->login);
132 138
 			}
133
-        }
134
-        elseif ($action == 'USER_DELETE')
139
+        } elseif ($action == 'USER_DELETE')
135 140
         {
136 141
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137 142
             $langs->load("users");
@@ -148,16 +153,14 @@  discard block
 block discarded – undo
148 153
             // Initialisation donnees (date,duree,texte,desc)
149 154
             $text=$langs->transnoentities("NewGroupCreated",$object->name);
150 155
             $desc=$langs->transnoentities("NewGroupCreated",$object->name);
151
-		}
152
-        elseif ($action == 'GROUP_MODIFY')
156
+		} elseif ($action == 'GROUP_MODIFY')
153 157
         {
154 158
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
155 159
             $langs->load("users");
156 160
             // Initialisation donnees (date,duree,texte,desc)
157 161
             $text=$langs->transnoentities("GroupModified",$object->name);
158 162
             $desc=$langs->transnoentities("GroupModified",$object->name);
159
-		}
160
-        elseif ($action == 'GROUP_DELETE')
163
+		} elseif ($action == 'GROUP_DELETE')
161 164
         {
162 165
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
163 166
             $langs->load("users");
@@ -176,7 +179,9 @@  discard block
 block discarded – undo
176 179
 */
177 180
 
178 181
 		// Add more information into desc from the context property
179
-		if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
182
+		if (! empty($desc) && ! empty($object->context['audit'])) {
183
+			$desc.=' - '.$object->context['audit'];
184
+		}
180 185
 		
181 186
         // Add entry in event table
182 187
 		include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
@@ -192,8 +197,7 @@  discard block
 block discarded – undo
192 197
         if ($result > 0)
193 198
         {
194 199
             return 1;
195
-        }
196
-        else
200
+        } else
197 201
         {
198 202
             $error ="Failed to insert security event: ".$event->error;
199 203
             $this->error=$error;
Please login to merge, or discard this patch.
htdocs/core/triggers/interface_50_modNotification_Notification.class.php 3 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	public $version = self::VERSION_DOLIBARR;
36 36
 	public $picto = 'email';
37 37
 
38
-    var $listofmanagedevents=array(
39
-        'BILL_VALIDATE',
40
-        'BILL_PAYED',
41
-    	'ORDER_VALIDATE',
42
-    	'PROPAL_VALIDATE',
43
-        'FICHINTER_VALIDATE',
44
-        'FICHINTER_ADD_CONTACT',
45
-    	'ORDER_SUPPLIER_VALIDATE',
46
-    	'ORDER_SUPPLIER_APPROVE',
47
-    	'ORDER_SUPPLIER_REFUSE',
48
-        'SHIPPING_VALIDATE'
38
+	var $listofmanagedevents=array(
39
+		'BILL_VALIDATE',
40
+		'BILL_PAYED',
41
+		'ORDER_VALIDATE',
42
+		'PROPAL_VALIDATE',
43
+		'FICHINTER_VALIDATE',
44
+		'FICHINTER_ADD_CONTACT',
45
+		'ORDER_SUPPLIER_VALIDATE',
46
+		'ORDER_SUPPLIER_APPROVE',
47
+		'ORDER_SUPPLIER_REFUSE',
48
+		'SHIPPING_VALIDATE'
49 49
    	);
50 50
 
51 51
 	/**
@@ -73,62 +73,62 @@  discard block
 block discarded – undo
73 73
 		$notify->send($action, $object);
74 74
 
75 75
 		return 1;
76
-    }
77
-
78
-
79
-    /**
80
-     * Return list of events managed by notification module
81
-     *
82
-     * @return      array       Array of events managed by notification module
83
-     */
84
-    function getListOfManagedEvents()
85
-    {
86
-        global $conf;
87
-
88
-        $ret=array();
89
-
90
-        $sql = "SELECT rowid, code, label, description, elementtype";
91
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
92
-        $sql.= $this->db->order("rang, elementtype, code");
93
-        dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
94
-        $resql=$this->db->query($sql);
95
-        if ($resql)
96
-        {
97
-            $num=$this->db->num_rows($resql);
98
-            $i=0;
99
-            while ($i < $num)
100
-            {
101
-                $obj=$this->db->fetch_object($resql);
102
-
103
-                $qualified=0;
104
-                // Check is this event is supported by notification module
105
-                if (in_array($obj->code,$this->listofmanagedevents)) $qualified=1;
106
-                // Check if module for this event is active
107
-                if ($qualified)
108
-                {
109
-                    //print 'xx'.$obj->code;
110
-                    $element=$obj->elementtype;
111
-
112
-                    // Exclude events if related module is disabled
113
-                    if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
114
-                    elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
115
-                    elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
116
-                    elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
117
-                    elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
118
-                    elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) $qualified=0;
119
-                }
120
-
121
-                if ($qualified)
122
-                {
123
-                    $ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
124
-                }
125
-
126
-                $i++;
127
-            }
128
-        }
129
-        else dol_print_error($this->db);
130
-
131
-        return $ret;
132
-    }
76
+	}
77
+
78
+
79
+	/**
80
+	 * Return list of events managed by notification module
81
+	 *
82
+	 * @return      array       Array of events managed by notification module
83
+	 */
84
+	function getListOfManagedEvents()
85
+	{
86
+		global $conf;
87
+
88
+		$ret=array();
89
+
90
+		$sql = "SELECT rowid, code, label, description, elementtype";
91
+		$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
92
+		$sql.= $this->db->order("rang, elementtype, code");
93
+		dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
94
+		$resql=$this->db->query($sql);
95
+		if ($resql)
96
+		{
97
+			$num=$this->db->num_rows($resql);
98
+			$i=0;
99
+			while ($i < $num)
100
+			{
101
+				$obj=$this->db->fetch_object($resql);
102
+
103
+				$qualified=0;
104
+				// Check is this event is supported by notification module
105
+				if (in_array($obj->code,$this->listofmanagedevents)) $qualified=1;
106
+				// Check if module for this event is active
107
+				if ($qualified)
108
+				{
109
+					//print 'xx'.$obj->code;
110
+					$element=$obj->elementtype;
111
+
112
+					// Exclude events if related module is disabled
113
+					if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
114
+					elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
115
+					elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
116
+					elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
117
+					elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
118
+					elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) $qualified=0;
119
+				}
120
+
121
+				if ($qualified)
122
+				{
123
+					$ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
124
+				}
125
+
126
+				$i++;
127
+			}
128
+		}
129
+		else dol_print_error($this->db);
130
+
131
+		return $ret;
132
+	}
133 133
 
134 134
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	public $version = self::VERSION_DOLIBARR;
36 36
 	public $picto = 'email';
37 37
 
38
-    var $listofmanagedevents=array(
38
+    var $listofmanagedevents = array(
39 39
         'BILL_VALIDATE',
40 40
         'BILL_PAYED',
41 41
     	'ORDER_VALIDATE',
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
63 63
 	{
64
-		if (empty($conf->notification->enabled)) return 0;     // Module not active, we do nothing
64
+		if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing
65 65
 
66
-		require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
66
+		require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
67 67
 		$notify = new Notify($this->db);
68 68
 
69
-		if (! in_array($action, $notify->arrayofnotifsupported)) return 0;
69
+		if (!in_array($action, $notify->arrayofnotifsupported)) return 0;
70 70
 
71 71
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
72 72
 
@@ -85,42 +85,42 @@  discard block
 block discarded – undo
85 85
     {
86 86
         global $conf;
87 87
 
88
-        $ret=array();
88
+        $ret = array();
89 89
 
90 90
         $sql = "SELECT rowid, code, label, description, elementtype";
91
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
92
-        $sql.= $this->db->order("rang, elementtype, code");
91
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
92
+        $sql .= $this->db->order("rang, elementtype, code");
93 93
         dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
94
-        $resql=$this->db->query($sql);
94
+        $resql = $this->db->query($sql);
95 95
         if ($resql)
96 96
         {
97
-            $num=$this->db->num_rows($resql);
98
-            $i=0;
97
+            $num = $this->db->num_rows($resql);
98
+            $i = 0;
99 99
             while ($i < $num)
100 100
             {
101
-                $obj=$this->db->fetch_object($resql);
101
+                $obj = $this->db->fetch_object($resql);
102 102
 
103
-                $qualified=0;
103
+                $qualified = 0;
104 104
                 // Check is this event is supported by notification module
105
-                if (in_array($obj->code,$this->listofmanagedevents)) $qualified=1;
105
+                if (in_array($obj->code, $this->listofmanagedevents)) $qualified = 1;
106 106
                 // Check if module for this event is active
107 107
                 if ($qualified)
108 108
                 {
109 109
                     //print 'xx'.$obj->code;
110
-                    $element=$obj->elementtype;
110
+                    $element = $obj->elementtype;
111 111
 
112 112
                     // Exclude events if related module is disabled
113
-                    if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
114
-                    elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
115
-                    elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
116
-                    elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
117
-                    elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
118
-                    elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) $qualified=0;
113
+                    if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified = 0;
114
+                    elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified = 0;
115
+                    elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified = 0;
116
+                    elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified = 0;
117
+                    elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified = 0;
118
+                    elseif (!in_array($element, array('order_supplier', 'invoice_supplier', 'withdraw', 'shipping', 'member')) && empty($conf->$element->enabled)) $qualified = 0;
119 119
                 }
120 120
 
121 121
                 if ($qualified)
122 122
                 {
123
-                    $ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
123
+                    $ret[] = array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$obj->label, 'description'=>$obj->description, 'elementtype'=>$obj->elementtype);
124 124
                 }
125 125
 
126 126
                 $i++;
Please login to merge, or discard this patch.
Braces   +25 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,12 +61,17 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
63 63
 	{
64
-		if (empty($conf->notification->enabled)) return 0;     // Module not active, we do nothing
64
+		if (empty($conf->notification->enabled)) {
65
+			return 0;
66
+		}
67
+		// Module not active, we do nothing
65 68
 
66 69
 		require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
67 70
 		$notify = new Notify($this->db);
68 71
 
69
-		if (! in_array($action, $notify->arrayofnotifsupported)) return 0;
72
+		if (! in_array($action, $notify->arrayofnotifsupported)) {
73
+			return 0;
74
+		}
70 75
 
71 76
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
72 77
 
@@ -102,7 +107,9 @@  discard block
 block discarded – undo
102 107
 
103 108
                 $qualified=0;
104 109
                 // Check is this event is supported by notification module
105
-                if (in_array($obj->code,$this->listofmanagedevents)) $qualified=1;
110
+                if (in_array($obj->code,$this->listofmanagedevents)) {
111
+                	$qualified=1;
112
+                }
106 113
                 // Check if module for this event is active
107 114
                 if ($qualified)
108 115
                 {
@@ -110,12 +117,19 @@  discard block
 block discarded – undo
110 117
                     $element=$obj->elementtype;
111 118
 
112 119
                     // Exclude events if related module is disabled
113
-                    if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
114
-                    elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
115
-                    elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
116
-                    elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
117
-                    elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
118
-                    elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) $qualified=0;
120
+                    if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) {
121
+                    	$qualified=0;
122
+                    } elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) {
123
+                    	$qualified=0;
124
+                    } elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) {
125
+                    	$qualified=0;
126
+                    } elseif ($element == 'shipping' && empty($conf->expedition->enabled)) {
127
+                    	$qualified=0;
128
+                    } elseif ($element == 'member' && empty($conf->adherent->enabled)) {
129
+                    	$qualified=0;
130
+                    } elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) {
131
+                    	$qualified=0;
132
+                    }
119 133
                 }
120 134
 
121 135
                 if ($qualified)
@@ -125,8 +139,9 @@  discard block
 block discarded – undo
125 139
 
126 140
                 $i++;
127 141
             }
142
+        } else {
143
+        	dol_print_error($this->db);
128 144
         }
129
-        else dol_print_error($this->db);
130 145
 
131 146
         return $ret;
132 147
     }
Please login to merge, or discard this patch.
core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -49,52 +49,52 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
51 51
 	{
52
-        if (empty($conf->mailmanspip->enabled)) return 0;     // Module not active, we do nothing
53
-
54
-        if ($action == 'CATEGORY_LINK')
55
-        {
56
-        	dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
57
-
58
-        	// We add subscription if we change category (new category may means more mailing-list to subscribe)
59
-    		if (is_object($object->linkto) && method_exists($object->linkto, 'add_to_abo') && $object->linkto->add_to_abo() < 0)
60
-    		{
61
-    			$this->error=$object->linkto->error;
62
-    			$this->errors=$object->linkto->errors;
63
-    			$return=-1;
64
-    		}
52
+		if (empty($conf->mailmanspip->enabled)) return 0;     // Module not active, we do nothing
53
+
54
+		if ($action == 'CATEGORY_LINK')
55
+		{
56
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
57
+
58
+			// We add subscription if we change category (new category may means more mailing-list to subscribe)
59
+			if (is_object($object->linkto) && method_exists($object->linkto, 'add_to_abo') && $object->linkto->add_to_abo() < 0)
60
+			{
61
+				$this->error=$object->linkto->error;
62
+				$this->errors=$object->linkto->errors;
63
+				$return=-1;
64
+			}
65
+			else
66
+			{
67
+				$return=1;
68
+			}
69
+
70
+			return $return;
71
+		}
72
+		elseif ($action == 'CATEGORY_UNLINK')
73
+		{
74
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
75
+
76
+			// We remove subscription if we change category (lessw category may means less mailing-list to subscribe)
77
+			if (is_object($object->unlinkoff) && method_exists($object->unlinkoff, 'del_to_abo') && $object->unlinkoff->del_to_abo() < 0)
78
+			{
79
+				$this->error=$object->unlinkoff->error;
80
+				$this->errors=$object->unlinkoff->errors;
81
+				$return=-1;
82
+			}
65 83
 			else
66 84
 			{
67 85
 				$return=1;
68 86
 			}
69 87
 
70
-        	return $return;
71
-        }
72
-        elseif ($action == 'CATEGORY_UNLINK')
73
-        {
74
-        	dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
75
-
76
-        	// We remove subscription if we change category (lessw category may means less mailing-list to subscribe)
77
-        	if (is_object($object->unlinkoff) && method_exists($object->unlinkoff, 'del_to_abo') && $object->unlinkoff->del_to_abo() < 0)
78
-        	{
79
-    			$this->error=$object->unlinkoff->error;
80
-        		$this->errors=$object->unlinkoff->errors;
81
-        		$return=-1;
82
-        	}
83
-        	else
84
-        	{
85
-        		$return=1;
86
-        	}
87
-
88
-        	return $return;
89
-        }
90
-
91
-        // Members
92
-        elseif ($action == 'MEMBER_VALIDATE' || $action == 'MEMBER_MODIFY')
93
-        {
94
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
88
+			return $return;
89
+		}
90
+
91
+		// Members
92
+		elseif ($action == 'MEMBER_VALIDATE' || $action == 'MEMBER_MODIFY')
93
+		{
94
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
95 95
 
96 96
 			$return=0;
97
-            // Add user into some linked tools (mailman, spip, etc...)
97
+			// Add user into some linked tools (mailman, spip, etc...)
98 98
 			if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))	// TODO Do del/add also if type change
99 99
 			{
100 100
 				if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email))    // If email has changed we delete mailman subscription for old email
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 						$return=1;
111 111
 					}
112 112
 				}
113
-    			// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
114
-    			if ($object->add_to_abo() < 0)
115
-    			{
116
-    				 if (! empty($object->error)) $this->error=$object->error;
117
-    				 $this->errors=$object->errors;
118
-    				 $return=-1;
119
-    			}
113
+				// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
114
+				if ($object->add_to_abo() < 0)
115
+				{
116
+					 if (! empty($object->error)) $this->error=$object->error;
117
+					 $this->errors=$object->errors;
118
+					 $return=-1;
119
+				}
120 120
 				else
121 121
 				{
122 122
 					$return=1;
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 			}
125 125
 
126 126
 			return $return;
127
-        }
128
-        elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
129
-        {
130
-            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
131
-
132
-            $return=0;
133
-            // Remove from external tools (mailman, spip, etc...)
134
-        	if ($object->del_to_abo() < 0)
127
+		}
128
+		elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
129
+		{
130
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
131
+
132
+			$return=0;
133
+			// Remove from external tools (mailman, spip, etc...)
134
+			if ($object->del_to_abo() < 0)
135 135
 			{
136 136
 				if (! empty($object->error)) $this->error=$object->error;
137 137
 				$this->errors=$object->errors;
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
 				$return=1;
143 143
 			}
144 144
 
145
-	        return $return;
146
-        }
145
+			return $return;
146
+		}
147 147
 
148 148
 		return 0;
149
-    }
149
+	}
150 150
 
151 151
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
51 51
 	{
52
-        if (empty($conf->mailmanspip->enabled)) return 0;     // Module not active, we do nothing
52
+        if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing
53 53
 
54 54
         if ($action == 'CATEGORY_LINK')
55 55
         {
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
         	// We add subscription if we change category (new category may means more mailing-list to subscribe)
59 59
     		if (is_object($object->linkto) && method_exists($object->linkto, 'add_to_abo') && $object->linkto->add_to_abo() < 0)
60 60
     		{
61
-    			$this->error=$object->linkto->error;
62
-    			$this->errors=$object->linkto->errors;
63
-    			$return=-1;
61
+    			$this->error = $object->linkto->error;
62
+    			$this->errors = $object->linkto->errors;
63
+    			$return = -1;
64 64
     		}
65 65
 			else
66 66
 			{
67
-				$return=1;
67
+				$return = 1;
68 68
 			}
69 69
 
70 70
         	return $return;
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
         	// We remove subscription if we change category (lessw category may means less mailing-list to subscribe)
77 77
         	if (is_object($object->unlinkoff) && method_exists($object->unlinkoff, 'del_to_abo') && $object->unlinkoff->del_to_abo() < 0)
78 78
         	{
79
-    			$this->error=$object->unlinkoff->error;
80
-        		$this->errors=$object->unlinkoff->errors;
81
-        		$return=-1;
79
+    			$this->error = $object->unlinkoff->error;
80
+        		$this->errors = $object->unlinkoff->errors;
81
+        		$return = -1;
82 82
         	}
83 83
         	else
84 84
         	{
85
-        		$return=1;
85
+        		$return = 1;
86 86
         	}
87 87
 
88 88
         	return $return;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         {
94 94
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
95 95
 
96
-			$return=0;
96
+			$return = 0;
97 97
             // Add user into some linked tools (mailman, spip, etc...)
98 98
 			if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))	// TODO Do del/add also if type change
99 99
 			{
@@ -101,25 +101,25 @@  discard block
 block discarded – undo
101 101
 				{
102 102
 					if ($object->oldcopy->del_to_abo() < 0)
103 103
 					{
104
-						if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
105
-						$this->errors=$object->oldcopy->errors;
106
-						$return=-1;
104
+						if (!empty($object->oldcopy->error)) $this->error = $object->oldcopy->error;
105
+						$this->errors = $object->oldcopy->errors;
106
+						$return = -1;
107 107
 					}
108 108
 					else
109 109
 					{
110
-						$return=1;
110
+						$return = 1;
111 111
 					}
112 112
 				}
113 113
     			// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
114 114
     			if ($object->add_to_abo() < 0)
115 115
     			{
116
-    				 if (! empty($object->error)) $this->error=$object->error;
117
-    				 $this->errors=$object->errors;
118
-    				 $return=-1;
116
+    				 if (!empty($object->error)) $this->error = $object->error;
117
+    				 $this->errors = $object->errors;
118
+    				 $return = -1;
119 119
     			}
120 120
 				else
121 121
 				{
122
-					$return=1;
122
+					$return = 1;
123 123
 				}
124 124
 			}
125 125
 
@@ -129,17 +129,17 @@  discard block
 block discarded – undo
129 129
         {
130 130
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
131 131
 
132
-            $return=0;
132
+            $return = 0;
133 133
             // Remove from external tools (mailman, spip, etc...)
134 134
         	if ($object->del_to_abo() < 0)
135 135
 			{
136
-				if (! empty($object->error)) $this->error=$object->error;
137
-				$this->errors=$object->errors;
138
-				$return=-1;
136
+				if (!empty($object->error)) $this->error = $object->error;
137
+				$this->errors = $object->errors;
138
+				$return = -1;
139 139
 			}
140 140
 			else
141 141
 			{
142
-				$return=1;
142
+				$return = 1;
143 143
 			}
144 144
 
145 145
 	        return $return;
Please login to merge, or discard this patch.
Braces   +20 added lines, -18 removed lines patch added patch discarded remove patch
@@ -49,7 +49,10 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
51 51
 	{
52
-        if (empty($conf->mailmanspip->enabled)) return 0;     // Module not active, we do nothing
52
+        if (empty($conf->mailmanspip->enabled)) {
53
+        	return 0;
54
+        }
55
+        // Module not active, we do nothing
53 56
 
54 57
         if ($action == 'CATEGORY_LINK')
55 58
         {
@@ -61,15 +64,13 @@  discard block
 block discarded – undo
61 64
     			$this->error=$object->linkto->error;
62 65
     			$this->errors=$object->linkto->errors;
63 66
     			$return=-1;
64
-    		}
65
-			else
67
+    		} else
66 68
 			{
67 69
 				$return=1;
68 70
 			}
69 71
 
70 72
         	return $return;
71
-        }
72
-        elseif ($action == 'CATEGORY_UNLINK')
73
+        } elseif ($action == 'CATEGORY_UNLINK')
73 74
         {
74 75
         	dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
75 76
 
@@ -79,8 +80,7 @@  discard block
 block discarded – undo
79 80
     			$this->error=$object->unlinkoff->error;
80 81
         		$this->errors=$object->unlinkoff->errors;
81 82
         		$return=-1;
82
-        	}
83
-        	else
83
+        	} else
84 84
         	{
85 85
         		$return=1;
86 86
         	}
@@ -95,17 +95,18 @@  discard block
 block discarded – undo
95 95
 
96 96
 			$return=0;
97 97
             // Add user into some linked tools (mailman, spip, etc...)
98
-			if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))	// TODO Do del/add also if type change
98
+			if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) {
99
+				// TODO Do del/add also if type change
99 100
 			{
100 101
 				if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email))    // If email has changed we delete mailman subscription for old email
101 102
 				{
102 103
 					if ($object->oldcopy->del_to_abo() < 0)
103 104
 					{
104 105
 						if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
106
+			}
105 107
 						$this->errors=$object->oldcopy->errors;
106 108
 						$return=-1;
107
-					}
108
-					else
109
+					} else
109 110
 					{
110 111
 						$return=1;
111 112
 					}
@@ -113,19 +114,19 @@  discard block
 block discarded – undo
113 114
     			// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
114 115
     			if ($object->add_to_abo() < 0)
115 116
     			{
116
-    				 if (! empty($object->error)) $this->error=$object->error;
117
+    				 if (! empty($object->error)) {
118
+    				 	$this->error=$object->error;
119
+    				 }
117 120
     				 $this->errors=$object->errors;
118 121
     				 $return=-1;
119
-    			}
120
-				else
122
+    			} else
121 123
 				{
122 124
 					$return=1;
123 125
 				}
124 126
 			}
125 127
 
126 128
 			return $return;
127
-        }
128
-        elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
129
+        } elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
129 130
         {
130 131
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
131 132
 
@@ -133,11 +134,12 @@  discard block
 block discarded – undo
133 134
             // Remove from external tools (mailman, spip, etc...)
134 135
         	if ($object->del_to_abo() < 0)
135 136
 			{
136
-				if (! empty($object->error)) $this->error=$object->error;
137
+				if (! empty($object->error)) {
138
+					$this->error=$object->error;
139
+				}
137 140
 				$this->errors=$object->errors;
138 141
 				$return=-1;
139
-			}
140
-			else
142
+			} else
141 143
 			{
142 144
 				$return=1;
143 145
 			}
Please login to merge, or discard this patch.