Stud.IP
5.4
|
Static Public Member Functions | |
static | addFileTypeToArchive (ZipArchive $archive, FileType $file_type, $user_id=null, $archive_fs_path='', $do_user_permission_checks=true, $ignore_user=false, &$file_list=null) |
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 (FileType $archive_file, 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.
|
static |
Adds a FileRef to a Zip archive. This is only a wrapper to addFileTypeToArchive that exists only for compatibility reasons.
|
static |
Adds a file to an archive using its FileType object.
ZipArchive | $archive | The Zip archive where the FileRef shall be added to. |
FileType | $file_type | The FileType 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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
static |
Adds a FolderType instance to a Zip archive.
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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
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.
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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
static |
Creates an archive that contains all files of a course the given user is allowed to download.
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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
static |
Puts files (identified by their file refs) into one file archive.
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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
static |
Creates an archive that contains all files of a course the given user is allowed to download.
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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
static |
Creates an archive that contains all files of an institute the given user is allowed to download.
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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
static |
This method creates an archive with the content of a physical folder (A folder inside the operating system's file system).
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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
static |
Creates an archive that contains all files of a user, if the current user has root permissions to do this.
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. |
Exception|FileArchiveManagerException | If an error occurs a general exception or a more special exception is thrown. |
|
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.
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. |
|
static |
Extracts an archive into a folder inside the Stud.IP file area.
FileType | $archive_file | 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. |
|
static |
Extracts one file from an opened archive and stores it in a folder.
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. |