Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/login/functions_openid.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
         {
57 57
             $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]);      // Send Response from OpenID server to this script
58 58
             $openid->Redirect();     // This will redirect user to OpenID Server
59
-        }
60
-        else
59
+        } else
61 60
         {
62 61
             $error = $openid->GetError();
63 62
             return false;
@@ -89,21 +88,18 @@  discard block
 block discarded – undo
89 88
                     $login=$obj->login;
90 89
                 }
91 90
             }
92
-        }
93
-        else if($openid->IsError() === true)
91
+        } else if($openid->IsError() === true)
94 92
         {
95 93
             // ON THE WAY, WE GOT SOME ERROR
96 94
             $error = $openid->GetError();
97 95
             return false;
98
-        }
99
-        else
96
+        } else
100 97
         {
101 98
             // Signature Verification Failed
102 99
             //echo "INVALID AUTHORIZATION";
103 100
             return false;
104 101
         }
105
-    }
106
-    else if ($_GET['openid_mode'] == 'cancel')
102
+    } else if ($_GET['openid_mode'] == 'cancel')
107 103
     {
108 104
         // User Canceled your Request
109 105
         //echo "USER CANCELED REQUEST";
Please login to merge, or discard this patch.
dolibarr/htdocs/core/login/functions_forceuser.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,9 +40,13 @@
 block discarded – undo
40 40
 	dol_syslog("functions_forceuser::check_user_password_forceuser");
41 41
 
42 42
 	$login=$dolibarr_auto_user;
43
-	if (empty($login)) $login='auto';
43
+	if (empty($login)) {
44
+	    $login='auto';
45
+	}
44 46
 
45
-	if ($_SESSION["dol_loginmesg"]) $login='';
47
+	if ($_SESSION["dol_loginmesg"]) {
48
+	    $login='';
49
+	}
46 50
 
47 51
 	dol_syslog("functions_forceuser::check_user_password_forceuser ok. forced user = ".$login);
48 52
 	return $login;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/login/functions_dolibarr.php 1 patch
Braces   +22 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,7 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
 	// Force master entity in transversal mode
41 41
 	$entity=$entitytotest;
42
-	if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1;
42
+	if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
43
+	    $entity=1;
44
+	}
43 45
 
44 46
 	$login='';
45 47
 
@@ -56,7 +58,9 @@  discard block
 block discarded – undo
56 58
 		$sql ='SELECT rowid, login, entity, pass, pass_crypted';
57 59
 		$sql.=' FROM '.$table;
58 60
 		$sql.=' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'";
59
-		if (preg_match('/@/',$usertotest)) $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'";
61
+		if (preg_match('/@/',$usertotest)) {
62
+		    $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'";
63
+		}
60 64
 		$sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")";
61 65
 		$sql.=' AND statut = 1';
62 66
 		// Required to first found the user into entity, then the superadmin.
@@ -77,10 +81,14 @@  discard block
 block discarded – undo
77 81
 
78 82
 				// Check crypted password
79 83
 				$cryptType='';
80
-				if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED;
84
+				if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
85
+				    $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED;
86
+				}
81 87
 
82 88
 				// By default, we used MD5
83
-				if (! in_array($cryptType,array('md5'))) $cryptType='md5';
89
+				if (! in_array($cryptType,array('md5'))) {
90
+				    $cryptType='md5';
91
+				}
84 92
 				// Check crypted password according to crypt algorithm
85 93
 				if ($cryptType == 'md5')
86 94
 				{
@@ -106,8 +114,7 @@  discard block
 block discarded – undo
106 114
 				if ($passok)
107 115
 				{
108 116
 					$login=$obj->login;
109
-				}
110
-				else
117
+				} else
111 118
 				{
112 119
 					dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."'");
113 120
 					sleep(2);      // Anti brut force protection
@@ -119,11 +126,16 @@  discard block
 block discarded – undo
119 126
 				}
120 127
 
121 128
 				// We must check entity
122
-				if ($passok && ! empty($conf->multicompany->enabled))	// We must check entity
129
+				if ($passok && ! empty($conf->multicompany->enabled)) {
130
+				    // We must check entity
123 131
 				{
124 132
 					global $mc;
133
+				}
125 134
 
126
-					if (! isset($mc)) $conf->multicompany->enabled = false; 	// Global not available, disable $conf->multicompany->enabled for safety
135
+					if (! isset($mc)) {
136
+					    $conf->multicompany->enabled = false;
137
+					}
138
+					// Global not available, disable $conf->multicompany->enabled for safety
127 139
 					else
128 140
 					{
129 141
 						$ret = $mc->checkRight($obj->rowid, $entitytotest);
@@ -134,8 +146,7 @@  discard block
 block discarded – undo
134 146
 						}
135 147
 					}
136 148
 				}
137
-			}
138
-			else
149
+			} else
139 150
 			{
140 151
 				dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko user not found for '".$usertotest."'");
141 152
 				sleep(1);
@@ -145,8 +156,7 @@  discard block
 block discarded – undo
145 156
 
146 157
 				$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
147 158
 			}
148
-		}
149
-		else
159
+		} else
150 160
 		{
151 161
 			dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko db error for '".$usertotest."' error=".$db->lasterror());
152 162
 			sleep(1);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/login/functions_ldap.php 1 patch
Braces   +47 added lines, -19 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
 	// Force master entity in transversal mode
47 47
 	$entity=$entitytotest;
48
-	if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1;
48
+	if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
49
+	    $entity=1;
50
+	}
49 51
 
50 52
 	$login='';
51 53
 	$resultFetchUser='';
@@ -78,7 +80,9 @@  discard block
 block discarded – undo
78 80
 		$ldapadminpass=$dolibarr_main_auth_ldap_admin_pass;
79 81
 		$ldapdebug=(empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug=="false" ? false : true);
80 82
 
81
-		if ($ldapdebug) print "DEBUG: Logging LDAP steps<br>\n";
83
+		if ($ldapdebug) {
84
+		    print "DEBUG: Logging LDAP steps<br>\n";
85
+		}
82 86
 
83 87
 		require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
84 88
 		$ldap=new Ldap();
@@ -116,20 +120,25 @@  discard block
 block discarded – undo
116 120
 			{
117 121
 				$resultFetchLdapUser = $ldap->fetch($usertotest,$userSearchFilter);
118 122
 				//dol_syslog('functions_ldap::check_user_password_ldap resultFetchLdapUser='.$resultFetchLdapUser);
119
-				if ($resultFetchLdapUser > 0 && $ldap->pwdlastset == 0) // If ok but password need to be reset
123
+				if ($resultFetchLdapUser > 0 && $ldap->pwdlastset == 0) {
124
+				    // If ok but password need to be reset
120 125
 				{
121 126
 					dol_syslog('functions_ldap::check_user_password_ldap '.$usertotest.' must change password next logon');
122
-					if ($ldapdebug) print "DEBUG: User ".$usertotest." must change password<br>\n";
127
+				}
128
+					if ($ldapdebug) {
129
+					    print "DEBUG: User ".$usertotest." must change password<br>\n";
130
+					}
123 131
 					$ldap->close();
124 132
 					sleep(1);
125 133
 					$langs->load('ldap');
126 134
 					$_SESSION["dol_loginmesg"]=$langs->trans("YouMustChangePassNextLogon",$usertotest,$ldap->domainFQDN);
127 135
 					return '';
128 136
 				}
129
-			}
130
-			else
137
+			} else
131 138
 			{
132
-				 if ($ldapdebug) print "DEBUG: ".$ldap->error."<br>\n";
139
+				 if ($ldapdebug) {
140
+				     print "DEBUG: ".$ldap->error."<br>\n";
141
+				 }
133 142
 			}
134 143
 			$ldap->close();
135 144
 		}
@@ -140,7 +149,9 @@  discard block
 block discarded – undo
140 149
 		$ldap->searchUser=$ldapuserattr."=".$usertotest.",".$ldapdn;  // Default dn (will work if LDAP accept a dn with login value inside)
141 150
 		// But if LDAP need a dn with name like "cn=Jhon Bloggs,ou=People,dc=foo,dc=com", previous part must have been executed to have
142 151
 		// dn detected into ldapUserDN.
143
-		if ($resultFetchLdapUser && !empty($ldap->ldapUserDN)) $ldap->searchUser = $ldap->ldapUserDN;
152
+		if ($resultFetchLdapUser && !empty($ldap->ldapUserDN)) {
153
+		    $ldap->searchUser = $ldap->ldapUserDN;
154
+		}
144 155
 		$ldap->searchPassword=$passwordtotest;
145 156
 
146 157
 		// Test with this->seachUser and this->searchPassword
@@ -148,27 +159,41 @@  discard block
 block discarded – undo
148 159
 		$result=$ldap->connect_bind();
149 160
 		if ($result > 0)
150 161
 		{
151
-			if ($result == 2)	// Connection is ok for user/pass into LDAP
162
+			if ($result == 2) {
163
+			    // Connection is ok for user/pass into LDAP
152 164
 			{
153 165
 				dol_syslog("functions_ldap::check_user_password_ldap Authentification ok");
166
+			}
154 167
 				$login=$usertotest;
155 168
 
156 169
 				// ldap2dolibarr synchronisation
157
-				if ($login && ! empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')	// ldap2dolibarr synchronisation
170
+				if ($login && ! empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
171
+				    // ldap2dolibarr synchronisation
158 172
 				{
159 173
 						dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr");
174
+				}
160 175
 
161 176
 						// On charge les attributs du user ldap
162
-						if ($ldapdebug) print "DEBUG: login ldap = ".$login."<br>\n";
177
+						if ($ldapdebug) {
178
+						    print "DEBUG: login ldap = ".$login."<br>\n";
179
+						}
163 180
 						$resultFetchLdapUser = $ldap->fetch($login,$userSearchFilter);
164 181
 
165
-						if ($ldapdebug) print "DEBUG: UACF = ".join(',',$ldap->uacf)."<br>\n";
166
-						if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset,'day')."<br>\n";
167
-						if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime,'day')."<br>\n";
182
+						if ($ldapdebug) {
183
+						    print "DEBUG: UACF = ".join(',',$ldap->uacf)."<br>\n";
184
+						}
185
+						if ($ldapdebug) {
186
+						    print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset,'day')."<br>\n";
187
+						}
188
+						if ($ldapdebug) {
189
+						    print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime,'day')."<br>\n";
190
+						}
168 191
 
