Completed
Branch develop (3ab0d1)
by
unknown
27:27
created
htdocs/admin/remotestore/class/externalModules.class.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
 		$this->url       = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace';
150 150
 
151 151
 		// For dolistore modules
152
-		$this->dolistore_api_url = getDolGlobalString('MAIN_MODULE_DOLISTORE_API_SRV', 'https://www.dolistore.com/api/');	// 'https://www.dolistore.com/api/', 'https://admin2.dolibarr.org/api/index.php/marketplace/'
152
+		$this->dolistore_api_url = getDolGlobalString('MAIN_MODULE_DOLISTORE_API_SRV', 'https://www.dolistore.com/api/'); // 'https://www.dolistore.com/api/', 'https://admin2.dolibarr.org/api/index.php/marketplace/'
153 153
 		$this->dolistore_api_key = getDolGlobalString('MAIN_MODULE_DOLISTORE_API_KEY', 'dolistorepublicapi');
154
-		$this->shop_url  = getDolGlobalString('MAIN_MODULE_DOLISTORE_SHOP_URL', 'https://www.dolistore.com');
154
+		$this->shop_url = getDolGlobalString('MAIN_MODULE_DOLISTORE_SHOP_URL', 'https://www.dolistore.com');
155 155
 
156 156
 		// For community modules
157 157
 		$this->file_source_url = "https://raw.githubusercontent.com/Dolibarr/dolibarr-community-modules/refs/heads/main/index.yaml";
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 			$httpheader[] = 'Authorization: Basic '.base64_encode($basicAuthLogin.':'.$basicAuthPassword);
216 216
 		}
217 217
 
218
-		$url = $this->dolistore_api_url . (preg_match('/\/$/', $this->dolistore_api_url) ? '' : '/') . $resource;
218
+		$url = $this->dolistore_api_url.(preg_match('/\/$/', $this->dolistore_api_url) ? '' : '/').$resource;
219 219
 
220 220
 		$options['apikey'] = $this->dolistore_api_key;
221 221
 
222 222
 		if ($options) {
223
-			$url .= '?' . http_build_query($options);
223
+			$url .= '?'.http_build_query($options);
224 224
 		}
225 225
 
226 226
 		$response = getURLContent($url, 'GET', '', 1, $httpheader, array('https'), 0, -1, 5, 5);
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 		$modules = array();
263 263
 
264 264
 		if (!empty($this->cache_file) && file_exists($this->cache_file)) {
265
-			dol_syslog(__METHOD__ . " - Loading cache file: " . $this->cache_file, LOG_DEBUG);
265
+			dol_syslog(__METHOD__." - Loading cache file: ".$this->cache_file, LOG_DEBUG);
266 266
 
267 267
 			$content = file_get_contents($this->cache_file);
268 268
 			if ($content !== false) {
269 269
 				$modules = $this->readYaml($content);
270 270
 			} else {
271
-				dol_syslog(__METHOD__ . " - Error reading cache file", LOG_ERR);
271
+				dol_syslog(__METHOD__." - Error reading cache file", LOG_ERR);
272 272
 			}
273 273
 		}
274 274
 
@@ -296,20 +296,20 @@  discard block
 block discarded – undo
296 296
 		if (isset($resCategories['response']) && is_array($resCategories['response'])) {
297 297
 			$organized_tree = $resCategories['response'];
298 298
 		} else {
299
-			return $html ;
299
+			return $html;
300 300
 		}
301 301
 
302 302
 		$html = '';
303 303
 		foreach ($organized_tree as $key => $value) {
304 304
 			if ($value['label'] != "Versions" && $value['label'] != "Specials") {
305
-				$html .= '<li' . ($current == $value['rowid'] ? ' class="active"' : '') . '>';
306
-				$html .= '<a href="?mode=marketplace&categorie=' . $value['rowid'] . '">' . $value['label'] . '</a>';
305
+				$html .= '<li'.($current == $value['rowid'] ? ' class="active"' : '').'>';
306
+				$html .= '<a href="?mode=marketplace&categorie='.$value['rowid'].'">'.$value['label'].'</a>';
307 307
 				if (isset($value['children'])) {
308 308
 					$html .= '<ul>';
309 309
 					usort($value['children'], $this->buildSorter('position'));
310 310
 					foreach ($value['children'] as $key_children => $value_children) {
311
-						$html .= '<li' . ($current == $value_children['rowid'] ? ' class="active"' : '') . '>';
312
-						$html .= '<a href="?mode=marketplace&categorie=' . $value_children['rowid'] . '" title="' . dol_escape_htmltag(strip_tags($value_children['description'])) . '">' . $value_children['label'] . '</a>';
311
+						$html .= '<li'.($current == $value_children['rowid'] ? ' class="active"' : '').'>';
312
+						$html .= '<a href="?mode=marketplace&categorie='.$value_children['rowid'].'" title="'.dol_escape_htmltag(strip_tags($value_children['description'])).'">'.$value_children['label'].'</a>';
313 313
 						$html .= '</li>';
314 314
 					}
315 315
 					$html .= '</ul>';
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 
335 335
 		$html       = "";
336 336
 		$last_month = dol_now() - (30 * 24 * 60 * 60);
337
-		$dolibarrversiontouse = DOL_VERSION;	// full string with version
337
+		$dolibarrversiontouse = DOL_VERSION; // full string with version
338 338
 
339 339
 		$this->products = array();
340 340
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$this->no_page  = $options['no_page'] ?? 1;
344 344
 		$this->search    = $options['search'] ?? '';
345 345
 
346
-		$this->per_page = 11;	// We fix number of products per page to 11
346
+		$this->per_page = 11; // We fix number of products per page to 11
347 347
 
348 348
 		// Length of $search must be at least 2 characters
349 349
 		if (!empty($this->search) && strlen(str_replace(' ', '', (string) $this->search)) < 2) {
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 		$fileProducts = array();
405 405
 		$fileProductsTotal = 0;
406 406
 		if (!empty($this->githubFileStatus) && getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_COMMUNITY')) {
407
-			$fileProducts = $this->fetchModulesFromFile($data);			// Return an array with all modules from the cache filecontent in $data
407
+			$fileProducts = $this->fetchModulesFromFile($data); // Return an array with all modules from the cache filecontent in $data
408 408
 
409 409
 			$fileProducts = $this->adaptData($fileProducts, 'githubcommunity');
410 410
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 					$download_link .= img_picto('', 'file-code', 'class="size2x paddingright colorgrey"');
496 496
 					$download_link .= '</a>';
497 497
 
498
-					$urlview = $product["dolistore-download"];		// In a future, we will have the download to the zip file
498
+					$urlview = $product["dolistore-download"]; // In a future, we will have the download to the zip file
499 499
 					if ($urlview) {
500 500
 						$download_link .= '<a class="paddingleft paddingright" target="_blank" title="'.$langs->trans("View").'" href="'.$urlview.'" rel="noopener noreferrer">';
501 501
 						$download_link .= img_picto('', 'url', 'class="size2x"');
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 					}
515 515
 				} elseif ($product['source'] === 'dolistore') {
516 516
 					$urlview = $this->shop_url.'/product.php?id='.((int) $product["id"]);
517
-					$urldownload = 'https://www.dolistore.com/_service_download.php?t=free&p=' . $product['id'];
517
+					$urldownload = 'https://www.dolistore.com/_service_download.php?t=free&p='.$product['id'];
518 518
 					$download_link = '<a class="paddingleft paddingright" target="_blank" title="'.$langs->trans("View").'" href="'.$urlview.'">';
519 519
 					$download_link .= img_picto('', 'url', 'class="size2x"');
520 520
 					$download_link .= '</a>';
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 
579 579
 			// Logo
580 580
 			$html .= '<td class="center width150"><div class="newAppParent">';
581
-			$html .= $newapp.$images;	// No dol_escape_htmltag, it is already escape html
581
+			$html .= $newapp.$images; // No dol_escape_htmltag, it is already escape html
582 582
 			$html .= '</div></td>';
583 583
 
584 584
 			// Description
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 				$html .= '</small>';
595 595
 			}
596 596
 			$html .= '<br><small>';
597
-			$html .= $version;			// Version Dolibarr. No dol_escape_htmltag, it is already escape html
597
+			$html .= $version; // Version Dolibarr. No dol_escape_htmltag, it is already escape html
598 598
 			$html .= '</small>';
599 599
 			$html .= '</h2>';
600 600
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 		 * @param array<string, mixed> $b
672 672
 		 * @return int
673 673
 		 */
674
-		function (array $a, array $b) use ($key) {
674
+		function(array $a, array $b) use ($key) {
675 675
 			$valA = isset($a[$key]) && is_scalar($a[$key]) ? (string) $a[$key] : '';
676 676
 			$valB = isset($b[$key]) && is_scalar($b[$key]) ? (string) $b[$key] : '';
677 677
 
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 				$pagelist .= '<li class="pagination">';
833 833
 				$pagelist .= '<label for="page_input">Page </label>';
834 834
 				if ($this->categorie != 0) {
835
-					$pagelist .= '<input type="hidden" name="categorie" value="' . $this->categorie . '">';
835
+					$pagelist .= '<input type="hidden" name="categorie" value="'.$this->categorie.'">';
836 836
 				}
837 837
 				$pagelist .= '<input type="text" id="page_input" name="no_page" value="'.($page).'" min="1" max="'.$nbpages.'" class="width40 page_input right" oninput="if(this.value > '.$nbpages.') this.value='.$nbpages.'">';
838 838
 				$pagelist .= ' / '.$nbpages;
@@ -882,17 +882,17 @@  discard block
 block discarded – undo
882 882
 		}
883 883
 
884 884
 		// Get the predefined error message or use a default one
885
-		$error_message = $error_messages[$request['status_code']] ?? 'Unexpected HTTP status: ' . $request['status_code'];
885
+		$error_message = $error_messages[$request['status_code']] ?? 'Unexpected HTTP status: '.$request['status_code'];
886 886
 
887 887
 		// Append error details if available
888 888
 		if (!empty($request['response']) && isset($request['response']['errors']) && is_array($request['response']['errors'])) {
889 889
 			foreach ($request['response']['errors'] as $error) {
890
-				$error_message .= ' - (Code ' . $error['code'] . '): ' . $error['message'];
890
+				$error_message .= ' - (Code '.$error['code'].'): '.$error['message'];
891 891
 			}
892 892
 		}
893 893
 
894 894
 		if (!empty($request['curl_error_msg'])) {
895
-			$error_message .= ' - ' . $request['curl_error_msg'];
895
+			$error_message .= ' - '.$request['curl_error_msg'];
896 896
 		}
897 897
 
898 898
 		// Return the formatted error message
@@ -920,12 +920,12 @@  discard block
 block discarded – undo
920 920
 		if (!file_exists($cache_file) || filemtime($cache_file) < (dol_now() - $cache_time)) {
921 921
 			// We get remote url
922 922
 			$addheaders = array();
923
-			$result = getURLContent($file_source_url, 'GET', '', 1, $addheaders);	// TODO Force timeout to 5 s on both connect and response.
923
+			$result = getURLContent($file_source_url, 'GET', '', 1, $addheaders); // TODO Force timeout to 5 s on both connect and response.
924 924
 			if (!empty($result) && $result['http_code'] == 200) {
925 925
 				$yaml = $result['content'];
926 926
 				$result = file_put_contents($cache_file, $yaml);
927 927
 				if ($result === false) {
928
-					$this->error = 'Failed to create cache file: ' . $cache_file;
928
+					$this->error = 'Failed to create cache file: '.$cache_file;
929 929
 				}
930 930
 			}
931 931
 		} else {
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 
1038 1038
 				$adaptedPackage = [
1039 1039
 					'id' => $id,
1040
-					'ref' => str_replace(' ', '', $package['modulename'] . '-' . $package['current_version'] . '@' .
1040
+					'ref' => str_replace(' ', '', $package['modulename'].'-'.$package['current_version'].'@'.
1041 1041
 						(array_key_exists('author', $package) ? $package['author'] : 'unkownauthor')),
1042 1042
 					'label' => !empty($package['label'][substr($this->lang, 0, 2)])
1043 1043
 						? $package['label'][substr($this->lang, 0, 2)]
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 			 *
1154 1154
 			 * @return int
1155 1155
 			 */
1156
-			static function ($a, $b) {
1156
+			static function($a, $b) {
1157 1157
 				return strtotime($b['datec'] ?? '0') - strtotime($a['datec'] ?? '0');
1158 1158
 			}
1159 1159
 		);
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 				 *
1169 1169
 				 * @return bool
1170 1170
 				 */
1171
-				static function ($package) use ($options) {
1171
+				static function($package) use ($options) {
1172 1172
 					return stripos($package['label'], $options['search']) !== false || stripos($package['description'], $options['search']) !== false;
1173 1173
 				}
1174 1174
 			);
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 				 *
1185 1185
 				 * @return bool
1186 1186
 				 */
1187
-				static function ($package) use ($options) {
1187
+				static function($package) use ($options) {
1188 1188
 					return in_array($options['categorieid'], $package['category']);
1189 1189
 				}
1190 1190
 			);
Please login to merge, or discard this patch.
htdocs/user/class/api_users.class.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -347,8 +347,9 @@
 block discarded – undo
347 347
 		}
348 348
 
349 349
 		// check mandatory fields
350
-		if (!isset($request_data["login"]))
351
-			throw new RestException(500, "login field missing");
350
+		if (!isset($request_data["login"])) {
351
+					throw new RestException(500, "login field missing");
352
+		}
352 353
 		/*if (!isset($request_data["password"]))
353 354
 			throw new RestException(400, "password field missing");
354 355
 		if (!isset($request_data["lastname"]))
Please login to merge, or discard this patch.