ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
28 
29  $log = $DIC['log'];
30 
31  $this->log = $log;
32  parent::__construct(ilFileSystemStorage::STORAGE_DATA, true, $a_container_id);
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 }
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.
$files
Definition: metarefresh.php:49
global $DIC
Definition: saml.php:7
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.
getAbsolutePath()
Get absolute path of storage directory.
__construct($a_container_id=0)
Constructor.
deleteFile($a_abs_name)
Delete file.