169 192
 						// On recherche le user dolibarr en fonction de son SID ldap
170 193
 						$sid = $ldap->getObjectSid($login);
171
-						if ($ldapdebug) print "DEBUG: sid = ".$sid."<br>\n";
194
+						if ($ldapdebug) {
195
+						    print "DEBUG: sid = ".$sid."<br>\n";
196
+						}
172 197
 
173 198
 						$usertmp=new User($db);
174 199
 						$resultFetchUser=$usertmp->fetch('',$login,$sid);
@@ -189,9 +214,11 @@  discard block
 block discarded – undo
189 214
 						unset($usertmp);
190 215
 				}
191 216
 
192
-				if (! empty($conf->multicompany->enabled))	// We must check entity (even if sync is not active)
217
+				if (! empty($conf->multicompany->enabled)) {
218
+				    // We must check entity (even if sync is not active)
193 219
 				{
194 220
 					global $mc;
221
+				}
195 222
 
196 223
 					$usertmp=new User($db);
197 224
 					$usertmp->fetch('',$login);
@@ -214,8 +241,7 @@  discard block
 block discarded – undo
214 241
 
215 242
 				$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
216 243
 			}
217
-		}
218
-		else
244
+		} else
219 245
 		{
220 246
 			/* Login failed. Return false, together with the error code and text from
221 247
              ** the LDAP server. The common error codes and reasons are listed below :
@@ -226,9 +252,11 @@  discard block
 block discarded – undo
226 252
              ** 53 - Account inactive (manually locked out by administrator)
227 253
              */
228 254
 			dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP for '".$usertotest."'");
229
-			if (is_resource($ldap->connection))    // If connection ok but bind ko
255
+			if (is_resource($ldap->connection)) {
256
+			    // If connection ok but bind ko
230 257
 			{
231 258
 				$ldap->ldapErrorCode = ldap_errno($ldap->connection);
259
+			}
232 260
 				$ldap->ldapErrorText = ldap_error($ldap->connection);
233 261
 				dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText);
234 262
 			}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_changeselectedfields.inc.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,11 @@
 block discarded – undo
34 34
 
35 35
     $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
36 36
 
37
-    if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields");
38
-    else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]='';
37
+    if (GETPOST("selectedfields")) {
38
+        $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields");
39
+    } else {
40
+        $tabparam["MAIN_SELECTEDFIELDS_".$varpage]='';
41
+    }
39 42
 
40 43
     include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
41 44
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_dellink.inc.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,6 +41,8 @@
 block discarded – undo
41 41
 if ($action == 'dellink' && ! empty($permissiondellink) && ! GETPOST('cancel','alpha') && $dellinkid > 0)
42 42
 {
43 43
 	$result=$object->deleteObjectLinked(0, '', 0, '', $dellinkid);
44
-	if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
45
-}
44
+	if ($result < 0) {
45
+	    setEventMessages($object->error,$object->errors,'errors');
46
+	}
47
+	}
46 48
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_fetchobject.inc.php 1 patch
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,24 +30,28 @@
 block discarded – undo
30 30
 
31 31
 if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0))
32 32
 {
33
-	if (($id > 0 && is_numeric($id)) || ! empty($ref))	// To discard case when id is list of ids like '1,2,3...'
33
+	if (($id > 0 && is_numeric($id)) || ! empty($ref)) {
34
+	    // To discard case when id is list of ids like '1,2,3...'
34 35
 	{
35 36
 	    $ret = $object->fetch($id, $ref);
37
+	}
36 38
 	    if ($ret > 0)
37 39
 	    {
38 40
 	        $object->fetch_thirdparty();
39 41
 	        $id = $object->id;
40
-	    }
41
-	    else
42
+	    } else
42 43
 	    {
43 44
 	    	if (empty($object->error) && ! count($object->errors))
44 45
 	    	{
45
-	    		if ($ret < 0)	// if $ret == 0, it means not found.
46
+	    		if ($ret < 0) {
47
+	    		    // if $ret == 0, it means not found.
46 48
 	    		{
47 49
 	    			setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors');
48 50
 	    		}
49
-	    	}
50
-	        else setEventMessages($object->error, $object->errors, 'errors');
51
+	    		}
52
+	    	} else {
53
+	            setEventMessages($object->error, $object->errors, 'errors');
54
+	        }
51 55
 	        $action='';
52 56
 	    }
53 57
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/ajax/ajaxdirtree.php 1 patch
Braces   +110 added lines, -44 removed lines patch added patch discarded remove patch
@@ -26,15 +26,26 @@  discard block
 block discarded – undo
26 26
 // This script is called with a POST method.
27 27
 // Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax
28 28
 
29
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
30
-if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
31
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
32
-if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
29
+if (! defined('NOTOKENRENEWAL')) {
30
+    define('NOTOKENRENEWAL',1);
31
+}
32
+// Disables token renewal
33
+if (! defined('NOREQUIREMENU')) {
34
+    define('NOREQUIREMENU','1');
35
+}
36
+if (! defined('NOREQUIREHTML')) {
37
+    define('NOREQUIREHTML','1');
38
+}
39
+if (! defined('NOREQUIREAJAX')) {
40
+    define('NOREQUIREAJAX','1');
41
+}
33 42
 
34 43
 
35
-if (! isset($mode) || $mode != 'noajax')    // For ajax call
44
+if (! isset($mode) || $mode != 'noajax') {
45
+    // For ajax call
36 46
 {
37 47
 	$res=@include '../../main.inc.php';
48
+}
38 49
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 50
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40 51
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
@@ -49,9 +60,11 @@  discard block
 block discarded – undo
49 60
 
50 61
 	$preopened = GETPOST('preopened');
51 62
 
52
-	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
53
-}
54
-else    // For no ajax call
63
+	if ($selecteddir != '/') {
64
+	    $selecteddir = preg_replace('/\/$/','',$selecteddir);
65
+	}
66
+	// We removed last '/' except if it is '/'
67
+} else    // For no ajax call
55 68
 {
56 69
 	//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); }
57 70
 
@@ -61,9 +74,14 @@  discard block
 block discarded – undo
61 74
 
62 75
 	$preopened = GETPOST('preopened');
63 76
 
64
-	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
65
-	if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
66
-}
77
+	if ($selecteddir != '/') {
78
+	    $selecteddir = preg_replace('/\/$/','',$selecteddir);
79
+	}
80
+	// We removed last '/' except if it is '/'
81
+	if (empty($url)) {
82
+	    $url=DOL_URL_ROOT.'/ecm/index.php';
83
+	}
84
+	}
67 85
 
68 86
 // Load translation files required by the page
69 87
 $langs->load("ecm");
@@ -74,8 +92,7 @@  discard block
 block discarded – undo
74 92
 {
75 93
 	$fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
76 94
 	$fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
77
-}
78
-elseif ($modulepart == 'medias')
95
+} elseif ($modulepart == 'medias')
79 96
 {
80 97
 	$fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
81 98
 	$fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
@@ -95,9 +112,10 @@  discard block
 block discarded – undo
95 112
 // Check permissions
96 113
 if ($modulepart == 'ecm')
97 114
 {
98
-	if (! $user->rights->ecm->read) accessforbidden();
99
-}
100
-elseif ($modulepart == 'medias')
115
+	if (! $user->rights->ecm->read) {
116
+	    accessforbidden();
117
+	}
118
+	} elseif ($modulepart == 'medias')
101 119
 {
102 120
 	// Always allowed
103 121
 }
@@ -107,10 +125,12 @@  discard block
 block discarded – undo
107 125
  * View
108 126
  */
109 127
 
110
-if (! isset($mode) || $mode != 'noajax')	// if ajax mode
128
+if (! isset($mode) || $mode != 'noajax') {
129
+    // if ajax mode
111 130
 {
112 131
 	top_httphead();
113 132
 }
133
+}
114 134
 
115 135
 //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n";
116 136
 $userstatic=new User($db);
@@ -118,7 +138,9 @@  discard block
 block discarded – undo
118 138
 $ecmdirstatic = new EcmDirectory($db);
119 139
 
120 140
 // Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir
121
-if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);
141
+if (empty($sqltree)) {
142
+    $sqltree=$ecmdirstatic->get_full_arbo(0);
143
+}
122 144
 
123 145
 // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id
124 146
 $current_ecmdir_id=-1;
@@ -164,7 +186,10 @@  discard block
 block discarded – undo
164 186
 	print '<ul class="ecmjqft">';
165 187
 
166 188
 	// Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
167
-	if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);    // Slow
189
+	if (empty($sqltree)) {
190
+	    $sqltree=$ecmdirstatic->get_full_arbo(0);
191
+	}
192
+	// Slow
168 193
 
169 194
 	// ----- This section will show a tree from a fulltree array -----
170 195
 	// $section must also be defined
@@ -185,7 +210,9 @@  discard block
 block discarded – undo
185 210
 
186 211
 	// Update expandedsectionarray in session
187 212
 	$expandedsectionarray=array();
188
-	if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
213
+	if (isset($_SESSION['dol_ecmexpandedsectionarray'])) {
214
+	    $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
215
+	}
189 216
 
190 217
 	if ($section && GETPOST('sectionexpand') == 'true')
191 218
 	{
@@ -193,10 +220,12 @@  discard block
 block discarded – undo
193 220
 		$pathtosection=explode('_',$fullpathselected);
194 221
 		foreach($pathtosection as $idcursor)
195 222
 		{
196
-			if ($idcursor && ! in_array($idcursor,$expandedsectionarray))	// Not already in array
223
+			if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) {
224
+			    // Not already in array
197 225
 			{
198 226
 				$expandedsectionarray[]=$idcursor;
199 227
 			}
228
+			}
200 229
 		}
201 230
 		$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
202 231
 	}
@@ -238,18 +267,29 @@  discard block
 block discarded – undo
238 267
 		$showline=0;
239 268
 
240 269
 		// If directory is son of expanded directory, we show line
241
-		if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
270
+		if (in_array($val['id_mere'],$expandedsectionarray)) {
271
+		    $showline=4;
272
+		}
242 273
 		// If directory is brother of selected directory, we show line
243
-		elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
274
+		elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) {
275
+		    $showline=3;
276
+		}
244 277
 		// If directory is parent of selected directory or is selected directory, we show line
