ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilFileSystemStorageMailMigration Class Reference
+ Inheritance diagram for ilFileSystemStorageMailMigration:
+ Collaboration diagram for ilFileSystemStorageMailMigration:

Public Member Functions

 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 getContainerId ()
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 writeToFile ($a_data, $a_absolute_path)
 Write data to file. More...
 
 deleteFile ($a_abs_name)
 Delete file. More...
 
 deleteDirectory ($a_abs_name)
 Delete directory. More...
 
 delete ()
 Delete complete directory. More...
 
 copyFile ($a_from, $a_to)
 Copy files. More...
 
 appendToPath ($a_appendix)
 
 getStorageType ()
 

Static Public Member Functions

static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 
 _copyDirectory ($a_source, $a_target)
 Copy directory and all contents. More...
 

Data Fields

const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const FACTOR = 100
 
const MAX_EXPONENT = 3
 

Protected Member Functions

 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 

Private Member Functions

 init ()
 Read path info. More...
 

Private Attributes

 $container_id
 
 $storage_type
 
 $path_conversion = false
 
 $path
 

Detailed Description

Definition at line 33 of file class.ilFileSystemStorageMailMigration.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileSystemStorageMailMigration::__construct (   $a_storage_type,
  $a_path_conversion,
  $a_container_id 
)

Constructor.

public

Parameters
intstorage type
boolEn/Disable automatic path conversion. If enabled files with id 123 will be stored in directory files/1/file_123
intobject id of container (e.g file_id or mob_id)

Definition at line 57 of file class.ilFileSystemStorageMailMigration.php.

References init().

58  {
59  $this->storage_type = $a_storage_type;
60  $this->path_conversion = $a_path_conversion;
61  $this->container_id = $a_container_id;
62 
63  // Get path info
64  $this->init();
65  }
+ Here is the call graph for this function:

Member Function Documentation

◆ _copyDirectory()

ilFileSystemStorageMailMigration::_copyDirectory (   $a_source,
  $a_target 
)
static

Copy directory and all contents.

public

Parameters
stringabsolute source path
stringabsolute target path

Definition at line 285 of file class.ilFileSystemStorageMailMigration.php.

286  {
287  return ilUpdateUtilsMailMigration::rCopy($a_source,$a_target);
288  }

◆ _createPathFromId()

static ilFileSystemStorageMailMigration::_createPathFromId (   $a_container_id,
  $a_name 
)
static

Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.

public

Parameters
intcontainer id
stringname

Definition at line 81 of file class.ilFileSystemStorageMailMigration.php.

References $path, array, getPathPostfix(), and getPathPrefix().

