ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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  $this->log->write('Cannot write to file: ' . $this->getMemberExportDirectory() . '/' . $a_rel_name);
68  return false;
69  }
70 
71  return true;
72  }
73 
80  public function getMemberExportFiles()
81  {
82  if (!@is_dir($this->getMemberExportDirectory())) {
83  return array();
84  }
85 
86  $files = array();
87  $dp = @opendir($this->getMemberExportDirectory());
88 
89  while ($file = readdir($dp)) {
90  if (is_dir($file)) {
91  continue;
92  }
93 
94  if (preg_match("/^([0-9]{10})_[a-zA-Z]*_export_([a-z]+)_([0-9]+)\.[a-z]+$/", $file, $matches) and $matches[3] == $this->getContainerId()) {
95  $timest = $matches[1];
96  $file_info['name'] = $matches[0];
97  $file_info['timest'] = $matches[1];
98  $file_info['type'] = $matches[2];
99  $file_info['id'] = $matches[3];
100  $file_info['size'] = filesize($this->getMemberExportDirectory() . '/' . $file);
101 
102  $files[$timest] = $file_info;
103  }
104  }
105  closedir($dp);
106  return $files ? $files : array();
107  }
108 
109  public function getMemberExportFile($a_name)
110  {
111  $file_name = $this->getMemberExportDirectory() . '/' . $a_name;
112 
113  if (@file_exists($file_name)) {
114  return file_get_contents($file_name);
115  }
116  }
117 
125  public function deleteMemberExportFile($a_export_name)
126  {
127  return $this->deleteFile($this->getMemberExportDirectory() . '/' . $a_export_name);
128  }
129 
130 
131 
132 
133 
140  protected function getPathPostfix()
141  {
142  return 'grp';
143  }
144 
151  protected function getPathPrefix()
152  {
153  return 'ilGroup';
154  }
155 }
$files
Definition: add-vimline.php:18
getMemberExportDirectory()
Get path of export directory.
initMemberExportDirectory()
Init export directory and create it if it does not exist.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
deleteMemberExportFile($a_export_name)
Delete Member Export File.
getMemberExportFiles()
Get all member export files.
getPathPostfix()
Implementation of abstract method.
addMemberExportFile($a_data, $a_rel_name)
Add new export file.
getPathPrefix()
Implementation of abstract method.
writeToFile($a_data, $a_absolute_path)
Write data to file.
Create styles array
The data for the language used.
getAbsolutePath()
Get absolute path of storage directory.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
__construct($a_container_id=0)
Constructor.
deleteFile($a_abs_name)
Delete file.