245
-		elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
278
+		elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) {
279
+		    $showline=2;
280
+		}
246 281
 		// If we are level one we show line
247
-		elseif ($val['level'] < 2) $showline=1;
282
+		elseif ($val['level'] < 2) {
283
+		    $showline=1;
284
+		}
248 285
 
249 286
 		if ($showline)
250 287
 		{
251
-			if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
252
-			else $option='indexnotexpanded';
288
+			if (in_array($val['id'],$expandedsectionarray)) {
289
+			    $option='indexexpanded';
290
+			} else {
291
+			    $option='indexnotexpanded';
292
+			}
253 293
 			//print $option;
254 294
 
255 295
 			print '<li class="directory collapsed">';
@@ -276,7 +316,9 @@  discard block
 block discarded – undo
276 316
 			print $val['cachenbofdoc'];
277 317
 			print '</td>';
278 318
 			print '<td align="left">';
279
-			if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
319
+			if ($nbofsubdir && $nboffilesinsubdir) {
320
+			    print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
321
+			}
280 322
 			print '</td>';
281 323
 
282 324
 			// Info
@@ -289,8 +331,11 @@  discard block
 block discarded – undo
289 331
 			$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
290 332
 			$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
291 333
 			$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
292
-			if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
293
-			else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
334
+			if ($nbofsubdir) {
335
+			    $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
336
+			} else {
337
+			    $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
338
+			}
294 339
 			print $form->textwithpicto('', $htmltooltip, 1, 'info');
295 340
 			print "</td>";
296 341
 
@@ -320,7 +365,9 @@  discard block
 block discarded – undo
320 365
 
321 366
 
322 367
 // Close db if mode is not noajax
323
-if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
368
+if ((! isset($mode) || $mode != 'noajax') && is_object($db)) {
369
+    $db->close();
370
+}
324 371
 
325 372
 
326 373
 
@@ -353,14 +400,18 @@  discard block
 block discarded – undo
353 400
 		if (! empty($files))
354 401
 		{
355 402
 			natcasesort($files);
356
-			if (count($files) > 2)    /* The 2 accounts for . and .. */
403
+			if (count($files) > 2) {
404
+			    /* The 2 accounts for . and .. */
357 405
 			{
358 406
 				echo '<ul class="ecmjqft" style="display: none;">'."\n";
407
+			}
359 408
 
360 409
 				// All dirs
361
-				foreach ($files as $file)    // $file can be '.', '..', or 'My dir' or 'My file'
410
+				foreach ($files as $file) {
411
+				    // $file can be '.', '..', or 'My dir' or 'My file'
362 412
 				{
363 413
 					if ($file == 'temp') continue;
414
+				}
364 415
 
365 416
 					$nbofsubdir=0;
366 417
 					$nboffilesinsubdir=0;
@@ -371,15 +422,19 @@  discard block
 block discarded – undo
371 422
 					foreach($sqltree as $key => $tmpval)
372 423
 					{
373 424
 						//print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
374
-						if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file))		// We found equivalent record into database
425
+						if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) {
426
+						    // We found equivalent record into database
375 427
 						{
376 428
 							$val=$tmpval;
429
+						}
377 430
 							$resarray=tree_showpad($sqltree,$key,1);
378 431
 
379 432
 							// Refresh cache for this subdir
380
-							if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0)	// Cache is not up to date, so we update it for this directory t
433
+							if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) {
434
+							    // Cache is not up to date, so we update it for this directory t
381 435
 							{
382 436
 								$result=$ecmdirstatic->fetch($val['id']);
437
+							}
383 438
 								$ecmdirstatic->ref=$ecmdirstatic->label;
384 439
 
385 440
 								$result=$ecmdirstatic->refreshcachenboffile(0);
@@ -396,9 +451,11 @@  discard block
 block discarded – undo
396 451
 					//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
397 452
 					if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file)))
398 453
 					{
399
-						if (empty($val['fullrelativename']))	// If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
454
+						if (empty($val['fullrelativename'])) {
455
+						    // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
400 456
 						{
401 457
 							$val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file;
458
+						}
402 459
 							$val['id']=0;
403 460
 							$val['label']=$file;
404 461
 							$val['description']='';
@@ -406,7 +463,9 @@  discard block
 block discarded – undo
406 463
 						}
407 464
 
408 465
 						$collapsedorexpanded='collapsed';
409
-						if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded';
466
+						if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) {
467
+						    $collapsedorexpanded='expanded';
468
+						}
410 469
 						print '<li class="directory '.$collapsedorexpanded.'">';	// collapsed is opposite if expanded
411 470
 
412 471
 						print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
@@ -430,7 +489,9 @@  discard block
 block discarded – undo
430 489
 						print (isset($val['cachenbofdoc']) && $val['cachenbofdoc']  >= 0)?$val['cachenbofdoc']:'&nbsp;';
431 490
 						print '</td>';
432 491
 						print '<td align="left">';
433
-						if ($nbofsubdir > 0  && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
492
+						if ($nbofsubdir > 0  && $nboffilesinsubdir > 0) {
493
+						    print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
494
+						}
434 495
 						print '</td>';
435 496
 
436 497
 						// Edit link
@@ -455,8 +516,11 @@  discard block
 block discarded – undo
455 516
 							$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>';
456 517
 							$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
457 518
 							$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>';
458
-							if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
459
-							else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
519
+							if ($nboffilesinsubdir > 0) {
520
+							    $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
521
+							} else {
522
+							    $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
523
+							}
460 524
 							print $form->textwithpicto('',$htmltooltip,1,"info");
461 525
 							print "</td>";
462 526
 						}
@@ -473,13 +537,14 @@  discard block
 block discarded – undo
473 537
 							if ($modulepart == 'ecm')
474 538
 							{
475 539
 								$newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
476
-							}
477
-							elseif ($modulepart == 'medias')
540
+							} elseif ($modulepart == 'medias')
478 541
 							{
479 542
 								$newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
480 543
 							}
481 544
 
482
-							if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
545
+							if ($newfullpathselecteddir) {
546
+							    treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
547
+							}
483 548
 						}
484 549
 
485 550
 						print "</li>\n";
@@ -488,8 +553,9 @@  discard block
 block discarded – undo
488 553
 
489 554
 				echo "</ul>\n";
490 555
 			}
556
+		} else {
557
+		    print "PermissionDenied";
491 558
 		}
492
-		else print "PermissionDenied";
493 559
 	}
494 560
 }
495 561
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/ajax/ajaxdirpreview.php 1 patch
Braces   +145 added lines, -60 removed lines patch added patch discarded remove patch
@@ -27,14 +27,25 @@  discard block
 block discarded – undo
27 27
  * 				ajaxdirpreview.php?mode=nojs&action=preview&module=ecm&section=0&file=xxx
28 28
  */
29 29
 
30
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
31
-if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
32
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
33
-if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
30
+if (! defined('NOTOKENRENEWAL')) {
31
+    define('NOTOKENRENEWAL',1);
32
+}
33
+// Disables token renewal
34
+if (! defined('NOREQUIREMENU')) {
35
+    define('NOREQUIREMENU','1');
36
+}
37
+if (! defined('NOREQUIREHTML')) {
38
+    define('NOREQUIREHTML','1');
39
+}
40
+if (! defined('NOREQUIREAJAX')) {
41
+    define('NOREQUIREAJAX','1');
42
+}
34 43
 
35
-if (! isset($mode) || $mode != 'noajax')    // For ajax call
44
+if (! isset($mode) || $mode != 'noajax') {
45
+    // For ajax call
36 46
 {
37 47
     require_once '../../main.inc.php';
48
+}
38 49
     require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 50
     require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
40 51
     require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
@@ -53,8 +64,12 @@  discard block
 block discarded – undo
53 64
     $offset = $conf->liste_limit * $page;
54 65
     $pageprev = $page - 1;
55 66
     $pagenext = $page + 1;
56
-    if (! $sortorder) $sortorder="ASC";
57
-    if (! $sortfield) $sortfield="name";
67
+    if (! $sortorder) {
68
+        $sortorder="ASC";
69
+    }
70
+    if (! $sortfield) {
71
+        $sortfield="name";
72
+    }
58 73
 
59 74
 	$rootdirfordoc = $conf->ecm->dir_output;
60 75
 
@@ -67,8 +82,7 @@  discard block
 block discarded – undo
67 82
         //dol_print_error($db,$ecmdir->error);
68 83
         //exit;
69 84
     }
70
-}
71
-else    // For no ajax call
85
+} else    // For no ajax call
72 86
 {
73 87
 	$rootdirfordoc = $conf->ecm->dir_output;
74 88
 
@@ -84,8 +98,7 @@  discard block
 block discarded – undo
84 98
         }
85 99
 
86 100
         $relativepath=$ecmdir->getRelativePath();	// Example   'mydir/'
87
-    }
88
-	elseif (GETPOST('section_dir'))
101
+    } elseif (GETPOST('section_dir'))
89 102
 	{
90 103
 		$relativepath=GETPOST('section_dir');
91 104
 	}
@@ -96,15 +109,20 @@  discard block
 block discarded – undo
96 109
 
97 110
 if (empty($url))
98 111
 {
99
-	if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php';
100
-	else $url=DOL_URL_ROOT.'/ecm/index.php';
101
-}
112
+	if (GETPOSTISSET('website')) {
113
+	    $url=DOL_URL_ROOT.'/website/index.php';
114
+	} else {
115
+	    $url=DOL_URL_ROOT.'/ecm/index.php';
116
+	}
117
+	}
102 118
 
103 119
 // Load translation files required by the page
104 120
 $langs->loadLangs(array("ecm","companies","other"));
105 121
 
106 122
 // Security check
107
-if ($user->societe_id > 0) $socid = $user->societe_id;
123
+if ($user->societe_id > 0) {
124
+    $socid = $user->societe_id;
125
+}
108 126
 
109 127
 //print 'xxx'.$upload_dir;
110 128
 
@@ -121,8 +139,10 @@  discard block
 block discarded – undo
121 139
 // Check permissions
122 140
 if ($modulepart == 'ecm')
123 141
 {
124
-	if (! $user->rights->ecm->read) accessforbidden();
125
-}
142
+	if (! $user->rights->ecm->read) {
143
+	    accessforbidden();
144
+	}
145
+	}
126 146
 if ($modulepart == 'medias')
127 147
 {
128 148
 	// Always allowed
@@ -165,8 +185,12 @@  discard block
 block discarded – undo
165 185
 //print '<!-- Page called with mode='.dol_escape_htmltag(isset($mode)?$mode:'').' type='.dol_escape_htmltag($type).' module='.dol_escape_htmltag($module).' url='.dol_escape_htmltag($url).' '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
166 186
 
167 187
 $param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
168
-if (! empty($websitekey)) $param.='&website='.$websitekey;
169
-if (! empty($pageid))     $param.='&pageid='.$pageid;
188
+if (! empty($websitekey)) {
189
+    $param.='&website='.$websitekey;
190
+}
191
+if (! empty($pageid)) {
192
+    $param.='&pageid='.$pageid;
193
+}
170 194
 
171 195
 
172 196
 // Dir scan
@@ -183,45 +207,80 @@  discard block
 block discarded – undo
183 207
 
184 208
     // TODO change for multicompany sharing
185 209
     // Auto area for suppliers invoices
186
-    if ($module == 'company') $upload_dir = $conf->societe->dir_output;
210
+    if ($module == 'company') {
211
+        $upload_dir = $conf->societe->dir_output;
212
+    }
187 213
     // Auto area for suppliers invoices
188
-    else if ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
214
+    else if ($module == 'invoice') {
215
+        $upload_dir = $conf->facture->dir_output;
216
+    }
189 217
     // Auto area for suppliers invoices
190
-    else if ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
218
+    else if ($module == 'invoice_supplier') {
219
+        $upload_dir = $conf->fournisseur->facture->dir_output;
220
+    }
191 221
     // Auto area for customers proposal
192
-    else if ($module == 'propal') $upload_dir = $conf->propal->dir_output;
222
+    else if ($module == 'propal') {
223
+        $upload_dir = $conf->propal->dir_output;
224
+    }
193 225
     // Auto area for suppliers proposal
194
-    else if ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output;
226
+    else if ($module == 'supplier_proposal') {
227
+        $upload_dir = $conf->supplier_proposal->dir_output;
228
+    }
195 229
     // Auto area for customers orders
196
-    else if ($module == 'order') $upload_dir = $conf->commande->dir_output;
230
+    else if ($module == 'order') {
231
+        $upload_dir = $conf->commande->dir_output;
232
+    }
197 233
     // Auto area for suppliers orders
198
-    else if ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
234
+    else if ($module == 'order_supplier') {
235
+        $upload_dir = $conf->fournisseur->commande->dir_output;
236
+    }
199 237
     // Auto area for suppliers invoices
200
-    else if ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
238
+    else if ($module == 'contract') {
239
+        $upload_dir = $conf->contrat->dir_output;
240
+    }
201 241
     // Auto area for products
202
-    else if ($module == 'product') $upload_dir = $conf->product->dir_output;
242
+    else if ($module == 'product') {
243
+        $upload_dir = $conf->product->dir_output;
244
+    }
203 245
     // Auto area for suppliers invoices
204
-    else if ($module == 'tax') $upload_dir = $conf->tax->dir_output;
246
+    else if ($module == 'tax') {
247
+        $upload_dir = $conf->tax->dir_output;
248
+    }
205 249
     // Auto area for projects
206
-    else if ($module == 'project') $upload_dir = $conf->projet->dir_output;
250
+    else if ($module == 'project') {
251
+        $upload_dir = $conf->projet->dir_output;
252
+    }
207 253
     // Auto area for interventions
208
-    else if ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output;
254
+    else if ($module == 'fichinter') {
255
+        $upload_dir = $conf->ficheinter->dir_output;
256
+    }
209 257
     // Auto area for users
210
-    else if ($module == 'user') $upload_dir = $conf->user->dir_output;
258
+    else if ($module == 'user') {
259
+        $upload_dir = $conf->user->dir_output;
260
+    }
211 261
     // Auto area for expense report
212
-    else if ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
262
+    else if ($module == 'expensereport') {
263
+        $upload_dir = $conf->expensereport->dir_output;
264
+    }
213 265
 	// Auto area for holiday
214
-    else if ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
266
+    else if ($module == 'holiday') {
267
+        $upload_dir = $conf->holiday->dir_output;
268
+    }
215 269
 
216 270
     // Automatic list
217 271
     if (in_array($module, $automodules))
218 272
     {
219 273
         $param.='&module='.$module;
220
-        if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref;
274
+        if (isset($search_doc_ref) && $search_doc_ref != '') {
275
+            $param.='&search_doc_ref='.$search_doc_ref;
276
+        }
221 277
 
222 278
         $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
223 279
 
224
-        if ($module == 'company') $excludefiles[]='^contact$';   // The subdir 'contact' contains files of contacts with no id of thirdparty.
280
+        if ($module == 'company') {
281
+            $excludefiles[]='^contact$';
282
+        }
283
+        // The subdir 'contact' contains files of contacts with no id of thirdparty.
225 284
 
226 285
         $filter=preg_quote($search_doc_ref, '/');
227 286
         $filearray=dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting,1);
@@ -247,17 +306,22 @@  discard block
 block discarded – undo
247 306
 			  'sendit' => string 'Envoyer fichier' (length=15)
248 307
     		 */
249 308
     		$relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha');
250
-    		if ($relativepath && $relativepath!= '/') $relativepath.='/';
309
+    		if ($relativepath && $relativepath!= '/') {
310
+    		    $relativepath.='/';
311
+    		}
251 312
     		$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
252 313
     		if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
253 314
 	    	{
254 315
 	    		$param.='&file_manager=1';
255
-	    		if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha'));
256
-	    		if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int'));
316
+	    		if (!preg_match('/website=/',$param)) {
317
+	    		    $param.='&website='.urlencode(GETPOST('website','alpha'));
318
+	    		}
319
+	    		if (!preg_match('/pageid=/',$param)) {
320
+	    		    $param.='&pageid='.urlencode(GETPOST('pageid','int'));
321
+	    		}
257 322
 	    		//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
258 323
 	    	}
259
-    	}
260
-    	else
324
+    	} else
261 325
     	{
262 326
         	$relativepath=$ecmdir->getRelativePath();
263 327
         	$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
@@ -267,8 +331,7 @@  discard block
 block discarded – undo
267 331
 		if (($section === '0' || empty($section)) && ($module != 'medias'))
268 332
         {
269 333
             $filearray=array();
270
-        }
271
-        else
334
+        } else
272 335
         {
273 336
         	$filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1);
