MCPcopy Create free account
hub / github.com/error311/FileRise / loadFresh

Method loadFresh

src/FileRise/Support/ACL.php:342–469  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

340 }
341
342 private static function loadFresh(): array
343 {
344 $path = self::path();
345 if (!is_file($path)) {
346 @mkdir(dirname($path), 0755, true);
347 $init = [
348 'folders' => [
349 'root' => [
350 'owners' => ['admin'],
351 'read' => ['admin'],
352 'write' => ['admin'],
353 'share' => ['admin'],
354 'read_own' => [],
355 'inherit' => [],
356 'explicit' => [],
357 'create' => [],
358 'upload' => [],
359 'edit' => [],
360 'rename' => [],
361 'copy' => [],
362 'move' => [],
363 'delete' => [],
364 'extract' => [],
365 'share_file' => [],
366 'share_folder' => [],
367 ],
368 ],
369 'groups' => [],
370 ];
371 @file_put_contents($path, json_encode($init, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOCK_EX);
372 }
373
374 $json = (string) @file_get_contents($path);
375 $data = json_decode($json, true);
376 if (!is_array($data)) {
377 $data = [];
378 }
379 $data['folders'] = isset($data['folders']) && is_array($data['folders']) ? $data['folders'] : [];
380 $data['groups'] = isset($data['groups']) && is_array($data['groups']) ? $data['groups'] : [];
381
382 if (!isset($data['folders']['root']) || !is_array($data['folders']['root'])) {
383 $data['folders']['root'] = [
384 'owners' => ['admin'],
385 'read' => ['admin'],
386 'write' => ['admin'],
387 'share' => ['admin'],
388 'read_own' => [],
389 'inherit' => [],
390 'explicit' => [],
391 'create' => [],
392 'upload' => [],
393 'edit' => [],
394 'rename' => [],
395 'copy' => [],
396 'move' => [],
397 'delete' => [],
398 'extract' => [],
399 'share_file' => [],

Callers 10

renameTreeMethod · 0.95
deleteTreeMethod · 0.95
listForMethod · 0.95
inheritMapMethod · 0.95
hasAnyExplicitEntryMethod · 0.95
ensureFolderRecordMethod · 0.95
explicitMethod · 0.95
explicitAllMethod · 0.95
upsertMethod · 0.95

Calls 2

pathMethod · 0.95
resetMemoMethod · 0.95

Tested by

no test coverage detected