Completed
Branch develop (372487)
by
unknown
26:45
created
htdocs/core/ajax/ajaxextrafield.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 }
41 41
 
42 42
 include '../../main.inc.php';
43
-include_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
43
+include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
44 44
 /**
45 45
  * @var Conf $conf
46 46
  * @var DoliDB $db
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 // Load object according to $element
70 70
 $object = fetchObjectByElement($objectid, $objecttype, $element_ref);
71 71
 if (empty($object->element)) {
72
-	httponly_accessforbidden('Failed to get object with fetchObjectByElement(id=' . $objectid . ', objecttype=' . $objecttype . ')');
72
+	httponly_accessforbidden('Failed to get object with fetchObjectByElement(id='.$objectid.', objecttype='.$objecttype.')');
73 73
 }
74 74
 
75 75
 $module = $object->module;
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 		// 7 : sort field (not used here but used into format for commobject)
128 128
 
129 129
 		// If there is a filter, we extract it by taking all content inside parenthesis.
130
-		if (! empty($InfoFieldList[4])) {
131
-			$pos = 0;	// $pos will be position of ending filter
130
+		if (!empty($InfoFieldList[4])) {
131
+			$pos = 0; // $pos will be position of ending filter
132 132
 			$parenthesisopen = 0;
133 133
 			while (substr($InfoFieldList[4], $pos, 1) !== '' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) != ':')) {
134 134
 				if (substr($InfoFieldList[4], $pos, 1) == '(') {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			// Fix better compatibility with some old extrafield syntax filter "(field=123)"
151 151
 			$reg = array();
152 152
 			if (preg_match('/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
153
-				$InfoFieldList[4] = '(' . $reg[1] . ':' . $reg[2] . ':' . $reg[3] . ')';
153
+				$InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')';
154 154
 			}
155 155
 
156 156
 			//var_dump($InfoFieldList);
@@ -158,17 +158,17 @@  discard block
 block discarded – undo
158 158
 
159 159
 		$parentName = '';
160 160
 		$parentField = '';
161
-		$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid');
161
+		$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
162 162
 
163 163
 		if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
164 164
 			list($parentName, $parentField) = explode('|', $InfoFieldList[3]);
165
-			$keyList .= ', ' . $parentField;
165
+			$keyList .= ', '.$parentField;
166 166
 		}
167 167
 		if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
168 168
 			if (strpos($InfoFieldList[4], 'extra.') !== false) {
169
-				$keyList = 'main.' . $InfoFieldList[2] . ' as rowid';
169
+				$keyList = 'main.'.$InfoFieldList[2].' as rowid';
170 170
 			} else {
171
-				$keyList = $InfoFieldList[2] . ' as rowid';
171
+				$keyList = $InfoFieldList[2].' as rowid';
172 172
 			}
173 173
 		}
174 174
 
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 			}
188 188
 
189 189
 			$sqlwhere = '';
190
-			$sql = "SELECT " . $keyList;
191
-			$sql .= ' FROM ' . $db->prefix() . $InfoFieldList[0];
190
+			$sql = "SELECT ".$keyList;
191
+			$sql .= ' FROM '.$db->prefix().$InfoFieldList[0];
192 192
 
193 193
 			// Add filter from 4th field
194 194
 			if (!empty($InfoFieldList[4])) {
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 				// We have to filter on a field of the extrafield table
232 232
 				$errstr = '';
233 233
 				if (strpos($InfoFieldList[4], 'extra.') !== false) {
234
-					$sql .= ' as main, ' . $db->sanitize($db->prefix() . $InfoFieldList[0]) . '_extrafields as extra';	// Add the join
235
-					$sqlwhere .= " WHERE extra.fk_object = main." . $db->sanitize($InfoFieldList[2]);
236
-					$sqlwhere .= " AND " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1);	// Add the filter
234
+					$sql .= ' as main, '.$db->sanitize($db->prefix().$InfoFieldList[0]).'_extrafields as extra'; // Add the join
235
+					$sqlwhere .= " WHERE extra.fk_object = main.".$db->sanitize($InfoFieldList[2]);
236
+					$sqlwhere .= " AND ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); // Add the filter
237 237
 				} else {
238
-					$sqlwhere .= " WHERE " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1);
238
+					$sqlwhere .= " WHERE ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1);
239 239
 				}
240 240
 			} else {
241 241
 				$sqlwhere .= ' WHERE 1=1';
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 
244 244
 			// Some tables may have field, some other not. For the moment we disable it.
245 245
 			if (in_array($InfoFieldList[0], array('tablewithentity'))) {
246
-				$sqlwhere .= ' AND entity = ' . ((int) $conf->entity);
246
+				$sqlwhere .= ' AND entity = '.((int) $conf->entity);
247 247
 			}
248 248
 			if ($search) {
249 249
 				if ($fields_label) {
250
-					$sqlwhere .= " " . natural_search($fields_label, $search, 0);
250
+					$sqlwhere .= " ".natural_search($fields_label, $search, 0);
251 251
 				}
252 252
 			}
253 253
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 					if (count($fields_label) > 1) {
279 279
 						$notrans = true;
280 280
 						foreach ($fields_label as $field_toshow) {
281
-							$labeltoshow .= $obj->$field_toshow . ' ';
281
+							$labeltoshow .= $obj->$field_toshow.' ';
282 282
 						}
283 283
 					} else {
284 284
 						$labeltoshow = $obj->{$InfoFieldList[1]};
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 						if (!$notrans) {
289 289
 							foreach ($fields_label as $field_toshow) {
290 290
 								$translabel = $langs->trans($obj->$field_toshow);
291
-								$labeltoshow = $translabel . ' ';
291
+								$labeltoshow = $translabel.' ';
292 292
 							}
293 293
 						}
294 294
 						// $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 				}
326 326
 				$db->free($resql);
327 327
 			} else {
328
-				dol_syslog('Error in request ' . $db->lasterror() . '. Check setup of extra parameters.', LOG_ERR);
328
+				dol_syslog('Error in request '.$db->lasterror().'. Check setup of extra parameters.', LOG_ERR);
329 329
 			}
330 330
 		} else {
331
-			require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
332
-			require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
331
+			require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
332
+			require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
333 333
 		}
334 334
 	}
335 335
 }
Please login to merge, or discard this patch.