274 337
         }
@@ -276,16 +339,21 @@  discard block
 block discarded – undo
276 339
         if ($section)
277 340
         {
278 341
             $param.='&section='.$section;
279
-        	if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref;
342
+        	if (isset($search_doc_ref) && $search_doc_ref != '') {
343
+        	    $param.='&search_doc_ref='.$search_doc_ref;
344
+        	}
280 345
 
281 346
             $textifempty = $langs->trans('NoFileFound');
282
-        }
283
-        else if ($section === '0')
347
+        } else if ($section === '0')
284 348
         {
285
-        	if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
286
-        	else $textifempty = $langs->trans('NoFileFound');
349
+        	if ($module == 'ecm') {
350
+        	    $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
351
+        	} else {
352
+        	    $textifempty = $langs->trans('NoFileFound');
353
+        	}
354
+        } else {
355
+            $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"));
287 356
         }
288
-        else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"));
289 357
 
290 358
     	if ($module == 'medias')
291 359
     	{
@@ -293,8 +361,7 @@  discard block
 block discarded – undo
293 361
     		$modulepart='medias';
294 362
         	$perm=($user->rights->website->write || $user->rights->emailing->creer);
295 363
         	$title='none';
296
-    	}
297
-    	else
364
+    	} else
298 365
     	{
299 366
     		$useinecm = 1;
300 367
     		$modulepart='ecm';
@@ -313,18 +380,28 @@  discard block
 block discarded – undo
313 380
 
314 381
 // Bottom of page
315 382
 $useajax=1;
316
-if (! empty($conf->dol_use_jmobile)) $useajax=0;
317
-if (empty($conf->use_javascript_ajax)) $useajax=0;
318
-if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0;
383
+if (! empty($conf->dol_use_jmobile)) {
384
+    $useajax=0;
385
+}
386
+if (empty($conf->use_javascript_ajax)) {
387
+    $useajax=0;
388
+}
389
+if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) {
390
+    $useajax=0;
391
+}
319 392
 
320 393
 //$param.=($param?'?':'').(preg_replace('/^&/','',$param));
321 394
 
322 395
 if ($useajax || $action == 'delete')
323 396
 {
324 397
 	$urlfile='';
325
-	if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha');
398
+	if ($action == 'delete') {
399
+	    $urlfile=GETPOST('urlfile','alpha');
400
+	}
326 401
 
327
-	if (empty($section_dir)) $section_dir=GETPOST("file","alpha");
402
+	if (empty($section_dir)) {
403
+	    $section_dir=GETPOST("file","alpha");
404
+	}
328 405
 	$section_id=$section;
329 406
 
330 407
 	require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@@ -334,9 +411,15 @@  discard block
 block discarded – undo
334 411
 	$formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section');				// We must always put field, even if empty because it is fille by javascript later
335 412
 	$formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id');		// We must always put field, even if empty because it is fille by javascript later
336 413
 	$formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir');	// We must always put field, even if empty because it is fille by javascript later
337
-	if (! empty($action) && $action == 'file_manager')	$formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
338
-	if (! empty($websitekey))							$formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website');
339
-	if (! empty($pageid) && $pageid > 0)				$formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
414
+	if (! empty($action) && $action == 'file_manager') {
415
+	    $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
416
+	}
417
+	if (! empty($websitekey)) {
418
+	    $formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website');
419
+	}
420
+	if (! empty($pageid) && $pageid > 0) {
421
+	    $formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
422
+	}
340 423
 
341 424
 	print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
342 425
 }
@@ -376,4 +459,6 @@  discard block
 block discarded – undo
376 459
 }
377 460
 
378 461
 // Close db if mode is not noajax
379
-if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
462
+if ((! isset($mode) || $mode != 'noajax') && is_object($db)) {
463
+    $db->close();
464
+}
Please login to merge, or discard this patch.