ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 272 of file class.ilFileSystemStorageMailMigration.php.

273  {
274  return ilUpdateUtilsMailMigration::rCopy($a_source, $a_target);
275  }

◆ _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 $i, $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  $factor = pow(self::FACTOR, $i);
88  if (($tmp = (int) ($num / $factor)) or $found) {
89  $path[] = $tmp;
90  $num = $num % $factor;
91  $found = true;
92  }
93  }
94 
95  if (count($path)) {
96  $path_string = (implode('/', $path) . '/');
97  }
98  return $path_string . $a_name . '_' . $a_container_id;
99  }
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ appendToPath()

ilFileSystemStorageMailMigration::appendToPath (   $a_appendix)

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

Referenced by ilFSStorageMailMailMigration\__construct().

278  {
279  $this->path .= $a_appendix;
280  }
+ 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 254 of file class.ilFileSystemStorageMailMigration.php.

255  {
256  if (@file_exists($a_from)) {
257  @copy($a_from, $a_to);
258  return true;
259  }
260  return false;
261  }

◆ create()

ilFileSystemStorageMailMigration::create ( )

Create directory.

public

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

References ilUpdateUtilsMailMigration\makeDirParents().

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

◆ delete()

ilFileSystemStorageMailMigration::delete ( )

Delete complete directory.

public

Parameters

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

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

241  {
243  }
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 223 of file class.ilFileSystemStorageMailMigration.php.

References ilUpdateUtilsMailMigration\delDir().

224  {
225  if (@file_exists($a_abs_name)) {
227  return true;
228  }
229  return false;
230  }
+ Here is the call graph for this function:

◆ deleteFile()

ilFileSystemStorageMailMigration::deleteFile (   $a_abs_name)

Delete file.

public

Parameters
stringabsolute name

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

208  {
209  if (@file_exists($a_abs_name)) {
210  @unlink($a_abs_name);
211  return true;
212  }
213  return false;
214  }

◆ getAbsolutePath()

ilFileSystemStorageMailMigration::getAbsolutePath ( )

Get absolute path of storage directory.

public

Definition at line 145 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 282 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 155 of file class.ilFileSystemStorageMailMigration.php.

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

Referenced by __construct().

156  {
157  switch ($this->storage_type) {
158  case self::STORAGE_DATA:
160  break;
161 
162  case self::STORAGE_WEB:
164  break;
165  }
167  $this->path .= '/';
168 
169  // Append path prefix
170  $this->path .= ($this->getPathPrefix() . '/');
171 
172  if ($this->path_conversion) {
173  $this->path .= self::_createPathFromId($this->container_id, $this->getPathPostfix());
174  } else {
175  $this->path .= ($this->getPathPostfix() . '_' . $this->container_id);
176  }
177  return true;
178  }
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 187 of file class.ilFileSystemStorageMailMigration.php.

188  {
189  if (!$fp = @fopen($a_absolute_path, 'w+')) {
190  return false;
191  }
192  if (@fwrite($fp, $a_data) === false) {
193  @fclose($fp);
194  return false;
195  }
196  @fclose($fp);
197  return true;
198  }

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: