ILIAS  release_8 Revision v8.24
ilFileObjectToStorageMigrationHelper Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilFileObjectToStorageMigrationHelper:

Public Member Functions

 __construct (ilResourceStorageMigrationHelper $irss_helper)
 
 getNext ()
 

Data Fields

const MIGRATED = ".migrated"
 

Protected Attributes

string $base_path = '/var/iliasdata/ilias/default/ilFile'
 
ilDBInterface $database
 

Private Member Functions

 getNextFileId ()
 
 createPathFromId (int $file_id)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 of file class.ilFileObjectToStorageMigrationHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileObjectToStorageMigrationHelper::__construct ( ilResourceStorageMigrationHelper  $irss_helper)

Definition at line 26 of file class.ilFileObjectToStorageMigrationHelper.php.

27 {
28 $this->base_path = $irss_helper->getClientDataDir() . '/ilFile';
29 $this->database = $irss_helper->getDatabase();
30 }

References ilResourceStorageMigrationHelper\getClientDataDir(), and ilResourceStorageMigrationHelper\getDatabase().

+ Here is the call graph for this function:

Member Function Documentation

◆ createPathFromId()

ilFileObjectToStorageMigrationHelper::createPathFromId ( int  $file_id)
private

Definition at line 68 of file class.ilFileObjectToStorageMigrationHelper.php.

68 : string
69 {
70 $path = [];
71 $found = false;
72 $num = $file_id;
73 $path_string = '';
74 for ($i = 3; $i > 0; $i--) {
75 $factor = pow(100, $i);
76 if (($tmp = (int) ($num / $factor)) or $found) {
77 $path[] = $tmp;
78 $num = $num % $factor;
79 $found = true;
80 }
81 }
82
83 if (count($path)) {
84 $path_string = (implode('/', $path) . '/');
85 }
86
87 return $this->base_path . '/' . $path_string . 'file_' . $file_id;
88 }
$path
Definition: ltiservices.php:32
$i
Definition: metadata.php:41

References $i, and $path.

Referenced by getNext().

+ Here is the caller graph for this function:

◆ getNext()

ilFileObjectToStorageMigrationHelper::getNext ( )

Definition at line 32 of file class.ilFileObjectToStorageMigrationHelper.php.

33 {
34 do {
35 $next_id = $this->getNextFileId();
36 $path = $this->createPathFromId($next_id);
37 $path_found = file_exists($path);
38 if (!$path_found) {
39 $this->database->update(
40 'file_data',
41 ['rid' => ['text', 'unknown']],
42 ['file_id' => ['integer', $next_id]]
43 );
44 } else {
45 return new ilFileObjectToStorageDirectory($next_id, $path);
46 }
47 } while (!$path_found);
48 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $path, createPathFromId(), and getNextFileId().

+ Here is the call graph for this function:

◆ getNextFileId()

ilFileObjectToStorageMigrationHelper::getNextFileId ( )
private

Definition at line 50 of file class.ilFileObjectToStorageMigrationHelper.php.

50 : int
51 {
52 $query = "SELECT file_id
53 FROM file_data
54 WHERE
55 (rid IS NULL OR rid = '')
56 AND (file_id != '' AND file_id IS NOT NULL)
57 LIMIT 1;";
58 $r = $this->database->query($query);
59 $d = $this->database->fetchObject($r);
60 if (!isset($d->file_id) || null === $d->file_id || '' === $d->file_id) {
61 throw new LogicException("error fetching file_id");
62 }
63
64 return (int) $d->file_id;
65 }
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$query

References $d, and $query.

Referenced by getNext().

+ Here is the caller graph for this function:

Field Documentation

◆ $base_path

string ilFileObjectToStorageMigrationHelper::$base_path = '/var/iliasdata/ilias/default/ilFile'
protected

◆ $database

ilDBInterface ilFileObjectToStorageMigrationHelper::$database
protected

◆ MIGRATED

const ilFileObjectToStorageMigrationHelper::MIGRATED = ".migrated"

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