Skip to content

Commit ef2d805

Browse files
committed
Minor: Format code
1 parent 2b202b0 commit ef2d805

36 files changed

+439
-452
lines changed

main/admin/statistics/index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
get_lang('Users') => [
3131
'report=users' => get_lang('CountUsers'),
3232
'report=recentlogins' => get_lang('Logins'),
33-
'report=logins&type=month' => get_lang('Logins') . ' (' . get_lang('PeriodMonth') . ')',
34-
'report=logins&type=day' => get_lang('Logins') . ' (' . get_lang('PeriodDay') . ')',
35-
'report=logins&type=hour' => get_lang('Logins') . ' (' . get_lang('PeriodHour') . ')',
36-
'report=pictures' => get_lang('CountUsers') . ' (' . get_lang('UserPicture') . ')',
33+
'report=logins&type=month' => get_lang('Logins').' ('.get_lang('PeriodMonth').')',
34+
'report=logins&type=day' => get_lang('Logins').' ('.get_lang('PeriodDay').')',
35+
'report=logins&type=hour' => get_lang('Logins').' ('.get_lang('PeriodHour').')',
36+
'report=pictures' => get_lang('CountUsers').' ('.get_lang('UserPicture').')',
3737
'report=logins_by_date' => get_lang('LoginsByDate'),
3838
'report=no_login_users' => get_lang('StatsUsersDidNotLoginInLastPeriods'),
3939
'report=zombies' => get_lang('Zombies'),

main/admin/user_advanced_edit.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
COURSEMANAGER => get_lang('Teacher'),
4848
DRH => get_lang('Drh'),
4949
SESSIONADMIN => get_lang('SessionsAdmin'),
50-
PLATFORM_ADMIN => get_lang('Administrator')
50+
PLATFORM_ADMIN => get_lang('Administrator'),
5151
];
5252
$form->addElement('select', 'keywordStatus', get_lang('Profile'), $statusOptions);
5353

@@ -110,7 +110,7 @@
110110
'official_code' => get_lang('OfficialCode'),
111111
'status' => get_lang('Profile'),
112112
'active' => get_lang('ActiveAccount'),
113-
'password' => get_lang('Password')
113+
'password' => get_lang('Password'),
114114
];
115115

116116
foreach ($extraFields as $field) {
@@ -119,7 +119,7 @@
119119

120120
$form->addElement('select', 'editableFields', get_lang('FieldsToEdit'), $editableFields, [
121121
'multiple' => 'multiple',
122-
'size' => 7
122+
'size' => 7,
123123
]);
124124
$form->addElement('submit', 'filter', get_lang('View'));
125125
}
@@ -151,7 +151,7 @@
151151
'keywordFirstname' => 'firstname',
152152
'keywordLastname' => 'lastname',
153153
'keywordOfficialCode' => 'official_code',
154-
'keywordStatus' => 'status'
154+
'keywordStatus' => 'status',
155155
];
156156

157157
foreach ($filtersUsed as $filterKey => $fieldName) {
@@ -247,7 +247,7 @@
247247

248248
case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
249249
if (is_array($value) && isset($value["extra_{$field}"]) && isset($value["extra_{$field}_second"])) {
250-
$formattedValue = $value["extra_{$field}"] . ',' . $value["extra_{$field}_second"];
250+
$formattedValue = $value["extra_{$field}"].','.$value["extra_{$field}_second"];
251251
} else {
252252
$formattedValue = '';
253253
}
@@ -259,18 +259,16 @@
259259
$row[] = '<input type="text" name="extra_'.$field.'['.$user['id'].']" value="'.$value.'" class="form-control">';
260260
break;
261261
}
262-
}
263-
else {
262+
} else {
264263
if ($field === 'password') {
265264
$row[] = '<input type="password" name="'.$field.'['.$user['id'].']" value="" class="form-control" placeholder="'.get_lang('Password').'">';
266-
}
267-
elseif ($field === 'status') {
265+
} elseif ($field === 'status') {
268266
$statusOptions = [
269267
STUDENT => get_lang('Student'),
270268
COURSEMANAGER => get_lang('Teacher'),
271269
DRH => get_lang('Drh'),
272270
SESSIONADMIN => get_lang('SessionsAdmin'),
273-
PLATFORM_ADMIN => get_lang('Administrator')
271+
PLATFORM_ADMIN => get_lang('Administrator'),
274272
];
275273
$select = '<select name="status['.$user['id'].']" class="form-control">';
276274
foreach ($statusOptions as $key => $label) {
@@ -279,14 +277,12 @@
279277
}
280278
$select .= '</select>';
281279
$row[] = $select;
282-
}
283-
elseif ($field === 'active') {
280+
} elseif ($field === 'active') {
284281
$checkedActive = ($user['active'] == 1) ? 'checked' : '';
285282
$checkedInactive = ($user['active'] == 0) ? 'checked' : '';
286283
$row[] = '<label><input type="radio" name="active['.$user['id'].']" value="1" '.$checkedActive.'> '.get_lang('Active').'</label>
287284
<label><input type="radio" name="active['.$user['id'].']" value="0" '.$checkedInactive.'> '.get_lang('Inactive').'</label>';
288-
}
289-
else {
285+
} else {
290286
$row[] = '<input type="text" name="'.$field.'['.$user['id'].']" value="'.$value.'" class="form-control">';
291287
}
292288
}
@@ -388,5 +384,5 @@ function getUserData(userId) {
388384
$tpl = new Template($tool_name);
389385
$tpl->assign('actions', $toolbarActions);
390386
$tpl->assign('message', $message);
391-
$tpl->assign('content', $formContent . $fieldSelector . $tableResult . (!empty($users) ? '<button class="btn btn-success" id="saveAll">'.get_lang('SaveAll').'</button>' : ''));
387+
$tpl->assign('content', $formContent.$fieldSelector.$tableResult.(!empty($users) ? '<button class="btn btn-success" id="saveAll">'.get_lang('SaveAll').'</button>' : ''));
392388
$tpl->display_one_col_template();

main/admin/user_import.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ function complete_missing_data(array $user): array
258258
*/
259259
function save_data(
260260
array $users,
261-
bool $sendMail = false,
261+
bool $sendMail = false,
262262
?string $targetFolder = null
263263
): array {
264264
global $inserted_in_course, $extra_fields;

main/coursecopy/copy_course_session_selected.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,12 @@ function checkSelected(id_select,id_radio,id_title,id_destination) {
329329
$cr->restore($courseDestination, $destinationSession);
330330
echo Display::return_message(get_lang('CopyFinished'), 'confirmation');
331331
}
332-
333332
} else {
334333
echo Display::return_message(
335334
get_lang('YouMustSelectACourseFromOriginalSession'),
336335
'error'
337336
);
338337
}
339-
340338
}
341339

342340
displayForm();

main/exercise/AnswerInOfficeDoc.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function initFile(int $sessionId, int $userId, int $exerciseId, int $exeI
4646

4747
$this->storePath = $this->generateDirectory();
4848
$this->fileName = $this->generateFileName();
49-
$this->filePath = $this->storePath . $this->fileName;
49+
$this->filePath = $this->storePath.$this->fileName;
5050
}
5151

5252
/**
@@ -62,7 +62,7 @@ public function createAnswersForm($form): void
6262
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', // .docx
6363
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx
6464
'application/msword', // .doc
65-
'application/vnd.ms-excel' // .xls
65+
'application/vnd.ms-excel', // .xls
6666
];
6767

6868
$form->addElement('file', 'office_file', get_lang('UploadOfficeDoc'));
@@ -73,7 +73,7 @@ public function createAnswersForm($form): void
7373
$form->addElement('static', 'file_hint', get_lang('AllowedFormats'), "<p>{$allowedExtensions}</p>");
7474

7575
if (!empty($this->extra)) {
76-
$fileUrl = api_get_path(WEB_COURSE_PATH) . $this->getStoredFilePath();
76+
$fileUrl = api_get_path(WEB_COURSE_PATH).$this->getStoredFilePath();
7777
$form->addElement('static', 'current_office_file', get_lang('CurrentOfficeDoc'), "<a href='{$fileUrl}' target='_blank'>{$this->extra}</a>");
7878
}
7979

@@ -98,8 +98,8 @@ public function processAnswersCreation($form, $exercise): void
9898
{
9999
if (!empty($_FILES['office_file']['name'])) {
100100
$extension = pathinfo($_FILES['office_file']['name'], PATHINFO_EXTENSION);
101-
$tempFilename = "office_" . uniqid() . "." . $extension;
102-
$tempPath = sys_get_temp_dir() . '/' . $tempFilename;
101+
$tempFilename = "office_".uniqid().".".$extension;
102+
$tempPath = sys_get_temp_dir().'/'.$tempFilename;
103103

104104
if (!move_uploaded_file($_FILES['office_file']['tmp_name'], $tempPath)) {
105105
return;
@@ -117,7 +117,7 @@ public function processAnswersCreation($form, $exercise): void
117117
}
118118

119119
$filename = "office_".$this->iid.".".$extension;
120-
$filePath = $uploadDir . $filename;
120+
$filePath = $uploadDir.$filename;
121121

122122
if (!rename($tempPath, $filePath)) {
123123
return;
@@ -128,20 +128,6 @@ public function processAnswersCreation($form, $exercise): void
128128
}
129129
}
130130

131-
/**
132-
* Generate the necessary directory for OnlyOffice documents.
133-
*/
134-
private function generateDirectory(): string
135-
{
136-
$exercisePath = api_get_path(SYS_COURSE_PATH).$this->course['path']."/exercises/onlyoffice/{$this->exerciseId}/{$this->iid}/";
137-
138-
if (!is_dir($exercisePath)) {
139-
mkdir($exercisePath, 0775, true);
140-
}
141-
142-
return rtrim($exercisePath, '/') . '/';
143-
}
144-
145131
/**
146132
* Get the stored file path dynamically.
147133
*/
@@ -184,7 +170,7 @@ public function getFileUrl(bool $loadFromDatabase = false): ?string
184170

185171
$filePath = $this->getStoredFilePath();
186172

187-
if (is_file(api_get_path(SYS_COURSE_PATH) . $filePath)) {
173+
if (is_file(api_get_path(SYS_COURSE_PATH).$filePath)) {
188174
return $filePath;
189175
}
190176

@@ -206,11 +192,25 @@ public function return_header(Exercise $exercise, $counter = null, $score = [])
206192
return $header;
207193
}
208194

195+
/**
196+
* Generate the necessary directory for OnlyOffice documents.
197+
*/
198+
private function generateDirectory(): string
199+
{
200+
$exercisePath = api_get_path(SYS_COURSE_PATH).$this->course['path']."/exercises/onlyoffice/{$this->exerciseId}/{$this->iid}/";
201+
202+
if (!is_dir($exercisePath)) {
203+
mkdir($exercisePath, 0775, true);
204+
}
205+
206+
return rtrim($exercisePath, '/').'/';
207+
}
208+
209209
/**
210210
* Generate the file name for the OnlyOffice document.
211211
*/
212212
private function generateFileName(): string
213213
{
214-
return 'office_' . uniqid();
214+
return 'office_'.uniqid();
215215
}
216216
}

main/exercise/multiple_answer.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ public function createAnswersForm($form)
188188
* Validate question answers before saving.
189189
*
190190
* @param object $form The form object.
191+
*
191192
* @return array|bool True if valid, or an array with errors if invalid.
192193
*/
193194
public function validateAnswers($form)

