ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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.

@access 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.

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 }

References init().

+ Here is the call graph for this function:

Member Function Documentation

◆ _copyDirectory()

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

Copy directory and all contents.

@access 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.

@access public

Parameters
intcontainer id
stringname

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

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 }
$i
Definition: metadata.php:24

References $i, and $path.

Referenced by init().

+ Here is the caller graph for this function:

◆ appendToPath()

ilFileSystemStorageMailMigration::appendToPath (   $a_appendix)

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

278 {
279 $this->path .= $a_appendix;
280 }

Referenced by ilFSStorageMailMailMigration\__construct().

+ Here is the caller graph for this function:

◆ copyFile()

ilFileSystemStorageMailMigration::copyFile (   $a_from,
  $a_to 
)

Copy files.

@access 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.

@access public

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

131 {
132 if (!file_exists($this->path)) {
134 }
135 return true;
136 }

References ilUpdateUtilsMailMigration\makeDirParents().

+ Here is the call graph for this function:

◆ delete()

ilFileSystemStorageMailMigration::delete ( )

Delete complete directory.

@access public

Parameters

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

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

+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileSystemStorageMailMigration::deleteDirectory (   $a_abs_name)

Delete directory.

@access public

Parameters
stringabsolute name

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

224 {
225 if (@file_exists($a_abs_name)) {
227 return true;
228 }
229 return false;
230 }

References ilUpdateUtilsMailMigration\delDir().

+ Here is the call graph for this function:

◆ deleteFile()

ilFileSystemStorageMailMigration::deleteFile (   $a_abs_name)

Delete file.

@access 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.

@access public

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

146 {
147 return $this->path;
148 }

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

@abstract @access protected

Returns
string directory name

Reimplemented in ilFSStorageMailMailMigration.

Referenced by 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

@abstract @access protected

Returns
string path prefix e.g files

Reimplemented in ilFSStorageMailMailMigration.

Referenced by 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.

@access private

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

156 {
157 switch ($this->storage_type) {
160 break;
161
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 }
static _createPathFromId($a_container_id, $a_name)
Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
getPathPostfix()
Get directory name.
getPathPrefix()
Get path prefix.

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

Referenced by __construct().

+ 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.

@access 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

◆ STORAGE_WEB

const ilFileSystemStorageMailMigration::STORAGE_WEB = 1

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