Test Failed
Branch develop (86e751)
by Laurent
34:11
created
htdocs/webservices/server_other.php 3 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -55,30 +55,30 @@  discard block
 block discarded – undo
55 55
 
56 56
 // Define WSDL Authentication object
57 57
 $server->wsdl->addComplexType(
58
-    'authentication',
59
-    'complexType',
60
-    'struct',
61
-    'all',
62
-    '',
63
-    array(
64
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
65
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
66
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
67
-        'password' => array('name'=>'password','type'=>'xsd:string'),
68
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
69
-    )
58
+	'authentication',
59
+	'complexType',
60
+	'struct',
61
+	'all',
62
+	'',
63
+	array(
64
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
65
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
66
+		'login' => array('name'=>'login','type'=>'xsd:string'),
67
+		'password' => array('name'=>'password','type'=>'xsd:string'),
68
+		'entity' => array('name'=>'entity','type'=>'xsd:string'),
69
+	)
70 70
 );
71 71
 // Define WSDL Return object
72 72
 $server->wsdl->addComplexType(
73
-    'result',
74
-    'complexType',
75
-    'struct',
76
-    'all',
77
-    '',
78
-    array(
79
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
80
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
81
-    )
73
+	'result',
74
+	'complexType',
75
+	'struct',
76
+	'all',
77
+	'',
78
+	array(
79
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
80
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
81
+	)
82 82
 );
83 83
 
84 84
 // Define WSDL Return object for document
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 
110 110
 // Register WSDL
111 111
 $server->register(
112
-    'getVersions',
113
-    // Entry values
114
-    array('authentication'=>'tns:authentication'),
115
-    // Exit values
116
-    array('result'=>'tns:result','dolibarr'=>'xsd:string','os'=>'xsd:string','php'=>'xsd:string','webserver'=>'xsd:string'),
117
-    $ns,
118
-    $ns.'#getVersions',
119
-    $styledoc,
120
-    $styleuse,
121
-    'WS to get Versions'
112
+	'getVersions',
113
+	// Entry values
114
+	array('authentication'=>'tns:authentication'),
115
+	// Exit values
116
+	array('result'=>'tns:result','dolibarr'=>'xsd:string','os'=>'xsd:string','php'=>'xsd:string','webserver'=>'xsd:string'),
117
+	$ns,
118
+	$ns.'#getVersions',
119
+	$styledoc,
120
+	$styleuse,
121
+	'WS to get Versions'
122 122
 );
123 123
 
124 124
 // Register WSDL
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 
147 147
 	if ($authentication['entity']) $conf->entity=$authentication['entity'];
148 148
 
149
-    // Init and check authentication
150
-    $objectresp=array();
151
-    $errorcode='';$errorlabel='';
152
-    $error=0;
153
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
154
-    // Check parameters
149
+	// Init and check authentication
150
+	$objectresp=array();
151
+	$errorcode='';$errorlabel='';
152
+	$error=0;
153
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
154
+	// Check parameters
155 155
 
156 156
 
157
-    if (! $error)
157
+	if (! $error)
158 158
 	{
159 159
 		$objectresp['result']=array('result_code'=>'OK', 'result_label'=>'');
160 160
 		$objectresp['dolibarr']=version_dolibarr();
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  *       \brief      File that is entry point to call Dolibarr WebServices
21 21
  */
22 22
 
23
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
23
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
24 24
 
25 25
 require_once '../master.inc.php';
26
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
26
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
27 27
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
28 28
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
29 29
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 {
40 40
 	$langs->load("admin");
41 41
 	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
42
-	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
42
+	print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
43 43
 	print $langs->trans("ToActivateModule");
44 44
 	exit;
45 45
 }
46 46
 
47 47
 // Create the soap Object
48 48
 $server = new nusoap_server();
49
-$server->soap_defencoding='UTF-8';
50
-$server->decode_utf8=false;
51
-$ns='http://www.dolibarr.org/ns/';
52
-$server->configureWSDL('WebServicesDolibarrOther',$ns);
53
-$server->wsdl->schemaTargetNamespace=$ns;
49
+$server->soap_defencoding = 'UTF-8';
50
+$server->decode_utf8 = false;
51
+$ns = 'http://www.dolibarr.org/ns/';
52
+$server->configureWSDL('WebServicesDolibarrOther', $ns);
53
+$server->wsdl->schemaTargetNamespace = $ns;
54 54
 
55 55
 
56 56
 // Define WSDL Authentication object
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
     'all',
62 62
     '',
63 63
     array(
64
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
65
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
66
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
67
-        'password' => array('name'=>'password','type'=>'xsd:string'),
68
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
64
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
65
+    	'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
66
+    	'login' => array('name'=>'login', 'type'=>'xsd:string'),
67
+        'password' => array('name'=>'password', 'type'=>'xsd:string'),
68
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
69 69
     )
70 70
 );
71 71
 // Define WSDL Return object
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
     'all',
77 77
     '',
78 78
     array(
79
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
80
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
79
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
80
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
81 81
     )
82 82
 );
83 83
 
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 	'all',
90 90
 	'',
91 91
 	array(
92
-		'filename' => array('name'=>'filename','type'=>'xsd:string'),
93
-		'mimetype' => array('name'=>'mimetype','type'=>'xsd:string'),
94
-		'content' => array('name'=>'content','type'=>'xsd:string'),
95
-		'length' => array('name'=>'length','type'=>'xsd:string')
92
+		'filename' => array('name'=>'filename', 'type'=>'xsd:string'),
93
+		'mimetype' => array('name'=>'mimetype', 'type'=>'xsd:string'),
94
+		'content' => array('name'=>'content', 'type'=>'xsd:string'),
95
+		'length' => array('name'=>'length', 'type'=>'xsd:string')
96 96
 	)
97 97
 );
98 98
 
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
104 104
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
105 105
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
106
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
107
-$styleuse='encoded';   // encoded/literal/literal wrapped
106
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
107
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
108 108
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
109 109
 
110 110
 // Register WSDL
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     // Entry values
114 114
     array('authentication'=>'tns:authentication'),
115 115
     // Exit values
116
-    array('result'=>'tns:result','dolibarr'=>'xsd:string','os'=>'xsd:string','php'=>'xsd:string','webserver'=>'xsd:string'),
116
+    array('result'=>'tns:result', 'dolibarr'=>'xsd:string', 'os'=>'xsd:string', 'php'=>'xsd:string', 'webserver'=>'xsd:string'),
117 117
     $ns,
118 118
     $ns.'#getVersions',
119 119
     $styledoc,
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 $server->register(
126 126
 	'getDocument',
127 127
 	// Entry values
128
-	array('authentication'=>'tns:authentication', 'modulepart'=>'xsd:string', 'file'=>'xsd:string' ),
128
+	array('authentication'=>'tns:authentication', 'modulepart'=>'xsd:string', 'file'=>'xsd:string'),
129 129
 	// Exit values
130
-	array('result'=>'tns:result','document'=>'tns:document'),
130
+	array('result'=>'tns:result', 'document'=>'tns:document'),
131 131
 	$ns,
132 132
 	$ns.'#getDocument',
133 133
 	$styledoc,
@@ -140,27 +140,27 @@  discard block
 block discarded – undo
140 140
 // Full methods code
141 141
 function getVersions($authentication)
142 142
 {
143
-	global $db,$conf,$langs;
143
+	global $db, $conf, $langs;
144 144
 
145 145
 	dol_syslog("Function: getVersions login=".$authentication['login']);
146 146
 
147
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
147
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
148 148
 
149 149
     // Init and check authentication
150
-    $objectresp=array();
151
-    $errorcode='';$errorlabel='';
152
-    $error=0;
153
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
150
+    $objectresp = array();
151
+    $errorcode = ''; $errorlabel = '';
152
+    $error = 0;
153
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
154 154
     // Check parameters
155 155
 
156 156
 
157
-    if (! $error)
157
+    if (!$error)
158 158
 	{
159
-		$objectresp['result']=array('result_code'=>'OK', 'result_label'=>'');
160
-		$objectresp['dolibarr']=version_dolibarr();
161
-		$objectresp['os']=version_os();
162
-		$objectresp['php']=version_php();
163
-		$objectresp['webserver']=version_webserver();
159
+		$objectresp['result'] = array('result_code'=>'OK', 'result_label'=>'');
160
+		$objectresp['dolibarr'] = version_dolibarr();
161
+		$objectresp['os'] = version_os();
162
+		$objectresp['php'] = version_php();
163
+		$objectresp['webserver'] = version_webserver();
164 164
 	}
165 165
 
166 166
 	if ($error)
@@ -181,49 +181,49 @@  discard block
 block discarded – undo
181 181
  * @param	string	$refname			Ref of object to check permission for external users (autodetect if not provided)
182 182
  * @return	void
183 183
  */
184
-function getDocument($authentication, $modulepart, $file, $refname='')
184
+function getDocument($authentication, $modulepart, $file, $refname = '')
185 185
 {
186
-	global $db,$conf,$langs,$mysoc;
186
+	global $db, $conf, $langs, $mysoc;
187 187
 
188 188
 	dol_syslog("Function: getDocument login=".$authentication['login'].' - modulepart='.$modulepart.' - file='.$file);
189 189
 
190
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
190
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
191 191
 
192
-	$objectresp=array();
193
-	$errorcode='';$errorlabel='';
194
-	$error=0;
192
+	$objectresp = array();
193
+	$errorcode = ''; $errorlabel = '';
194
+	$error = 0;
195 195
 
196 196
 	// Properties of doc
197 197
 	$original_file = $file;
198
-	$type=dol_mimetype($original_file);
198
+	$type = dol_mimetype($original_file);
199 199
 	//$relativefilepath = $ref . "/";
200 200
 	//$relativepath = $relativefilepath . $ref.'.pdf';
201 201
 
202
-	$accessallowed=0;
202
+	$accessallowed = 0;
203 203
 
204
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
204
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
205 205
 
206
-	if ($fuser->societe_id) $socid=$fuser->societe_id;
206
+	if ($fuser->societe_id) $socid = $fuser->societe_id;
207 207
 
208 208
 	// Check parameters
209
-	if (! $error && ( ! $file || ! $modulepart ) )
209
+	if (!$error && (!$file || !$modulepart))
210 210
 	{
211 211
 		$error++;
212
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter file and modulepart must be both provided.";
212
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter file and modulepart must be both provided.";
213 213
 	}
214 214
 
215
-	if (! $error)
215
+	if (!$error)
216 216
 	{
217 217
 		$fuser->getrights();
218 218
 
219 219
 		// Suppression de la chaine de caractere ../ dans $original_file
220
-		$original_file = str_replace("../","/", $original_file);
220
+		$original_file = str_replace("../", "/", $original_file);
221 221
 
222 222
 		// find the subdirectory name as the reference
223
-		if (empty($refname)) $refname=basename(dirname($original_file)."/");
223
+		if (empty($refname)) $refname = basename(dirname($original_file)."/");
224 224
 
225 225
 		// Security check
226
-		$check_access = dol_check_secure_access_document($modulepart,$original_file,$conf->entity,$fuser,$refname);
226
+		$check_access = dol_check_secure_access_document($modulepart, $original_file, $conf->entity, $fuser, $refname);
227 227
 		$accessallowed              = $check_access['accessallowed'];
228 228
 		$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
229 229
 		$original_file              = $check_access['original_file'];
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
 				$resql = $db->query($sqlprotectagainstexternals);
237 237
 				if ($resql)
238 238
 				{
239
-					$num=$db->num_rows($resql);
240
-					$i=0;
239
+					$num = $db->num_rows($resql);
240
+					$i = 0;
241 241
 					while ($i < $num)
242 242
 					{
243 243
 						$obj = $db->fetch_object($resql);
244 244
 						if ($fuser->societe_id != $obj->fk_soc)
245 245
 						{
246
-							$accessallowed=0;
246
+							$accessallowed = 0;
247 247
 							break;
248 248
 						}
249 249
 						$i++;
@@ -254,37 +254,37 @@  discard block
 block discarded – undo
254 254
 
255 255
 		// Security:
256 256
 		// Limite acces si droits non corrects
257
-		if (! $accessallowed)
257
+		if (!$accessallowed)
258 258
 		{
259
-			$errorcode='NOT_PERMITTED';
260
-			$errorlabel='Access not allowed';
259
+			$errorcode = 'NOT_PERMITTED';
260
+			$errorlabel = 'Access not allowed';
261 261
 			$error++;
262 262
 		}
263 263
 
264 264
 		// Security:
265 265
 		// On interdit les remontees de repertoire ainsi que les pipe dans
266 266
 		// les noms de fichiers.
267
-		if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
267
+		if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file))
268 268
 		{
269 269
 			dol_syslog("Refused to deliver file ".$original_file);
270
-			$errorcode='REFUSED';
271
-			$errorlabel='';
270
+			$errorcode = 'REFUSED';
271
+			$errorlabel = '';
272 272
 			$error++;
273 273
 		}
274 274
 
275 275
 		clearstatcache();
276 276
 
277
-		if(!$error)
277
+		if (!$error)
278 278
 		{
279
-			if(file_exists($original_file))
279
+			if (file_exists($original_file))
280 280
 			{
281 281
 				dol_syslog("Function: getDocument $original_file $filename content-type=$type");
282 282
 
283
-				$file=$fileparams['fullname'];
283
+				$file = $fileparams['fullname'];
284 284
 				$filename = basename($file);
285 285
 
286
-				$f = fopen($original_file,'r');
287
-				$content_file = fread($f,filesize($original_file));
286
+				$f = fopen($original_file, 'r');
287
+				$content_file = fread($f, filesize($original_file));
288 288
 
289 289
 				$objectret = array(
290 290
 					'filename' => basename($original_file),
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 			else
303 303
 			{
304 304
 				dol_syslog("File doesn't exist ".$original_file);
305
-				$errorcode='NOT_FOUND';
306
-				$errorlabel='';
305
+				$errorcode = 'NOT_FOUND';
306
+				$errorlabel = '';
307 307
 				$error++;
308 308
 			}
309 309
 		}
Please login to merge, or discard this patch.
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
  *       \brief      File that is entry point to call Dolibarr WebServices
21 21
  */
22 22
 
23
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
23
+if (! defined("NOCSRFCHECK")) {
24
+	define("NOCSRFCHECK",'1');
25
+}
24 26
 
25 27
 require_once '../master.inc.php';
26 28
 require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
@@ -144,7 +146,9 @@  discard block
 block discarded – undo
144 146
 
145 147
 	dol_syslog("Function: getVersions login=".$authentication['login']);
146 148
 
147
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
149
+	if ($authentication['entity']) {
150
+		$conf->entity=$authentication['entity'];
151
+	}
148 152
 
149 153
     // Init and check authentication
150 154
     $objectresp=array();
@@ -187,7 +191,9 @@  discard block
 block discarded – undo
187 191
 
188 192
 	dol_syslog("Function: getDocument login=".$authentication['login'].' - modulepart='.$modulepart.' - file='.$file);
189 193
 
190
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
194
+	if ($authentication['entity']) {
195
+		$conf->entity=$authentication['entity'];
196
+	}
191 197
 
192 198
 	$objectresp=array();
193 199
 	$errorcode='';$errorlabel='';
@@ -203,7 +209,9 @@  discard block
 block discarded – undo
203 209
 
204 210
 	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
205 211
 
206
-	if ($fuser->societe_id) $socid=$fuser->societe_id;
212
+	if ($fuser->societe_id) {
213
+		$socid=$fuser->societe_id;
214
+	}
207 215
 
208 216
 	// Check parameters
209 217
 	if (! $error && ( ! $file || ! $modulepart ) )
@@ -220,7 +228,9 @@  discard block
 block discarded – undo
220 228
 		$original_file = str_replace("../","/", $original_file);
221 229
 
222 230
 		// find the subdirectory name as the reference
223
-		if (empty($refname)) $refname=basename(dirname($original_file)."/");
231
+		if (empty($refname)) {
232
+			$refname=basename(dirname($original_file)."/");
233
+		}
224 234
 
225 235
 		// Security check
226 236
 		$check_access = dol_check_secure_access_document($modulepart,$original_file,$conf->entity,$fuser,$refname);
@@ -298,8 +308,7 @@  discard block
 block discarded – undo
298 308
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
299 309
 					'document'=>$objectret
300 310
 				);
301
-			}
302
-			else
311
+			} else
303 312
 			{
304 313
 				dol_syslog("File doesn't exist ".$original_file);
305 314
 				$errorcode='NOT_FOUND';
Please login to merge, or discard this patch.
htdocs/webservices/server_category.php 3 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
  * Les catégories filles, sous tableau dez la catégorie
94 94
  */
95 95
  $server->wsdl->addComplexType(
96
-    'FillesArray',
97
-    'complexType',
98
-    'array',
99
-    '',
100
-    'SOAP-ENC:Array',
101
-    array(),
102
-    array(
103
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:categorie[]')
104
-    ),
105
-    'tns:categorie'
96
+	'FillesArray',
97
+	'complexType',
98
+	'array',
99
+	'',
100
+	'SOAP-ENC:Array',
101
+	array(),
102
+	array(
103
+		array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:categorie[]')
104
+	),
105
+	'tns:categorie'
106 106
 );
107 107
 
108 108
  /*
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 	// Exit values
173 173
 	array('result'=>'tns:result','categorie'=>'tns:categorie'),
174 174
 	$ns,
175
-    $ns.'#getCategory',
176
-    $styledoc,
177
-    $styleuse,
178
-    'WS to get category'
175
+	$ns.'#getCategory',
176
+	$styledoc,
177
+	$styleuse,
178
+	'WS to get category'
179 179
 );
180 180
 
181 181
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 						'type' => $categorie->type,
230 230
 						'dir' => $pdir,
231 231
 						'photos' => $categorie->liste_photos($dir,$nbmax=10)
232
-			    	);
232
+					);
233 233
 
234 234
 					$cats = $categorie->get_filles();
235 235
 					if (count($cats) > 0)
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 
256 256
 					}
257 257
 
258
-			    // Create
259
-			    $objectresp = array(
258
+				// Create
259
+				$objectresp = array(
260 260
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
261 261
 					'categorie'=> $cat
262 262
 			   );
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
  *       \brief      File that is entry point to call Dolibarr WebServices
22 22
  */
23 23
 
24
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
24
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
25 25
 
26 26
 require_once("../master.inc.php");
27
-require_once(NUSOAP_PATH.'/nusoap.php');		// Include SOAP
27
+require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
28 28
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
29 29
 require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
30 30
 
@@ -36,18 +36,18 @@  discard block
 block discarded – undo
36 36
 {
37 37
 	$langs->load("admin");
38 38
 	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
39
-	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
39
+	print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
40 40
 	print $langs->trans("ToActivateModule");
41 41
 	exit;
42 42
 }
43 43
 
44 44
 // Create the soap Object
45 45
 $server = new nusoap_server();
46
-$server->soap_defencoding='UTF-8';
47
-$server->decode_utf8=false;
48
-$ns='http://www.dolibarr.org/ns/';
49
-$server->configureWSDL('WebServicesDolibarrCategorie',$ns);
50
-$server->wsdl->schemaTargetNamespace=$ns;
46
+$server->soap_defencoding = 'UTF-8';
47
+$server->decode_utf8 = false;
48
+$ns = 'http://www.dolibarr.org/ns/';
49
+$server->configureWSDL('WebServicesDolibarrCategorie', $ns);
50
+$server->wsdl->schemaTargetNamespace = $ns;
51 51
 
52 52
 
53 53
 // Define WSDL content
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 	'all',
59 59
 	'',
60 60
 	array(
61
-		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
62
-		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
63
-		'login' => array('name'=>'login','type'=>'xsd:string'),
64
-		'password' => array('name'=>'password','type'=>'xsd:string'),
65
-		'entity' => array('name'=>'entity','type'=>'xsd:string'),
61
+		'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
62
+		'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
63
+		'login' => array('name'=>'login', 'type'=>'xsd:string'),
64
+		'password' => array('name'=>'password', 'type'=>'xsd:string'),
65
+		'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
66 66
 	)
67 67
 );
68 68
 
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 	'all',
77 77
 	'',
78 78
 	array(
79
-		'id' => array('name'=>'id','type'=>'xsd:string'),
80
-		'id_mere' => array('name'=>'id_mere','type'=>'xsd:string'),
81
-		'label' => array('name'=>'label','type'=>'xsd:string'),
82
-		'description' => array('name'=>'description','type'=>'xsd:string'),
83
-		'socid' => array('name'=>'socid','type'=>'xsd:string'),
84
-		'type' => array('name'=>'type','type'=>'xsd:string'),
85
-		'visible' => array('name'=>'visible','type'=>'xsd:string'),
86
-		'dir'=> array('name'=>'dir','type'=>'xsd:string'),
87
-		'photos' => array('name'=>'photos','type'=>'tns:PhotosArray'),
88
-		'filles' => array('name'=>'filles','type'=>'tns:FillesArray')
79
+		'id' => array('name'=>'id', 'type'=>'xsd:string'),
80
+		'id_mere' => array('name'=>'id_mere', 'type'=>'xsd:string'),
81
+		'label' => array('name'=>'label', 'type'=>'xsd:string'),
82
+		'description' => array('name'=>'description', 'type'=>'xsd:string'),
83
+		'socid' => array('name'=>'socid', 'type'=>'xsd:string'),
84
+		'type' => array('name'=>'type', 'type'=>'xsd:string'),
85
+		'visible' => array('name'=>'visible', 'type'=>'xsd:string'),
86
+		'dir'=> array('name'=>'dir', 'type'=>'xsd:string'),
87
+		'photos' => array('name'=>'photos', 'type'=>'tns:PhotosArray'),
88
+		'filles' => array('name'=>'filles', 'type'=>'tns:FillesArray')
89 89
 	)
90 90
 );
91 91
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     'SOAP-ENC:Array',
101 101
     array(),
102 102
     array(
103
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:categorie[]')
103
+        array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:categorie[]')
104 104
     ),
105 105
     'tns:categorie'
106 106
 );
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
  		'all',
135 135
  		'',
136 136
  		array(
137
- 				'photo' => array('name'=>'photo','type'=>'xsd:string'),
138
- 				'photo_vignette' => array('name'=>'photo_vignette','type'=>'xsd:string'),
139
- 				'imgWidth' => array('name'=>'imgWidth','type'=>'xsd:string'),
140
- 				'imgHeight' => array('name'=>'imgHeight','type'=>'xsd:string')
137
+ 				'photo' => array('name'=>'photo', 'type'=>'xsd:string'),
138
+ 				'photo_vignette' => array('name'=>'photo_vignette', 'type'=>'xsd:string'),
139
+ 				'imgWidth' => array('name'=>'imgWidth', 'type'=>'xsd:string'),
140
+ 				'imgHeight' => array('name'=>'imgHeight', 'type'=>'xsd:string')
141 141
  		)
142 142
  );
143 143
 
@@ -151,16 +151,16 @@  discard block
 block discarded – undo
151 151
 	'all',
152 152
 	'',
153 153
 	array(
154
-		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
155
-		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
154
+		'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
155
+		'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
156 156
 	)
157 157
 );
158 158
 
159 159
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
160 160
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
161 161
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
162
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
163
-$styleuse='encoded';   // encoded/literal/literal wrapped
162
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
163
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
164 164
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
165 165
 
166 166
 
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 $server->register(
169 169
 	'getCategory',
170 170
 	// Entry values
171
-	array('authentication'=>'tns:authentication','id'=>'xsd:string'),
171
+	array('authentication'=>'tns:authentication', 'id'=>'xsd:string'),
172 172
 	// Exit values
173
-	array('result'=>'tns:result','categorie'=>'tns:categorie'),
173
+	array('result'=>'tns:result', 'categorie'=>'tns:categorie'),
174 174
 	$ns,
175 175
     $ns.'#getCategory',
176 176
     $styledoc,
@@ -186,38 +186,38 @@  discard block
 block discarded – undo
186 186
  * @param	int			$id					Id of object
187 187
  * @return	mixed
188 188
  */
189
-function getCategory($authentication,$id)
189
+function getCategory($authentication, $id)
190 190
 {
191
-	global $db,$conf,$langs;
191
+	global $db, $conf, $langs;
192 192
 
193 193
 	dol_syslog("Function: getCategory login=".$authentication['login']." id=".$id);
194 194
 
195
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
195
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
196 196
 
197
-	$objectresp=array();
198
-	$errorcode='';$errorlabel='';
199
-	$error=0;
200
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
197
+	$objectresp = array();
198
+	$errorcode = ''; $errorlabel = '';
199
+	$error = 0;
200
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
201 201
 
202
-	if (! $error && !$id)
202
+	if (!$error && !$id)
203 203
 	{
204 204
 		$error++;
205
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id must be provided.";
205
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id must be provided.";
206 206
 	}
207 207
 
208
-	if (! $error)
208
+	if (!$error)
209 209
 	{
210 210
 		$fuser->getrights();
211 211
 
212 212
 		if ($fuser->rights->categorie->lire)
213 213
 		{
214
-			$categorie=new Categorie($db);
215
-			$result=$categorie->fetch($id);
214
+			$categorie = new Categorie($db);
215
+			$result = $categorie->fetch($id);
216 216
 			if ($result > 0)
217 217
 			{
218
-					$dir = (!empty($conf->categorie->dir_output)?$conf->categorie->dir_output:$conf->service->dir_output);
219
-					$pdir = get_exdir($categorie->id,2,0,0,$categorie,'category') . $categorie->id ."/photos/";
220
-					$dir = $dir . '/'. $pdir;
218
+					$dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
219
+					$pdir = get_exdir($categorie->id, 2, 0, 0, $categorie, 'category').$categorie->id."/photos/";
220
+					$dir = $dir.'/'.$pdir;
221 221
 
222 222
 					$cat = array(
223 223
 						'id' => $categorie->id,
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
 						//'visible'=>$categorie->visible,
229 229
 						'type' => $categorie->type,
230 230
 						'dir' => $pdir,
231
-						'photos' => $categorie->liste_photos($dir,$nbmax=10)
231
+						'photos' => $categorie->liste_photos($dir, $nbmax = 10)
232 232
 			    	);
233 233
 
234 234
 					$cats = $categorie->get_filles();
235 235
 					if (count($cats) > 0)
236 236
 					{
237
-					 	foreach($cats as $fille)
237
+					 	foreach ($cats as $fille)
238 238
 						{
239
-							$dir = (!empty($conf->categorie->dir_output)?$conf->categorie->dir_output:$conf->service->dir_output);
240
-							$pdir = get_exdir($fille->id,2,0,0,$categorie,'category') . $fille->id ."/photos/";
241
-							$dir = $dir . '/'. $pdir;
239
+							$dir = (!empty($conf->categorie->dir_output) ? $conf->categorie->dir_output : $conf->service->dir_output);
240
+							$pdir = get_exdir($fille->id, 2, 0, 0, $categorie, 'category').$fille->id."/photos/";
241
+							$dir = $dir.'/'.$pdir;
242 242
 							$cat['filles'][] = array(
243 243
 								'id'=>$fille->id,
244 244
 								'id_mere' => $categorie->id_mere,
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 								//'visible'=>$fille->visible,
249 249
 								'type'=>$fille->type,
250 250
 								'dir' => $pdir,
251
-								'photos' => $fille->liste_photos($dir,$nbmax=10)
251
+								'photos' => $fille->liste_photos($dir, $nbmax = 10)
252 252
 							);
253 253
 
254 254
 						}
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
 			else
265 265
 			{
266 266
 				$error++;
267
-				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id;
267
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id;
268 268
 			}
269 269
 		}
270 270
 		else
271 271
 		{
272 272
 			$error++;
273
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
273
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
274 274
 		}
275 275
 	}
276 276
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
  *       \brief      File that is entry point to call Dolibarr WebServices
22 22
  */
23 23
 
24
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
24
+if (! defined("NOCSRFCHECK")) {
25
+	define("NOCSRFCHECK",'1');
26
+}
25 27
 
26 28
 require_once("../master.inc.php");
27 29
 require_once(NUSOAP_PATH.'/nusoap.php');		// Include SOAP
@@ -192,7 +194,9 @@  discard block
 block discarded – undo
192 194
 
193 195
 	dol_syslog("Function: getCategory login=".$authentication['login']." id=".$id);
194 196
 
195
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
197
+	if ($authentication['entity']) {
198
+		$conf->entity=$authentication['entity'];
199
+	}
196 200
 
197 201
 	$objectresp=array();
198 202
 	$errorcode='';$errorlabel='';
@@ -260,14 +264,12 @@  discard block
 block discarded – undo
260 264
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
261 265
 					'categorie'=> $cat
262 266
 			   );
263
-			}
264
-			else
267
+			} else
265 268
 			{
266 269
 				$error++;
267 270
 				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id;
268 271
 			}
269
-		}
270
-		else
272
+		} else
271 273
 		{
272 274
 			$error++;
273 275
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
Please login to merge, or discard this patch.
htdocs/webservices/index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
26 26
 
27 27
 require_once '../master.inc.php';
28
-require_once NUSOAP_PATH.'/nusoap.php';		// Include SOAP
28
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
29 29
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
30 30
 
31 31
 $langs->load("admin");
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 {
43 43
 	$langs->load("admin");
44 44
 	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
45
-	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
45
+	print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
46 46
 	print $langs->trans("ToActivateModule");
47 47
 	exit;
48 48
 }
Please login to merge, or discard this patch.
htdocs/webservices/admin/index.php 3 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,22 +37,22 @@  discard block
 block discarded – undo
37 37
 // Sauvegardes parametres
38 38
 if ($actionsave)
39 39
 {
40
-    $i=0;
41
-
42
-    $db->begin();
43
-
44
-    $i+=dolibarr_set_const($db,'WEBSERVICES_KEY',trim(GETPOST("WEBSERVICES_KEY")),'chaine',0,'',$conf->entity);
45
-
46
-    if ($i >= 1)
47
-    {
48
-        $db->commit();
49
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
50
-    }
51
-    else
52
-    {
53
-        $db->rollback();
54
-        setEventMessages($langs->trans("Error"), null, 'errors');
55
-    }
40
+	$i=0;
41
+
42
+	$db->begin();
43
+
44
+	$i+=dolibarr_set_const($db,'WEBSERVICES_KEY',trim(GETPOST("WEBSERVICES_KEY")),'chaine',0,'',$conf->entity);
45
+
46
+	if ($i >= 1)
47
+	{
48
+		$db->commit();
49
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
50
+	}
51
+	else
52
+	{
53
+		$db->rollback();
54
+		setEventMessages($langs->trans("Error"), null, 'errors');
55
+	}
56 56
 }
57 57
 
58 58
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		'actioncomm'		=> '!empty($conf->agenda->enabled)',
111 111
 		'category'			=> '!empty($conf->categorie->enabled)',
112 112
 		'project'			=> '!empty($conf->projet->enabled)',
113
-        'other'				=> ''
113
+		'other'				=> ''
114 114
 );
115 115
 
116 116
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 
30 30
 $langs->load("admin");
31 31
 
32
-if (! $user->admin)
32
+if (! $user->admin) {
33 33
 	accessforbidden();
34
+}
34 35
 
35 36
 $actionsave=GETPOST("save");
36 37
 
@@ -47,8 +48,7 @@  discard block
 block discarded – undo
47 48
     {
48 49
         $db->commit();
49 50
         setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
50
-    }
51
-    else
51
+    } else
52 52
     {
53 53
         $db->rollback();
54 54
         setEventMessages($langs->trans("Error"), null, 'errors');
@@ -82,8 +82,9 @@  discard block
 block discarded – undo
82 82
 print '<tr class="impair">';
83 83
 print '<td class="fieldrequired">'.$langs->trans("KeyForWebServicesAccess").'</td>';
84 84
 print '<td><input type="text" class="flat" id="WEBSERVICES_KEY" name="WEBSERVICES_KEY" value="'. (GETPOST('WEBSERVICES_KEY')?GETPOST('WEBSERVICES_KEY'):(! empty($conf->global->WEBSERVICES_KEY)?$conf->global->WEBSERVICES_KEY:'')) . '" size="40">';
85
-if (! empty($conf->use_javascript_ajax))
85
+if (! empty($conf->use_javascript_ajax)) {
86 86
 	print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
87
+}
87 88
 print '</td>';
88 89
 print '<td>&nbsp;</td>';
89 90
 print '</tr>';
@@ -118,7 +119,9 @@  discard block
 block discarded – undo
118 119
 print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
119 120
 foreach($webservices as $name => $right)
120 121
 {
121
-	if (!empty($right) && !verifCond($right)) continue;
122
+	if (!empty($right) && !verifCond($right)) {
123
+		continue;
124
+	}
122 125
 	$url=DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl';
123 126
 	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
124 127
 }
@@ -129,7 +132,9 @@  discard block
 block discarded – undo
129 132
 print '<u>'.$langs->trans("EndPointIs").':</u><br>';
130 133
 foreach($webservices as $name => $right)
131 134
 {
132
-	if (!empty($right) && !verifCond($right)) continue;
135
+	if (!empty($right) && !verifCond($right)) {
136
+		continue;
137
+	}
133 138
 	$url=DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php';
134 139
 	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
135 140
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
 
30 30
 $langs->load("admin");
31 31
 
32
-if (! $user->admin)
32
+if (!$user->admin)
33 33
 	accessforbidden();
34 34
 
35
-$actionsave=GETPOST("save");
35
+$actionsave = GETPOST("save");
36 36
 
37 37
 // Sauvegardes parametres
38 38
 if ($actionsave)
39 39
 {
40
-    $i=0;
40
+    $i = 0;
41 41
 
42 42
     $db->begin();
43 43
 
44
-    $i+=dolibarr_set_const($db,'WEBSERVICES_KEY',trim(GETPOST("WEBSERVICES_KEY")),'chaine',0,'',$conf->entity);
44
+    $i += dolibarr_set_const($db, 'WEBSERVICES_KEY', trim(GETPOST("WEBSERVICES_KEY")), 'chaine', 0, '', $conf->entity);
45 45
 
46 46
     if ($i >= 1)
47 47
     {
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 
63 63
 llxHeader();
64 64
 
65
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
66
-print load_fiche_titre($langs->trans("WebServicesSetup"),$linkback,'title_setup');
65
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
66
+print load_fiche_titre($langs->trans("WebServicesSetup"), $linkback, 'title_setup');
67 67
 
68 68
 print $langs->trans("WebServicesDesc")."<br>\n";
69 69
 print "<br>\n";
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 
82 82
 print '<tr class="impair">';
83 83
 print '<td class="fieldrequired">'.$langs->trans("KeyForWebServicesAccess").'</td>';
84
-print '<td><input type="text" class="flat" id="WEBSERVICES_KEY" name="WEBSERVICES_KEY" value="'. (GETPOST('WEBSERVICES_KEY')?GETPOST('WEBSERVICES_KEY'):(! empty($conf->global->WEBSERVICES_KEY)?$conf->global->WEBSERVICES_KEY:'')) . '" size="40">';
85
-if (! empty($conf->use_javascript_ajax))
84
+print '<td><input type="text" class="flat" id="WEBSERVICES_KEY" name="WEBSERVICES_KEY" value="'.(GETPOST('WEBSERVICES_KEY') ?GETPOST('WEBSERVICES_KEY') : (!empty($conf->global->WEBSERVICES_KEY) ? $conf->global->WEBSERVICES_KEY : '')).'" size="40">';
85
+if (!empty($conf->use_javascript_ajax))
86 86
 	print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
87 87
 print '</td>';
88 88
 print '<td>&nbsp;</td>';
@@ -116,22 +116,22 @@  discard block
 block discarded – undo
116 116
 
117 117
 // WSDL
118 118
 print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
119
-foreach($webservices as $name => $right)
119
+foreach ($webservices as $name => $right)
120 120
 {
121 121
 	if (!empty($right) && !verifCond($right)) continue;
122
-	$url=DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl';
123
-	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
122
+	$url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl';
123
+	print img_picto('', 'object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
124 124
 }
125 125
 print '<br>';
126 126
 
127 127
 
128 128
 // Endpoint
129 129
 print '<u>'.$langs->trans("EndPointIs").':</u><br>';
130
-foreach($webservices as $name => $right)
130
+foreach ($webservices as $name => $right)
131 131
 {
132 132
 	if (!empty($right) && !verifCond($right)) continue;
133
-	$url=DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php';
134
-	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
133
+	$url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php';
134
+	print img_picto('', 'object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
135 135
 }
136 136
 print '<br>';
137 137
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 print '<br>';
140 140
 print $langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php');
141 141
 
142
-if (! empty($conf->use_javascript_ajax))
142
+if (!empty($conf->use_javascript_ajax))
143 143
 {
144 144
 	print "\n".'<script type="text/javascript">';
145 145
 	print '$(document).ready(function () {
Please login to merge, or discard this patch.
htdocs/webservices/server_contact.php 3 patches
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 // Enable and test if module web services is enabled
36 36
 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
37 37
 {
38
-    $langs->load("admin");
39
-    dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
40
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
41
-    print $langs->trans("ToActivateModule");
42
-    exit;
38
+	$langs->load("admin");
39
+	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
40
+	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
41
+	print $langs->trans("ToActivateModule");
42
+	exit;
43 43
 }
44 44
 
45 45
 // Create the soap Object
@@ -53,31 +53,31 @@  discard block
 block discarded – undo
53 53
 
54 54
 // Define WSDL Authentication object
55 55
 $server->wsdl->addComplexType(
56
-    'authentication',
57
-    'complexType',
58
-    'struct',
59
-    'all',
60
-    '',
61
-    array(
62
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
63
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
64
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
65
-    	'password' => array('name'=>'password','type'=>'xsd:string'),
66
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
67
-    )
56
+	'authentication',
57
+	'complexType',
58
+	'struct',
59
+	'all',
60
+	'',
61
+	array(
62
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
63
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
64
+		'login' => array('name'=>'login','type'=>'xsd:string'),
65
+		'password' => array('name'=>'password','type'=>'xsd:string'),
66
+		'entity' => array('name'=>'entity','type'=>'xsd:string'),
67
+	)
68 68
 );
69 69
 
70 70
 // Define WSDL Return object
71 71
 $server->wsdl->addComplexType(
72
-    'result',
73
-    'complexType',
74
-    'struct',
75
-    'all',
76
-    '',
77
-    array(
78
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
79
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
80
-    )
72
+	'result',
73
+	'complexType',
74
+	'struct',
75
+	'all',
76
+	'',
77
+	array(
78
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
79
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
80
+	)
81 81
 );
82 82
 
83 83
 $contact_fields = array(
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 
137 137
 // Define other specific objects
138 138
 $server->wsdl->addComplexType(
139
-    'contact',
140
-    'complexType',
141
-    'struct',
142
-    'all',
143
-    '',
139
+	'contact',
140
+	'complexType',
141
+	'struct',
142
+	'all',
143
+	'',
144 144
 	$contact_fields
145 145
 );
146 146
 
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 
174 174
 // Register WSDL
175 175
 $server->register(
176
-    'getContact',
177
-    // Entry values
178
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref_ext'=>'xsd:string'),
179
-    // Exit values
180
-    array('result'=>'tns:result','contact'=>'tns:contact'),
181
-    $ns,
182
-    $ns.'#getContact',
183
-    $styledoc,
184
-    $styleuse,
185
-    'WS to get a contact'
176
+	'getContact',
177
+	// Entry values
178
+	array('authentication'=>'tns:authentication','id'=>'xsd:string','ref_ext'=>'xsd:string'),
179
+	// Exit values
180
+	array('result'=>'tns:result','contact'=>'tns:contact'),
181
+	$ns,
182
+	$ns.'#getContact',
183
+	$styledoc,
184
+	$styleuse,
185
+	'WS to get a contact'
186 186
 );
187 187
 
188 188
 // Register WSDL
@@ -237,112 +237,112 @@  discard block
 block discarded – undo
237 237
  */
238 238
 function getContact($authentication,$id,$ref_ext)
239 239
 {
240
-    global $db,$conf,$langs;
241
-
242
-    dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext);
243
-
244
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
245
-
246
-    // Init and check authentication
247
-    $objectresp=array();
248
-    $errorcode='';$errorlabel='';
249
-    $error=0;
250
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
251
-    // Check parameters
252
-    if (! $error && ($id && $ref_ext))
253
-    {
254
-        $error++;
255
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be both provided. You must choose one or other but not both.";
256
-    }
257
-
258
-    if (! $error)
259
-    {
260
-        $fuser->getrights();
261
-
262
-        $contact=new Contact($db);
263
-        $result=$contact->fetch($id,0,$ref_ext);
264
-        if ($result > 0)
265
-        {
266
-        	// Only internal user who have contact read permission
267
-        	// Or for external user who have contact read permission, with restrict on societe_id
268
-	        if (
269
-	        	$fuser->rights->societe->contact->lire && !$fuser->societe_id
270
-	        	|| ( $fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid))
271
-	        ){
272
-            	$contact_result_fields =array(
273
-	            	'id' => $contact->id,
274
-	            	'ref_ext' => $contact->ref_ext,
275
-	            	'lastname' => $contact->lastname,
276
-	            	'firstname' => $contact->firstname,
277
-	            	'address' => $contact->address,
278
-	            	'zip' => $contact->zip,
279
-	            	'town' => $contact->town,
280
-	            	'state_id' => $contact->state_id,
281
-	            	'state_code' => $contact->state_code,
282
-	            	'state' => $contact->state,
283
-	            	'country_id' => $contact->country_id,
284
-	            	'country_code' => $contact->country_code,
285
-	            	'country' => $contact->country,
286
-	            	'socid' => $contact->socid,
287
-	            	'status' => $contact->statut,
288
-	            	'phone_pro' => $contact->phone_pro,
289
-	            	'fax' => $contact->fax,
290
-	            	'phone_perso' => $contact->phone_perso,
291
-	            	'phone_mobile' => $contact->phone_mobile,
292
-	            	'code' => $contact->code,
293
-	            	'email' => $contact->email,
294
-	            	'birthday' => $contact->birthday,
295
-	            	'default_lang' => $contact->default_lang,
296
-	            	'note' => $contact->note,
297
-	            	'no_email' => $contact->no_email,
298
-	            	'ref_facturation' => $contact->ref_facturation,
299
-	            	'ref_contrat' => $contact->ref_contrat,
300
-	            	'ref_commande' => $contact->ref_commande,
301
-	            	'ref_propal' => $contact->ref_propal,
302
-	            	'user_id' => $contact->user_id,
303
-	            	'user_login' => $contact->user_login,
304
-	            	'civility_id' => $contact->civility_id,
305
-            		'poste' => $contact->poste
306
-            	);
307
-
308
-            	//Retreive all extrafield for thirdsparty
309
-            	// fetch optionals attributes and labels
310
-            	$extrafields=new ExtraFields($db);
311
-            	$extralabels=$extrafields->fetch_name_optionals_label('socpeople',true);
312
-            	//Get extrafield values
313
-            	$contact->fetch_optionals($contact->id,$extralabels);
314
-
315
-            	foreach($extrafields->attribute_label as $key=>$label)
316
-            	{
317
-            		$contact_result_fields=array_merge($contact_result_fields,array('options_'.$key => $contact->array_options['options_'.$key]));
318
-            	}
319
-
320
-
321
-                // Create
322
-                $objectresp = array(
323
-			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
324
-			        'contact'=>$contact_result_fields
325
-                );
326
-	        }
327
-	        else
328
-	        {
329
-	            $error++;
330
-	            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
331
-	        }
332
-         }
333
-         else
334
-         {
335
-             $error++;
336
-             $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref_ext='.$ref_ext;
337
-         }
338
-    }
339
-
340
-    if ($error)
341
-    {
342
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
343
-    }
344
-
345
-    return $objectresp;
240
+	global $db,$conf,$langs;
241
+
242
+	dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext);
243
+
244
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
245
+
246
+	// Init and check authentication
247
+	$objectresp=array();
248
+	$errorcode='';$errorlabel='';
249
+	$error=0;
250
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
251
+	// Check parameters
252
+	if (! $error && ($id && $ref_ext))
253
+	{
254
+		$error++;
255
+		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be both provided. You must choose one or other but not both.";
256
+	}
257
+
258
+	if (! $error)
259
+	{
260
+		$fuser->getrights();
261
+
262
+		$contact=new Contact($db);
263
+		$result=$contact->fetch($id,0,$ref_ext);
264
+		if ($result > 0)
265
+		{
266
+			// Only internal user who have contact read permission
267
+			// Or for external user who have contact read permission, with restrict on societe_id
268
+			if (
269
+				$fuser->rights->societe->contact->lire && !$fuser->societe_id
270
+				|| ( $fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid))
271
+			){
272
+				$contact_result_fields =array(
273
+					'id' => $contact->id,
274
+					'ref_ext' => $contact->ref_ext,
275
+					'lastname' => $contact->lastname,
276
+					'firstname' => $contact->firstname,
277
+					'address' => $contact->address,
278
+					'zip' => $contact->zip,
279
+					'town' => $contact->town,
280
+					'state_id' => $contact->state_id,
281
+					'state_code' => $contact->state_code,
282
+					'state' => $contact->state,
283
+					'country_id' => $contact->country_id,
284
+					'country_code' => $contact->country_code,
285
+					'country' => $contact->country,
286
+					'socid' => $contact->socid,
287
+					'status' => $contact->statut,
288
+					'phone_pro' => $contact->phone_pro,
289
+					'fax' => $contact->fax,
290
+					'phone_perso' => $contact->phone_perso,
291
+					'phone_mobile' => $contact->phone_mobile,
292
+					'code' => $contact->code,
293
+					'email' => $contact->email,
294
+					'birthday' => $contact->birthday,
295
+					'default_lang' => $contact->default_lang,
296
+					'note' => $contact->note,
297
+					'no_email' => $contact->no_email,
298
+					'ref_facturation' => $contact->ref_facturation,
299
+					'ref_contrat' => $contact->ref_contrat,
300
+					'ref_commande' => $contact->ref_commande,
301
+					'ref_propal' => $contact->ref_propal,
302
+					'user_id' => $contact->user_id,
303
+					'user_login' => $contact->user_login,
304
+					'civility_id' => $contact->civility_id,
305
+					'poste' => $contact->poste
306
+				);
307
+
308
+				//Retreive all extrafield for thirdsparty
309
+				// fetch optionals attributes and labels
310
+				$extrafields=new ExtraFields($db);
311
+				$extralabels=$extrafields->fetch_name_optionals_label('socpeople',true);
312
+				//Get extrafield values
313
+				$contact->fetch_optionals($contact->id,$extralabels);
314
+
315
+				foreach($extrafields->attribute_label as $key=>$label)
316
+				{
317
+					$contact_result_fields=array_merge($contact_result_fields,array('options_'.$key => $contact->array_options['options_'.$key]));
318
+				}
319
+
320
+
321
+				// Create
322
+				$objectresp = array(
323
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
324
+					'contact'=>$contact_result_fields
325
+				);
326
+			}
327
+			else
328
+			{
329
+				$error++;
330
+				$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
331
+			}
332
+		 }
333
+		 else
334
+		 {
335
+			 $error++;
336
+			 $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref_ext='.$ref_ext;
337
+		 }
338
+	}
339
+
340
+	if ($error)
341
+	{
342
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
343
+	}
344
+
345
+	return $objectresp;
346 346
 }
347 347
 
348 348
 
@@ -618,11 +618,11 @@  discard block
 block discarded – undo
618 618
 		$error++; $errorcode='KO'; $errorlabel="Contact id or ref_ext is mandatory.";
619 619
 	}
620 620
 	// Check parameters
621
-    if (! $error && ($id && $ref_ext))
622
-    {
623
-        $error++;
624
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be all provided. You must choose one of them.";
625
-    }
621
+	if (! $error && ($id && $ref_ext))
622
+	{
623
+		$error++;
624
+		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be all provided. You must choose one of them.";
625
+	}
626 626
 
627 627
 	if (! $error)
628 628
 	{
Please login to merge, or discard this patch.
Spacing   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
  *       \brief      File that is entry point to call Dolibarr WebServices
22 22
  */
23 23
 
24
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
24
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
25 25
 
26 26
 require_once("../master.inc.php");
27
-require_once(NUSOAP_PATH.'/nusoap.php');		// Include SOAP
27
+require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
28 28
 require_once(DOL_DOCUMENT_ROOT."/core/lib/ws.lib.php");
29 29
 require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
@@ -37,18 +37,18 @@  discard block
 block discarded – undo
37 37
 {
38 38
     $langs->load("admin");
39 39
     dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
40
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
40
+    print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
41 41
     print $langs->trans("ToActivateModule");
42 42
     exit;
43 43
 }
44 44
 
45 45
 // Create the soap Object
46 46
 $server = new nusoap_server();
47
-$server->soap_defencoding='UTF-8';
48
-$server->decode_utf8=false;
49
-$ns='http://www.dolibarr.org/ns/';
50
-$server->configureWSDL('WebServicesDolibarrContact',$ns);
51
-$server->wsdl->schemaTargetNamespace=$ns;
47
+$server->soap_defencoding = 'UTF-8';
48
+$server->decode_utf8 = false;
49
+$ns = 'http://www.dolibarr.org/ns/';
50
+$server->configureWSDL('WebServicesDolibarrContact', $ns);
51
+$server->wsdl->schemaTargetNamespace = $ns;
52 52
 
53 53
 
54 54
 // Define WSDL Authentication object
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
     'all',
60 60
     '',
61 61
     array(
62
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
63
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
64
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
65
-    	'password' => array('name'=>'password','type'=>'xsd:string'),
66
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
62
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
63
+    	'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
64
+    	'login' => array('name'=>'login', 'type'=>'xsd:string'),
65
+    	'password' => array('name'=>'password', 'type'=>'xsd:string'),
66
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
67 67
     )
68 68
 );
69 69
 
@@ -75,64 +75,64 @@  discard block
 block discarded – undo
75 75
     'all',
76 76
     '',
77 77
     array(
78
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
79
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
78
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
79
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
80 80
     )
81 81
 );
82 82
 
83 83
 $contact_fields = array(
84
-	'id' => array('name'=>'id','type'=>'xsd:string'),
85
-	'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
86
-	'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
87
-	'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
88
-	'address' => array('name'=>'address','type'=>'xsd:string'),
89
-	'zip' => array('name'=>'zip','type'=>'xsd:string'),
90
-	'town' => array('name'=>'town','type'=>'xsd:string'),
91
-	'state_id' => array('name'=>'state_id','type'=>'xsd:string'),
92
-	'state_code' => array('name'=>'state_code','type'=>'xsd:string'),
93
-	'state' => array('name'=>'state','type'=>'xsd:string'),
94
-	'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
95
-	'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
96
-	'country' => array('name'=>'country','type'=>'xsd:string'),
97
-	'socid' => array('name'=>'socid','type'=>'xsd:string'),
98
-	'status' => array('name'=>'status','type'=>'xsd:string'),
99
-	'phone_pro' => array('name'=>'phone_pro','type'=>'xsd:string'),
100
-	'fax' => array('name'=>'fax','type'=>'xsd:string'),
101
-	'phone_perso' => array('name'=>'phone_perso','type'=>'xsd:string'),
102
-	'phone_mobile' => array('name'=>'phone_mobile','type'=>'xsd:string'),
103
-	'code' => array('name'=>'code','type'=>'xsd:string'),
104
-	'email' => array('name'=>'email','type'=>'xsd:string'),
105
-	'birthday' => array('name'=>'birthday','type'=>'xsd:string'),
106
-	'default_lang' => array('name'=>'default_lang','type'=>'xsd:string'),
107
-	'note' => array('name'=>'note','type'=>'xsd:string'),
108
-	'no_email' => array('name'=>'no_email','type'=>'xsd:string'),
109
-	'ref_facturation' => array('name'=>'ref_facturation','type'=>'xsd:string'),
110
-	'ref_contrat' => array('name'=>'ref_contrat','type'=>'xsd:string'),
111
-	'ref_commande' => array('name'=>'ref_commande','type'=>'xsd:string'),
112
-	'ref_propal' => array('name'=>'ref_propal','type'=>'xsd:string'),
113
-	'user_id' => array('name'=>'user_id','type'=>'xsd:string'),
114
-	'user_login' => array('name'=>'user_login','type'=>'xsd:string'),
115
-	'civility_id' => array('name'=>'civility_id','type'=>'xsd:string'),
116
-	'poste' => array('name'=>'poste','type'=>'xsd:string')
84
+	'id' => array('name'=>'id', 'type'=>'xsd:string'),
85
+	'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'),
86
+	'lastname' => array('name'=>'lastname', 'type'=>'xsd:string'),
87
+	'firstname' => array('name'=>'firstname', 'type'=>'xsd:string'),
88
+	'address' => array('name'=>'address', 'type'=>'xsd:string'),
89
+	'zip' => array('name'=>'zip', 'type'=>'xsd:string'),
90
+	'town' => array('name'=>'town', 'type'=>'xsd:string'),
91
+	'state_id' => array('name'=>'state_id', 'type'=>'xsd:string'),
92
+	'state_code' => array('name'=>'state_code', 'type'=>'xsd:string'),
93
+	'state' => array('name'=>'state', 'type'=>'xsd:string'),
94
+	'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'),
95
+	'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'),
96
+	'country' => array('name'=>'country', 'type'=>'xsd:string'),
97
+	'socid' => array('name'=>'socid', 'type'=>'xsd:string'),
98
+	'status' => array('name'=>'status', 'type'=>'xsd:string'),
99
+	'phone_pro' => array('name'=>'phone_pro', 'type'=>'xsd:string'),
100
+	'fax' => array('name'=>'fax', 'type'=>'xsd:string'),
101
+	'phone_perso' => array('name'=>'phone_perso', 'type'=>'xsd:string'),
102
+	'phone_mobile' => array('name'=>'phone_mobile', 'type'=>'xsd:string'),
103
+	'code' => array('name'=>'code', 'type'=>'xsd:string'),
104
+	'email' => array('name'=>'email', 'type'=>'xsd:string'),
105
+	'birthday' => array('name'=>'birthday', 'type'=>'xsd:string'),
106
+	'default_lang' => array('name'=>'default_lang', 'type'=>'xsd:string'),
107
+	'note' => array('name'=>'note', 'type'=>'xsd:string'),
108
+	'no_email' => array('name'=>'no_email', 'type'=>'xsd:string'),
109
+	'ref_facturation' => array('name'=>'ref_facturation', 'type'=>'xsd:string'),
110
+	'ref_contrat' => array('name'=>'ref_contrat', 'type'=>'xsd:string'),
111
+	'ref_commande' => array('name'=>'ref_commande', 'type'=>'xsd:string'),
112
+	'ref_propal' => array('name'=>'ref_propal', 'type'=>'xsd:string'),
113
+	'user_id' => array('name'=>'user_id', 'type'=>'xsd:string'),
114
+	'user_login' => array('name'=>'user_login', 'type'=>'xsd:string'),
115
+	'civility_id' => array('name'=>'civility_id', 'type'=>'xsd:string'),
116
+	'poste' => array('name'=>'poste', 'type'=>'xsd:string')
117 117
 	//...
118 118
 );
119 119
 //Retreive all extrafield for contact
120 120
 // fetch optionals attributes and labels
121
-$extrafields=new ExtraFields($db);
122
-$extralabels=$extrafields->fetch_name_optionals_label('socpeople',true);
123
-if (count($extrafields)>0) {
121
+$extrafields = new ExtraFields($db);
122
+$extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
123
+if (count($extrafields) > 0) {
124 124
 	$extrafield_array = array();
125 125
 }
126
-foreach($extrafields->attribute_label as $key=>$label)
126
+foreach ($extrafields->attribute_label as $key=>$label)
127 127
 {
128
-	$type =$extrafields->attribute_type[$key];
129
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
130
-	else {$type='xsd:string';}
128
+	$type = $extrafields->attribute_type[$key];
129
+	if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; }
130
+	else {$type = 'xsd:string'; }
131 131
 
132
-	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
132
+	$extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type);
133 133
 }
134 134
 
135
-$contact_fields=array_merge($contact_fields,$extrafield_array);
135
+$contact_fields = array_merge($contact_fields, $extrafield_array);
136 136
 
137 137
 // Define other specific objects
138 138
 $server->wsdl->addComplexType(
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
167 167
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
168 168
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
169
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
170
-$styleuse='encoded';   // encoded/literal/literal wrapped
169
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
170
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
171 171
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
172 172
 
173 173
 
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 $server->register(
176 176
     'getContact',
177 177
     // Entry values
178
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref_ext'=>'xsd:string'),
178
+    array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref_ext'=>'xsd:string'),
179 179
     // Exit values
180
-    array('result'=>'tns:result','contact'=>'tns:contact'),
180
+    array('result'=>'tns:result', 'contact'=>'tns:contact'),
181 181
     $ns,
182 182
     $ns.'#getContact',
183 183
     $styledoc,
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 $server->register(
190 190
 	'createContact',
191 191
 	// Entry values
192
-	array('authentication'=>'tns:authentication','contact'=>'tns:contact'),
192
+	array('authentication'=>'tns:authentication', 'contact'=>'tns:contact'),
193 193
 	// Exit values
194
-	array('result'=>'tns:result','id'=>'xsd:string'),
194
+	array('result'=>'tns:result', 'id'=>'xsd:string'),
195 195
 	$ns,
196 196
 	$ns.'#createContact',
197 197
 	$styledoc,
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 $server->register(
203 203
 	'getContactsForThirdParty',
204 204
 	// Entry values
205
-	array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
205
+	array('authentication'=>'tns:authentication', 'idthirdparty'=>'xsd:string'),
206 206
 	// Exit values
207
-	array('result'=>'tns:result','contacts'=>'tns:ContactsArray2'),
207
+	array('result'=>'tns:result', 'contacts'=>'tns:ContactsArray2'),
208 208
 	$ns,
209 209
 	$ns.'#getContactsForThirdParty',
210 210
 	$styledoc,
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 $server->register(
217 217
 	'updateContact',
218 218
 	// Entry values
219
-	array('authentication'=>'tns:authentication','contact'=>'tns:contact'),
219
+	array('authentication'=>'tns:authentication', 'contact'=>'tns:contact'),
220 220
 	// Exit values
221
-	array('result'=>'tns:result','id'=>'xsd:string'),
221
+	array('result'=>'tns:result', 'id'=>'xsd:string'),
222 222
 	$ns,
223 223
 	$ns.'#updateContact',
224 224
 	$styledoc,
@@ -235,41 +235,41 @@  discard block
 block discarded – undo
235 235
  * @param	string		$ref_ext			Ref external of object
236 236
  * @return	mixed
237 237
  */
238
-function getContact($authentication,$id,$ref_ext)
238
+function getContact($authentication, $id, $ref_ext)
239 239
 {
240
-    global $db,$conf,$langs;
240
+    global $db, $conf, $langs;
241 241
 
242 242
     dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext);
243 243
 
244
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
244
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
245 245
 
246 246
     // Init and check authentication
247
-    $objectresp=array();
248
-    $errorcode='';$errorlabel='';
249
-    $error=0;
250
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
247
+    $objectresp = array();
248
+    $errorcode = ''; $errorlabel = '';
249
+    $error = 0;
250
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
251 251
     // Check parameters
252
-    if (! $error && ($id && $ref_ext))
252
+    if (!$error && ($id && $ref_ext))
253 253
     {
254 254
         $error++;
255
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be both provided. You must choose one or other but not both.";
255
+        $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be both provided. You must choose one or other but not both.";
256 256
     }
257 257
 
258
-    if (! $error)
258
+    if (!$error)
259 259
     {
260 260
         $fuser->getrights();
261 261
 
262
-        $contact=new Contact($db);
263
-        $result=$contact->fetch($id,0,$ref_ext);
262
+        $contact = new Contact($db);
263
+        $result = $contact->fetch($id, 0, $ref_ext);
264 264
         if ($result > 0)
265 265
         {
266 266
         	// Only internal user who have contact read permission
267 267
         	// Or for external user who have contact read permission, with restrict on societe_id
268 268
 	        if (
269 269
 	        	$fuser->rights->societe->contact->lire && !$fuser->societe_id
270
-	        	|| ( $fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid))
271
-	        ){
272
-            	$contact_result_fields =array(
270
+	        	|| ($fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid))
271
+	        ) {
272
+            	$contact_result_fields = array(
273 273
 	            	'id' => $contact->id,
274 274
 	            	'ref_ext' => $contact->ref_ext,
275 275
 	            	'lastname' => $contact->lastname,
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
 
308 308
             	//Retreive all extrafield for thirdsparty
309 309
             	// fetch optionals attributes and labels
310
-            	$extrafields=new ExtraFields($db);
311
-            	$extralabels=$extrafields->fetch_name_optionals_label('socpeople',true);
310
+            	$extrafields = new ExtraFields($db);
311
+            	$extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
312 312
             	//Get extrafield values
313
-            	$contact->fetch_optionals($contact->id,$extralabels);
313
+            	$contact->fetch_optionals($contact->id, $extralabels);
314 314
 
315
-            	foreach($extrafields->attribute_label as $key=>$label)
315
+            	foreach ($extrafields->attribute_label as $key=>$label)
316 316
             	{
317
-            		$contact_result_fields=array_merge($contact_result_fields,array('options_'.$key => $contact->array_options['options_'.$key]));
317
+            		$contact_result_fields = array_merge($contact_result_fields, array('options_'.$key => $contact->array_options['options_'.$key]));
318 318
             	}
319 319
 
320 320
 
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
 	        else
328 328
 	        {
329 329
 	            $error++;
330
-	            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
330
+	            $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
331 331
 	        }
332 332
          }
333 333
          else
334 334
          {
335 335
              $error++;
336
-             $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref_ext='.$ref_ext;
336
+             $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref_ext='.$ref_ext;
337 337
          }
338 338
     }
339 339
 
@@ -353,75 +353,75 @@  discard block
 block discarded – undo
353 353
  * @param	Contact		$contact		    $contact
354 354
  * @return	array							Array result
355 355
  */
356
-function createContact($authentication,$contact)
356
+function createContact($authentication, $contact)
357 357
 {
358
-	global $db,$conf,$langs;
358
+	global $db, $conf, $langs;
359 359
 
360
-	$now=dol_now();
360
+	$now = dol_now();
361 361
 
362 362
 	dol_syslog("Function: createContact login=".$authentication['login']);
363 363
 
364
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
364
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
365 365
 
366 366
 	// Init and check authentication
367
-	$objectresp=array();
368
-	$errorcode='';$errorlabel='';
369
-	$error=0;
370
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
367
+	$objectresp = array();
368
+	$errorcode = ''; $errorlabel = '';
369
+	$error = 0;
370
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
371 371
 	// Check parameters
372 372
 	if (empty($contact['lastname']))
373 373
 	{
374
-		$error++; $errorcode='KO'; $errorlabel="Name is mandatory.";
374
+		$error++; $errorcode = 'KO'; $errorlabel = "Name is mandatory.";
375 375
 	}
376 376
 
377
-	if (! $error)
377
+	if (!$error)
378 378
 	{
379 379
 
380 380
 
381
-		$newobject=new Contact($db);
382
-
383
-		$newobject->id=$contact['id'];
384
-		$newobject->ref_ext=$contact['ref_ext'];
385
-		$newobject->civility_id=$contact['civility_id'];
386
-		$newobject->lastname=$contact['lastname'];
387
-		$newobject->firstname=$contact['firstname'];
388
-		$newobject->address=$contact['address'];
389
-		$newobject->zip=$contact['zip'];
390
-		$newobject->town=$contact['town'];
391
-		$newobject->state_id=$contact['state_id'];
392
-		$newobject->state_code=$contact['state_code'];
393
-		$newobject->state=$contact['state'];
394
-		$newobject->country_id=$contact['country_id'];
395
-		$newobject->country_code=$contact['country_code'];
396
-		$newobject->country=$contact['country'];
397
-		$newobject->socid=$contact['socid'];
398
-		$newobject->statut=$contact['status'];
399
-		$newobject->phone_pro=$contact['phone_pro'];
400
-		$newobject->fax=$contact['fax'];
401
-		$newobject->phone_perso=$contact['phone_perso'];
402
-		$newobject->phone_mobile=$contact['phone_mobile'];
403
-		$newobject->code=$contact['code'];
404
-		$newobject->email=$contact['email'];
405
-		$newobject->birthday=$contact['birthday'];
406
-		$newobject->default_lang=$contact['default_lang'];
407
-		$newobject->note=$contact['note'];
408
-		$newobject->no_email=$contact['no_email'];
409
-		$newobject->ref_facturation=$contact['ref_facturation'];
410
-		$newobject->ref_contrat=$contact['ref_contrat'];
411
-		$newobject->ref_commande=$contact['ref_commande'];
412
-		$newobject->ref_propal=$contact['ref_propal'];
413
-		$newobject->user_id=$contact['user_id'];
414
-		$newobject->user_login=$contact['user_login'];
415
-		$newobject->poste=$contact['poste'];
381
+		$newobject = new Contact($db);
382
+
383
+		$newobject->id = $contact['id'];
384
+		$newobject->ref_ext = $contact['ref_ext'];
385
+		$newobject->civility_id = $contact['civility_id'];
386
+		$newobject->lastname = $contact['lastname'];
387
+		$newobject->firstname = $contact['firstname'];
388
+		$newobject->address = $contact['address'];
389
+		$newobject->zip = $contact['zip'];
390
+		$newobject->town = $contact['town'];
391
+		$newobject->state_id = $contact['state_id'];
392
+		$newobject->state_code = $contact['state_code'];
393
+		$newobject->state = $contact['state'];
394
+		$newobject->country_id = $contact['country_id'];
395
+		$newobject->country_code = $contact['country_code'];
396
+		$newobject->country = $contact['country'];
397
+		$newobject->socid = $contact['socid'];
398
+		$newobject->statut = $contact['status'];
399
+		$newobject->phone_pro = $contact['phone_pro'];
400
+		$newobject->fax = $contact['fax'];
401
+		$newobject->phone_perso = $contact['phone_perso'];
402
+		$newobject->phone_mobile = $contact['phone_mobile'];
403
+		$newobject->code = $contact['code'];
404
+		$newobject->email = $contact['email'];
405
+		$newobject->birthday = $contact['birthday'];
406
+		$newobject->default_lang = $contact['default_lang'];
407
+		$newobject->note = $contact['note'];
408
+		$newobject->no_email = $contact['no_email'];
409
+		$newobject->ref_facturation = $contact['ref_facturation'];
410
+		$newobject->ref_contrat = $contact['ref_contrat'];
411
+		$newobject->ref_commande = $contact['ref_commande'];
412
+		$newobject->ref_propal = $contact['ref_propal'];
413
+		$newobject->user_id = $contact['user_id'];
414
+		$newobject->user_login = $contact['user_login'];
415
+		$newobject->poste = $contact['poste'];
416 416
 
417 417
 		//Retreive all extrafield for thirdsparty
418 418
 		// fetch optionals attributes and labels
419
-		$extrafields=new ExtraFields($db);
420
-		$extralabels=$extrafields->fetch_name_optionals_label('socpeople',true);
421
-		foreach($extrafields->attribute_label as $key=>$label)
419
+		$extrafields = new ExtraFields($db);
420
+		$extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
421
+		foreach ($extrafields->attribute_label as $key=>$label)
422 422
 		{
423
-			$key='options_'.$key;
424
-			$newobject->array_options[$key]=$contact[$key];
423
+			$key = 'options_'.$key;
424
+			$newobject->array_options[$key] = $contact[$key];
425 425
 		}
426 426
 
427 427
 
@@ -430,23 +430,23 @@  discard block
 block discarded – undo
430 430
 
431 431
 		$db->begin();
432 432
 
433
-		$result=$newobject->create($fuser);
433
+		$result = $newobject->create($fuser);
434 434
 		if ($result <= 0)
435 435
 		{
436 436
 			$error++;
437 437
 		}
438 438
 
439
-		if (! $error)
439
+		if (!$error)
440 440
 		{
441 441
 			$db->commit();
442
-			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
442
+			$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref);
443 443
 		}
444 444
 		else
445 445
 		{
446 446
 			$db->rollback();
447 447
 			$error++;
448
-			$errorcode='KO';
449
-			$errorlabel=$newobject->error;
448
+			$errorcode = 'KO';
449
+			$errorlabel = $newobject->error;
450 450
 		}
451 451
 	}
452 452
 
@@ -465,111 +465,111 @@  discard block
 block discarded – undo
465 465
  * @param	int			$idthirdparty		Id thirdparty
466 466
  * @return	array							Array result
467 467
  */
468
-function getContactsForThirdParty($authentication,$idthirdparty)
468
+function getContactsForThirdParty($authentication, $idthirdparty)
469 469
 {
470
-	global $db,$conf,$langs;
470
+	global $db, $conf, $langs;
471 471
 
472 472
 	dol_syslog("Function: getContactsForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
473 473
 
474
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
474
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
475 475
 
476 476
 	// Init and check authentication
477
-	$objectresp=array();
478
-	$errorcode='';$errorlabel='';
479
-	$error=0;
480
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
477
+	$objectresp = array();
478
+	$errorcode = ''; $errorlabel = '';
479
+	$error = 0;
480
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
481 481
 	// Check parameters
482
-	if (! $error && empty($idthirdparty))
482
+	if (!$error && empty($idthirdparty))
483 483
 	{
484 484
 		$error++;
485
-		$errorcode='BAD_PARAMETERS'; $errorlabel='Parameter id is not provided';
485
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = 'Parameter id is not provided';
486 486
 	}
487 487
 
488
-	if (! $error)
488
+	if (!$error)
489 489
 	{
490
-		$linesinvoice=array();
490
+		$linesinvoice = array();
491 491
 
492 492
 		$sql = "SELECT c.rowid, c.fk_soc, c.civility as civility_id, c.lastname, c.firstname, c.statut as status,";
493
-		$sql.= " c.address, c.zip, c.town,";
494
-		$sql.= " c.fk_pays as country_id,";
495
-		$sql.= " c.fk_departement,";
496
-		$sql.= " c.birthday,";
497
-		$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,";
493
+		$sql .= " c.address, c.zip, c.town,";
494
+		$sql .= " c.fk_pays as country_id,";
495
+		$sql .= " c.fk_departement,";
496
+		$sql .= " c.birthday,";
497
+		$sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,";
498 498
 		//$sql.= " c.priv, c.note, c.default_lang, c.no_email, c.canvas,";
499
-		$sql.= " co.label as country, co.code as country_code,";
500
-		$sql.= " d.nom as state, d.code_departement as state_code,";
501
-		$sql.= " u.rowid as user_id, u.login as user_login,";
502
-		$sql.= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
503
-		$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
504
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid";
505
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid";
506
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
507
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
508
-		$sql.= " WHERE c.fk_soc=$idthirdparty";
509
-
510
-		$resql=$db->query($sql);
499
+		$sql .= " co.label as country, co.code as country_code,";
500
+		$sql .= " d.nom as state, d.code_departement as state_code,";
501
+		$sql .= " u.rowid as user_id, u.login as user_login,";
502
+		$sql .= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
503
+		$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
504
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid";
505
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid";
506
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
507
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
508
+		$sql .= " WHERE c.fk_soc=$idthirdparty";
509
+
510
+		$resql = $db->query($sql);
511 511
 		if ($resql)
512 512
 		{
513
-			$num=$db->num_rows($resql);
514
-			$i=0;
513
+			$num = $db->num_rows($resql);
514
+			$i = 0;
515 515
 			while ($i < $num)
516 516
 			{
517 517
 				// En attendant remplissage par boucle
518
-				$obj=$db->fetch_object($resql);
518
+				$obj = $db->fetch_object($resql);
519 519
 
520
-				$contact=new Contact($db);
520
+				$contact = new Contact($db);
521 521
 				$contact->fetch($obj->rowid);
522 522
 
523 523
 				// Now define invoice
524
-				$linescontact[]=array(
524
+				$linescontact[] = array(
525 525
 					'id' => $contact->id,
526 526
 					'ref' => $contact->ref,
527
-					'civility_id' => $contact->civility_id?$contact->civility_id:'',
528
-					'lastname' => $contact->lastname?$contact->lastname:'',
529
-					'firstname' => $contact->firstname?$contact->firstname:'',
530
-					'address' => $contact->address?$contact->address:'',
531
-					'zip' => $contact->zip?$contact->zip:'',
532
-					'town' => $contact->town?$contact->town:'',
533
-
534
-					'state_id' => $contact->state_id?$contact->state_id:'',
535
-					'state_code' => $contact->state_code?$contact->state_code:'',
536
-					'state' => $contact->state?$contact->state:'',
537
-
538
-					'country_id' => $contact->country_id?$contact->country_id:'',
539
-					'country_code' => $contact->country_code?$contact->country_code:'',
540
-					'country' => $contact->country?$contact->country:'',
541
-
542
-					'socid' => $contact->socid?$contact->socid:'',
543
-					'socname' => $contact->socname?$contact->socname:'',
544
-					'poste' => $contact->poste?$contact->poste:'',
545
-
546
-					'phone_pro' => $contact->phone_pro?$contact->phone_pro:'',
547
-					'fax' => $contact->fax?$contact->fax:'',
548
-					'phone_perso' => $contact->phone_perso?$contact->phone_perso:'',
549
-					'phone_mobile' => $contact->phone_mobile?$contact->phone_mobile:'',
550
-
551
-					'email' => $contact->email?$contact->email:'',
552
-					'jabberid' => $contact->jabberid?$contact->jabberid:'',
553
-					'priv' => $contact->priv?$contact->priv:'',
554
-					'mail' => $contact->mail?$contact->mail:'',
555
-
556
-					'birthday' => $contact->birthday?$contact->birthday:'',
557
-					'default_lang' => $contact->default_lang?$contact->default_lang:'',
558
-					'note' => $contact->note?$contact->note:'',
559
-					'no_email' => $contact->no_email?$contact->no_email:'',
560
-					'ref_facturation' => $contact->ref_facturation?$contact->ref_facturation:'',
561
-					'ref_contrat' => $contact->ref_contrat?$contact->ref_contrat:'',
562
-					'ref_commande' => $contact->ref_commande?$contact->ref_commande:'',
563
-					'ref_propal' => $contact->ref_propal?$contact->ref_propal:'',
564
-					'user_id' => $contact->user_id?$contact->user_id:'',
565
-					'user_login' => $contact->user_login?$contact->user_login:'',
566
-					'status' => $contact->statut?$contact->statut:''
527
+					'civility_id' => $contact->civility_id ? $contact->civility_id : '',
528
+					'lastname' => $contact->lastname ? $contact->lastname : '',
529
+					'firstname' => $contact->firstname ? $contact->firstname : '',
530
+					'address' => $contact->address ? $contact->address : '',
531
+					'zip' => $contact->zip ? $contact->zip : '',
532
+					'town' => $contact->town ? $contact->town : '',
533
+
534
+					'state_id' => $contact->state_id ? $contact->state_id : '',
535
+					'state_code' => $contact->state_code ? $contact->state_code : '',
536
+					'state' => $contact->state ? $contact->state : '',
537
+
538
+					'country_id' => $contact->country_id ? $contact->country_id : '',
539
+					'country_code' => $contact->country_code ? $contact->country_code : '',
540
+					'country' => $contact->country ? $contact->country : '',
541
+
542
+					'socid' => $contact->socid ? $contact->socid : '',
543
+					'socname' => $contact->socname ? $contact->socname : '',
544
+					'poste' => $contact->poste ? $contact->poste : '',
545
+
546
+					'phone_pro' => $contact->phone_pro ? $contact->phone_pro : '',
547
+					'fax' => $contact->fax ? $contact->fax : '',
548
+					'phone_perso' => $contact->phone_perso ? $contact->phone_perso : '',
549
+					'phone_mobile' => $contact->phone_mobile ? $contact->phone_mobile : '',
550
+
551
+					'email' => $contact->email ? $contact->email : '',
552
+					'jabberid' => $contact->jabberid ? $contact->jabberid : '',
553
+					'priv' => $contact->priv ? $contact->priv : '',
554
+					'mail' => $contact->mail ? $contact->mail : '',
555
+
556
+					'birthday' => $contact->birthday ? $contact->birthday : '',
557
+					'default_lang' => $contact->default_lang ? $contact->default_lang : '',
558
+					'note' => $contact->note ? $contact->note : '',
559
+					'no_email' => $contact->no_email ? $contact->no_email : '',
560
+					'ref_facturation' => $contact->ref_facturation ? $contact->ref_facturation : '',
561
+					'ref_contrat' => $contact->ref_contrat ? $contact->ref_contrat : '',
562
+					'ref_commande' => $contact->ref_commande ? $contact->ref_commande : '',
563
+					'ref_propal' => $contact->ref_propal ? $contact->ref_propal : '',
564
+					'user_id' => $contact->user_id ? $contact->user_id : '',
565
+					'user_login' => $contact->user_login ? $contact->user_login : '',
566
+					'status' => $contact->statut ? $contact->statut : ''
567 567
 				);
568 568
 
569 569
 				$i++;
570 570
 			}
571 571
 
572
-			$objectresp=array(
572
+			$objectresp = array(
573 573
 			'result'=>array('result_code'=>'OK', 'result_label'=>''),
574 574
 			'contacts'=>$linescontact
575 575
 
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 		else
579 579
 		{
580 580
 			$error++;
581
-			$errorcode=$db->lasterrno(); $errorlabel=$db->lasterror();
581
+			$errorcode = $db->lasterrno(); $errorlabel = $db->lasterror();
582 582
 		}
583 583
 	}
584 584
 
@@ -598,92 +598,92 @@  discard block
 block discarded – undo
598 598
  * @param	Contact		$contact		    Contact
599 599
  * @return	array							Array result
600 600
  */
601
-function updateContact($authentication,$contact)
601
+function updateContact($authentication, $contact)
602 602
 {
603
-	global $db,$conf,$langs;
603
+	global $db, $conf, $langs;
604 604
 
605
-	$now=dol_now();
605
+	$now = dol_now();
606 606
 
607 607
 	dol_syslog("Function: updateContact login=".$authentication['login']);
608 608
 
609
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
609
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
610 610
 
611 611
 	// Init and check authentication
612
-	$objectresp=array();
613
-	$errorcode='';$errorlabel='';
614
-	$error=0;
615
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
612
+	$objectresp = array();
613
+	$errorcode = ''; $errorlabel = '';
614
+	$error = 0;
615
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
616 616
 	// Check parameters
617
-	if (empty($contact['id']) && empty($contact['ref_ext']))	{
618
-		$error++; $errorcode='KO'; $errorlabel="Contact id or ref_ext is mandatory.";
617
+	if (empty($contact['id']) && empty($contact['ref_ext'])) {
618
+		$error++; $errorcode = 'KO'; $errorlabel = "Contact id or ref_ext is mandatory.";
619 619
 	}
620 620
 	// Check parameters
621
-    if (! $error && ($id && $ref_ext))
621
+    if (!$error && ($id && $ref_ext))
622 622
     {
623 623
         $error++;
624
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be all provided. You must choose one of them.";
624
+        $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be all provided. You must choose one of them.";
625 625
     }
626 626
 
627
-	if (! $error)
627
+	if (!$error)
628 628
 	{
629
-		$objectfound=false;
629
+		$objectfound = false;
630 630
 
631 631
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
632 632
 
633
-		$object=new Contact($db);
634
-		$result=$object->fetch($contact['id'],0,$contact['ref_ext']);
633
+		$object = new Contact($db);
634
+		$result = $object->fetch($contact['id'], 0, $contact['ref_ext']);
635 635
 
636 636
 		if (!empty($object->id)) {
637 637
 
638
-			$objectfound=true;
638
+			$objectfound = true;
639 639
 
640 640
 
641
-			$object->firstname=$contact['firstname'];
642
-			$object->lastname=$contact['lastname'];
641
+			$object->firstname = $contact['firstname'];
642
+			$object->lastname = $contact['lastname'];
643 643
 
644
-			$object->address=$contact['address'];
645
-			$object->zip=$contact['zip'];
646
-			$object->town=$contact['town'];
644
+			$object->address = $contact['address'];
645
+			$object->zip = $contact['zip'];
646
+			$object->town = $contact['town'];
647 647
 
648
-			$object->country_id=$contact['country_id'];
649
-			if ($contact['country_code']) $object->country_id=getCountry($contact['country_code'],3);
650
-			$object->province_id=$contact['province_id'];
648
+			$object->country_id = $contact['country_id'];
649
+			if ($contact['country_code']) $object->country_id = getCountry($contact['country_code'], 3);
650
+			$object->province_id = $contact['province_id'];
651 651
 
652 652
 
653
-			$object->phone_pro=$contact['phone_pro'];
654
-			$object->phone_perso=$contact['phone_perso'];
655
-			$object->phone_mobile=$contact['phone_mobile'];
656
-			$object->fax=$contact['fax'];
657
-			$object->email=$contact['email'];
653
+			$object->phone_pro = $contact['phone_pro'];
654
+			$object->phone_perso = $contact['phone_perso'];
655
+			$object->phone_mobile = $contact['phone_mobile'];
656
+			$object->fax = $contact['fax'];
657
+			$object->email = $contact['email'];
658 658
 
659
-			$object->civility_id=$contact['civility_id'];
660
-			$object->poste=$contact['poste'];
659
+			$object->civility_id = $contact['civility_id'];
660
+			$object->poste = $contact['poste'];
661 661
 
662
-			$object->statut=$contact['status'];
662
+			$object->statut = $contact['status'];
663 663
 
664 664
 
665 665
 			//Retreive all extrafield for contact
666 666
 			// fetch optionals attributes and labels
667
-			$extrafields=new ExtraFields($db);
668
-			$extralabels=$extrafields->fetch_name_optionals_label('socpeople',true);
669
-			foreach($extrafields->attribute_label as $key=>$label)
667
+			$extrafields = new ExtraFields($db);
668
+			$extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
669
+			foreach ($extrafields->attribute_label as $key=>$label)
670 670
 			{
671
-				$key='options_'.$key;
672
-				$object->array_options[$key]=$contact[$key];
671
+				$key = 'options_'.$key;
672
+				$object->array_options[$key] = $contact[$key];
673 673
 			}
674 674
 
675 675
 			$db->begin();
676 676
 
677
-			$result=$object->update($contact['id'],$fuser);
677
+			$result = $object->update($contact['id'], $fuser);
678 678
 			if ($result <= 0) {
679 679
 				$error++;
680 680
 			}
681 681
 		}
682 682
 
683
-		if ((! $error) && ($objectfound))
683
+		if ((!$error) && ($objectfound))
684 684
 		{
685 685
 			$db->commit();
686
-			$objectresp=array(
686
+			$objectresp = array(
687 687
 			'result'=>array('result_code'=>'OK', 'result_label'=>''),
688 688
 			'id'=>$object->id
689 689
 			);
@@ -692,12 +692,12 @@  discard block
 block discarded – undo
692 692
 		{
693 693
 			$db->rollback();
694 694
 			$error++;
695
-			$errorcode='KO';
696
-			$errorlabel=$object->error;
695
+			$errorcode = 'KO';
696
+			$errorlabel = $object->error;
697 697
 		} else {
698 698
 			$error++;
699
-			$errorcode='NOT_FOUND';
700
-			$errorlabel='Contact id='.$contact['id'].' cannot be found';
699
+			$errorcode = 'NOT_FOUND';
700
+			$errorlabel = 'Contact id='.$contact['id'].' cannot be found';
701 701
 		}
702 702
 	}
703 703
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -18 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
  *       \brief      File that is entry point to call Dolibarr WebServices
22 22
  */
23 23
 
24
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
24
+if (! defined("NOCSRFCHECK")) {
25
+	define("NOCSRFCHECK",'1');
26
+}
25 27
 
26 28
 require_once("../master.inc.php");
27 29
 require_once(NUSOAP_PATH.'/nusoap.php');		// Include SOAP
@@ -126,8 +128,7 @@  discard block
 block discarded – undo
126 128
 foreach($extrafields->attribute_label as $key=>$label)
127 129
 {
128 130
 	$type =$extrafields->attribute_type[$key];
129
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
130
-	else {$type='xsd:string';}
131
+	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';} else {$type='xsd:string';}
131 132
 
132 133
 	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
133 134
 }
@@ -241,7 +242,9 @@  discard block
 block discarded – undo
241 242
 
242 243
     dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext);
243 244
 
244
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
245
+    if ($authentication['entity']) {
246
+    	$conf->entity=$authentication['entity'];
247
+    }
245 248
 
246 249
     // Init and check authentication
247 250
     $objectresp=array();
@@ -323,14 +326,12 @@  discard block
 block discarded – undo
323 326
 			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
324 327
 			        'contact'=>$contact_result_fields
325 328
                 );
326
-	        }
327
-	        else
329
+	        } else
328 330
 	        {
329 331
 	            $error++;
330 332
 	            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
331 333
 	        }
332
-         }
333
-         else
334
+         } else
334 335
          {
335 336
              $error++;
336 337
              $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref_ext='.$ref_ext;
@@ -361,7 +362,9 @@  discard block
 block discarded – undo
361 362
 
362 363
 	dol_syslog("Function: createContact login=".$authentication['login']);
363 364
 
364
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
365
+	if ($authentication['entity']) {
366
+		$conf->entity=$authentication['entity'];
367
+	}
365 368
 
366 369
 	// Init and check authentication
367 370
 	$objectresp=array();
@@ -440,8 +443,7 @@  discard block
 block discarded – undo
440 443
 		{
441 444
 			$db->commit();
442 445
 			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
443
-		}
444
-		else
446
+		} else
445 447
 		{
446 448
 			$db->rollback();
447 449
 			$error++;
@@ -471,7 +473,9 @@  discard block
 block discarded – undo
471 473
 
472 474
 	dol_syslog("Function: getContactsForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
473 475
 
474
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
476
+	if ($authentication['entity']) {
477
+		$conf->entity=$authentication['entity'];
478
+	}
475 479
 
476 480
 	// Init and check authentication
477 481
 	$objectresp=array();
@@ -574,8 +578,7 @@  discard block
 block discarded – undo
574 578
 			'contacts'=>$linescontact
575 579
 
576 580
 			);
577
-		}
578
-		else
581
+		} else
579 582
 		{
580 583
 			$error++;
581 584
 			$errorcode=$db->lasterrno(); $errorlabel=$db->lasterror();
@@ -606,7 +609,9 @@  discard block
 block discarded – undo
606 609
 
607 610
 	dol_syslog("Function: updateContact login=".$authentication['login']);
608 611
 
609
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
612
+	if ($authentication['entity']) {
613
+		$conf->entity=$authentication['entity'];
614
+	}
610 615
 
611 616
 	// Init and check authentication
612 617
 	$objectresp=array();
@@ -646,7 +651,9 @@  discard block
 block discarded – undo
646 651
 			$object->town=$contact['town'];
647 652
 
648 653
 			$object->country_id=$contact['country_id'];
649
-			if ($contact['country_code']) $object->country_id=getCountry($contact['country_code'],3);
654
+			if ($contact['country_code']) {
655
+				$object->country_id=getCountry($contact['country_code'],3);
656
+			}
650 657
 			$object->province_id=$contact['province_id'];
651 658
 
652 659
 
@@ -687,8 +694,7 @@  discard block
 block discarded – undo
687 694
 			'result'=>array('result_code'=>'OK', 'result_label'=>''),
688 695
 			'id'=>$object->id
689 696
 			);
690
-		}
691
-		elseif ($objectfound)
697
+		} elseif ($objectfound)
692 698
 		{
693 699
 			$db->rollback();
694 700
 			$error++;
Please login to merge, or discard this patch.
htdocs/core/actions_extrafields.inc.php 3 patches
Braces   +25 added lines, -27 removed lines patch added patch discarded remove patch
@@ -30,10 +30,18 @@  discard block
 block discarded – undo
30 30
 $type=GETPOST('type','alpha');
31 31
 $param=GETPOST('param','alpha');;
32 32
 
33
-if ($type=='double' && strpos($extrasize,',')===false) $extrasize='24,8';
34
-if ($type=='date')     $extrasize='';
35
-if ($type=='datetime') $extrasize='';
36
-if ($type=='select')   $extrasize='';
33
+if ($type=='double' && strpos($extrasize,',')===false) {
34
+	$extrasize='24,8';
35
+}
36
+if ($type=='date') {
37
+	$extrasize='';
38
+}
39
+if ($type=='datetime') {
40
+	$extrasize='';
41
+}
42
+if ($type=='select') {
43
+	$extrasize='';
44
+}
37 45
 
38 46
 
39 47
 // Add attribute
@@ -121,8 +129,7 @@  discard block
 block discarded – undo
121 129
 	    					$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
122 130
 	    					$action = 'create';
123 131
 	    				}
124
-	    			}
125
-	    			else
132
+	    			} else
126 133
 	    			{
127 134
 	    				$error++;
128 135
 	    				$langs->load("errors");
@@ -148,8 +155,7 @@  discard block
 block discarded – undo
148 155
     				{
149 156
     					$params['options'] = array($parameters=>null);
150 157
     				}
151
-    			}
152
-    			else
158
+    			} else
153 159
     			{
154 160
     				//Esle it's separated key/value and coma list
155 161
     				foreach($parameters_array as $param_ligne)
@@ -181,15 +187,13 @@  discard block
 block discarded – undo
181 187
     				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
182 188
     				header("Location: ".$_SERVER["PHP_SELF"]);
183 189
     				exit;
184
-    			}
185
-    			else
190
+    			} else
186 191
     			{
187 192
                     $error++;
188 193
     			    $mesg=$extrafields->error;
189 194
                     setEventMessages($mesg, null, 'errors');
190 195
     			}
191
-    		}
192
-    		else
196
+    		} else
193 197
     		{
194 198
                 $error++;
195 199
     		    $langs->load("errors");
@@ -197,8 +201,7 @@  discard block
 block discarded – undo
197 201
     			setEventMessages($mesg, null, 'errors');
198 202
     			$action = 'create';
199 203
     		}
200
-	    }
201
-	    else
204
+	    } else
202 205
 	    {
203 206
 	    	setEventMessages($mesg, null, 'errors');
204 207
 	    }
@@ -283,8 +286,7 @@  discard block
 block discarded – undo
283 286
 	        				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
284 287
 	        				$action = 'edit';
285 288
 	        			}
286
-	        		}
287
-	        		else
289
+	        		} else
288 290
 	        		{
289 291
 	        			$error++;
290 292
 	        			$langs->load("errors");
@@ -309,8 +311,7 @@  discard block
 block discarded – undo
309 311
     				{
310 312
     					$params['options'] = array($parameters=>null);
311 313
     				}
312
-    			}
313
-    			else
314
+    			} else
314 315
     			{
315 316
     				//Esle it's separated key/value and coma list
316 317
     				foreach($parameters_array as $param_ligne)
@@ -342,23 +343,20 @@  discard block
 block discarded – undo
342 343
     				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
343 344
     				header("Location: ".$_SERVER["PHP_SELF"]);
344 345
     				exit;
345
-    			}
346
-    			else
346
+    			} else
347 347
     			{
348 348
                     $error++;
349 349
     			    $mesg=$extrafields->error;
350 350
     			    setEventMessages($mesg, null, 'errors');
351 351
     			}
352
-    		}
353
-    		else
352
+    		} else
354 353
     		{
355 354
     		    $error++;
356 355
     			$langs->load("errors");
357 356
     			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
358 357
     			setEventMessages($mesg, null, 'errors');
359 358
     		}
360
-	    }
361
-	    else
359
+	    } else
362 360
 	    {
363 361
 	    	setEventMessages($mesg, null, 'errors');
364 362
 	    }
@@ -375,10 +373,10 @@  discard block
 block discarded – undo
375 373
         {
376 374
             header("Location: ".$_SERVER["PHP_SELF"]);
377 375
             exit;
376
+        } else {
377
+        	$mesg=$extrafields->error;
378 378
         }
379
-        else $mesg=$extrafields->error;
380
-	}
381
-	else
379
+	} else
382 380
 	{
383 381
 	    $error++;
384 382
 		$langs->load("errors");
Please login to merge, or discard this patch.
Indentation   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 {
43 43
 	if ($_POST["button"] != $langs->trans("Cancel"))
44 44
 	{
45
-	    // Check values
45
+		// Check values
46 46
 		if (! $type)
47 47
 		{
48 48
 			$error++;
@@ -52,159 +52,159 @@  discard block
 block discarded – undo
52 52
 		}
53 53
 		if ($type=='varchar' && $extrasize <= 0)
54 54
 		{
55
-		    $error++;
56
-		    $langs->load("errors");
57
-		    $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
58
-		    $action = 'edit';
55
+			$error++;
56
+			$langs->load("errors");
57
+			$mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
58
+			$action = 'edit';
59
+		}
60
+		if ($type=='varchar' && $extrasize > $maxsizestring)
61
+		{
62
+			$error++;
63
+			$langs->load("errors");
64
+			$mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
65
+			$action = 'create';
66
+		}
67
+		if ($type=='int' && $extrasize > $maxsizeint)
68
+		{
69
+			$error++;
70
+			$langs->load("errors");
71
+			$mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
72
+			$action = 'create';
73
+		}
74
+		if ($type=='select' && !$param)
75
+		{
76
+			$error++;
77
+			$langs->load("errors");
78
+			$mesg[]=$langs->trans("ErrorNoValueForSelectType");
79
+			$action = 'create';
80
+		}
81
+		if ($type=='sellist' && !$param)
82
+		{
83
+			$error++;
84
+			$langs->load("errors");
85
+			$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
86
+			$action = 'create';
87
+		}
88
+		if ($type=='checkbox' && !$param)
89
+		{
90
+			$error++;
91
+			$langs->load("errors");
92
+			$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
93
+			$action = 'create';
94
+		}
95
+		if ($type=='link' && !$param)
96
+		{
97
+			$error++;
98
+			$langs->load("errors");
99
+			$mesg[]=$langs->trans("ErrorNoValueForLinkType");
100
+			$action = 'create';
101
+		}
102
+		if ($type=='radio' && !$param)
103
+		{
104
+			$error++;
105
+			$langs->load("errors");
106
+			$mesg[]=$langs->trans("ErrorNoValueForRadioType");
107
+			$action = 'create';
108
+		}
109
+		if  ((($type=='radio') || ($type=='checkbox')) && $param)
110
+		{
111
+			// Construct array for parameter (value of select list)
112
+			$parameters = $param;
113
+			$parameters_array = explode("\r\n",$parameters);
114
+			foreach($parameters_array as $param_ligne)
115
+			{
116
+				if (!empty($param_ligne)) {
117
+					if (preg_match_all('/,/',$param_ligne,$matches))
118
+					{
119
+						if (count($matches[0])>1) {
120
+							$error++;
121
+							$langs->load("errors");
122
+							$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
123
+							$action = 'create';
124
+						}
125
+					}
126
+					else
127
+					{
128
+						$error++;
129
+						$langs->load("errors");
130
+						$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
131
+						$action = 'create';
132
+					}
133
+				}
134
+			}
59 135
 		}
60
-        if ($type=='varchar' && $extrasize > $maxsizestring)
61
-        {
62
-            $error++;
63
-            $langs->load("errors");
64
-            $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
65
-            $action = 'create';
66
-        }
67
-        if ($type=='int' && $extrasize > $maxsizeint)
68
-        {
69
-            $error++;
70
-            $langs->load("errors");
71
-            $mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
72
-            $action = 'create';
73
-        }
74
-        if ($type=='select' && !$param)
75
-        {
76
-        	$error++;
77
-        	$langs->load("errors");
78
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectType");
79
-        	$action = 'create';
80
-        }
81
-        if ($type=='sellist' && !$param)
82
-        {
83
-        	$error++;
84
-        	$langs->load("errors");
85
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
86
-        	$action = 'create';
87
-        }
88
-        if ($type=='checkbox' && !$param)
89
-        {
90
-        	$error++;
91
-        	$langs->load("errors");
92
-        	$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
93
-        	$action = 'create';
94
-        }
95
-        if ($type=='link' && !$param)
96
-        {
97
-        	$error++;
98
-        	$langs->load("errors");
99
-        	$mesg[]=$langs->trans("ErrorNoValueForLinkType");
100
-        	$action = 'create';
101
-        }
102
-        if ($type=='radio' && !$param)
103
-        {
104
-        	$error++;
105
-        	$langs->load("errors");
106
-        	$mesg[]=$langs->trans("ErrorNoValueForRadioType");
107
-        	$action = 'create';
108
-        }
109
-        if  ((($type=='radio') || ($type=='checkbox')) && $param)
110
-        {
111
-        	// Construct array for parameter (value of select list)
112
-    		$parameters = $param;
113
-    		$parameters_array = explode("\r\n",$parameters);
114
-    		foreach($parameters_array as $param_ligne)
115
-    		{
116
-    			if (!empty($param_ligne)) {
117
-	    			if (preg_match_all('/,/',$param_ligne,$matches))
118
-	    			{
119
-	    				if (count($matches[0])>1) {
120
-	    					$error++;
121
-	    					$langs->load("errors");
122
-	    					$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
123
-	    					$action = 'create';
124
-	    				}
125
-	    			}
126
-	    			else
127
-	    			{
128
-	    				$error++;
129
-	    				$langs->load("errors");
130
-	    				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
131
-	    				$action = 'create';
132
-	    			}
133
-    			}
134
-    		}
135
-        }
136 136
 
137
-	    if (! $error)
138
-	    {
139
-    		// attrname must be alphabetical and lower case only
140
-    		if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']) && !is_numeric($_POST["attrname"]))
141
-    		{
142
-    			// Construct array for parameter (value of select list)
143
-        		$default_value = GETPOST('default_value','alpha');
144
-    			$parameters = $param;
145
-    			$parameters_array = explode("\r\n",$parameters);
146
-    			//In sellist we have only one line and it can have come to do SQL expression
147
-    			if ($type=='sellist') {
148
-    				foreach($parameters_array as $param_ligne)
149
-    				{
150
-    					$params['options'] = array($parameters=>null);
151
-    				}
152
-    			}
153
-    			else
154
-    			{
155
-    				//Esle it's separated key/value and coma list
156
-    				foreach($parameters_array as $param_ligne)
157
-    				{
158
-    					list($key,$value) = explode(',',$param_ligne);
159
-    					$params['options'][$key] = $value;
160
-    				}
161
-    			}
137
+		if (! $error)
138
+		{
139
+			// attrname must be alphabetical and lower case only
140
+			if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']) && !is_numeric($_POST["attrname"]))
141
+			{
142
+				// Construct array for parameter (value of select list)
143
+				$default_value = GETPOST('default_value','alpha');
144
+				$parameters = $param;
145
+				$parameters_array = explode("\r\n",$parameters);
146
+				//In sellist we have only one line and it can have come to do SQL expression
147
+				if ($type=='sellist') {
148
+					foreach($parameters_array as $param_ligne)
149
+					{
150
+						$params['options'] = array($parameters=>null);
151
+					}
152
+				}
153
+				else
154
+				{
155
+					//Esle it's separated key/value and coma list
156
+					foreach($parameters_array as $param_ligne)
157
+					{
158
+						list($key,$value) = explode(',',$param_ligne);
159
+						$params['options'][$key] = $value;
160
+					}
161
+				}
162 162
 
163
-                $result=$extrafields->addExtraField(
164
-                	GETPOST('attrname', 'alpha'),
165
-                	GETPOST('label', 'alpha'),
166
-                	$type,
167
-                	GETPOST('pos', 'int'),
168
-                	$extrasize,
169
-                	$elementtype,
170
-                	(GETPOST('unique', 'alpha')?1:0),
171
-                	(GETPOST('required', 'alpha')?1:0),
172
-                	$default_value,
173
-                	$params,
174
-                	(GETPOST('alwayseditable', 'alpha')?1:0),
175
-                	(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
176
-                	GETPOST('list', 'alpha'),				// Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
163
+				$result=$extrafields->addExtraField(
164
+					GETPOST('attrname', 'alpha'),
165
+					GETPOST('label', 'alpha'),
166
+					$type,
167
+					GETPOST('pos', 'int'),
168
+					$extrasize,
169
+					$elementtype,
170
+					(GETPOST('unique', 'alpha')?1:0),
171
+					(GETPOST('required', 'alpha')?1:0),
172
+					$default_value,
173
+					$params,
174
+					(GETPOST('alwayseditable', 'alpha')?1:0),
175
+					(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
176
+					GETPOST('list', 'alpha'),				// Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
177 177
 					(GETPOST('ishidden', 'alpha')?1:0),
178
-                    GETPOST('computed_value','alpha'),
179
-                	(GETPOST('entitycurrentorall', 'alpha')?0:''),
180
-                	GETPOST('langfile', 'alpha')
181
-                );
182
-    			if ($result > 0)
183
-    			{
184
-    				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
185
-    				header("Location: ".$_SERVER["PHP_SELF"]);
186
-    				exit;
187
-    			}
188
-    			else
189
-    			{
190
-                    $error++;
191
-    			    $mesg=$extrafields->error;
192
-                    setEventMessages($mesg, null, 'errors');
193
-    			}
194
-    		}
195
-    		else
196
-    		{
197
-                $error++;
198
-    		    $langs->load("errors");
199
-    			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode"));
200
-    			setEventMessages($mesg, null, 'errors');
201
-    			$action = 'create';
202
-    		}
203
-	    }
204
-	    else
205
-	    {
206
-	    	setEventMessages($mesg, null, 'errors');
207
-	    }
178
+					GETPOST('computed_value','alpha'),
179
+					(GETPOST('entitycurrentorall', 'alpha')?0:''),
180
+					GETPOST('langfile', 'alpha')
181
+				);
182
+				if ($result > 0)
183
+				{
184
+					setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
185
+					header("Location: ".$_SERVER["PHP_SELF"]);
186
+					exit;
187
+				}
188
+				else
189
+				{
190
+					$error++;
191
+					$mesg=$extrafields->error;
192
+					setEventMessages($mesg, null, 'errors');
193
+				}
194
+			}
195
+			else
196
+			{
197
+				$error++;
198
+				$langs->load("errors");
199
+				$mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode"));
200
+				setEventMessages($mesg, null, 'errors');
201
+				$action = 'create';
202
+			}
203
+		}
204
+		else
205
+		{
206
+			setEventMessages($mesg, null, 'errors');
207
+		}
208 208
 	}
209 209
 }
210 210
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 {
214 214
 	if ($_POST["button"] != $langs->trans("Cancel"))
215 215
 	{
216
-        // Check values
216
+		// Check values
217 217
 		if (! $type)
218 218
 		{
219 219
 			$error++;
@@ -223,150 +223,150 @@  discard block
 block discarded – undo
223 223
 		}
224 224
 		if ($type=='varchar' && $extrasize <= 0)
225 225
 		{
226
-		    $error++;
227
-		    $langs->load("errors");
228
-		    $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
229
-		    $action = 'edit';
226
+			$error++;
227
+			$langs->load("errors");
228
+			$mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
229
+			$action = 'edit';
230 230
 		}
231 231
 		if ($type=='varchar' && $extrasize > $maxsizestring)
232
-        {
233
-            $error++;
234
-            $langs->load("errors");
235
-            $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
236
-            $action = 'edit';
237
-        }
238
-        if ($type=='int' && $extrasize > $maxsizeint)
239
-        {
240
-            $error++;
241
-            $langs->load("errors");
242
-            $mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
243
-            $action = 'edit';
244
-        }
245
-        if ($type=='select' && !$param)
246
-        {
247
-        	$error++;
248
-        	$langs->load("errors");
249
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectType");
250
-        	$action = 'edit';
251
-        }
252
-        if ($type=='sellist' && !$param)
253
-        {
254
-        	$error++;
255
-        	$langs->load("errors");
256
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
257
-        	$action = 'edit';
258
-        }
259
-        if ($type=='checkbox' && !$param)
260
-        {
261
-        	$error++;
262
-        	$langs->load("errors");
263
-        	$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
264
-        	$action = 'edit';
265
-        }
266
-        if ($type=='radio' && !$param)
267
-        {
268
-        	$error++;
269
-        	$langs->load("errors");
270
-        	$mesg[]=$langs->trans("ErrorNoValueForRadioType");
271
-        	$action = 'edit';
272
-        }
273
-        if  ((($type=='radio') || ($type=='checkbox')) && $param)
274
-        {
275
-        	// Construct array for parameter (value of select list)
276
-        	$parameters = $param;
277
-        	$parameters_array = explode("\r\n",$parameters);
278
-        	foreach($parameters_array as $param_ligne)
279
-        	{
280
-        		if (!empty($param_ligne)) {
281
-	        		if (preg_match_all('/,/',$param_ligne,$matches))
282
-	        		{
283
-	        			if (count($matches[0])>1) {
284
-	        				$error++;
285
-	        				$langs->load("errors");
286
-	        				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
287
-	        				$action = 'edit';
288
-	        			}
289
-	        		}
290
-	        		else
291
-	        		{
292
-	        			$error++;
293
-	        			$langs->load("errors");
294
-	        			$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
295
-	        			$action = 'edit';
296
-	        		}
297
-        		}
298
-        	}
299
-        }
232
+		{
233
+			$error++;
234
+			$langs->load("errors");
235
+			$mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
236
+			$action = 'edit';
237
+		}
238
+		if ($type=='int' && $extrasize > $maxsizeint)
239
+		{
240
+			$error++;
241
+			$langs->load("errors");
242
+			$mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
243
+			$action = 'edit';
244
+		}
245
+		if ($type=='select' && !$param)
246
+		{
247
+			$error++;
248
+			$langs->load("errors");
249
+			$mesg[]=$langs->trans("ErrorNoValueForSelectType");
250
+			$action = 'edit';
251
+		}
252
+		if ($type=='sellist' && !$param)
253
+		{
254
+			$error++;
255
+			$langs->load("errors");
256
+			$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
257
+			$action = 'edit';
258
+		}
259
+		if ($type=='checkbox' && !$param)
260
+		{
261
+			$error++;
262
+			$langs->load("errors");
263
+			$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
264
+			$action = 'edit';
265
+		}
266
+		if ($type=='radio' && !$param)
267
+		{
268
+			$error++;
269
+			$langs->load("errors");
270
+			$mesg[]=$langs->trans("ErrorNoValueForRadioType");
271
+			$action = 'edit';
272
+		}
273
+		if  ((($type=='radio') || ($type=='checkbox')) && $param)
274
+		{
275
+			// Construct array for parameter (value of select list)
276
+			$parameters = $param;
277
+			$parameters_array = explode("\r\n",$parameters);
278
+			foreach($parameters_array as $param_ligne)
279
+			{
280
+				if (!empty($param_ligne)) {
281
+					if (preg_match_all('/,/',$param_ligne,$matches))
282
+					{
283
+						if (count($matches[0])>1) {
284
+							$error++;
285
+							$langs->load("errors");
286
+							$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
287
+							$action = 'edit';
288
+						}
289
+					}
290
+					else
291
+					{
292
+						$error++;
293
+						$langs->load("errors");
294
+						$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
295
+						$action = 'edit';
296
+					}
297
+				}
298
+			}
299
+		}
300 300
 
301
-	    if (! $error)
302
-	    {
303
-            if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
304
-    		{
305
-    			$pos = GETPOST('pos','int');
306
-    			// Construct array for parameter (value of select list)
307
-    			$parameters = $param;
308
-    			$parameters_array = explode("\r\n",$parameters);
309
-    			//In sellist we have only one line and it can have come to do SQL expression
310
-    			if ($type=='sellist') {
311
-    				foreach($parameters_array as $param_ligne)
312
-    				{
313
-    					$params['options'] = array($parameters=>null);
314
-    				}
315
-    			}
316
-    			else
317
-    			{
318
-    				//Esle it's separated key/value and coma list
319
-    				foreach($parameters_array as $param_ligne)
320
-    				{
321
-    					list($key,$value) = explode(',',$param_ligne);
322
-    					$params['options'][$key] = $value;
323
-    				}
324
-    			}
301
+		if (! $error)
302
+		{
303
+			if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
304
+			{
305
+				$pos = GETPOST('pos','int');
306
+				// Construct array for parameter (value of select list)
307
+				$parameters = $param;
308
+				$parameters_array = explode("\r\n",$parameters);
309
+				//In sellist we have only one line and it can have come to do SQL expression
310
+				if ($type=='sellist') {
311
+					foreach($parameters_array as $param_ligne)
312
+					{
313
+						$params['options'] = array($parameters=>null);
314
+					}
315
+				}
316
+				else
317
+				{
318
+					//Esle it's separated key/value and coma list
319
+					foreach($parameters_array as $param_ligne)
320
+					{
321
+						list($key,$value) = explode(',',$param_ligne);
322
+						$params['options'][$key] = $value;
323
+					}
324
+				}
325 325
 
326
-    			$result=$extrafields->update(
327
-    				GETPOST('attrname', 'alpha'),
328
-    				GETPOST('label', 'alpha'),
329
-    				$type,
330
-    				$extrasize,
331
-    				$elementtype,
332
-    				(GETPOST('unique', 'alpha')?1:0),
333
-    				(GETPOST('required', 'alpha')?1:0),
334
-    				$pos,
335
-    				$params,
336
-    				(GETPOST('alwayseditable', 'alpha')?1:0),
337
-    				(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
338
-                	GETPOST('list', 'alpha'),				// Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
326
+				$result=$extrafields->update(
327
+					GETPOST('attrname', 'alpha'),
328
+					GETPOST('label', 'alpha'),
329
+					$type,
330
+					$extrasize,
331
+					$elementtype,
332
+					(GETPOST('unique', 'alpha')?1:0),
333
+					(GETPOST('required', 'alpha')?1:0),
334
+					$pos,
335
+					$params,
336
+					(GETPOST('alwayseditable', 'alpha')?1:0),
337
+					(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
338
+					GETPOST('list', 'alpha'),				// Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
339 339
 					(GETPOST('ishidden', 'alpha')?1:0),
340
-    			    GETPOST('default_value','alpha'),
341
-    				GETPOST('computed_value','alpha'),
342
-    				(GETPOST('entitycurrentorall', 'alpha')?0:''),
343
-    				GETPOST('langfile')
344
-    			);
345
-    			if ($result > 0)
346
-    			{
347
-    				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
348
-    				header("Location: ".$_SERVER["PHP_SELF"]);
349
-    				exit;
350
-    			}
351
-    			else
352
-    			{
353
-                    $error++;
354
-    			    $mesg=$extrafields->error;
355
-    			    setEventMessages($mesg, null, 'errors');
356
-    			}
357
-    		}
358
-    		else
359
-    		{
360
-    		    $error++;
361
-    			$langs->load("errors");
362
-    			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
363
-    			setEventMessages($mesg, null, 'errors');
364
-    		}
365
-	    }
366
-	    else
367
-	    {
368
-	    	setEventMessages($mesg, null, 'errors');
369
-	    }
340
+					GETPOST('default_value','alpha'),
341
+					GETPOST('computed_value','alpha'),
342
+					(GETPOST('entitycurrentorall', 'alpha')?0:''),
343
+					GETPOST('langfile')
344
+				);
345
+				if ($result > 0)
346
+				{
347
+					setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
348
+					header("Location: ".$_SERVER["PHP_SELF"]);
349
+					exit;
350
+				}
351
+				else
352
+				{
353
+					$error++;
354
+					$mesg=$extrafields->error;
355
+					setEventMessages($mesg, null, 'errors');
356
+				}
357
+			}
358
+			else
359
+			{
360
+				$error++;
361
+				$langs->load("errors");
362
+				$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
363
+				setEventMessages($mesg, null, 'errors');
364
+			}
365
+		}
366
+		else
367
+		{
368
+			setEventMessages($mesg, null, 'errors');
369
+		}
370 370
 	}
371 371
 }
372 372
 
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 {
376 376
 	if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"]))
377 377
 	{
378
-        $result=$extrafields->delete($_GET["attrname"],$elementtype);
379
-        if ($result >= 0)
380
-        {
381
-            header("Location: ".$_SERVER["PHP_SELF"]);
382
-            exit;
383
-        }
384
-        else $mesg=$extrafields->error;
378
+		$result=$extrafields->delete($_GET["attrname"],$elementtype);
379
+		if ($result >= 0)
380
+		{
381
+			header("Location: ".$_SERVER["PHP_SELF"]);
382
+			exit;
383
+		}
384
+		else $mesg=$extrafields->error;
385 385
 	}
386 386
 	else
387 387
 	{
388
-	    $error++;
388
+		$error++;
389 389
 		$langs->load("errors");
390 390
 		$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
391 391
 	}
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
  *  \brief			Code for actions on extrafields admin pages
24 24
  */
25 25
 
26
-$maxsizestring=255;
27
-$maxsizeint=10;
28
-$mesg=array();
26
+$maxsizestring = 255;
27
+$maxsizeint = 10;
28
+$mesg = array();
29 29
 
30
-$extrasize=GETPOST('size','int');
31
-$type=GETPOST('type','alpha');
32
-$param=GETPOST('param','alpha');;
30
+$extrasize = GETPOST('size', 'int');
31
+$type = GETPOST('type', 'alpha');
32
+$param = GETPOST('param', 'alpha'); ;
33 33
 
34
-if ($type=='double' && strpos($extrasize,',')===false) $extrasize='24,8';
35
-if ($type=='date')     $extrasize='';
36
-if ($type=='datetime') $extrasize='';
37
-if ($type=='select')   $extrasize='';
34
+if ($type == 'double' && strpos($extrasize, ',') === false) $extrasize = '24,8';
35
+if ($type == 'date')     $extrasize = '';
36
+if ($type == 'datetime') $extrasize = '';
37
+if ($type == 'select')   $extrasize = '';
38 38
 
39 39
 
40 40
 // Add attribute
@@ -43,83 +43,83 @@  discard block
 block discarded – undo
43 43
 	if ($_POST["button"] != $langs->trans("Cancel"))
44 44
 	{
45 45
 	    // Check values
46
-		if (! $type)
46
+		if (!$type)
47 47
 		{
48 48
 			$error++;
49 49
 			$langs->load("errors");
50
-			$mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"));
50
+			$mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
51 51
 			$action = 'create';
52 52
 		}
53
-		if ($type=='varchar' && $extrasize <= 0)
53
+		if ($type == 'varchar' && $extrasize <= 0)
54 54
 		{
55 55
 		    $error++;
56 56
 		    $langs->load("errors");
57
-		    $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
57
+		    $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size"));
58 58
 		    $action = 'edit';
59 59
 		}
60
-        if ($type=='varchar' && $extrasize > $maxsizestring)
60
+        if ($type == 'varchar' && $extrasize > $maxsizestring)
61 61
         {
62 62
             $error++;
63 63
             $langs->load("errors");
64
-            $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
64
+            $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring);
65 65
             $action = 'create';
66 66
         }
67
-        if ($type=='int' && $extrasize > $maxsizeint)
67
+        if ($type == 'int' && $extrasize > $maxsizeint)
68 68
         {
69 69
             $error++;
70 70
             $langs->load("errors");
71
-            $mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
71
+            $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint);
72 72
             $action = 'create';
73 73
         }
74
-        if ($type=='select' && !$param)
74
+        if ($type == 'select' && !$param)
75 75
         {
76 76
         	$error++;
77 77
         	$langs->load("errors");
78
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectType");
78
+        	$mesg[] = $langs->trans("ErrorNoValueForSelectType");
79 79
         	$action = 'create';
80 80
         }
81
-        if ($type=='sellist' && !$param)
81
+        if ($type == 'sellist' && !$param)
82 82
         {
83 83
         	$error++;
84 84
         	$langs->load("errors");
85
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
85
+        	$mesg[] = $langs->trans("ErrorNoValueForSelectListType");
86 86
         	$action = 'create';
87 87
         }
88
-        if ($type=='checkbox' && !$param)
88
+        if ($type == 'checkbox' && !$param)
89 89
         {
90 90
         	$error++;
91 91
         	$langs->load("errors");
92
-        	$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
92
+        	$mesg[] = $langs->trans("ErrorNoValueForCheckBoxType");
93 93
         	$action = 'create';
94 94
         }
95
-        if ($type=='link' && !$param)
95
+        if ($type == 'link' && !$param)
96 96
         {
97 97
         	$error++;
98 98
         	$langs->load("errors");
99
-        	$mesg[]=$langs->trans("ErrorNoValueForLinkType");
99
+        	$mesg[] = $langs->trans("ErrorNoValueForLinkType");
100 100
         	$action = 'create';
101 101
         }
102
-        if ($type=='radio' && !$param)
102
+        if ($type == 'radio' && !$param)
103 103
         {
104 104
         	$error++;
105 105
         	$langs->load("errors");
106
-        	$mesg[]=$langs->trans("ErrorNoValueForRadioType");
106
+        	$mesg[] = $langs->trans("ErrorNoValueForRadioType");
107 107
         	$action = 'create';
108 108
         }
109
-        if  ((($type=='radio') || ($type=='checkbox')) && $param)
109
+        if ((($type == 'radio') || ($type == 'checkbox')) && $param)
110 110
         {
111 111
         	// Construct array for parameter (value of select list)
112 112
     		$parameters = $param;
113
-    		$parameters_array = explode("\r\n",$parameters);
114
-    		foreach($parameters_array as $param_ligne)
113
+    		$parameters_array = explode("\r\n", $parameters);
114
+    		foreach ($parameters_array as $param_ligne)
115 115
     		{
116 116
     			if (!empty($param_ligne)) {
117
-	    			if (preg_match_all('/,/',$param_ligne,$matches))
117
+	    			if (preg_match_all('/,/', $param_ligne, $matches))
118 118
 	    			{
119
-	    				if (count($matches[0])>1) {
119
+	    				if (count($matches[0]) > 1) {
120 120
 	    					$error++;
121 121
 	    					$langs->load("errors");
122
-	    					$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
122
+	    					$mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne);
123 123
 	    					$action = 'create';
124 124
 	    				}
125 125
 	    			}
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 	    			{
128 128
 	    				$error++;
129 129
 	    				$langs->load("errors");
130
-	    				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
130
+	    				$mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne);
131 131
 	    				$action = 'create';
132 132
 	    			}
133 133
     			}
134 134
     		}
135 135
         }
136 136
 
137
-	    if (! $error)
137
+	    if (!$error)
138 138
 	    {
139 139
     		// attrname must be alphabetical and lower case only
140
-    		if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']) && !is_numeric($_POST["attrname"]))
140
+    		if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"]))
141 141
     		{
142 142
     			// Construct array for parameter (value of select list)
143
-        		$default_value = GETPOST('default_value','alpha');
143
+        		$default_value = GETPOST('default_value', 'alpha');
144 144
     			$parameters = $param;
145
-    			$parameters_array = explode("\r\n",$parameters);
145
+    			$parameters_array = explode("\r\n", $parameters);
146 146
     			//In sellist we have only one line and it can have come to do SQL expression
147
-    			if ($type=='sellist') {
148
-    				foreach($parameters_array as $param_ligne)
147
+    			if ($type == 'sellist') {
148
+    				foreach ($parameters_array as $param_ligne)
149 149
     				{
150 150
     					$params['options'] = array($parameters=>null);
151 151
     				}
@@ -153,30 +153,30 @@  discard block
 block discarded – undo
153 153
     			else
154 154
     			{
155 155
     				//Esle it's separated key/value and coma list
156
-    				foreach($parameters_array as $param_ligne)
156
+    				foreach ($parameters_array as $param_ligne)
157 157
     				{
158
-    					list($key,$value) = explode(',',$param_ligne);
158
+    					list($key, $value) = explode(',', $param_ligne);
159 159
     					$params['options'][$key] = $value;
160 160
     				}
161 161
     			}
162 162
 
163
-                $result=$extrafields->addExtraField(
163
+                $result = $extrafields->addExtraField(
164 164
                 	GETPOST('attrname', 'alpha'),
165 165
                 	GETPOST('label', 'alpha'),
166 166
                 	$type,
167 167
                 	GETPOST('pos', 'int'),
168 168
                 	$extrasize,
169 169
                 	$elementtype,
170
-                	(GETPOST('unique', 'alpha')?1:0),
171
-                	(GETPOST('required', 'alpha')?1:0),
170
+                	(GETPOST('unique', 'alpha') ? 1 : 0),
171
+                	(GETPOST('required', 'alpha') ? 1 : 0),
172 172
                 	$default_value,
173 173
                 	$params,
174
-                	(GETPOST('alwayseditable', 'alpha')?1:0),
175
-                	(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
176
-                	GETPOST('list', 'alpha'),				// Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
177
-					(GETPOST('ishidden', 'alpha')?1:0),
178
-                    GETPOST('computed_value','alpha'),
179
-                	(GETPOST('entitycurrentorall', 'alpha')?0:''),
174
+                	(GETPOST('alwayseditable', 'alpha') ? 1 : 0),
175
+                	(GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''),
176
+                	GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
177
+					(GETPOST('ishidden', 'alpha') ? 1 : 0),
178
+                    GETPOST('computed_value', 'alpha'),
179
+                	(GETPOST('entitycurrentorall', 'alpha') ? 0 : ''),
180 180
                 	GETPOST('langfile', 'alpha')
181 181
                 );
182 182
     			if ($result > 0)
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
     			else
189 189
     			{
190 190
                     $error++;
191
-    			    $mesg=$extrafields->error;
191
+    			    $mesg = $extrafields->error;
192 192
                     setEventMessages($mesg, null, 'errors');
193 193
     			}
194 194
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     		{
197 197
                 $error++;
198 198
     		    $langs->load("errors");
199
-    			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode"));
199
+    			$mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode"));
200 200
     			setEventMessages($mesg, null, 'errors');
201 201
     			$action = 'create';
202 202
     		}
@@ -214,76 +214,76 @@  discard block
 block discarded – undo
214 214
 	if ($_POST["button"] != $langs->trans("Cancel"))
215 215
 	{
216 216
         // Check values
217
-		if (! $type)
217
+		if (!$type)
218 218
 		{
219 219
 			$error++;
220 220
 			$langs->load("errors");
221
-			$mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"));
221
+			$mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
222 222
 			$action = 'edit';
223 223
 		}
224
-		if ($type=='varchar' && $extrasize <= 0)
224
+		if ($type == 'varchar' && $extrasize <= 0)
225 225
 		{
226 226
 		    $error++;
227 227
 		    $langs->load("errors");
228
-		    $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
228
+		    $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size"));
229 229
 		    $action = 'edit';
230 230
 		}
231
-		if ($type=='varchar' && $extrasize > $maxsizestring)
231
+		if ($type == 'varchar' && $extrasize > $maxsizestring)
232 232
         {
233 233
             $error++;
234 234
             $langs->load("errors");
235
-            $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
235
+            $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring);
236 236
             $action = 'edit';
237 237
         }
238
-        if ($type=='int' && $extrasize > $maxsizeint)
238
+        if ($type == 'int' && $extrasize > $maxsizeint)
239 239
         {
240 240
             $error++;
241 241
             $langs->load("errors");
242
-            $mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
242
+            $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint);
243 243
             $action = 'edit';
244 244
         }
245
-        if ($type=='select' && !$param)
245
+        if ($type == 'select' && !$param)
246 246
         {
247 247
         	$error++;
248 248
         	$langs->load("errors");
249
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectType");
249
+        	$mesg[] = $langs->trans("ErrorNoValueForSelectType");
250 250
         	$action = 'edit';
251 251
         }
252
-        if ($type=='sellist' && !$param)
252
+        if ($type == 'sellist' && !$param)
253 253
         {
254 254
         	$error++;
255 255
         	$langs->load("errors");
256
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
256
+        	$mesg[] = $langs->trans("ErrorNoValueForSelectListType");
257 257
         	$action = 'edit';
258 258
         }
259
-        if ($type=='checkbox' && !$param)
259
+        if ($type == 'checkbox' && !$param)
260 260
         {
261 261
         	$error++;
262 262
         	$langs->load("errors");
263
-        	$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
263
+        	$mesg[] = $langs->trans("ErrorNoValueForCheckBoxType");
264 264
         	$action = 'edit';
265 265
         }
266
-        if ($type=='radio' && !$param)
266
+        if ($type == 'radio' && !$param)
267 267
         {
268 268
         	$error++;
269 269
         	$langs->load("errors");
270
-        	$mesg[]=$langs->trans("ErrorNoValueForRadioType");
270
+        	$mesg[] = $langs->trans("ErrorNoValueForRadioType");
271 271
         	$action = 'edit';
272 272
         }
273
-        if  ((($type=='radio') || ($type=='checkbox')) && $param)
273
+        if ((($type == 'radio') || ($type == 'checkbox')) && $param)
274 274
         {
275 275
         	// Construct array for parameter (value of select list)
276 276
         	$parameters = $param;
277
-        	$parameters_array = explode("\r\n",$parameters);
278
-        	foreach($parameters_array as $param_ligne)
277
+        	$parameters_array = explode("\r\n", $parameters);
278
+        	foreach ($parameters_array as $param_ligne)
279 279
         	{
280 280
         		if (!empty($param_ligne)) {
281
-	        		if (preg_match_all('/,/',$param_ligne,$matches))
281
+	        		if (preg_match_all('/,/', $param_ligne, $matches))
282 282
 	        		{
283
-	        			if (count($matches[0])>1) {
283
+	        			if (count($matches[0]) > 1) {
284 284
 	        				$error++;
285 285
 	        				$langs->load("errors");
286
-	        				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
286
+	        				$mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne);
287 287
 	        				$action = 'edit';
288 288
 	        			}
289 289
 	        		}
@@ -291,24 +291,24 @@  discard block
 block discarded – undo
291 291
 	        		{
292 292
 	        			$error++;
293 293
 	        			$langs->load("errors");
294
-	        			$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
294
+	        			$mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne);
295 295
 	        			$action = 'edit';
296 296
 	        		}
297 297
         		}
298 298
         	}
299 299
         }
300 300
 
301
-	    if (! $error)
301
+	    if (!$error)
302 302
 	    {
303
-            if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
303
+            if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname']))
304 304
     		{
305
-    			$pos = GETPOST('pos','int');
305
+    			$pos = GETPOST('pos', 'int');
306 306
     			// Construct array for parameter (value of select list)
307 307
     			$parameters = $param;
308
-    			$parameters_array = explode("\r\n",$parameters);
308
+    			$parameters_array = explode("\r\n", $parameters);
309 309
     			//In sellist we have only one line and it can have come to do SQL expression
310
-    			if ($type=='sellist') {
311
-    				foreach($parameters_array as $param_ligne)
310
+    			if ($type == 'sellist') {
311
+    				foreach ($parameters_array as $param_ligne)
312 312
     				{
313 313
     					$params['options'] = array($parameters=>null);
314 314
     				}
@@ -316,30 +316,30 @@  discard block
 block discarded – undo
316 316
     			else
317 317
     			{
318 318
     				//Esle it's separated key/value and coma list
319
-    				foreach($parameters_array as $param_ligne)
319
+    				foreach ($parameters_array as $param_ligne)
320 320
     				{
321
-    					list($key,$value) = explode(',',$param_ligne);
321
+    					list($key, $value) = explode(',', $param_ligne);
322 322
     					$params['options'][$key] = $value;
323 323
     				}
324 324
     			}
325 325
 
326
-    			$result=$extrafields->update(
326
+    			$result = $extrafields->update(
327 327
     				GETPOST('attrname', 'alpha'),
328 328
     				GETPOST('label', 'alpha'),
329 329
     				$type,
330 330
     				$extrasize,
331 331
     				$elementtype,
332
-    				(GETPOST('unique', 'alpha')?1:0),
333
-    				(GETPOST('required', 'alpha')?1:0),
332
+    				(GETPOST('unique', 'alpha') ? 1 : 0),
333
+    				(GETPOST('required', 'alpha') ? 1 : 0),
334 334
     				$pos,
335 335
     				$params,
336
-    				(GETPOST('alwayseditable', 'alpha')?1:0),
337
-    				(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
338
-                	GETPOST('list', 'alpha'),				// Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
339
-					(GETPOST('ishidden', 'alpha')?1:0),
340
-    			    GETPOST('default_value','alpha'),
341
-    				GETPOST('computed_value','alpha'),
342
-    				(GETPOST('entitycurrentorall', 'alpha')?0:''),
336
+    				(GETPOST('alwayseditable', 'alpha') ? 1 : 0),
337
+    				(GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''),
338
+                	GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
339
+					(GETPOST('ishidden', 'alpha') ? 1 : 0),
340
+    			    GETPOST('default_value', 'alpha'),
341
+    				GETPOST('computed_value', 'alpha'),
342
+    				(GETPOST('entitycurrentorall', 'alpha') ? 0 : ''),
343 343
     				GETPOST('langfile')
344 344
     			);
345 345
     			if ($result > 0)
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
     			else
352 352
     			{
353 353
                     $error++;
354
-    			    $mesg=$extrafields->error;
354
+    			    $mesg = $extrafields->error;
355 355
     			    setEventMessages($mesg, null, 'errors');
356 356
     			}
357 357
     		}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
     		{
360 360
     		    $error++;
361 361
     			$langs->load("errors");
362
-    			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
362
+    			$mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode"));
363 363
     			setEventMessages($mesg, null, 'errors');
364 364
     		}
365 365
 	    }
@@ -373,21 +373,21 @@  discard block
 block discarded – undo
373 373
 // Delete attribute
374 374
 if ($action == 'delete')
375 375
 {
376
-	if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"]))
376
+	if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"]))
377 377
 	{
378
-        $result=$extrafields->delete($_GET["attrname"],$elementtype);
378
+        $result = $extrafields->delete($_GET["attrname"], $elementtype);
379 379
         if ($result >= 0)
380 380
         {
381 381
             header("Location: ".$_SERVER["PHP_SELF"]);
382 382
             exit;
383 383
         }
384
-        else $mesg=$extrafields->error;
384
+        else $mesg = $extrafields->error;
385 385
 	}
386 386
 	else
387 387
 	{
388 388
 	    $error++;
389 389
 		$langs->load("errors");
390
-		$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
390
+		$mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode"));
391 391
 	}
392 392
 }
393 393
 
Please login to merge, or discard this patch.
htdocs/core/ajax/extraparams.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
  *	\brief      File to return Ajax response on set extra parameters of elements
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
26
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
27
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
23
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
24
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
25
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1');
26
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
27
+if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
28 28
 //if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
29 29
 
30 30
 include '../../main.inc.php';
31 31
 
32
-$id = GETPOST('id','int');
33
-$element = GETPOST('element','alpha');
34
-$htmlelement = GETPOST('htmlelement','alpha');
32
+$id = GETPOST('id', 'int');
33
+$element = GETPOST('element', 'alpha');
34
+$htmlelement = GETPOST('htmlelement', 'alpha');
35 35
 $type = GETPOST('type', 'alpha');
36 36
 
37 37
 /*
@@ -42,37 +42,37 @@  discard block
 block discarded – undo
42 42
 
43 43
 print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
44 44
 
45
-if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type))
45
+if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type))
46 46
 {
47
-	$value = GETPOST('value','alpha');
48
-	$params=array();
47
+	$value = GETPOST('value', 'alpha');
48
+	$params = array();
49 49
 
50 50
 	dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG);
51 51
 
52 52
 	$classpath = $subelement = $element;
53 53
 
54 54
 	// For compatibility
55
-	if ($element == 'order' || $element == 'commande')    { $classpath = $subelement = 'commande'; }
56
-	else if ($element == 'propal')				{ $classpath = 'comm/propal'; $subelement = 'propal'; }
57
-	else if ($element == 'facture')				{ $classpath = 'compta/facture'; $subelement = 'facture'; }
58
-	else if ($element == 'contract')			{ $classpath = $subelement = 'contrat'; }
59
-	else if ($element == 'shipping')			{ $classpath = $subelement = 'expedition'; }
60
-	else if ($element == 'deplacement')			{ $classpath = 'compta/deplacement'; $subelement = 'deplacement'; }
61
-	else if ($element == 'order_supplier')		{ $classpath = 'fourn'; $subelement = 'fournisseur.commande'; }
62
-	else if ($element == 'invoice_supplier')	{ $classpath = 'fourn'; $subelement = 'fournisseur.facture'; }
55
+	if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; }
56
+	else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; }
57
+	else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; }
58
+	else if ($element == 'contract') { $classpath = $subelement = 'contrat'; }
59
+	else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; }
60
+	else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; }
61
+	else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; }
62
+	else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; }
63 63
 
64 64
 	dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php');
65 65
 
66
-	if ($element == 'order_supplier')			{ $classname = 'CommandeFournisseur'; }
67
-	else if ($element == 'invoice_supplier')	{ $classname = 'FactureFournisseur'; }
66
+	if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; }
67
+	else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; }
68 68
 	else $classname = ucfirst($subelement);
69 69
 
70
-	$object	= new $classname($db);
70
+	$object = new $classname($db);
71 71
 	$object->fetch($id);
72 72
 
73 73
 	$params[$htmlelement] = array($type => $value);
74 74
 	$object->extraparams = array_merge($object->extraparams, $params);
75 75
 
76
-	$result=$object->setExtraParameters();
76
+	$result = $object->setExtraParameters();
77 77
 }
78 78
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,11 +20,22 @@  discard block
 block discarded – undo
20 20
  *	\brief      File to return Ajax response on set extra parameters of elements
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
26
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
27
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
23
+if (! defined('NOTOKENRENEWAL')) {
24
+	define('NOTOKENRENEWAL','1');
25
+}
26
+// Disables token renewal
27
+if (! defined('NOREQUIREMENU')) {
28
+	define('NOREQUIREMENU','1');
29
+}
30
+if (! defined('NOREQUIREHTML')) {
31
+	define('NOREQUIREHTML','1');
32
+}
33
+if (! defined('NOREQUIREAJAX')) {
34
+	define('NOREQUIREAJAX','1');
35
+}
36
+if (! defined('NOREQUIRESOC')) {
37
+	define('NOREQUIRESOC','1');
38
+}
28 39
 //if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
29 40
 
30 41
 include '../../main.inc.php';
@@ -52,20 +63,13 @@  discard block
 block discarded – undo
52 63
 	$classpath = $subelement = $element;
53 64
 
54 65
 	// For compatibility
55
-	if ($element == 'order' || $element == 'commande')    { $classpath = $subelement = 'commande'; }
56
-	else if ($element == 'propal')				{ $classpath = 'comm/propal'; $subelement = 'propal'; }
57
-	else if ($element == 'facture')				{ $classpath = 'compta/facture'; $subelement = 'facture'; }
58
-	else if ($element == 'contract')			{ $classpath = $subelement = 'contrat'; }
59
-	else if ($element == 'shipping')			{ $classpath = $subelement = 'expedition'; }
60
-	else if ($element == 'deplacement')			{ $classpath = 'compta/deplacement'; $subelement = 'deplacement'; }
61
-	else if ($element == 'order_supplier')		{ $classpath = 'fourn'; $subelement = 'fournisseur.commande'; }
62
-	else if ($element == 'invoice_supplier')	{ $classpath = 'fourn'; $subelement = 'fournisseur.facture'; }
66
+	if ($element == 'order' || $element == 'commande')    { $classpath = $subelement = 'commande'; } else if ($element == 'propal')				{ $classpath = 'comm/propal'; $subelement = 'propal'; } else if ($element == 'facture')				{ $classpath = 'compta/facture'; $subelement = 'facture'; } else if ($element == 'contract')			{ $classpath = $subelement = 'contrat'; } else if ($element == 'shipping')			{ $classpath = $subelement = 'expedition'; } else if ($element == 'deplacement')			{ $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } else if ($element == 'order_supplier')		{ $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } else if ($element == 'invoice_supplier')	{ $classpath = 'fourn'; $subelement = 'fournisseur.facture'; }
63 67
 
64 68
 	dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php');
65 69
 
66
-	if ($element == 'order_supplier')			{ $classname = 'CommandeFournisseur'; }
67
-	else if ($element == 'invoice_supplier')	{ $classname = 'FactureFournisseur'; }
68
-	else $classname = ucfirst($subelement);
70
+	if ($element == 'order_supplier')			{ $classname = 'CommandeFournisseur'; } else if ($element == 'invoice_supplier')	{ $classname = 'FactureFournisseur'; } else {
71
+		$classname = ucfirst($subelement);
72
+	}
69 73
 
70 74
 	$object	= new $classname($db);
71 75
 	$object->fetch($id);
Please login to merge, or discard this patch.
htdocs/core/ajax/security.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@
 block discarded – undo
45 45
 {
46 46
 	if ($_GET['action'] == 'getrandompassword' && $user->admin)
47 47
 	{
48
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
49
-	    $generic = $_GET['generic'] ? true : false;
48
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
49
+		$generic = $_GET['generic'] ? true : false;
50 50
 		echo getRandomPassword($generic);
51 51
 	}
52 52
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
  *                   like key to use into URL to protect them.
22 22
  */
23 23
 
24
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
25
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
26
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
27
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
28
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
29
-if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
30
-if (! defined('NOREQUIREHOOK'))  define('NOREQUIREHOOK','1');
24
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
25
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
26
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1');
27
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
28
+if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
29
+if (!defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN', '1');
30
+if (!defined('NOREQUIREHOOK'))  define('NOREQUIREHOOK', '1');
31 31
 
32 32
 require '../../main.inc.php';
33 33
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
42 42
 
43 43
 // Registering the location of boxes
44
-if (isset($_GET['action']) && ! empty($_GET['action']))
44
+if (isset($_GET['action']) && !empty($_GET['action']))
45 45
 {
46 46
 	if ($_GET['action'] == 'getrandompassword' && $user->admin)
47 47
 	{
Please login to merge, or discard this patch.
Braces   +22 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,13 +21,28 @@
 block discarded – undo
21 21
  *                   like key to use into URL to protect them.
22 22
  */
23 23
 
24
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
25
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
26
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
27
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
28
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
29
-if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
30
-if (! defined('NOREQUIREHOOK'))  define('NOREQUIREHOOK','1');
24
+if (! defined('NOTOKENRENEWAL')) {
25
+	define('NOTOKENRENEWAL','1');
26
+}
27
+// Disables token renewal
28
+if (! defined('NOREQUIREMENU')) {
29
+	define('NOREQUIREMENU','1');
30
+}
31
+if (! defined('NOREQUIREHTML')) {
32
+	define('NOREQUIREHTML','1');
33
+}
34
+if (! defined('NOREQUIREAJAX')) {
35
+	define('NOREQUIREAJAX','1');
36
+}
37
+if (! defined('NOREQUIRESOC')) {
38
+	define('NOREQUIRESOC','1');
39
+}
40
+if (! defined('NOREQUIRETRAN')) {
41
+	define('NOREQUIRETRAN','1');
42
+}
43
+if (! defined('NOREQUIREHOOK')) {
44
+	define('NOREQUIREHOOK','1');
45
+}
31 46
 
32 47
 require '../../main.inc.php';
33 48
 
Please login to merge, or discard this patch.
htdocs/core/ajax/check_notifications.php 3 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -46,73 +46,73 @@
 block discarded – undo
46 46
 // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
47 47
 if ($time >= $_SESSION['auto_check_events_not_before']) 
48 48
 {
49
-    $time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY;   // Always defined
50
-    if (! empty($_SESSION['auto_check_events_not_before'])) 
51
-    {
52
-        // We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer),
53
-        // then we are not losing periods 
54
-        $starttime = $_SESSION['auto_check_events_not_before'];
55
-        // Protection to avoid too long sessions
56
-        if ($starttime < ($time - (int) $conf->global->MAIN_SESSION_TIMEOUT)) 
57
-        {
58
-            dol_syslog("We ask to check browser notification on a too large period. We fix this with current date.");
59
-            $starttime = $time;
60
-        }
61
-    }
62
-    else 
63
-    {
64
-        $starttime = $time;
65
-    }
49
+	$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY;   // Always defined
50
+	if (! empty($_SESSION['auto_check_events_not_before'])) 
51
+	{
52
+		// We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer),
53
+		// then we are not losing periods 
54
+		$starttime = $_SESSION['auto_check_events_not_before'];
55
+		// Protection to avoid too long sessions
56
+		if ($starttime < ($time - (int) $conf->global->MAIN_SESSION_TIMEOUT)) 
57
+		{
58
+			dol_syslog("We ask to check browser notification on a too large period. We fix this with current date.");
59
+			$starttime = $time;
60
+		}
61
+	}
62
+	else 
63
+	{
64
+		$starttime = $time;
65
+	}
66 66
     
67
-    $_SESSION['auto_check_events_not_before'] = $time + $time_update;
67
+	$_SESSION['auto_check_events_not_before'] = $time + $time_update;
68 68
     
69
-    // Force save of session change we did. 
70
-    // WARNING: Any change in sessions after that will not be saved !
71
-    session_write_close();
69
+	// Force save of session change we did. 
70
+	// WARNING: Any change in sessions after that will not be saved !
71
+	session_write_close();
72 72
     
73
-    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
73
+	require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
74 74
 	
75 75
     
76
-    dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']);
76
+	dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']);
77 77
     
78
-    $sql = 'SELECT id';
79
-    $sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm a, ' . MAIN_DB_PREFIX . 'actioncomm_resources ar';
80
-    $sql .= ' WHERE a.id = ar.fk_actioncomm';
81
-    // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
82
-    // This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet).
83
-    $sql .= " AND datep BETWEEN '" . $db->idate($starttime) . "' AND '" . $db->idate($time + $time_update - 1) . "'";
84
-    $sql .= ' AND a.code <> "AC_OTH_AUTO"';
85
-    $sql .= ' AND ar.element_type = "user"';
86
-    $sql .= ' AND ar.fk_element = ' . $user->id;
87
-    $sql .= ' LIMIT 10';    // Avoid too many notification at once
88
-
89
-    $resql = $db->query($sql);
90
-    if ($resql) {
91
-
92
-        $actionmod = new ActionComm($db);
93
-
94
-        while ($obj = $db->fetch_object($resql)) 
95
-        {
96
-            $langs->load("agenda");
97
-            $langs->load("commercial");
78
+	$sql = 'SELECT id';
79
+	$sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm a, ' . MAIN_DB_PREFIX . 'actioncomm_resources ar';
80
+	$sql .= ' WHERE a.id = ar.fk_actioncomm';
81
+	// TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
82
+	// This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet).
83
+	$sql .= " AND datep BETWEEN '" . $db->idate($starttime) . "' AND '" . $db->idate($time + $time_update - 1) . "'";
84
+	$sql .= ' AND a.code <> "AC_OTH_AUTO"';
85
+	$sql .= ' AND ar.element_type = "user"';
86
+	$sql .= ' AND ar.fk_element = ' . $user->id;
87
+	$sql .= ' LIMIT 10';    // Avoid too many notification at once
88
+
89
+	$resql = $db->query($sql);
90
+	if ($resql) {
91
+
92
+		$actionmod = new ActionComm($db);
93
+
94
+		while ($obj = $db->fetch_object($resql)) 
95
+		{
96
+			$langs->load("agenda");
97
+			$langs->load("commercial");
98 98
             
99
-            $actionmod->fetch($obj->id);
100
-
101
-            // Message must be formated and translated to be used with javascript directly
102
-            $event = array();
103
-            $event['type'] = 'agenda';
104
-            $event['id'] = $actionmod->id;
105
-            $event['tipo'] = $langs->transnoentities('Action' . $actionmod->code);
106
-            $event['titulo'] = $actionmod->label;
107
-            $event['location'] = $langs->transnoentities('Location').': '.$actionmod->location;
99
+			$actionmod->fetch($obj->id);
100
+
101
+			// Message must be formated and translated to be used with javascript directly
102
+			$event = array();
103
+			$event['type'] = 'agenda';
104
+			$event['id'] = $actionmod->id;
105
+			$event['tipo'] = $langs->transnoentities('Action' . $actionmod->code);
106
+			$event['titulo'] = $actionmod->label;
107
+			$event['location'] = $langs->transnoentities('Location').': '.$actionmod->location;
108 108
             
109
-            $eventfound[] = $event;
110
-        }
111
-    }
112
-    else
113
-    {
114
-        dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR);
115
-    }
109
+			$eventfound[] = $event;
110
+		}
111
+	}
112
+	else
113
+	{
114
+		dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR);
115
+	}
116 116
 
117 117
 }
118 118
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
  */
18 18
 
19
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
20
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
21
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
22
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
23
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
19
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
20
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
21
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1');
22
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
23
+if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
24 24
 
25 25
 require '../../main.inc.php';
26 26
 
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
  * View
30 30
  */
31 31
 
32
-top_httphead('text/html');  // TODO Use a json mime type
32
+top_httphead('text/html'); // TODO Use a json mime type
33 33
 
34 34
 global $user, $db, $langs, $conf;
35 35
 
36
-$time = (int) GETPOST('time','int');    // Use the time parameter that is always increased by time_update, even if call is late
36
+$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late
37 37
 //$time=dol_now();
38 38
 
39 39
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
47 47
 if ($time >= $_SESSION['auto_check_events_not_before']) 
48 48
 {
49
-    $time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY;   // Always defined
50
-    if (! empty($_SESSION['auto_check_events_not_before'])) 
49
+    $time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined
50
+    if (!empty($_SESSION['auto_check_events_not_before'])) 
51 51
     {
52 52
         // We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer),
53 53
         // then we are not losing periods 
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
     dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']);
77 77
     
78 78
     $sql = 'SELECT id';
79
-    $sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm a, ' . MAIN_DB_PREFIX . 'actioncomm_resources ar';
79
+    $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm a, '.MAIN_DB_PREFIX.'actioncomm_resources ar';
80 80
     $sql .= ' WHERE a.id = ar.fk_actioncomm';
81 81
     // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
82 82
     // This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet).
83
-    $sql .= " AND datep BETWEEN '" . $db->idate($starttime) . "' AND '" . $db->idate($time + $time_update - 1) . "'";
83
+    $sql .= " AND datep BETWEEN '".$db->idate($starttime)."' AND '".$db->idate($time + $time_update - 1)."'";
84 84
     $sql .= ' AND a.code <> "AC_OTH_AUTO"';
85 85
     $sql .= ' AND ar.element_type = "user"';
86
-    $sql .= ' AND ar.fk_element = ' . $user->id;
87
-    $sql .= ' LIMIT 10';    // Avoid too many notification at once
86
+    $sql .= ' AND ar.fk_element = '.$user->id;
87
+    $sql .= ' LIMIT 10'; // Avoid too many notification at once
88 88
 
89 89
     $resql = $db->query($sql);
90 90
     if ($resql) {
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             $event = array();
103 103
             $event['type'] = 'agenda';
104 104
             $event['id'] = $actionmod->id;
105
-            $event['tipo'] = $langs->transnoentities('Action' . $actionmod->code);
105
+            $event['tipo'] = $langs->transnoentities('Action'.$actionmod->code);
106 106
             $event['titulo'] = $actionmod->label;
107 107
             $event['location'] = $langs->transnoentities('Location').': '.$actionmod->location;
108 108
             
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,11 +16,22 @@  discard block
 block discarded – undo
16 16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
  */
18 18
 
19
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
20
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
21
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
22
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
23
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
19
+if (! defined('NOTOKENRENEWAL')) {
20
+	define('NOTOKENRENEWAL','1');
21
+}
22
+// Disables token renewal
23
+if (! defined('NOREQUIREMENU')) {
24
+	define('NOREQUIREMENU','1');
25
+}
26
+if (! defined('NOREQUIREHTML')) {
27
+	define('NOREQUIREHTML','1');
28
+}
29
+if (! defined('NOREQUIREAJAX')) {
30
+	define('NOREQUIREAJAX','1');
31
+}
32
+if (! defined('NOREQUIRESOC')) {
33
+	define('NOREQUIRESOC','1');
34
+}
24 35
 
25 36
 require '../../main.inc.php';
26 37
 
@@ -58,8 +69,7 @@  discard block
 block discarded – undo
58 69
             dol_syslog("We ask to check browser notification on a too large period. We fix this with current date.");
59 70
             $starttime = $time;
60 71
         }
61
-    }
62
-    else 
72
+    } else 
63 73
     {
64 74
         $starttime = $time;
65 75
     }
@@ -108,8 +118,7 @@  discard block
 block discarded – undo
108 118
             
109 119
             $eventfound[] = $event;
110 120
         }
111
-    }
112
-    else
121
+    } else
113 122
     {
114 123
         dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR);
115 124
     }
Please login to merge, or discard this patch.