ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $log;
28
29 $this->log = $log;
30 parent::__construct(ilFileSystemStorage::STORAGE_DATA,true,$a_container_id);
31 }
32
39 public function initMemberExportDirectory()
40 {
42 }
43
50 public function getMemberExportDirectory()
51 {
52 return $this->getAbsolutePath().'/'.self::MEMBER_EXPORT_DIR;
53 }
54
63 public function addMemberExportFile($a_data,$a_rel_name)
64 {
66 if(!$this->writeToFile($a_data,$this->getMemberExportDirectory().'/'.$a_rel_name))
67 {
68 $this->log->write('Cannot write to file: '.$this->getMemberExportDirectory().'/'.$a_rel_name);
69 return false;
70 }
71
72 return true;
73
74 }
75
82 public function getMemberExportFiles()
83 {
84 if(!@is_dir($this->getMemberExportDirectory()))
85 {
86 return array();
87 }
88
89 $files = array();
90 $dp = @opendir($this->getMemberExportDirectory());
91
92 while($file = readdir($dp))
93 {
94 if(is_dir($file))
95 {
96 continue;
97 }
98
99 if(preg_match("/^([0-9]{10})_[a-zA-Z]*_export_([a-z]+)_([0-9]+)\.[a-z]+$/",$file,$matches) and $matches[3] == $this->getContainerId())
100 {
101 $timest = $matches[1];
102 $file_info['name'] = $matches[0];
103 $file_info['timest'] = $matches[1];
104 $file_info['type'] = $matches[2];
105 $file_info['id'] = $matches[3];
106 $file_info['size'] = filesize($this->getMemberExportDirectory().'/'.$file);
107
108 $files[$timest] = $file_info;
109 }
110 }
111 closedir($dp);
112 return $files ? $files : array();
113 }
114
115 public function getMemberExportFile($a_name)
116 {
117 $file_name = $this->getMemberExportDirectory().'/'.$a_name;
118
119 if(@file_exists($file_name))
120 {
121 return file_get_contents($file_name);
122 }
123 }
124
132 public function deleteMemberExportFile($a_export_name)
133 {
134 return $this->deleteFile($this->getMemberExportDirectory().'/'.$a_export_name);
135 }
136
137
138
139
140
147 protected function getPathPostfix()
148 {
149 return 'grp';
150 }
151
158 protected function getPathPrefix()
159 {
160 return 'ilGroup';
161 }
162
163}
164?>
print $file
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.