main/exercise/unique_answer.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ public function setDirectOptions($i, FormValidator $form, $renderer, $select_lp_
337337

338338
/**
339339
* Validate question answers before saving.
340+
*
340341
* @return bool|string True if valid, error message if invalid.
341342
*/
342343
public function validateAnswers($form)
@@ -390,6 +391,7 @@ public function processAnswersCreation($form, $exercise)
390391
$validationResult = $this->validateAnswers($form);
391392
if ($validationResult !== true) {
392393
Display::addFlash(Display::return_message(implode("<br>", $validationResult['errors']), 'error'));
394+
393395
return;
394396
}
395397

main/inc/ajax/document.ajax.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@
268268
$personalDriver = new PersonalDriver();
269269
$uploadResult = $personalDriver->mimeAccepted(mime_content_type($fileUpload['tmp_name']), ['image']);
270270

271-
if (!$uploadResult || !move_uploaded_file($fileUpload['tmp_name'], $syspath . $fileUploadName)) {
271+
if (!$uploadResult || !move_uploaded_file($fileUpload['tmp_name'], $syspath.$fileUploadName)) {
272272
exit;
273273
}
274274

275-
$url = $webpath . $fileUploadName;
275+
$url = $webpath.$fileUploadName;
276276
$relativeUrl = str_replace(api_get_path(WEB_PATH), '/', $url);
277277
$data = [
278278
'uploaded' => 1,

main/inc/ajax/user_manager.ajax.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,13 @@
480480
}
481481

482482
$updatedData = [
483-
'firstname' => $userData['firstname'] ?? $currentUserData['firstname'],
484-
'lastname' => $userData['lastname'] ?? $currentUserData['lastname'],
485-
'email' => $userData['email'] ?? $currentUserData['email'],
486-
'phone' => $userData['phone'] ?? $currentUserData['phone'],
487-
'official_code' => $userData['official_code'] ?? $currentUserData['official_code'],
488-
'status' => isset($userData['status']) ? (int) $userData['status'] : $currentUserData['status'],
489-
'active' => isset($userData['active']) ? (int) $userData['active'] : $currentUserData['active'],
483+
'firstname' => $userData['firstname'] ?? $currentUserData['firstname'],
484+
'lastname' => $userData['lastname'] ?? $currentUserData['lastname'],
485+
'email' => $userData['email'] ?? $currentUserData['email'],
486+
'phone' => $userData['phone'] ?? $currentUserData['phone'],
487+
'official_code' => $userData['official_code'] ?? $currentUserData['official_code'],
488+
'status' => isset($userData['status']) ? (int) $userData['status'] : $currentUserData['status'],
489+
'active' => isset($userData['active']) ? (int) $userData['active'] : $currentUserData['active'],
490490
];
491491

492492
if (!empty($userData['password'])) {

main/inc/lib/PortfolioController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3675,7 +3675,7 @@ private function createFormStudentFilter(bool $listByUser = false, bool $listHig
36753675
}
36763676

36773677
$frmStudentList->addHtml("<p>$link</p>");
3678-
3678+
36793679
if ($listAlphabeticalOrder) {
36803680
$link = Display::url(
36813681
get_lang('BackToDateOrder'),
@@ -3690,7 +3690,6 @@ private function createFormStudentFilter(bool $listByUser = false, bool $listHig
36903690

36913691
$frmStudentList->addHtml("<p>$link</p>");
36923692

3693-
36943693
return $frmStudentList;
36953694
}
36963695

main/inc/lib/agenda.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3045,7 +3045,7 @@ public function getForm($params = [])
30453045
$sessionId = api_get_session_id();
30463046
if ($sessionId) {
30473047
$usersSendTo = SessionManager::getCoachesByCourseSession($sessionId, $currentCourseInfo['real_id']);
3048-
} else {
3048+
} else {
30493049
$courseTeachers = CourseManager::get_teacher_list_from_course_code($currentCourseInfo['code']);
30503050
$courseTeachersUid = [];
30513051
foreach ($courseTeachers as $courseTeacher) {

0 commit comments

Comments
 (0)