ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFSStorageGroup.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
29{
30 protected const MEMBER_EXPORT_DIR = 'memberExport';
31
33
34 public function __construct(int $a_container_id = 0)
35 {
36 global $DIC;
37
38 $this->logger = $DIC->logger()->grp();
40 }
41
45 public function initMemberExportDirectory(): void
46 {
48 }
49
53 public function getMemberExportDirectory(): string
54 {
55 return $this->getAbsolutePath() . '/' . self::MEMBER_EXPORT_DIR;
56 }
57
58 public function addMemberExportFile(string $a_data, string $a_rel_name): bool
59 {
61 if (!$this->writeToFile($a_data, $this->getMemberExportDirectory() . '/' . $a_rel_name)) {
62 $this->logger->warning('Cannot write to file: ' . $this->getMemberExportDirectory() . '/' . $a_rel_name);
63 return false;
64 }
65 return true;
66 }
67
71 public function getMemberExportFiles(): array
72 {
73 if (!is_dir($this->getMemberExportDirectory())) {
74 return [];
75 }
76
77 $dp = opendir($this->getMemberExportDirectory());
78 $files = [];
79 while ($file = readdir($dp)) {
80 if (is_dir($file)) {
81 continue;
82 }
83
84 if (
85 preg_match("/^([0-9]{10})_[a-zA-Z]*_export_([a-z]+)_([0-9]+)\.[a-z]+$/", $file, $matches) &&
86 $matches[3] == $this->getContainerId()) {
87 $timest = $matches[1];
88 $file_info['name'] = $matches[0];
89 $file_info['timest'] = $matches[1];
90 $file_info['type'] = $matches[2];
91 $file_info['id'] = $matches[3];
92 $file_info['size'] = filesize($this->getMemberExportDirectory() . '/' . $file);
93
94 $files[$timest] = $file_info;
95 }
96 }
97 closedir($dp);
98 return $files;
99 }
100
101 public function getMemberExportFile(string $a_name): string
102 {
103 $file_name = $this->getMemberExportDirectory() . '/' . $a_name;
104 if (file_exists($file_name)) {
105 return file_get_contents($file_name);
106 }
107 return '';
108 }
109
110 public function deleteMemberExportFile(string $a_export_name): bool
111 {
112 return $this->deleteFile($this->getMemberExportDirectory() . '/' . $a_export_name);
113 }
114
115 public function hasMemberExportFile(string $a_export_name): bool
116 {
117 return $this->fileExists($this->getMemberExportDirectory() . '/' . $a_export_name);
118 }
119
123 protected function getPathPostfix(): string
124 {
125 return 'grp';
126 }
127
131 protected function getPathPrefix(): string
132 {
133 return 'ilGroup';
134 }
135}
hasMemberExportFile(string $a_export_name)
__construct(int $a_container_id=0)
getMemberExportDirectory()
Get path of export directory.
initMemberExportDirectory()
Init export directory and create it if it does not exist.
deleteMemberExportFile(string $a_export_name)
addMemberExportFile(string $a_data, string $a_rel_name)
getMemberExportFile(string $a_name)
getAbsolutePath()
Calculates the full path on the filesystem.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
Component logger with individual log levels by component id.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26