|
static | addFileRefToArchive (ZipArchive $archive, FileRef $file_ref, $user_id=null, $archive_fs_path='', $do_user_permission_checks=true, $ignore_user=false, &$file_list=null) |
|
static | addFolderToArchive (ZipArchive $archive, FolderType $folder, $user_id=null, $archive_fs_path='', $do_user_permission_checks=true, $keep_hierarchy=true, $ignore_user=false, &$file_list=null) |
|
static | createArchive ( $file_area_objects=[], $user_id=null, $archive_file_path='', $do_user_permission_checks=true, $keep_hierarchy=true, $ignore_user=false, $zip_encoding='UTF-8', $add_filelist_to_archive=false) |
|
static | createArchiveFromFileRefs ( $file_refs, User $user, $archive_file_path='', $do_user_permission_checks=true) |
|
static | createArchiveFromFolder (FolderType $folder, $user_id=null, $archive_file_path='', $do_user_permission_checks=true, $keep_hierarchy=true) |
|
static | createArchiveFromCourse ( $course_id, $user_id=null, $archive_file_path='', $do_user_permission_checks=true, $keep_hierarchy=true) |
|
static | createArchiveFromInstitute ( $institute_id, $user_id=null, $archive_file_path='', $do_user_permission_checks=true, $keep_hierarchy=true) |
|
static | createArchiveFromUser ( $user_id, $archive_file_path='', $do_user_permission_checks=true, $keep_hierarchy=true) |
|
static | createArchiveFromPhysicalFolder ($folder_path, $archive_file_path) |
|
static | createFolderPath (FolderType $folder, User $user, $path='') |
|
static | extractFileFromArchive (Studip\ZipArchive $archive, $archive_path, FolderType $target_folder, User $user) |
|
static | extractArchiveFileToFolder (FileRef $archive_file_ref, FolderType $folder, $user_id=null) |
|
The FileArchiveManager class gives programmers a simple way to handle file archives by providing different methods for packing and unpacking file archives in a simple manner.
◆ addFileRefToArchive()
static addFileRefToArchive |
( |
ZipArchive |
$archive, |
|
|
FileRef |
$file_ref, |
|
|
|
$user_id = null , |
|
|
|
$archive_fs_path = '' , |
|
|
|
$do_user_permission_checks = true , |
|
|
|
$ignore_user = false , |
|
|
& |
$file_list = null |
|
) |
| |
|
static |
Adds a FileRef to a Zip archive.
- Parameters
-
ZipArchive | $archive | The Zip archive where the FileRef shall be added to. |
FileRef | $file_ref | The FileRef which shall be added to the zip archive. |
string | $user_id | The user who wishes to add the FileRef to the archive. |
string | $archive_fs_path | The path of the file inside the archive's file system. |
bool | $do_user_permission_checks | Set to true if reading/downloading permissions shall be checked. False otherwise. Default is true. |
bool | $ignore_user | Set to true, if a file which has no download restrictions shall be included and the user-specific download condition check shall be ignored. If this parameter is set to true, the user_id parameter is irrelevant. The default for this parameter is false. |
- Returns
- bool True on success, false on failure.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ addFolderToArchive()
static addFolderToArchive |
( |
ZipArchive |
$archive, |
|
|
FolderType |
$folder, |
|
|
|
$user_id = null , |
|
|
|
$archive_fs_path = '' , |
|
|
|
$do_user_permission_checks = true , |
|
|
|
$keep_hierarchy = true , |
|
|
|
$ignore_user = false , |
|
|
& |
$file_list = null |
|
) |
| |
|
static |
Adds a FolderType instance to a Zip archive.
- Parameters
-
ZipArchive | $archive | The Zip archive where the FileRef shall be added to. |
FileRef | $file_ref | The FileRef which shall be added to the zip archive. |
string | $user_id | The user who wishes to add the FileRef to the archive. |
string | $archive_fs_path | The path of the folder inside the archive's file system. |
bool | $do_user_permission_checks | Set to true if reading/downloading permissions shall be checked. False otherwise. Default is true. |
bool | $keep_hierarchy | True, if the folder hierarchy shall be kept. False, if the folder hierarchy shall be flattened. |
bool | $ignore_user | Set to true, if a folder of type StandardFolder shall be included without checking if the user (identified by user_id) can read it. |
- Returns
- bool True on success, false on failure.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ createArchive()
static createArchive |
( |
|
$file_area_objects = [] , |
|
|
|
$user_id = null , |
|
|
|
$archive_file_path = '' , |
|
|
|
$do_user_permission_checks = true , |
|
|
|
$keep_hierarchy = true , |
|
|
|
$ignore_user = false , |
|
|
|
$zip_encoding = 'UTF-8' , |
|
|
|
$add_filelist_to_archive = false |
|
) |
| |
|
static |
General method for creating file archives.
This method is a generalisation for all archive creation methods. For easier archive creation you may use the other archive creation methods which work with less arguments.
- Parameters
-
Array | $file_area_objects | Array of FileRef, FileURL, Folder or FolderType objects. $file_area_objects may contain a mix between those object types. |
string | $user_id | The user who wishes to pack files. |
string | $archive_file_path | The path for the archive file. |
bool | $do_user_permission_checks | Set to true if individual reading/downloading permissions shall be checked. False otherwise. Default is true. |
bool | $keep_hierarchy | True, if the folder hierarchy shall be kept. False, if the folder hierarchy shall be flattened. Default is true. |
bool | $ignore_user | Set to true, if all files which have no download restrictions and all folders which are of type StandardFolder shall be included and the user-specific download condition check shall be ignored. If this parameter is set to true, the user_id parameter is irrelevant. The default for this parameter is false. |
string | $zip_encoding | encoding for filenames in zip |
bool | $add_filelist_to_archive | If this is set to true a file list in the CSV format will be added to the archive. Its name is hardcoded to archive_filelist.csv. The default value of $add_filelist_to_archive is false which means no file list is added. |
- Returns
- bool True, if the archive file was created and saved successfully at $archive_file_path, false otherwise.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ createArchiveFromCourse()
static createArchiveFromCourse |
( |
|
$course_id, |
|
|
|
$user_id = null , |
|
|
|
$archive_file_path = '' , |
|
|
|
$do_user_permission_checks = true , |
|
|
|
$keep_hierarchy = true |
|
) |
| |
|
static |
Creates an archive that contains all files of a course the given user is allowed to download.
- Parameters
-
string | $course_id | The ID of the course whose files shall be put inside an archive. |
string | $user_id | The ID of the user who wishes to put the course's files into an archive |
string | $archive_file_path | The path for the archive file. |
bool | $do_user_permission_checks | Set to true if reading/downloading permissions shall be checked. False otherwise. Default is true. |
bool | $keep_hierarchy | True, if the file hierarchy shall be kept inside the archive. If $keep_hierarchy is set to false you will get an archive that contains only files and no subdirectories. |
- Returns
- bool True, if the archive file was created and saved successfully at $archive_file_path, false otherwise.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ createArchiveFromFileRefs()
static createArchiveFromFileRefs |
( |
|
$file_refs, |
|
|
User |
$user, |
|
|
|
$archive_file_path = '' , |
|
|
|
$do_user_permission_checks = true |
|
) |
| |
|
static |
Puts files (identified by their file refs) into one file archive.
- Parameters
-
| FileRef[] | $file_refs Array of FileRef objects. |
User | $user | The user who wishes to pack files. |
string | $archive_file_path | The path for the archive file. |
bool | $do_user_permission_checks | Set to true if reading/downloading permissions shall be checked. False otherwise. Default is true. |
- Returns
- bool True, if the archive file was created and saved successfully at $archive_file_path, false otherwise.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ createArchiveFromFolder()
static createArchiveFromFolder |
( |
FolderType |
$folder, |
|
|
|
$user_id = null , |
|
|
|
$archive_file_path = '' , |
|
|
|
$do_user_permission_checks = true , |
|
|
|
$keep_hierarchy = true |
|
) |
| |
|
static |
Creates an archive that contains all files of a course the given user is allowed to download.
- Parameters
-
FolderType | $folder | The folder whose files shall be put inside an archive. |
string | $user_id | The ID of the user who wishes to put the course's files into an archive |
string | $archive_file_path | The path for the archive file. |
bool | $do_user_permission_checks | Set to true if reading/downloading permissions shall be checked. False otherwise. Default is true. |
bool | $keep_hierarchy | True, if the file hierarchy shall be kept inside the archive. If $keep_hierarchy is set to false you will get an archive that contains only files and no subdirectories. |
- Returns
- bool True, if the archive file was created and saved successfully at $archive_file_path, false otherwise.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ createArchiveFromInstitute()
static createArchiveFromInstitute |
( |
|
$institute_id, |
|
|
|
$user_id = null , |
|
|
|
$archive_file_path = '' , |
|
|
|
$do_user_permission_checks = true , |
|
|
|
$keep_hierarchy = true |
|
) |
| |
|
static |
Creates an archive that contains all files of an institute the given user is allowed to download.
- Parameters
-
string | $institute_id | The ID of the institute whose files shall be put inside an archive. |
string | $user_id | The ID of the user who wishes to put the institute's files into an archive |
string | $archive_file_path | The path for the archive file. |
bool | $do_user_permission_checks | Set to true if reading/downloading permissions shall be checked. False otherwise. Default is true. |
bool | $keep_hierarchy | True, if the file hierarchy shall be kept inside the archive. If $keep_hierarchy is set to false you will get an archive that contains only files and no subdirectories. |
- Returns
- bool True, if the archive file was created and saved successfully at $archive_file_path, false otherwise.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ createArchiveFromPhysicalFolder()
static createArchiveFromPhysicalFolder |
( |
|
$folder_path, |
|
|
|
$archive_file_path |
|
) |
| |
|
static |
This method creates an archive with the content of a physical folder (A folder inside the operating system's file system).
- Parameters
-
string | $folder_path | The path to the physical folder which content shall be added to a file archive. |
string | $archive_file_path | The path to the archive file which shall be created. |
- Returns
- True, if all files were added successfully, false otherwise.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ createArchiveFromUser()
static createArchiveFromUser |
( |
|
$user_id, |
|
|
|
$archive_file_path = '' , |
|
|
|
$do_user_permission_checks = true , |
|
|
|
$keep_hierarchy = true |
|
) |
| |
|
static |
Creates an archive that contains all files of a user, if the current user has root permissions to do this.
- Parameters
-
string | $user_id | The ID of the user whose files shall be put inside an archive. |
string | $archive_file_path | The path for the archive file. |
bool | $do_user_permission_checks | Set to true if reading/downloading permissions shall be checked. False otherwise. Default is true. |
bool | $keep_hierarchy | True, if the file hierarchy shall be kept inside the archive. If $keep_hierarchy is set to false you will get an archive that contains only files and no subdirectories. |
- Returns
- bool True, if the archive file was created and saved successfully at $archive_file_path, false otherwise.
- Exceptions
-
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
◆ createFolderPath()
static createFolderPath |
( |
FolderType |
$folder, |
|
|
User |
$user, |
|
|
|
$path = '' |
|
) |
| |
|
static |
This is a helper method that builds a subfolder hierarchy inside a folder by looking at a string representing a file system path.
The variable $path contains a hierarchy of subfolders that shall be created inside the given folder. If $path contains "folder1/folder2/folder3" then the given folder will get a subfolder named "folder1". The folder "folder1" itself will get a subfolder named "folder2" and so on.
- Parameters
-
FolderType | $folder | The folder where a subfolder path shall be created. |
User | $user | The user who wishes to create the path. |
string | $path | The path which shall be created inside $folder. |
- Returns
- FolderType[] An array with FolderType objects representing each element of $path.
◆ extractArchiveFileToFolder()
static extractArchiveFileToFolder |
( |
FileRef |
$archive_file_ref, |
|
|
FolderType |
$folder, |
|
|
|
$user_id = null |
|
) |
| |
|
static |
Extracts an archive into a folder inside the Stud.IP file area.
- Parameters
-
FileRef | $archive_file_ref | The archive file which shall be extracted. |
FolderType | $folder | The folder where the archive shall be extracted. |
string | $user_id | The ID of the user who wants to extract the archive. |
- Returns
- FileRef[] Array with extracted files, represented as FileRef objects.
◆ extractFileFromArchive()
Extracts one file from an opened archive and stores it in a folder.
- Parameters
-
ZipArchive | $archive | The archive from which a file shall be extracted. |
string | $archive_path | The path of the file in the archive. |
FolderType | $target_folder | The folder where the file shall be stored. |
User | $user | The user who wishes to extract the file from the archive. |
- Returns
- FileRef|null FileRef instance on success, null otherwise.
The documentation for this class was generated from the following file: