Skip to content

Commit 7c5857d

Browse files
committed
Minor: Format code
1 parent 7e95c3d commit 7c5857d

34 files changed

+1648
-1643
lines changed

main/admin/add_users_to_usergroup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ function showLastTenUsers() {
191191
'id' => $user['id'],
192192
'username' => $user['username'],
193193
'firstname' => $user['firstname'],
194-
'lastname' => $user['lastname']
194+
'lastname' => $user['lastname'],
195195
];
196196
}
197197

198198
header('Content-Type: application/json');
199199
echo json_encode($users);
200-
die();
200+
exit();
201201
}
202202

203203
$first_letter_user = '';
@@ -528,7 +528,7 @@ function formatCompleteName(array $userInfo, bool $orderListByOfficialCode): str
528528
</button>
529529
</span>
530530
<span class="input-group-btn">
531-
<button class="btn btn-default" type="button" id="show_last_ten_users_button" title="<?php echo get_lang('ShowLastTenUsers') ?>">
531+
<button class="btn btn-default" type="button" id="show_last_ten_users_button" title="<?php echo get_lang('ShowLastTenUsers'); ?>">
532532
<i class="fa fa-clock-o"></i>
533533
</button>
534534
</span>

main/admin/db.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
/* For licensing terms, see /license.txt */
44

55
require_once __DIR__.'/../inc/global.inc.php';
6+
67
if (!api_is_global_platform_admin()) {
7-
die('Please connect as a global administrator to access this page');
8+
exit('Please connect as a global administrator to access this page');
89
}
10+
911
echo "In this version, the script allowing you to connect to the database from your Chamilo interface has been
1012
deprecated/removed due to increasing reports about a possible vulnerability (which we agree with, in principle).
1113
To use this feature, please download Adminer as one single PHP file from https://www.adminer.org/#download,

main/auth/sort_my_courses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'deletecoursecategory',
2020
'createcoursecategory',
2121
'set_collapsable',
22-
'unsubscribe'
22+
'unsubscribe',
2323
];
2424
if (in_array(trim($_REQUEST['action']), $authorizedActions)) {
2525
$action = trim($_REQUEST['action']);

main/coursecopy/export_moodle.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/**
1010
* Create a Moodle export.
11-
*
1211
*/
1312
require_once __DIR__.'/../inc/global.inc.php';
1413
require_once api_get_path(SYS_PATH).'main/work/work.lib.php';
@@ -72,7 +71,7 @@
7271

7372
// Perform export
7473
$courseId = api_get_course_id();
75-
$exportDir = 'moodle_export_' . $courseId;
74+
$exportDir = 'moodle_export_'.$courseId;
7675
try {
7776
$moodleVersion = isset($_POST['moodle_version']) ? (int) $_POST['moodle_version'] : 3;
7877
$mbzFile = $exporter->export($courseId, $exportDir, $moodleVersion);
@@ -135,7 +134,7 @@
135134
$exporter->setAdminUserData($adminId, $adminUsername, $adminEmail);
136135

137136
$courseId = api_get_course_id(); // Get course ID
138-
$exportDir = 'moodle_export_' . $courseId;
137+
$exportDir = 'moodle_export_'.$courseId;
139138

140139
try {
141140
$moodleVersion = isset($values['moodle_version']) ? $values['moodle_version'] : '3';

main/inc/ajax/session_clock.ajax.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
$session = new ChamiloSession();
2929

30-
$endTime = 0;
30+
$endTime = 0;
3131
$isExpired = false;
3232
$timeLeft = -1;
3333

@@ -44,9 +44,8 @@
4444
}
4545

4646
$timeLeft = $endTime - $currentTime;
47-
}
48-
else {
49-
$endTime = 999999;
47+
} else {
48+
$endTime = 999999;
5049
$isExpired = false;
5150
$timeLeft = 999999;
5251
}
@@ -72,4 +71,4 @@
7271
// No action provided
7372
http_response_code(400);
7473
echo json_encode(['error' => 'No action parameter provided']);
75-
}
74+
}

main/inc/lib/Compilatio.php

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ class Compilatio
1515
{
1616
/** Identification key for the Compilatio account*/
1717
public $key;
18+
19+
/**
20+
* @var Client
21+
*/
22+
public $client;
1823
/**
1924
* @var string
2025
*/
@@ -24,11 +29,6 @@ class Compilatio
2429
private $proxyHost;
2530
private $proxyPort;
2631

27-
/**
28-
* @var Client
29-
*/
30-
public $client;
31-
3232
/**
3333
* Compilatio constructor.
3434
*
@@ -62,36 +62,6 @@ public function __construct()
6262
$this->client = new Client($clientConfig);
6363
}
6464

65-
/**
66-
* @throws Exception
67-
*/
68-
protected function getSettings(): array
69-
{
70-
if (empty(api_get_configuration_value('allow_compilatio_tool')) ||
71-
empty(api_get_configuration_value('compilatio_tool'))
72-
) {
73-
throw new Exception('Compilatio not available');
74-
}
75-
76-
$compilatioTool = api_get_configuration_value('compilatio_tool');
77-
78-
if (!isset($compilatioTool['settings'])) {
79-
throw new Exception('Compilatio config available');
80-
}
81-
82-
$settings = $compilatioTool['settings'];
83-
84-
if (empty($settings['key'])) {
85-
throw new Exception('API key not available');
86-
}
87-
88-
if (empty($settings['api_url'])) {
89-
throw new Exception('Api URL not available');
90-
}
91-
92-
return $settings;
93-
}
94-
9565
/**
9666
* @return string
9767
*/
@@ -153,20 +123,20 @@ public function sendDoc(
153123
'filename' => basename($filename),
154124
'indexed' => 'true',
155125
'user_notes' => [
156-
'description' => $description
126+
'description' => $description,
157127
],
158128
'authors' => [
159129
[
160130
'firstname' => $user->getFirstname(),
161131
'lastname' => $user->getlastname(),
162132
'email_address' => $user->getEmail(),
163-
]
133+
],
164134
],
165135
'depositor' => [
166136
'firstname' => $user->getFirstname(),
167137
'lastname' => $user->getlastname(),
168138
'email_address' => $user->getEmail(),
169-
]
139+
],
170140
];
171141

172142
try {
@@ -176,14 +146,14 @@ public function sendDoc(
176146
[
177147
'multipart' => [
178148
[
179-
'name' => 'postData',
180-
'contents' => json_encode($postData)
149+
'name' => 'postData',
150+
'contents' => json_encode($postData),
181151
],
182152
[
183-
'name' => 'file',
153+
'name' => 'file',
184154
'contents' => Utils::tryFopen($filepath, 'r'),
185-
]
186-
]
155+
],
156+
],
187157
]
188158
)
189159
->getBody()
@@ -238,7 +208,6 @@ public function getDoc(string $documentId): array
238208
*/
239209
public function deldoc(string $documentId)
240210
{
241-
242211
}
243212

244213
/**
@@ -255,7 +224,7 @@ public function startAnalyse(string $compilatioId): string
255224
[
256225
'json' => [
257226
'doc_id' => $compilatioId,
258-
'recipe_name' => 'anasim'
227+
'recipe_name' => 'anasim',
259228
],
260229
]
261230
)
@@ -332,7 +301,7 @@ public function getCompilatioId(int $documentId, int $courseId): ?string
332301
$result = Database::query($sql);
333302
$result = Database::fetch_object($result);
334303

335-
return $result ? (string)$result->compilatio_id : null;
304+
return $result ? (string) $result->compilatio_id : null;
336305
}
337306

338307
public function giveWorkIdState(int $workId): string
@@ -372,7 +341,7 @@ public function giveWorkIdState(int $workId): string
372341
$actionCompilatio .= "<div style='font-size:80%;font-style:italic;margin-bottom:5px;'>"
373342
.get_lang('CompilatioAnalysisPercentage')
374343
."</div>";
375-
$actionCompilatio .= $spinnerIcon.PHP_EOL .get_lang('CompilatioAnalysisEnding');
344+
$actionCompilatio .= $spinnerIcon.PHP_EOL.get_lang('CompilatioAnalysisEnding');
376345
break;
377346
case 'waiting':
378347
$actionCompilatio .= $spinnerIcon.PHP_EOL.get_lang('CompilatioWaitingAnalysis');
@@ -388,4 +357,34 @@ public function giveWorkIdState(int $workId): string
388357

389358
return $workId.'|'.$actionCompilatio.'|'.$status.'|';
390359
}
360+
361+
/**
362+
* @throws Exception
363+
*/
364+
protected function getSettings(): array
365+
{
366+
if (empty(api_get_configuration_value('allow_compilatio_tool')) ||
367+
empty(api_get_configuration_value('compilatio_tool'))
368+
) {
369+
throw new Exception('Compilatio not available');
370+
}
371+
372+
$compilatioTool = api_get_configuration_value('compilatio_tool');
373+
374+
if (!isset($compilatioTool['settings'])) {
375+
throw new Exception('Compilatio config available');
376+
}
377+
378+
$settings = $compilatioTool['settings'];
379+
380+
if (empty($settings['key'])) {
381+
throw new Exception('API key not available');
382+
}
383+
384+
if (empty($settings['api_url'])) {
385+
throw new Exception('Api URL not available');
386+
}
387+
388+
return $settings;
389+
}
391390
}

0 commit comments

Comments
 (0)