@@ -112,8 +112,9 @@ discard block |
||
112 | 112 | */ |
113 | 113 | private function isParentFolderAllowed($parent_id, $user_accessible_folders, $user_is_admin, $user_can_create_root_folder) |
114 | 114 | { |
115 | - if ($parent_id == 0 && $user_can_create_root_folder == true) |
|
116 | - return true; |
|
115 | + if ($parent_id == 0 && $user_can_create_root_folder == true) { |
|
116 | + return true; |
|
117 | + } |
|
117 | 118 | |
118 | 119 | if (in_array($parent_id, $user_accessible_folders) === false |
119 | 120 | && (int) $user_is_admin !== 1 |
@@ -438,8 +439,9 @@ discard block |
||
438 | 439 | )['count']; |
439 | 440 | |
440 | 441 | // Don't insert duplicates |
441 | - if ($count > 0) |
|
442 | - continue; |
|
442 | + if ($count > 0) { |
|
443 | + continue; |
|
444 | + } |
|
443 | 445 | |
444 | 446 | // Insert new background task |
445 | 447 | DB::insert( |
@@ -54,13 +54,17 @@ discard block |
||
54 | 54 | ); |
55 | 55 | |
56 | 56 | if (empty($subtasks)) { |
57 | - if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
57 | + if (LOG_TASKS=== true) { |
|
58 | + $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
59 | + } |
|
58 | 60 | return; |
59 | 61 | } |
60 | 62 | |
61 | 63 | // Process each subtask |
62 | 64 | foreach ($subtasks as $subtask) { |
63 | - if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
65 | + if (LOG_TASKS=== true) { |
|
66 | + $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
67 | + } |
|
64 | 68 | $this->processGenerateUserKeysSubtask($subtask, $arguments); |
65 | 69 | } |
66 | 70 | |
@@ -97,7 +101,9 @@ discard block |
||
97 | 101 | $subtask['increment_id'] |
98 | 102 | ); |
99 | 103 | |
100 | - if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
104 | + if (LOG_TASKS=== true) { |
|
105 | + $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
106 | + } |
|
101 | 107 | switch ($taskData['step'] ?? '') { |
102 | 108 | case 'step0': |
103 | 109 | $this->generateNewUserStep0($arguments); |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | trait ItemHandlerTrait { |
30 | 30 | |
31 | 31 | private function generateUserPasswordKeys($arguments) { |
32 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG'); |
|
32 | + if (LOG_TASKS=== true) { |
|
33 | + $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG'); |
|
34 | + } |
|
33 | 35 | // Generate keys for user passwords |
34 | 36 | storeUsersShareKey( |
35 | 37 | prefixTable('sharekeys_items'), |
@@ -49,7 +51,9 @@ discard block |
||
49 | 51 | * @param array $taskData |
50 | 52 | */ |
51 | 53 | private function generateUserFileKeys($taskData) { |
52 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG'); |
|
54 | + if (LOG_TASKS=== true) { |
|
55 | + $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG'); |
|
56 | + } |
|
53 | 57 | foreach($taskData['files_keys'] as $file) { |
54 | 58 | storeUsersShareKey( |
55 | 59 | prefixTable('sharekeys_files'), |
@@ -70,7 +74,9 @@ discard block |
||
70 | 74 | * @param array $arguments |
71 | 75 | */ |
72 | 76 | private function generateUserFieldKeys($arguments) { |
73 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG'); |
|
77 | + if (LOG_TASKS=== true) { |
|
78 | + $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG'); |
|
79 | + } |
|
74 | 80 | foreach($arguments['fields_keys'] as $field) { |
75 | 81 | $this->logger->log('Processing generateUserFieldKeys for: ' . $field['object_id'], 'DEBUG'); |
76 | 82 | storeUsersShareKey( |
@@ -64,7 +64,9 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function execute() { |
66 | 66 | try { |
67 | - if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
67 | + if (LOG_TASKS=== true) { |
|
68 | + $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
69 | + } |
|
68 | 70 | // Dispatch selon le type de processus |
69 | 71 | switch ($this->processType) { |
70 | 72 | case 'item_copy': |
@@ -136,7 +138,9 @@ discard block |
||
136 | 138 | $arguments = ''; |
137 | 139 | } |
138 | 140 | |
139 | - if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
141 | + if (LOG_TASKS=== true) { |
|
142 | + $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
143 | + } |
|
140 | 144 | |
141 | 145 | // Add 'arguments' only if not empty |
142 | 146 | if (!empty($arguments)) { |
@@ -150,7 +154,9 @@ discard block |
||
150 | 154 | 'increment_id = %i', |
151 | 155 | $this->taskId |
152 | 156 | ); |
153 | - if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
157 | + if (LOG_TASKS=== true) { |
|
158 | + $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
159 | + } |
|
154 | 160 | } |
155 | 161 | |
156 | 162 | /** |
@@ -185,7 +191,9 @@ discard block |
||
185 | 191 | * @return void |
186 | 192 | */ |
187 | 193 | private function processSubTasks($arguments) { |
188 | - if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
194 | + if (LOG_TASKS=== true) { |
|
195 | + $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
196 | + } |
|
189 | 197 | // Get all subtasks related to this task |
190 | 198 | $subtasks = DB::query( |
191 | 199 | 'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
@@ -194,7 +202,9 @@ discard block |
||
194 | 202 | |
195 | 203 | // Check if there are any subtasks to process |
196 | 204 | if (empty($subtasks)) { |
197 | - if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
205 | + if (LOG_TASKS=== true) { |
|
206 | + $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
207 | + } |
|
198 | 208 | return; |
199 | 209 | } |
200 | 210 | |
@@ -204,7 +214,9 @@ discard block |
||
204 | 214 | // Get the subtask data |
205 | 215 | $subtaskData = json_decode($subtask['task'], true); |
206 | 216 | |
207 | - if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
217 | + if (LOG_TASKS=== true) { |
|
218 | + $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
219 | + } |
|
208 | 220 | |
209 | 221 | // Process the subtask based on its type |
210 | 222 | switch ($subtaskData['step'] ?? '') { |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | public function processBackgroundTasks() { |
56 | 56 | // Prevent multiple concurrent executions |
57 | 57 | if (!$this->acquireProcessLock()) { |
58 | - if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO'); |
|
58 | + if (LOG_TASKS=== true) { |
|
59 | + $this->logger->log('Process already running', 'INFO'); |
|
60 | + } |
|
59 | 61 | return false; |
60 | 62 | } |
61 | 63 | |
@@ -64,7 +66,9 @@ discard block |
||
64 | 66 | $this->processTaskBatches(); |
65 | 67 | $this->performMaintenanceTasks(); |
66 | 68 | } catch (Exception $e) { |
67 | - if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR'); |
|
69 | + if (LOG_TASKS=== true) { |
|
70 | + $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR'); |
|
71 | + } |
|
68 | 72 | } finally { |
69 | 73 | $this->releaseProcessLock(); |
70 | 74 | } |
@@ -131,7 +135,9 @@ discard block |
||
131 | 135 | |
132 | 136 | // Check if the maximum number of parallel tasks is reached |
133 | 137 | if ($runningTasks >= $this->maxParallelTasks) { |
134 | - if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO'); |
|
138 | + if (LOG_TASKS=== true) { |
|
139 | + $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO'); |
|
140 | + } |
|
135 | 141 | return; |
136 | 142 | } |
137 | 143 | |
@@ -149,7 +155,9 @@ discard block |
||
149 | 155 | ); |
150 | 156 | |
151 | 157 | foreach ($tasks as $task) { |
152 | - if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO'); |
|
158 | + if (LOG_TASKS=== true) { |
|
159 | + $this->logger->log('Launching '.$task['increment_id'], 'INFO'); |
|
160 | + } |
|
153 | 161 | $this->processIndividualTask($task); |
154 | 162 | } |
155 | 163 | } |
@@ -160,7 +168,9 @@ discard block |
||
160 | 168 | * @param array $task The task to process. |
161 | 169 | */ |
162 | 170 | private function processIndividualTask(array $task) { |
163 | - if (LOG_TASKS=== true) $this->logger->log('Starting task: ' . print_r($task, true), 'INFO'); |
|
171 | + if (LOG_TASKS=== true) { |
|
172 | + $this->logger->log('Starting task: ' . print_r($task, true), 'INFO'); |
|
173 | + } |
|
164 | 174 | |
165 | 175 | // Store progress in the database |
166 | 176 | DB::update( |
@@ -188,7 +198,9 @@ discard block |
||
188 | 198 | $process->mustRun(); |
189 | 199 | |
190 | 200 | } catch (Exception $e) { |
191 | - if (LOG_TASKS=== true) $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR'); |
|
201 | + if (LOG_TASKS=== true) { |
|
202 | + $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR'); |
|
203 | + } |
|
192 | 204 | DB::update( |
193 | 205 | prefixTable('background_tasks'), |
194 | 206 | [ |
@@ -290,7 +302,9 @@ discard block |
||
290 | 302 | $taskIds |
291 | 303 | ); |
292 | 304 | |
293 | - if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO'); |
|
305 | + if (LOG_TASKS=== true) { |
|
306 | + $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO'); |
|
307 | + } |
|
294 | 308 | } |
295 | 309 | } |
296 | 310 |
@@ -134,7 +134,9 @@ |
||
134 | 134 | handleAttachmentError('File exceeds the maximum allowed size', 120, 413); |
135 | 135 | die(); |
136 | 136 | } |
137 | - if (WIP === true) error_log('POST_MAX_SIZE: ' . $POST_MAX_SIZE." - CONTENT_LENGTH: ".$_SERVER['CONTENT_LENGTH']." - UNIT: ".$unit." - MAX: ".$maxSize." - MULTIPLIER: ".$multiplier." - FILE_SIZE: ".$post_fileSize); |
|
137 | + if (WIP === true) { |
|
138 | + error_log('POST_MAX_SIZE: ' . $POST_MAX_SIZE." - CONTENT_LENGTH: ".$_SERVER['CONTENT_LENGTH']." - UNIT: ".$unit." - MAX: ".$maxSize." - MULTIPLIER: ".$multiplier." - FILE_SIZE: ".$post_fileSize); |
|
139 | + } |
|
138 | 140 | |
139 | 141 | // delete expired tokens |
140 | 142 | DB::delete(prefixTable('tokens'), 'end_timestamp < %i', time()); |
@@ -1234,7 +1234,9 @@ discard block |
||
1234 | 1234 | ); |
1235 | 1235 | |
1236 | 1236 | // Create a task to create sharekeys for users |
1237 | - if (WIP=== true) error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw); |
|
1237 | + if (WIP=== true) { |
|
1238 | + error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw); |
|
1239 | + } |
|
1238 | 1240 | $tasksToBePerformed = ['item_password']; |
1239 | 1241 | $encryptionTaskIsRequested = true; |
1240 | 1242 | } else { |
@@ -1554,7 +1556,9 @@ discard block |
||
1554 | 1556 | |
1555 | 1557 | // create a task for all fields updated |
1556 | 1558 | if ($encryptionTaskIsRequested === true) { |
1557 | - if (WIP === true) error_log('createTaskForItem - '.print_r($tasksToBePerformed, true)); |
|
1559 | + if (WIP === true) { |
|
1560 | + error_log('createTaskForItem - '.print_r($tasksToBePerformed, true)); |
|
1561 | + } |
|
1558 | 1562 | createTaskForItem( |
1559 | 1563 | 'item_update_create_keys', |
1560 | 1564 | array_unique($tasksToBePerformed), |
@@ -2055,7 +2059,9 @@ discard block |
||
2055 | 2059 | $inputData['itemId'] |
2056 | 2060 | ); |
2057 | 2061 | foreach ($rows as $record) { |
2058 | - if ($record['raison'] === NULL) continue; |
|
2062 | + if ($record['raison'] === NULL) { |
|
2063 | + continue; |
|
2064 | + } |
|
2059 | 2065 | $reason = explode(':', $record['raison']); |
2060 | 2066 | if (count($reason) > 0) { |
2061 | 2067 | $sentence = date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) . ' - ' |
@@ -4757,8 +4763,9 @@ discard block |
||
4757 | 4763 | $ids = $tree->getDescendants($folder['id'], true, false, true); |
4758 | 4764 | |
4759 | 4765 | // This folder is owned by user |
4760 | - if (in_array($inputData['folderId'], $ids)) |
|
4761 | - $accessLevel = 30; |
|
4766 | + if (in_array($inputData['folderId'], $ids)) { |
|
4767 | + $accessLevel = 30; |
|
4768 | + } |
|
4762 | 4769 | } |
4763 | 4770 | } |
4764 | 4771 |