ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilFSStorageGroup.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('Services/FileSystem/classes/class.ilFileSystemStorage.php');
5
15{
16 const MEMBER_EXPORT_DIR = 'memberExport';
17
18 private $log;
25 public function __construct($a_container_id = 0)
26 {
27 global $DIC;
28
29 $log = $DIC['log'];
30
31 $this->log = $log;
33 }
34
41 public function initMemberExportDirectory()
42 {
44 }
45
52 public function getMemberExportDirectory()
53 {
54 return $this->getAbsolutePath() . '/' . self::MEMBER_EXPORT_DIR;
55 }
56
65 public function addMemberExportFile($a_data, $a_rel_name)
66 {
68 if (!$this->writeToFile($a_data, $this->getMemberExportDirectory() . '/' . $a_rel_name)) {
69 $this->log->write('Cannot write to file: ' . $this->getMemberExportDirectory() . '/' . $a_rel_name);
70 return false;
71 }
72
73 return true;
74 }
75
82 public function getMemberExportFiles()
83 {
84 if (!@is_dir($this->getMemberExportDirectory())) {
85 return array();
86 }
87
88 $files = array();
89 $dp = @opendir($this->getMemberExportDirectory());
90
91 while ($file = readdir($dp)) {
92 if (is_dir($file)) {
93 continue;
94 }
95
96 if (preg_match("/^([0-9]{10})_[a-zA-Z]*_export_([a-z]+)_([0-9]+)\.[a-z]+$/", $file, $matches) and $matches[3] == $this->getContainerId()) {
97 $timest = $matches[1];
98 $file_info['name'] = $matches[0];
99 $file_info['timest'] = $matches[1];
100 $file_info['type'] = $matches[2];
101 $file_info['id'] = $matches[3];
102 $file_info['size'] = filesize($this->getMemberExportDirectory() . '/' . $file);
103
104 $files[$timest] = $file_info;
105 }
106 }
107 closedir($dp);
108 return $files ? $files : array();
109 }
110
111 public function getMemberExportFile($a_name)
112 {
113 $file_name = $this->getMemberExportDirectory() . '/' . $a_name;
114
115 if (@file_exists($file_name)) {
116 return file_get_contents($file_name);
117 }
118 }
119
127 public function deleteMemberExportFile($a_export_name)
128 {
129 return $this->deleteFile($this->getMemberExportDirectory() . '/' . $a_export_name);
130 }
131
132
133
134
135
142 protected function getPathPostfix()
143 {
144 return 'grp';
145 }
146
153 protected function getPathPrefix()
154 {
155 return 'ilGroup';
156 }
157}
An exception for terminatinating execution or to throw for unit testing.
getMemberExportFiles()
Get all member export files.
deleteMemberExportFile($a_export_name)
Delete Member Export File.
getMemberExportDirectory()
Get path of export directory.
__construct($a_container_id=0)
Constructor.
getPathPrefix()
Implementation of abstract method.
initMemberExportDirectory()
Init export directory and create it if it does not exist.
getPathPostfix()
Implementation of abstract method.
addMemberExportFile($a_data, $a_rel_name)
Add new export file.
deleteFile($a_abs_name)
Delete file.
getAbsolutePath()
Get absolute path of storage directory.
writeToFile($a_data, $a_absolute_path)
Write data to file.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46