82  {
83  $path = array();
84  $found = false;
85  $num = $a_container_id;
86  for($i = self::MAX_EXPONENT; $i > 0;$i--)
87  {
88  $factor = pow(self::FACTOR,$i);
89  if(($tmp = (int) ($num / $factor)) or $found)
90  {
91  $path[] = $tmp;
92  $num = $num % $factor;
93  $found = true;
94  }
95  }
96 
97  if(count($path))
98  {
99  $path_string = (implode('/',$path).'/');
100  }
101  return $path_string.$a_name.'_'.$a_container_id;
102  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ appendToPath()

ilFileSystemStorageMailMigration::appendToPath (   $a_appendix)

Definition at line 290 of file class.ilFileSystemStorageMailMigration.php.

Referenced by ilFSStorageMailMailMigration\__construct().

291  {
292  $this->path .= $a_appendix;
293  }
+ Here is the caller graph for this function:

◆ copyFile()

ilFileSystemStorageMailMigration::copyFile (   $a_from,
  $a_to 
)

Copy files.

public

Parameters
stringabsolute source
stringabsolute target

Definition at line 266 of file class.ilFileSystemStorageMailMigration.php.

267  {
268  if(@file_exists($a_from))
269  {
270  @copy($a_from,$a_to);
271  return true;
272  }
273  return false;
274  }

◆ create()

ilFileSystemStorageMailMigration::create ( )

Create directory.

public

Definition at line 133 of file class.ilFileSystemStorageMailMigration.php.

References ilUpdateUtilsMailMigration\makeDirParents().

134  {
135  if(!file_exists($this->path))
136  {
138  }
139  return true;
140  }
+ Here is the call graph for this function:

◆ delete()

ilFileSystemStorageMailMigration::delete ( )

Delete complete directory.

public

Parameters

Definition at line 252 of file class.ilFileSystemStorageMailMigration.php.

References ilUpdateUtilsMailMigration\delDir(), and getAbsolutePath().

253  {
255  }
getAbsolutePath()
Get absolute path of storage directory.
+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileSystemStorageMailMigration::deleteDirectory (   $a_abs_name)

Delete directory.

public

Parameters
stringabsolute name

Definition at line 234 of file class.ilFileSystemStorageMailMigration.php.

References ilUpdateUtilsMailMigration\delDir().

235  {
236  if(@file_exists($a_abs_name))
237  {
239  return true;
240  }
241  return false;
242  }
+ Here is the call graph for this function:

◆ deleteFile()

ilFileSystemStorageMailMigration::deleteFile (   $a_abs_name)

Delete file.

public

Parameters
stringabsolute name

Definition at line 217 of file class.ilFileSystemStorageMailMigration.php.

218  {
219  if(@file_exists($a_abs_name))
220  {
221  @unlink($a_abs_name);
222  return true;
223  }
224  return false;
225  }

◆ getAbsolutePath()

ilFileSystemStorageMailMigration::getAbsolutePath ( )

Get absolute path of storage directory.

public

Definition at line 149 of file class.ilFileSystemStorageMailMigration.php.

References $path.

Referenced by delete(), and ilFSStorageMailMailMigration\getRelativePathExMailDirectory().

+ Here is the caller graph for this function:

◆ getContainerId()

ilFileSystemStorageMailMigration::getContainerId ( )

◆ getPathPostfix()

ilFileSystemStorageMailMigration::getPathPostfix ( )
abstractprotected

Get directory name.

E.g for files => file Only relative path, no trailing slash '_<obj_id>' will be appended automatically

protected

Returns
string directory name

Referenced by _createPathFromId(), and init().

+ Here is the caller graph for this function:

◆ getPathPrefix()

ilFileSystemStorageMailMigration::getPathPrefix ( )
abstractprotected

Get path prefix.

Prefix that will be prepended to the path No trailing slash. E.g ilFiles for files

protected

Returns
string path prefix e.g files

Referenced by _createPathFromId(), and init().

+ Here is the caller graph for this function:

◆ getStorageType()

ilFileSystemStorageMailMigration::getStorageType ( )

Definition at line 295 of file class.ilFileSystemStorageMailMigration.php.

References $storage_type.

Referenced by ilFSStorageMailMailMigration\getRelativePathExMailDirectory().

+ Here is the caller graph for this function:

◆ init()

ilFileSystemStorageMailMigration::init ( )
private

Read path info.

private

Definition at line 159 of file class.ilFileSystemStorageMailMigration.php.

References $container_id, ilUpdateUtilsMailMigration\getDataDir(), getPathPostfix(), getPathPrefix(), ilUpdateUtilsMailMigration\getWebspaceDir(), and ilUpdateUtilsMailMigration\removeTrailingPathSeparators().

Referenced by __construct().

160  {
161  switch($this->storage_type)
162  {
163  case self::STORAGE_DATA:
165  break;
166 
167  case self::STORAGE_WEB:
169  break;
170  }
172  $this->path .= '/';
173 
174  // Append path prefix
175  $this->path .= ($this->getPathPrefix().'/');
176 
177  if($this->path_conversion)
178  {
179  $this->path .= self::_createPathFromId($this->container_id,$this->getPathPostfix());
180  }
181  else
182  {
183  $this->path .= ($this->getPathPostfix().'_'.$this->container_id);
184  }
185  return true;
186  }
getPathPrefix()
Get path prefix.
getPathPostfix()
Get directory name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeToFile()

ilFileSystemStorageMailMigration::writeToFile (   $a_data,
  $a_absolute_path 
)

Write data to file.

public

Parameters

Definition at line 195 of file class.ilFileSystemStorageMailMigration.php.

196  {
197  if(!$fp = @fopen($a_absolute_path,'w+'))
198  {
199  return false;
200  }
201  if(@fwrite($fp,$a_data) === false)
202  {
203  @fclose($fp);
204  return false;
205  }
206  @fclose($fp);
207  return true;
208  }

Field Documentation

◆ $container_id

ilFileSystemStorageMailMigration::$container_id
private

Definition at line 42 of file class.ilFileSystemStorageMailMigration.php.

Referenced by getContainerId(), and init().

◆ $path

ilFileSystemStorageMailMigration::$path
private

◆ $path_conversion

ilFileSystemStorageMailMigration::$path_conversion = false
private

Definition at line 44 of file class.ilFileSystemStorageMailMigration.php.

◆ $storage_type

ilFileSystemStorageMailMigration::$storage_type
private

Definition at line 43 of file class.ilFileSystemStorageMailMigration.php.

Referenced by getStorageType().

◆ FACTOR

const ilFileSystemStorageMailMigration::FACTOR = 100

Definition at line 38 of file class.ilFileSystemStorageMailMigration.php.

◆ MAX_EXPONENT

const ilFileSystemStorageMailMigration::MAX_EXPONENT = 3

Definition at line 39 of file class.ilFileSystemStorageMailMigration.php.

◆ STORAGE_DATA

const ilFileSystemStorageMailMigration::STORAGE_DATA = 2

Definition at line 36 of file class.ilFileSystemStorageMailMigration.php.

◆ STORAGE_WEB

const ilFileSystemStorageMailMigration::STORAGE_WEB = 1

Definition at line 35 of file class.ilFileSystemStorageMailMigration.php.


The documentation for this class was generated from the following file: