Completed
Branch develop (582a6f)
by
unknown
19:18
created
htdocs/modulebuilder/index.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 $modulename = dol_sanitizeFileName(GETPOST('modulename', 'alpha'));
75 75
 $objectname = dol_sanitizeFileName(GETPOST('objectname', 'alpha'));
76 76
 $dicname = dol_sanitizeFileName(GETPOST('dicname', 'alpha'));
77
-$editorname= GETPOST('editorname', 'alpha');
78
-$editorurl= GETPOST('editorurl', 'alpha');
79
-$version= GETPOST('version', 'alpha');
80
-$family= GETPOST('family', 'alpha');
81
-$picto= GETPOST('idpicto', 'alpha');
82
-$idmodule= GETPOST('idmodule', 'alpha');
77
+$editorname = GETPOST('editorname', 'alpha');
78
+$editorurl = GETPOST('editorurl', 'alpha');
79
+$version = GETPOST('version', 'alpha');
80
+$family = GETPOST('family', 'alpha');
81
+$picto = GETPOST('idpicto', 'alpha');
82
+$idmodule = GETPOST('idmodule', 'alpha');
83 83
 
84 84
 // Security check
85 85
 if (!isModEnabled('modulebuilder')) {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 		// Copy last html.formsetup.class.php' to backport folder
250 250
 		$tryToCopyFromSetupClass = true;
251
-		$backportDest = $destdir .'/backport/v16/core/class';
251
+		$backportDest = $destdir.'/backport/v16/core/class';
252 252
 		$backportFileSrc = DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
253 253
 		$backportFileDest = $backportDest.'/html.formsetup.class.php';
254 254
 		$result = dol_mkdir($backportDest);
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 			);
352 352
 
353 353
 			if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
354
-				$arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' ' . getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR');
354
+				$arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR');
355 355
 			}
356 356
 
357 357
 			$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
 		clearstatcache(true);
381 381
 		if (function_exists('opcache_invalidate')) {
382
-			opcache_reset();	// remove the include cache hell !
382
+			opcache_reset(); // remove the include cache hell !
383 383
 		}
384 384
 
385 385
 		header("Location: ".$_SERVER["PHP_SELF"].'?module='.$modulename);
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 				}
829 829
 			}
830 830
 			$stringLog = implode("\n", $strreplace);
831
-			dolReplaceInFile($destfile, array('//include::ChangeLog.md[]' => '','__CHANGELOG__' => $stringLog));
831
+			dolReplaceInFile($destfile, array('//include::ChangeLog.md[]' => '', '__CHANGELOG__' => $stringLog));
832 832
 		}
833 833
 
834 834
 		// Delete old documentation files
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 			}
1304 1304
 			$rights = $moduleobj->rights;
1305 1305
 			$moduledescriptorfile = $destdir.'/core/modules/mod'.$module.'.class.php';
1306
-			$checkComment=checkExistComment($moduledescriptorfile, 1);
1306
+			$checkComment = checkExistComment($moduledescriptorfile, 1);
1307 1307
 			if ($checkComment < 0) {
1308 1308
 				setEventMessages($langs->trans("WarningCommentNotFound", $langs->trans("Permissions"), "mod".$module."class.php"), null, 'warnings');
1309 1309
 			} else {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 			}
1470 1470
 		}
1471 1471
 			$menus = $moduleobj->menu;
1472
-			$counter = 0 ;
1472
+			$counter = 0;
1473 1473
 		foreach ($menus as $menu) {
1474 1474
 			if ($menu['leftmenu'] == strtolower($objectname)) {
1475 1475
 				$counter++;
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
 			);
1511 1511
 
1512 1512
 			if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
1513
-				$arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' ' . getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR');
1513
+				$arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR');
1514 1514
 			}
1515 1515
 
1516 1516
 			$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
 		} else {
1611 1611
 			createNewDictionnary($module, $moduledescriptorfile, $newdicname, $dictionaries);
1612 1612
 			if (function_exists('opcache_invalidate')) {
1613
-				opcache_reset();	// remove the include cache hell !
1613
+				opcache_reset(); // remove the include cache hell !
1614 1614
 			}
1615 1615
 			clearstatcache(true);
1616 1616
 			header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : ''));
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 				'isameasure'=>GETPOST('propisameasure', 'int'),
1705 1705
 				'comment'=>GETPOST('propcomment', 'alpha'),
1706 1706
 				'help'=>GETPOST('prophelp', 'alpha'),
1707
-				'css'=>GETPOST('propcss', 'alpha'),        // Can be 'maxwidth500 widthcentpercentminusxx' for example
1707
+				'css'=>GETPOST('propcss', 'alpha'), // Can be 'maxwidth500 widthcentpercentminusxx' for example
1708 1708
 				'cssview'=>GETPOST('propcssview', 'alpha'),
1709 1709
 				'csslist'=>GETPOST('propcsslist', 'alpha'),
1710 1710
 				'default'=>GETPOST('propdefault', 'restricthtml'),
@@ -1858,7 +1858,7 @@  discard block
 block discarded – undo
1858 1858
 
1859 1859
 			clearstatcache(true);
1860 1860
 			if (function_exists('opcache_invalidate')) {
1861
-				opcache_reset();	// remove the include cache hell !
1861
+				opcache_reset(); // remove the include cache hell !
1862 1862
 			}
1863 1863
 
1864 1864
 			header("Location: ".$_SERVER["PHP_SELF"].'?module=deletemodule');
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
 
1951 1951
 			clearstatcache(true);
1952 1952
 			if (function_exists('opcache_invalidate')) {
1953
-				opcache_reset();	// remove the include cache hell !
1953
+				opcache_reset(); // remove the include cache hell !
1954 1954
 			}
1955 1955
 			$resultko = 0;
1956 1956
 			foreach ($filetodelete as $tmpfiletodelete) {
@@ -1970,7 +1970,7 @@  discard block
 block discarded – undo
1970 1970
 	}
1971 1971
 
1972 1972
 	$action = '';
1973
-	if (! $error) {
1973
+	if (!$error) {
1974 1974
 		$tabobj = 'newobject';
1975 1975
 	} else {
1976 1976
 		$tabobj = 'deleteobject';
@@ -2031,11 +2031,11 @@  discard block
 block discarded – undo
2031 2031
 	}
2032 2032
 
2033 2033
 	if (!empty(GETPOST('dictionnarykey'))) {
2034
-		$newdicname = $dicts['tabname'][GETPOST('dictionnarykey')-1];
2034
+		$newdicname = $dicts['tabname'][GETPOST('dictionnarykey') - 1];
2035 2035
 	}
2036 2036
 
2037 2037
 	//chercher la table dicname
2038
-	$query = "SHOW TABLES LIKE '" . MAIN_DB_PREFIX.strtolower($newdicname) . "'";
2038
+	$query = "SHOW TABLES LIKE '".MAIN_DB_PREFIX.strtolower($newdicname)."'";
2039 2039
 	$checkTable = $db->query($query);
2040 2040
 	if ($checkTable && $db->num_rows($checkTable) <= 0) {
2041 2041
 		$error++;
@@ -2074,7 +2074,7 @@  discard block
 block discarded – undo
2074 2074
 			setEventMessages($langs->trans("DictionaryDeleted", ucfirst(substr($newdicname, 2))), null);
2075 2075
 		}
2076 2076
 		if (function_exists('opcache_invalidate')) {
2077
-			opcache_reset();	// remove the include cache hell !
2077
+			opcache_reset(); // remove the include cache hell !
2078 2078
 		}
2079 2079
 		clearstatcache(true);
2080 2080
 		header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : ''));
@@ -2082,7 +2082,7 @@  discard block
 block discarded – undo
2082 2082
 	}
2083 2083
 }
2084 2084
 if ($dirins && $action == 'updatedictionary' && GETPOST('dictionnarykey')) {
2085
-	$keydict = GETPOST('dictionnarykey') - 1 ;
2085
+	$keydict = GETPOST('dictionnarykey') - 1;
2086 2086
 
2087 2087
 	$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
2088 2088
 	$destdir = $dirins.'/'.strtolower($module);
@@ -2116,7 +2116,7 @@  discard block
 block discarded – undo
2116 2116
 				setEventMessages($langs->trans("DictionaryNameUpdated", ucfirst(GETPOST('tablib'))), null);
2117 2117
 			}
2118 2118
 			if (function_exists('opcache_invalidate')) {
2119
-				opcache_reset();	// remove the include cache hell !
2119
+				opcache_reset(); // remove the include cache hell !
2120 2120
 			}
2121 2121
 			clearstatcache(true);
2122 2122
 			header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : ''));
@@ -2236,13 +2236,13 @@  discard block
 block discarded – undo
2236 2236
 
2237 2237
 	//check existing object permission
2238 2238
 	$counter = 0;
2239
-	$permsForObject =array();
2239
+	$permsForObject = array();
2240 2240
 	$permissions = $moduleobj->rights;
2241 2241
 	$allObject = array();
2242 2242
 
2243 2243
 	$countPerms = count($permissions);
2244 2244
 
2245
-	for ($i =0; $i<$countPerms; $i++) {
2245
+	for ($i = 0; $i < $countPerms; $i++) {
2246 2246
 		if ($permissions[$i][4] == $objectForPerms) {
2247 2247
 			$counter++;
2248 2248
 			if (count($permsForObject) < 3) {
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 
2255 2255
 	// check if label of object already exists
2256 2256
 	$countPermsObj = count($permsForObject);
2257
-	for ($j = 0; $j<$countPermsObj; $j++) {
2257
+	for ($j = 0; $j < $countPermsObj; $j++) {
2258 2258
 		if (in_array($crud, $permsForObject[$j])) {
2259 2259
 			$error++;
2260 2260
 			setEventMessages($langs->trans("ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)), null, 'errors');
@@ -2291,7 +2291,7 @@  discard block
 block discarded – undo
2291 2291
 
2292 2292
 		clearstatcache(true);
2293 2293
 		if (function_exists('opcache_invalidate')) {
2294
-			opcache_reset();	// remove the include cache hell !
2294
+			opcache_reset(); // remove the include cache hell !
2295 2295
 		}
2296 2296
 		header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
2297 2297
 		exit;
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
 
2301 2301
 
2302 2302
 // Update permission
2303
-if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& empty($cancel)) {
2303
+if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright') && empty($cancel)) {
2304 2304
 	$error = 0;
2305 2305
 	// load class and check if right exist
2306 2306
 	$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
@@ -2343,21 +2343,21 @@  discard block
 block discarded – undo
2343 2343
 	}
2344 2344
 
2345 2345
 	$permissions = $moduleobj->rights;
2346
-	$key =(int) GETPOST('counter')-1;
2346
+	$key = (int) GETPOST('counter') - 1;
2347 2347
 	//get permission want to delete from permissions array
2348 2348
 	$x1 = $permissions[$key][1];
2349 2349
 	$x2 = $permissions[$key][4];
2350 2350
 	$x3 = $permissions[$key][5];
2351 2351
 		//check existing object permission
2352 2352
 		$counter = 0;
2353
-		$permsForObject =array();
2353
+		$permsForObject = array();
2354 2354
 		$permissions = $moduleobj->rights;
2355 2355
 		$firstRight = 0;
2356 2356
 		$existRight = 0;
2357 2357
 		$allObject = array();
2358 2358
 
2359 2359
 		$countPerms = count($permissions);
2360
-	for ($i =0; $i<$countPerms; $i++) {
2360
+	for ($i = 0; $i < $countPerms; $i++) {
2361 2361
 		if ($permissions[$i][4] == $objectForPerms) {
2362 2362
 			$counter++;
2363 2363
 			if (count($permsForObject) < 3) {
@@ -2369,7 +2369,7 @@  discard block
 block discarded – undo
2369 2369
 
2370 2370
 	if ($label != $x1 && $crud != $x3) {
2371 2371
 		$countPermsObj = count($permsForObject);
2372
-		for ($j = 0; $j<$countPermsObj; $j++) {
2372
+		for ($j = 0; $j < $countPermsObj; $j++) {
2373 2373
 			if (in_array($label, $permsForObject[$j])) {
2374 2374
 				$error++;
2375 2375
 				setEventMessages($langs->trans("ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)), null, 'errors');
@@ -2397,7 +2397,7 @@  discard block
 block discarded – undo
2397 2397
 			setEventMessages($langs->trans('PermissionUpdatedSuccesfuly'), null);
2398 2398
 			clearstatcache(true);
2399 2399
 			if (function_exists('opcache_invalidate')) {
2400
-				opcache_reset();	// remove the include cache hell !
2400
+				opcache_reset(); // remove the include cache hell !
2401 2401
 			}
2402 2402
 			header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
2403 2403
 			exit;
@@ -2421,7 +2421,7 @@  discard block
 block discarded – undo
2421 2421
 	}
2422 2422
 
2423 2423
 	$permissions = $moduleobj->rights;
2424
-	$key = (int) GETPOST('permskey', 'int')-1;
2424
+	$key = (int) GETPOST('permskey', 'int') - 1;
2425 2425
 
2426 2426
 	if (!$error) {
2427 2427
 		// check if module is enabled
@@ -2447,7 +2447,7 @@  discard block
 block discarded – undo
2447 2447
 
2448 2448
 			clearstatcache(true);
2449 2449
 			if (function_exists('opcache_invalidate')) {
2450
-				opcache_reset();	// remove the include cache hell !
2450
+				opcache_reset(); // remove the include cache hell !
2451 2451
 			}
2452 2452
 
2453 2453
 			header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
@@ -2617,7 +2617,7 @@  discard block
 block discarded – undo
2617 2617
 
2618 2618
 		clearstatcache(true);
2619 2619
 		if (function_exists('opcache_invalidate')) {
2620
-			opcache_reset();	// remove the include cache hell !
2620
+			opcache_reset(); // remove the include cache hell !
2621 2621
 		}
2622 2622
 
2623 2623
 		setEventMessages($langs->trans('MenuDeletedSuccessfuly'), null);
@@ -2674,7 +2674,7 @@  discard block
 block discarded – undo
2674 2674
 		setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Url")), null, 'errors');
2675 2675
 	}
2676 2676
 	if (!empty(GETPOST('target'))) {
2677
-		$targets = array('_blank','_self','_parent','_top','');
2677
+		$targets = array('_blank', '_self', '_parent', '_top', '');
2678 2678
 		if (!in_array(GETPOST('target'), $targets)) {
2679 2679
 			$error++;
2680 2680
 			setEventMessages($langs->trans("ErrorFieldValue", $langs->transnoentities("target")), null, 'errors');
@@ -2708,7 +2708,7 @@  discard block
 block discarded – undo
2708 2708
 	 $objects = dolGetListOfObjectClasses($destdir);
2709 2709
 
2710 2710
 	if (GETPOST('type', 'alpha') == 'left') {
2711
-		if (empty(GETPOST('leftmenu')) && count($objects) >0) {
2711
+		if (empty(GETPOST('leftmenu')) && count($objects) > 0) {
2712 2712
 			$error++;
2713 2713
 			setEventMessages($langs->trans("ErrorCoherenceMenu", $langs->transnoentities("leftmenu"), $langs->transnoentities("type")), null, 'errors');
2714 2714
 		}
@@ -2780,7 +2780,7 @@  discard block
 block discarded – undo
2780 2780
 
2781 2781
 // Modify a menu entry
2782 2782
 if ($dirins && $action == "update_menu" && GETPOST('menukey', 'int') && GETPOST('tabobj')) {
2783
-	$objectname =  GETPOST('tabobj');
2783
+	$objectname = GETPOST('tabobj');
2784 2784
 	$dirins = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
2785 2785
 	$destdir = $dirins.'/'.strtolower($module);
2786 2786
 	$objects = dolGetListOfObjectClasses($destdir);
@@ -2865,7 +2865,7 @@  discard block
 block discarded – undo
2865 2865
 					if ($result < 0) {
2866 2866
 						setEventMessages($langs->trans('ErrorMenuExistValue'), null, 'errors');
2867 2867
 						//var_dump($_SESSION);exit;
2868
-						header("Location: ".$_SERVER["PHP_SELF"].'?action=editmenu&token='.newToken().'&menukey='.urlencode($key+1).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.($key+1));
2868
+						header("Location: ".$_SERVER["PHP_SELF"].'?action=editmenu&token='.newToken().'&menukey='.urlencode($key + 1).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.($key + 1));
2869 2869
 						exit;
2870 2870
 					}
2871 2871
 
@@ -3319,7 +3319,7 @@  discard block
 block discarded – undo
3319 3319
 		$h++;
3320 3320
 
3321 3321
 		$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '');
3322
-		$head2[$h][1] = ($countDictionaries == 0  ? $langs->trans("Dictionaries") : $langs->trans('Dictionaries').'<span class="marginleftonlyshort badge">'.$countDictionaries."</span>");
3322
+		$head2[$h][1] = ($countDictionaries == 0 ? $langs->trans("Dictionaries") : $langs->trans('Dictionaries').'<span class="marginleftonlyshort badge">'.$countDictionaries."</span>");
3323 3323
 		$head2[$h][2] = 'dictionaries';
3324 3324
 		$h++;
3325 3325
 
@@ -3830,7 +3830,7 @@  discard block
 block discarded – undo
3830 3830
 
3831 3831
 				print '</form>';
3832 3832
 			} elseif ($tabobj == 'createproperty') {
3833
-				$attributesUnique = array (
3833
+				$attributesUnique = array(
3834 3834
 					'proplabel' => $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")),
3835 3835
 					'propname' => $form->textwithpicto($langs->trans("Code"), $langs->trans("PropertyDesc"), 1, 'help', 'extracss', 0, 3, 'propertyhelp'),
3836 3836
 					'proptype' => $form->textwithpicto($langs->trans("Type"), $langs->trans("TypeOfFieldsHelpIntro").'<br><br>'.$langs->trans("TypeOfFieldsHelp"), 1, 'help', 'extracss', 0, 3, 'typehelp'),
@@ -3925,8 +3925,8 @@  discard block
 block discarded – undo
3925 3925
 				}
3926 3926
 				print '</table><br>'."\n";
3927 3927
 				print '<div class="center">';
3928
-				print '<input type="submit" class="button button-save" name="add" value="' . dol_escape_htmltag($langs->trans('Create')) . '">';
3929
-				print '<input type="button" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans('Cancel')) . '" onclick="goBack()">';
3928
+				print '<input type="submit" class="button button-save" name="add" value="'.dol_escape_htmltag($langs->trans('Create')).'">';
3929
+				print '<input type="button" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans('Cancel')).'" onclick="goBack()">';
3930 3930
 				print '</div>';
3931 3931
 				print '</form>';
3932 3932
 				// javascript
@@ -3991,7 +3991,7 @@  discard block
 block discarded – undo
3991 3991
 					// Print form confirm
3992 3992
 					print $formconfirm;
3993 3993
 				}
3994
-				if ($action != 'editfile' || empty($file) ) {
3994
+				if ($action != 'editfile' || empty($file)) {
3995 3995
 					try {
3996 3996
 						//$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
3997 3997
 
@@ -4031,16 +4031,16 @@  discard block
 block discarded – undo
4031 4031
 						// Define path for sql file
4032 4032
 						$pathtosql = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'-'.strtolower($module).'.sql';
4033 4033
 						$result = dol_buildpath($pathtosql);
4034
-						if (! dol_is_file($result)) {
4034
+						if (!dol_is_file($result)) {
4035 4035
 							$pathtosql = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'.sql';
4036 4036
 							$result = dol_buildpath($pathtosql);
4037
-							if (! dol_is_file($result)) {
4037
+							if (!dol_is_file($result)) {
4038 4038
 								$pathtosql = 'install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($tabobj).'-'.strtolower($module).'.sql';
4039 4039
 								$result = dol_buildpath($pathtosql);
4040
-								if (! dol_is_file($result)) {
4040
+								if (!dol_is_file($result)) {
4041 4041
 									$pathtosql = 'install/mysql/tables/llx_'.strtolower($module).'-'.strtolower($module).'.sql';
4042 4042
 									$result = dol_buildpath($pathtosql);
4043
-									if (! dol_is_file($result)) {
4043
+									if (!dol_is_file($result)) {
4044 4044
 										$pathtosql = 'install/mysql/tables/llx_'.strtolower($module).'.sql';
4045 4045
 										$pathtosqlextra = 'install/mysql/tables/llx_'.strtolower($module).'_extrafields.sql';
4046 4046
 										$result = dol_buildpath($pathtosql);
@@ -4059,7 +4059,7 @@  discard block
 block discarded – undo
4059 4059
 						$pathtosqlroot = preg_replace('/\/llx_.*$/', '', $pathtosql);
4060 4060
 
4061 4061
 						$pathtosqlkey   = preg_replace('/\.sql$/', '.key.sql', $pathtosql);
4062
-						$pathtosqlextrakey   = preg_replace('/\.sql$/', '.key.sql', $pathtosqlextra);
4062
+						$pathtosqlextrakey = preg_replace('/\.sql$/', '.key.sql', $pathtosqlextra);
4063 4063
 
4064 4064
 						$pathtolib      = strtolower($module).'/lib/'.strtolower($module).'.lib.php';
4065 4065
 						$pathtoobjlib   = strtolower($module).'/lib/'.strtolower($module).'_'.strtolower($tabobj).'.lib.php';
@@ -4118,7 +4118,7 @@  discard block
 block discarded – undo
4118 4118
 
4119 4119
 						// API file
4120 4120
 						print '<br>';
4121
-						print '<span class="fa fa-file-o"></span> '.$langs->trans("ApiClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtoapi) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'</span></strike>').'</strong>';
4121
+						print '<span class="fa fa-file-o"></span> '.$langs->trans("ApiClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtoapi) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi) ? '' : '</span></strike>').'</strong>';
4122 4122
 						if (dol_is_file($realpathtoapi)) {
4123 4123
 							$file = file_get_contents($realpathtoapi);
4124 4124
 							if (preg_match('/var '.$tabobj.'\s+([^\s]*)\s/ims', $file, $objs)) {
@@ -4140,7 +4140,7 @@  discard block
 block discarded – undo
4140 4140
 						}
4141 4141
 						// PHPUnit
4142 4142
 						print '<br>';
4143
-						print '<span class="fa fa-file-o"></span> '.$langs->trans("TestClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtophpunit) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'</span></strike>').'</strong>';
4143
+						print '<span class="fa fa-file-o"></span> '.$langs->trans("TestClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtophpunit) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit) ? '' : '</span></strike>').'</strong>';
4144 4144
 						if (dol_is_file($realpathtophpunit)) {
4145 4145
 							print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
4146 4146
 							print ' ';
@@ -4329,26 +4329,26 @@  discard block
 block discarded – undo
4329 4329
 									$propname = $propkey;
4330 4330
 									$proplabel = $propval['label'];
4331 4331
 									$proptype = $propval['type'];
4332
-									$proparrayofkeyval = !empty($propval['arrayofkeyval'])?$propval['arrayofkeyval']:'';
4332
+									$proparrayofkeyval = !empty($propval['arrayofkeyval']) ? $propval['arrayofkeyval'] : '';
4333 4333
 									$propnotnull = !empty($propval['notnull']) ? $propval['notnull'] : '0';
4334
-									$propdefault = !empty($propval['default'])?$propval['default']:'';
4335
-									$propindex = !empty($propval['index'])?$propval['index']:'';
4336
-									$propforeignkey = !empty($propval['foreignkey'])?$propval['foreignkey']:'';
4334
+									$propdefault = !empty($propval['default']) ? $propval['default'] : '';
4335
+									$propindex = !empty($propval['index']) ? $propval['index'] : '';
4336
+									$propforeignkey = !empty($propval['foreignkey']) ? $propval['foreignkey'] : '';
4337 4337
 									$propposition = $propval['position'];
4338 4338
 									$propenabled = $propval['enabled'];
4339 4339
 									$propvisible = $propval['visible'];
4340
-									$propnoteditable = !empty($propval['noteditable'])?$propval['noteditable']:0;
4340
+									$propnoteditable = !empty($propval['noteditable']) ? $propval['noteditable'] : 0;
4341 4341
 									//$propalwayseditable = !empty($propval['alwayseditable'])?$propval['alwayseditable']:0;
4342
-									$propsearchall = !empty($propval['searchall'])?$propval['searchall']:0;
4343
-									$propisameasure = !empty($propval['isameasure'])?$propval['isameasure']:0;
4344
-									$propcss = !empty($propval['css'])?$propval['css']:'';
4345
-									$propcssview = !empty($propval['cssview'])?$propval['cssview']:'';
4346
-									$propcsslist = !empty($propval['csslist'])?$propval['csslist']:'';
4347
-									$prophelp = !empty($propval['help'])?$propval['help']:'';
4348
-									$propshowoncombobox = !empty($propval['showoncombobox'])?$propval['showoncombobox']:0;
4342
+									$propsearchall = !empty($propval['searchall']) ? $propval['searchall'] : 0;
4343
+									$propisameasure = !empty($propval['isameasure']) ? $propval['isameasure'] : 0;
4344
+									$propcss = !empty($propval['css']) ? $propval['css'] : '';
4345
+									$propcssview = !empty($propval['cssview']) ? $propval['cssview'] : '';
4346
+									$propcsslist = !empty($propval['csslist']) ? $propval['csslist'] : '';
4347
+									$prophelp = !empty($propval['help']) ? $propval['help'] : '';
4348
+									$propshowoncombobox = !empty($propval['showoncombobox']) ? $propval['showoncombobox'] : 0;
4349 4349
 									//$propdisabled=$propval['disabled'];
4350
-									$propvalidate = !empty($propval['validate'])?$propval['validate']:0;
4351
-									$propcomment = !empty($propval['comment'])?$propval['comment']:'';
4350
+									$propvalidate = !empty($propval['validate']) ? $propval['validate'] : 0;
4351
+									$propcomment = !empty($propval['comment']) ? $propval['comment'] : '';
4352 4352
 
4353 4353
 									print '<!-- line for object property -->'."\n";
4354 4354
 									print '<tr class="oddeven">';
@@ -4739,14 +4739,14 @@  discard block
 block discarded – undo
4739 4739
 						$i = 0;
4740 4740
 						$maxi = count($dicts['tabname']);
4741 4741
 						while ($i < $maxi) {
4742
-							if ($action == 'editdict' && $i == (int) GETPOST('dictionnarykey', 'int')-1) {
4742
+							if ($action == 'editdict' && $i == (int) GETPOST('dictionnarykey', 'int') - 1) {
4743 4743
 								print '<tr class="oddeven">';
4744 4744
 								print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
4745 4745
 								print '<input type="hidden" name="token" value="'.newToken().'">';
4746 4746
 								print '<input type="hidden" name="tab" value="dictionaries">';
4747 4747
 								print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
4748 4748
 								print '<input type="hidden" name="action" value="updatedictionary">';
4749
-								print '<input type="hidden" name="dictionnarykey" value="'.($i+1).'">';
4749
+								print '<input type="hidden" name="dictionnarykey" value="'.($i + 1).'">';
4750 4750
 
4751 4751
 								print '<td class="tdsticky tdstickygray">';
4752 4752
 								print ($i + 1);
@@ -4842,8 +4842,8 @@  discard block
 block discarded – undo
4842 4842
 								print '</td>';
4843 4843
 
4844 4844
 								print '<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4845
-								print '<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=editdict&token='.newToken().'&dictionnarykey='.urlencode($i+1).'&tab='.urlencode($tab).'&module='.urlencode($module).'">'.img_edit().'</a>';
4846
-								print '<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=deletedict&token='.newToken().'&dictionnarykey='.urlencode($i+1).'&tab='.urlencode($tab).'&module='.urlencode($module).'">'.img_delete().'</a>';
4845
+								print '<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=editdict&token='.newToken().'&dictionnarykey='.urlencode($i + 1).'&tab='.urlencode($tab).'&module='.urlencode($module).'">'.img_edit().'</a>';
4846
+								print '<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=deletedict&token='.newToken().'&dictionnarykey='.urlencode($i + 1).'&tab='.urlencode($tab).'&module='.urlencode($module).'">'.img_delete().'</a>';
4847 4847
 								print '</td>';
4848 4848
 
4849 4849
 								print '</tr>';
@@ -5051,7 +5051,7 @@  discard block
 block discarded – undo
5051 5051
 
5052 5052
 				print "</tr>\n";
5053 5053
 
5054
-				$r = count($menus)+1;
5054
+				$r = count($menus) + 1;
5055 5055
 				// for adding menu on module
5056 5056
 				print '<tr>';
5057 5057
 				print '<td class="center tdsticky tdstickygray"><input type="hidden" readonly class="center maxwidth50" name="propenabled" value="#"></td>';
@@ -5075,7 +5075,7 @@  discard block
 block discarded – undo
5075 5075
 				print '<td class="left"><input id="url" type="text" class="left maxwidth50" name="url" value="'.dol_escape_htmltag(GETPOST('url', 'alpha')).'"></td>';
5076 5076
 				print '<td class="left"><input type="text" class="left maxwidth75" name="langs" value="'.strtolower($module).'@'.strtolower($module).'" readonly></td>';
5077 5077
 				// Position
5078
-				print '<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000+$r).'" readonly></td>';
5078
+				print '<td class="center"><input type="text" class="center maxwidth50 tdstickygray" name="position" value="'.(1000 + $r).'" readonly></td>';
5079 5079
 				// Enabled
5080 5080
 				print '<td class="center">';
5081 5081
 				print '<input type="enabled" class="maxwidth125" value="'.dol_escape_htmltag(GETPOSTISSET('enabled') ? GETPOST('enabled') : 'isModEnabled(\''.$module.'\')').'">';
@@ -5129,7 +5129,7 @@  discard block
 block discarded – undo
5129 5129
 						$propMainmenu = !empty($menu['mainmenu']) ? $menu['mainmenu'] : GETPOST('mainmenu');
5130 5130
 						$propLeftmenu = !empty($menu['leftmenu']) ? $menu['leftmenu'] : GETPOST('leftmenu');
5131 5131
 						$propUrl = !empty($menu['url']) ? $menu['url'] : GETPOST('url', 'alpha');
5132
-						$propPerms = !empty($menu['perms']) ?  $menu['perms'] : GETPOST('perms');
5132
+						$propPerms = !empty($menu['perms']) ? $menu['perms'] : GETPOST('perms');
5133 5133
 						$propUser = !empty($menu['user']) ? $menu['user'] : GETPOST('user');
5134 5134
 						$propTarget = !empty($menu['target']) ? $menu['target'] : GETPOST('target');
5135 5135
 						$propEnabled = !empty($menu['enabled']) ? $menu['enabled'] : GETPOST('enabled');
@@ -5305,7 +5305,7 @@  discard block
 block discarded – undo
5305 5305
 							print '<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
5306 5306
 							if ($menu['titre'] != 'Module'.$module.'Name') {
5307 5307
 									print '<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=editmenu&token='.newToken().'&menukey='.urlencode($i).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_edit().'</a>';
5308
-									print '<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=deletemenu&token='.newToken().'&menukey='.urlencode($i-1).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_delete().'</a>';
5308
+									print '<a class="marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=deletemenu&token='.newToken().'&menukey='.urlencode($i - 1).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj).'">'.img_delete().'</a>';
5309 5309
 							}
5310 5310
 							print '</td>';
5311 5311
 						}
@@ -5333,7 +5333,7 @@  discard block
 block discarded – undo
5333 5333
 						}
5334 5334
 					  });
5335 5335
 
5336
-					var groupedRights = ' . $groupedRights_json . ';
5336
+					var groupedRights = ' . $groupedRights_json.';
5337 5337
 					var objectsSelect = $("select[id=\'objects\']");
5338 5338
 					var permsSelect = $("select[id=\'perms\']");
5339 5339
 
@@ -5404,7 +5404,7 @@  discard block
 block discarded – undo
5404 5404
 			$dir = $dirread.'/'.$modulelowercase.'/class';
5405 5405
 			$listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$');
5406 5406
 			$objects = array('myobject');
5407
-			$reg =array();
5407
+			$reg = array();
5408 5408
 			foreach ($listofobject as $fileobj) {
5409 5409
 				$tmpcontent = file_get_contents($fileobj['fullname']);
5410 5410
 				if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
@@ -5556,7 +5556,7 @@  discard block
 block discarded – undo
5556 5556
 							if (in_array($perm[5], array('lire', 'read', 'creer', 'write', 'effacer', 'delete'))) {
5557 5557
 								print dol_escape_htmltag(ucfirst($perm[4]));
5558 5558
 							} else {
5559
-								print '';	// No particular object
5559
+								print ''; // No particular object
5560 5560
 							}
5561 5561
 							print '</td>';
5562 5562
 
@@ -6396,9 +6396,9 @@  discard block
 block discarded – undo
6396 6396
 
6397 6397
 						print '<td>';
6398 6398
 						if ($tabName[0] === "+") {
6399
-							print '<span class="badge badge-status4 badge-status">' . dol_escape_htmltag($tabName) . '</span>';
6399
+							print '<span class="badge badge-status4 badge-status">'.dol_escape_htmltag($tabName).'</span>';
6400 6400
 						} else {
6401
-							print '<span class="badge badge-status8 badge-status">' . dol_escape_htmltag($tabName) . '</span>';
6401
+							print '<span class="badge badge-status8 badge-status">'.dol_escape_htmltag($tabName).'</span>';
6402 6402
 						}
6403 6403
 						print '</td>';
6404 6404
 
Please login to merge, or discard this patch.
htdocs/core/lib/modulebuilder.lib.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 				}
130 130
 				$texttoinsert .= ' "enabled"=>"'.($val['enabled'] !== '' ? dol_escape_php($val['enabled']) : 1).'",';
131 131
 				$texttoinsert .= " 'position'=>".($val['position'] !== '' ? (int) $val['position'] : 50).",";
132
-				$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 :(int) $val['notnull']).",";
132
+				$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : (int) $val['notnull']).",";
133 133
 				$texttoinsert .= ' "visible"=>"'.($val['visible'] !== '' ? dol_escape_js($val['visible']) : -1).'",';
134 134
 				if (!empty($val['noteditable'])) {
135 135
 					$texttoinsert .= ' "noteditable"=>"'.dol_escape_php($val['noteditable']).'",';
@@ -271,22 +271,22 @@  discard block
 block discarded – undo
271 271
 	// Edit .sql file
272 272
 	if ($moduletype == 'internal') {
273 273
 		$pathoffiletoeditsrc = '/../install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
274
-		if (! dol_is_file($readdir.$pathoffiletoeditsrc)) {
274
+		if (!dol_is_file($readdir.$pathoffiletoeditsrc)) {
275 275
 			$pathoffiletoeditsrc = '/../install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($objectname).'-'.strtolower($module).'.sql';
276
-			if (! dol_is_file($readdir.$pathoffiletoeditsrc)) {
276
+			if (!dol_is_file($readdir.$pathoffiletoeditsrc)) {
277 277
 				$pathoffiletoeditsrc = '/../install/mysql/tables/llx_'.strtolower($module).'-'.strtolower($module).'.sql';
278
-				if (! dol_is_file($readdir.$pathoffiletoeditsrc)) {
278
+				if (!dol_is_file($readdir.$pathoffiletoeditsrc)) {
279 279
 					$pathoffiletoeditsrc = '/../install/mysql/tables/llx_'.strtolower($module).'.sql';
280 280
 				}
281 281
 			}
282 282
 		}
283 283
 	} else {
284 284
 		$pathoffiletoeditsrc = '/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
285
-		if (! dol_is_file($readdir.$pathoffiletoeditsrc)) {
285
+		if (!dol_is_file($readdir.$pathoffiletoeditsrc)) {
286 286
 			$pathoffiletoeditsrc = '/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'-'.strtolower($module).'.sql';
287
-			if (! dol_is_file($readdir.$pathoffiletoeditsrc)) {
287
+			if (!dol_is_file($readdir.$pathoffiletoeditsrc)) {
288 288
 				$pathoffiletoeditsrc = '/sql/llx_'.strtolower($module).'-'.strtolower($module).'.sql';
289
-				if (! dol_is_file($readdir.$pathoffiletoeditsrc)) {
289
+				if (!dol_is_file($readdir.$pathoffiletoeditsrc)) {
290 290
 					$pathoffiletoeditsrc = '/sql/llx_'.strtolower($module).'.sql';
291 291
 				}
292 292
 			}
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 			$objects[$fileobj['fullname']] = $objectnameloop;
451 451
 		}
452 452
 	}
453
-	if (count($objects)>0) {
453
+	if (count($objects) > 0) {
454 454
 		return $objects;
455 455
 	}
456 456
 
@@ -560,12 +560,12 @@  discard block
 block discarded – undo
560 560
 			}
561 561
 		}
562 562
 	} elseif ($action == -2 && !empty($objectname) && !empty($module)) {
563
-		$key= null;
563
+		$key = null;
564 564
 		$right = null;
565 565
 		$objectOfRights = array();
566 566
 		//check if object already declared in rights file
567 567
 		foreach ($permissions as $right) {
568
-			$objectOfRights[]= $right[4];
568
+			$objectOfRights[] = $right[4];
569 569
 		}
570 570
 		if (in_array(strtolower($objectname), $objectOfRights)) {
571 571
 			$error++;
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 	if (!$error) {
593 593
 		// prepare permissions array
594 594
 		$count_perms = count($permissions);
595
-		for ($i = 0;$i<$count_perms;$i++) {
595
+		for ($i = 0; $i < $count_perms; $i++) {
596 596
 			$permissions[$i][0] = "\$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1)";
597 597
 			$permissions[$i][1] = "\$this->rights[\$r][1] = '".$permissions[$i][1]."'";
598 598
 			$permissions[$i][4] = "\$this->rights[\$r][4] = '".$permissions[$i][4]."'";
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 
613 613
 
614 614
 		// parcourir les objets
615
-		$o=0;
615
+		$o = 0;
616 616
 		foreach ($permissions as &$object) {
617 617
 			// récupérer la permission de l'objet
618 618
 			$p = 1;
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 {
708 708
 
709 709
 	// stock all properties in array
710
-	$attributesUnique = array ('type','label', 'enabled', 'position', 'notnull', 'visible', 'noteditable', 'index', 'default' , 'foreignkey', 'arrayofkeyval', 'alwayseditable','validate', 'searchall','comment', 'isameasure', 'css', 'cssview','csslist', 'help', 'showoncombobox','picto' );
710
+	$attributesUnique = array('type', 'label', 'enabled', 'position', 'notnull', 'visible', 'noteditable', 'index', 'default', 'foreignkey', 'arrayofkeyval', 'alwayseditable', 'validate', 'searchall', 'comment', 'isameasure', 'css', 'cssview', 'csslist', 'help', 'showoncombobox', 'picto');
711 711
 
712 712
 	$start = "public \$fields=array(";
713 713
 	$end = ");";
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	foreach ($attributesUnique as $attUnique) {
738 738
 		$table .= "|".$attUnique;
739 739
 	}
740
-	$table .="\n";
740
+	$table .= "\n";
741 741
 	$valuesModif = array();
742 742
 	foreach ($keys as $string) {
743 743
 		$string = trim($string, "'");
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 				$valuesModif[$attUnique] = $values[$attUnique];
778 778
 			}
779 779
 		}
780
-		$table .= "|*" . $field[0] . "*|";
781
-		$table .= implode("|", $valuesModif) . "\n";
780
+		$table .= "|*".$field[0]."*|";
781
+		$table .= implode("|", $valuesModif)."\n";
782 782
 	}
783 783
 
784 784
 	// end table
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 
788 788
 	//write in file
789 789
 	$writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS' => $table));
790
-	if ($writeInFile<0) {
790
+	if ($writeInFile < 0) {
791 791
 		return -1;
792 792
 	}
793 793
 	return 1;
@@ -809,13 +809,13 @@  discard block
 block discarded – undo
809 809
 
810 810
 		$str = file_get_contents($file);
811 811
 
812
-		$search = '/' . preg_quote($start, '/') . '(.*?)' . preg_quote($end, '/') . '/s';
812
+		$search = '/'.preg_quote($start, '/').'(.*?)'.preg_quote($end, '/').'/s';
813 813
 		$new_contents = preg_replace($search, '', $str);
814 814
 		file_put_contents($file, $new_contents);
815 815
 
816 816
 		//perms If Exist
817 817
 		$perms = "|*".strtolower($objectname)."*|";
818
-		$search_pattern_perms = '/' . preg_quote($perms, '/') . '.*?\n/';
818
+		$search_pattern_perms = '/'.preg_quote($perms, '/').'.*?\n/';
819 819
 		$new_contents = preg_replace($search_pattern_perms, '', $new_contents);
820 820
 		file_put_contents($file, $new_contents);
821 821
 	}
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 	$string = "[options='header',grid=rows,width=60%,caption=Organisation]\n";
873 873
 	$string .= "|===\n";
874 874
 	// header for table
875
-	$header = array($langs->trans('Objects'),$langs->trans('Permission'));
875
+	$header = array($langs->trans('Objects'), $langs->trans('Permission'));
876 876
 	foreach ($header as $h) {
877 877
 		$string .= "|".$h;
878 878
 	}
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	foreach ($permissions as $key => $element) {
900 900
 		$element = str_replace(" '", '', $element);
901 901
 		$element = trim($element, "'");
902
-		$permsN[] = substr($element, strpos($element, "=")+1);
902
+		$permsN[] = substr($element, strpos($element, "=") + 1);
903 903
 	}
904 904
 	array_pop($permsN);
905 905
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 	// end table
930 930
 	$string .= "\n|===\n";
931 931
 	$write = dolReplaceInFile($destfile, array('__DATA_PERMISSIONS__'=> $string));
932
-	if ($write<0) {
932
+	if ($write < 0) {
933 933
 		return -1;
934 934
 	}
935 935
 	return 1;
@@ -958,26 +958,26 @@  discard block
 block discarded – undo
958 958
 		if (strpos($lineContent, $varcomented) !== false) {
959 959
 			$lineContent = '';
960 960
 			foreach ($objects as $object) {
961
-				$lineContent .= "\t * @var ".$object." \$".strtolower($object)." {@type ".$object."}". PHP_EOL;
961
+				$lineContent .= "\t * @var ".$object." \$".strtolower($object)." {@type ".$object."}".PHP_EOL;
962 962
 			}
963 963
 			//var_dump($lineContent);exit;
964 964
 		}
965 965
 		if (strpos($lineContent, $props) !== false) {
966 966
 			$lineContent = '';
967 967
 			foreach ($objects as $object) {
968
-				$lineContent .= "\tpublic \$".strtolower($object).";". PHP_EOL;
968
+				$lineContent .= "\tpublic \$".strtolower($object).";".PHP_EOL;
969 969
 			}
970 970
 		}
971 971
 		if (strpos($lineContent, $constructObj) !== false) {
972 972
 			$lineContent = '';
973 973
 			foreach ($objects as $object) {
974
-				$lineContent .= "\t\t\$this->".strtolower($object)." = new ".$object."(\$this->db);". PHP_EOL;
974
+				$lineContent .= "\t\t\$this->".strtolower($object)." = new ".$object."(\$this->db);".PHP_EOL;
975 975
 			}
976 976
 		}
977 977
 		if (strpos($lineContent, $includeClass) !== false) {
978 978
 			$lineContent = '';
979 979
 			foreach ($objects as $object) {
980
-				$lineContent .= "dol_include_once('/".strtolower($modulename)."/class/".strtolower($object).".class.php');". PHP_EOL;
980
+				$lineContent .= "dol_include_once('/".strtolower($modulename)."/class/".strtolower($object).".class.php');".PHP_EOL;
981 981
 			}
982 982
 		}
983 983
 	}
@@ -987,10 +987,10 @@  discard block
 block discarded – undo
987 987
 	//add methods for each object
988 988
 	$allContent = getFromFile($file, '/*begin methods CRUD*/', '/*end methods CRUD*/');
989 989
 	foreach ($objects as $object) {
990
-		$contentReplaced =str_replace(["myobject","MyObject"], [strtolower($object),$object], $allContent);
990
+		$contentReplaced = str_replace(["myobject", "MyObject"], [strtolower($object), $object], $allContent);
991 991
 		dolReplaceInFile($file, array('/*end methods CRUD*/' => '/*CRUD FOR '.strtoupper($object).'*/'."\n".$contentReplaced."\n\t".'/*END CRUD FOR '.strtoupper($object).'*/'."\n\t".'/*end methods CRUD*/'));
992 992
 	}
993
-	dolReplaceInFile($file, array($allContent => '','MyModule' => ucfirst($modulename)));
993
+	dolReplaceInFile($file, array($allContent => '', 'MyModule' => ucfirst($modulename)));
994 994
 	return 1;
995 995
 }
996 996
 
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
  */
1052 1052
 function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action)
1053 1053
 {
1054
-	$errors =0;
1054
+	$errors = 0;
1055 1055
 	$counter = 0;
1056 1056
 	if (!file_exists($file)) {
1057 1057
 		return -1;
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 		array_push($menus, $menuWantTo);
1065 1065
 	} elseif ($action == 2 && !empty($key) && !empty($menuWantTo)) {
1066 1066
 		// update right from permissions array
1067
-		$urlCounter=0;
1067
+		$urlCounter = 0;
1068 1068
 		// check if the values already exists
1069 1069
 		foreach ($menus as $index => $menu) {
1070 1070
 			if ($index !== $key) {
@@ -1113,20 +1113,20 @@  discard block
 block discarded – undo
1113 1113
 				//var_dump(dol_escape_php($menu['perms'], 1)); exit;
1114 1114
 
1115 1115
 				$str_menu .= $start."\n";
1116
-				$str_menu.= "\t\t\$this->menu[\$r++]=array(\n";
1117
-				$str_menu.= "\t\t\t 'fk_menu' => '".dol_escape_php($menu['fk_menu'], 1)."',\n";
1118
-				$str_menu.= "\t\t\t 'type' => '".dol_escape_php($menu['type'], 1)."',\n";
1119
-				$str_menu.= "\t\t\t 'titre' => '".dol_escape_php($menu['titre'], 1)."',\n";
1120
-				$str_menu.= "\t\t\t 'mainmenu' => '".dol_escape_php($menu['mainmenu'], 1)."',\n";
1121
-				$str_menu.= "\t\t\t 'leftmenu' => '".dol_escape_php($menu['leftmenu'], 1)."',\n";
1122
-				$str_menu.= "\t\t\t 'url' => '".dol_escape_php($menu['url'], 1)."',\n";
1123
-				$str_menu.= "\t\t\t 'langs' => '".dol_escape_php($menu['langs'], 1)."',\n";
1124
-				$str_menu.= "\t\t\t 'position' => ".((int) $menu['position']).",\n";
1125
-				$str_menu.= "\t\t\t 'enabled' => '".dol_escape_php($menu['enabled'], 1)."',\n";
1126
-				$str_menu.= "\t\t\t 'perms' => '".dol_escape_php($menu['perms'], 1)."',\n";
1127
-				$str_menu.= "\t\t\t 'target' => '".dol_escape_php($menu['target'], 1)."',\n";
1128
-				$str_menu.= "\t\t\t 'user' => ".((int) $menu['user']).",\n";
1129
-				$str_menu.= "\t\t);\n";
1116
+				$str_menu .= "\t\t\$this->menu[\$r++]=array(\n";
1117
+				$str_menu .= "\t\t\t 'fk_menu' => '".dol_escape_php($menu['fk_menu'], 1)."',\n";
1118
+				$str_menu .= "\t\t\t 'type' => '".dol_escape_php($menu['type'], 1)."',\n";
1119
+				$str_menu .= "\t\t\t 'titre' => '".dol_escape_php($menu['titre'], 1)."',\n";
1120
+				$str_menu .= "\t\t\t 'mainmenu' => '".dol_escape_php($menu['mainmenu'], 1)."',\n";
1121
+				$str_menu .= "\t\t\t 'leftmenu' => '".dol_escape_php($menu['leftmenu'], 1)."',\n";
1122
+				$str_menu .= "\t\t\t 'url' => '".dol_escape_php($menu['url'], 1)."',\n";
1123
+				$str_menu .= "\t\t\t 'langs' => '".dol_escape_php($menu['langs'], 1)."',\n";
1124
+				$str_menu .= "\t\t\t 'position' => ".((int) $menu['position']).",\n";
1125
+				$str_menu .= "\t\t\t 'enabled' => '".dol_escape_php($menu['enabled'], 1)."',\n";
1126
+				$str_menu .= "\t\t\t 'perms' => '".dol_escape_php($menu['perms'], 1)."',\n";
1127
+				$str_menu .= "\t\t\t 'target' => '".dol_escape_php($menu['target'], 1)."',\n";
1128
+				$str_menu .= "\t\t\t 'user' => ".((int) $menu['user']).",\n";
1129
+				$str_menu .= "\t\t);\n";
1130 1130
 
1131 1131
 				if (is_null($next_val) || $val_actuel['leftmenu'] !== $next_val['leftmenu']) {
1132 1132
 					$str_menu .= $end."\n";
@@ -1163,21 +1163,21 @@  discard block
 block discarded – undo
1163 1163
 		$dicData .= "\t\t\t'$key'=>";
1164 1164
 
1165 1165
 		if ($key === 'tabcond') {
1166
-			$conditions = array_map(function ($val) use ($module) {
1166
+			$conditions = array_map(function($val) use ($module) {
1167 1167
 				return ($val === true || $val === false) ? "isModEnabled('$module')" : $val;
1168 1168
 			}, $value);
1169
-			$dicData .= "array(" . implode(",", $conditions) . ")";
1169
+			$dicData .= "array(".implode(",", $conditions).")";
1170 1170
 		} elseif ($key === 'tabhelp') {
1171 1171
 			$helpItems = array();
1172 1172
 			foreach ($value as $key => $helpValue) {
1173 1173
 				$helpItems[] = "array('code'=>\$langs->trans('".$helpValue['code']."'), 'field2' => 'field2tooltip')";
1174 1174
 			}
1175
-			$dicData .= "array(" . implode(",", $helpItems) . ")";
1175
+			$dicData .= "array(".implode(",", $helpItems).")";
1176 1176
 		} else {
1177 1177
 			if (is_array($value)) {
1178
-				$dicData .= "array(" . implode(",", array_map(function ($val) {
1178
+				$dicData .= "array(".implode(",", array_map(function($val) {
1179 1179
 					return "'$val'";
1180
-				}, $value)) . ")";
1180
+				}, $value)).")";
1181 1181
 			} else {
1182 1182
 				$dicData .= "'$value'";
1183 1183
 			}
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
 		}
1244 1244
 	}
1245 1245
 	// check if tablename exist in Database and create it if not
1246
-	$query = "SHOW TABLES LIKE '" . MAIN_DB_PREFIX.strtolower($namedic) . "'";
1246
+	$query = "SHOW TABLES LIKE '".MAIN_DB_PREFIX.strtolower($namedic)."'";
1247 1247
 	$checkTable = $db->query($query);
1248 1248
 	if ($checkTable && $db->num_rows($checkTable) > 0) {
1249 1249
 		setEventMessages($langs->trans("ErrorTableExist", $namedic), null, 'errors');
@@ -1352,9 +1352,9 @@  discard block
 block discarded – undo
1352 1352
 
1353 1353
 	foreach ($allFilesAndDirs as $item) {
1354 1354
 		if ($item != '.' && $item != '..') {
1355
-			if ($type == 1 && is_file($path . DIRECTORY_SEPARATOR . $item) && strpos($item, '.back') === false) {
1355
+			if ($type == 1 && is_file($path.DIRECTORY_SEPARATOR.$item) && strpos($item, '.back') === false) {
1356 1356
 				$count++;
1357
-			} elseif ($type == 2 && is_dir($path . DIRECTORY_SEPARATOR . $item)) {
1357
+			} elseif ($type == 2 && is_dir($path.DIRECTORY_SEPARATOR.$item)) {
1358 1358
 				$count++;
1359 1359
 			}
1360 1360
 		}
Please login to merge, or discard this patch.