Stud.IP  3.1 Revision 48552
 All Data Structures Namespaces Files Functions Variables Groups Pages
datei.inc.php File Reference

Functions

if($GLOBALS['ZIP_USE_INTERNAL']) readfile_chunked ($filename)
 parse_header ($header)
 parse_link ($link, $level=0)
 createSelectedZip ($file_ids, $perm_check=TRUE, $size_check=false)
 createFolderZip ($folder_id, $perm_check=TRUE, $size_check=false)
 createTempFolder ($folder_id, $tmp_full_path, $sem_id, $perm_check=TRUE, $in_recursion=false)
 getFolderChildren ($folder_id)
 getFolderId ($parent_id, $in_recursion=false)
 doc_count ($parent_id, $range_id=null)
 doc_sum_filesize ($parent_id)
 doc_newest ($parent_id)
 doc_challenge ($parent_id)
 get_user_documents_in_folder ($folder_id, $user_id)
 move_item ($item_id, $new_parent, $change_sem_to=false)
 copy_item ($item_id, $new_parent, $change_sem_to=false)
 copy_doc ($doc_id, $new_range, $new_sem=false)
 copy_folder ($folder_id, $new_range, $seed=false, $seminar_id=null)
 edit_item ($item_id, $type, $name, $description, $protected=0, $url= '', $filesize= '')
 create_folder ($name, $description, $parent_id, $permission=7, $seminar_id=null)
 form ($refresh=FALSE)
 prepareFilename ($filename, $shorten=FALSE, $checkfolder=false)
 getFileExtension ($str)
 validate_upload ($the_file, $real_file_name='')
 upload ($the_file, $refresh, $range_id)
 getUploadMetadata ($range_id, $refresh=FALSE)
 JS_for_upload ()
 upload_item ($range_id, $create=FALSE, $echo=FALSE, $refresh=FALSE)
 insert_link_db ($range_id, $the_file_size, $refresh=FALSE)
 link_item ($range_id, $create=FALSE, $echo=FALSE, $refresh=FALSE, $link_update=FALSE)
 link_form ($range_id, $updating=FALSE)
 display_file_body ($datei, $folder_id, $open, $change, $move, $upload, $all, $refresh=FALSE, $filelink="")
 display_file_line ($datei, $folder_id, $open, $change, $move, $upload, $all, $refresh=FALSE, $filelink="", $anchor_id, $position="middle")
 display_folder_body ($folder_id, $open, $change, $move, $upload, $refresh=FALSE, $filelink="", $anchor_id, $level=0)
 display_folder ($folder_id, $open, $change, $move, $upload, $refresh=FALSE, $filelink="", $anchor_id, $position="middle", $isissuefolder=false)
 getLinkPath ($file_id)
 GetFileIcon ($ext, $with_img_tag=false)
 get_mime_type ($filename)
 GetDownloadLink ($file_id, $file_name, $type=0, $dltype= 'normal', $range_id= '', $list_id= '')
 delete_document ($dokument_id, $delete_only_file=FALSE)
 delete_link ($dokument_id)
 delete_folder ($folder_id, $delete_subfolders=false)
 recursiv_folder_delete ($parent_id)
 delete_all_documents ($range_id)
 rmdirr ($dirname)
 create_zip_from_file ($file_name, $zip_file_name)
 create_zip_from_directory ($fullpath, $zip_file_name)
 create_zip_from_newest_files ()
 unzip_file ($file_name, $dir_name= '', $testonly=false)
 upload_zip_item ()
 upload_recursively ($range_id, $dir)
 upload_zip_file ($dir_id, $file)
 pclzip_convert_filename_cb ($p_event, &$p_header)
 get_flash_player ($document_id, $filename, $type)
 get_upload_file_path ($document_id)
 check_protected_download ($document_id, $allow_owner=true)
 array_to_csv ($data, $filename=null, $caption=null, $delimiter= ';', $enclosure= '"', $eol = "\r\n" )

Variables

 $countfiles = 0
 $countfolder = 0
 $droppable_folder = 0

Function Documentation

array_to_csv (   $data,
  $filename = null,
  $caption = null,
  $delimiter = ';',
  $enclosure = '"',
  $eol = "\r\n" 
)

converts a given array to a csv format

Parameters
array$datathe data to convert, each row should be an array
string$filenamefull path to a file to write to, if omitted the csv content is returned
array$captionassoc array with captions, is written to the first line, $data is filtered by keys
string$delimitersets the field delimiter (one character only)
string$enclosuresets the field enclosure (one character only)
string$eolsets the end of line format
Returns
mixed if $filename is given the number of written bytes, else the csv content as string

Here is the caller graph for this function:

check_protected_download (   $document_id,
  $allow_owner = true 
)

checks if the 'protected' flag of a file is set and if the course access is closed

Parameters
stringMD5 id of the file
Returns
bool

Here is the caller graph for this function:

copy_doc (   $doc_id,
  $new_range,
  $new_sem = false 
)

Here is the call graph for this function:

Here is the caller graph for this function:

copy_folder (   $folder_id,
  $new_range,
  $seed = false,
  $seminar_id = null 
)

Here is the call graph for this function:

Here is the caller graph for this function:

copy_item (   $item_id,
  $new_parent,
  $change_sem_to = false 
)

Here is the call graph for this function:

create_folder (   $name,
  $description,
  $parent_id,
  $permission = 7,
  $seminar_id = null 
)

Create a 'folder' in the files module of a course or institution. Particularly interesting is the third parameter $parent_id mapping to the 'range_id' field in the database table 'folder'. It is used to create a tree structure of folders but is not the usual parent key. Instead it is one of these:

  • $parent_id equals the course's ID, if this folder is the "Allgemeine Dateien" folder.
  • $parent_id equals the ID of an entry in table 'statusgruppen', if the folder is associated to that entry.
  • $parent_id equals the ID of an entry in table 'themen', if the folder is associated to that entry.
  • $parent_id equals `md5($cid . 'top_folder')`, if that folder is not the "Allgemeine Dateien" folder, but exists in the same depth of the tree as the mentioned folder. (blame StEP0008)
  • otherwise $parent_id equals the ID of the parent folder.
Parameters
string$namethe name of the folder
string$descriptiona description of the folder, may be the empty string
string$parent_idsome kind of foreign key used to create a tree structure of folders as described above
int$permissionbit-OR your permission: 0001 = visible, 0010 = writable, 0100 = readable, 1000 = extendable
string$seminar_idan optional parameter used to associate with a course or institute. $SessionSeminar is used, if it is missing.
Returns
the ID of the folder if successful, otherwise NULL

Here is the call graph for this function:

Here is the caller graph for this function:

create_zip_from_directory (   $fullpath,
  $zip_file_name 
)

Here is the caller graph for this function:

create_zip_from_file (   $file_name,
  $zip_file_name 
)
create_zip_from_newest_files ( )

Here is the call graph for this function:

createFolderZip (   $folder_id,
  $perm_check = TRUE,
  $size_check = false 
)

creates a zip file from all files in given folder, including subfolders

Parameters
string$folder_idid of document folder
bool$perm_checkif true, files are checked for folder permissions
bool$size_checkif true, number and size of files are checked against config values
Returns
string filename(id) of the created zip without path

Here is the call graph for this function:

createSelectedZip (   $file_ids,
  $perm_check = TRUE,
  $size_check = false 
)

creates a zip file from given ids in tmp directory

Parameters
array$file_idsarray of document ids
bool$perm_checkif true, files are checked for folder permissions
bool$size_checkif true, number and size of files are checked against config values
Returns
string filename(id) of the created zip without path

Here is the call graph for this function:

Here is the caller graph for this function:

createTempFolder (   $folder_id,
  $tmp_full_path,
  $sem_id,
  $perm_check = TRUE,
  $in_recursion = false 
)

used by createFolderZip() to dive into subfolders collects a list of file metadata and returns it when recursion finishes

Parameters
string$folder_idid of a folder
string$tmp_full_pathtemporary path
bool$perm_checkif true, files are checked for folder permissions
bool$in_recursionused internally to indicate recursive call
Returns
array assoc array with metadata from zipped files

Here is the call graph for this function:

Here is the caller graph for this function:

delete_all_documents (   $range_id)

Here is the call graph for this function:

Here is the caller graph for this function:

delete_document (   $dokument_id,
  $delete_only_file = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

delete_folder (   $folder_id,
  $delete_subfolders = false 
)

Here is the call graph for this function:

Here is the caller graph for this function:

delete_link (   $dokument_id)

Here is the caller graph for this function:

display_file_body (   $datei,
  $folder_id,
  $open,
  $change,
  $move,
  $upload,
  $all,
  $refresh = FALSE,
  $filelink = "" 
)

Displays the body of a file containing the decription, downloadbuttons and change-forms

Here is the call graph for this function:

Here is the caller graph for this function:

display_file_line (   $datei,
  $folder_id,
  $open,
  $change,
  $move,
  $upload,
  $all,
  $refresh = FALSE,
  $filelink = "",
  $anchor_id,
  $position = "middle" 
)

Displays one file/document with all of its information and options.

Here is the call graph for this function:

Here is the caller graph for this function:

display_folder (   $folder_id,
  $open,
  $change,
  $move,
  $upload,
  $refresh = FALSE,
  $filelink = "",
  $anchor_id,
  $position = "middle",
  $isissuefolder = false 
)

Displays the folder and all of its documents and recursively subfolders. This function is not dependent on the recursive-level so it looks as if it all starts from here.

Here is the call graph for this function:

Here is the caller graph for this function:

display_folder_body (   $folder_id,
  $open,
  $change,
  $move,
  $upload,
  $refresh = FALSE,
  $filelink = "",
  $anchor_id,
  $level = 0 
)

Displays the body of a folder including the description, changeform, subfolder and files

Here is the call graph for this function:

Here is the caller graph for this function:

doc_challenge (   $parent_id)

Here is the call graph for this function:

doc_count (   $parent_id,
  $range_id = null 
)

Counts and returns the number files in the given folder and subfolders. Files not visible to the current user are not counted

Parameters
$parent_ida folder id
$range_idthe range id for the folder, course or institute id
Returns
integer

Here is the call graph for this function:

Here is the caller graph for this function:

doc_newest (   $parent_id)

Here is the call graph for this function:

Here is the caller graph for this function:

doc_sum_filesize (   $parent_id)

Here is the call graph for this function:

Here is the caller graph for this function:

edit_item (   $item_id,
  $type,
  $name,
  $description,
  $protected = 0,
  $url = '',
  $filesize = '' 
)

Here is the call graph for this function:

Here is the caller graph for this function:

form (   $refresh = FALSE)

Here is the call graph for this function:

Here is the caller graph for this function:

get_flash_player (   $document_id,
  $filename,
  $type 
)

Here is the call graph for this function:

Here is the caller graph for this function:

get_mime_type (   $filename)

Determines an appropriate MIME type for a file based on the extension of the file name.

Parameters
string$filenamefile name to check

Here is the call graph for this function:

Here is the caller graph for this function:

get_upload_file_path (   $document_id)

Return the absolute path of an uploaded file. The uploaded files are organized in sub-folders of UPLOAD_PATH to avoid performance problems with large directories. If the document_id is empty, NULL is returned.

Parameters
stringMD5 id of the uploaded file

Here is the caller graph for this function:

get_user_documents_in_folder (   $folder_id,
  $user_id 
)

Here is the call graph for this function:

Here is the caller graph for this function:

GetDownloadLink (   $file_id,
  $file_name,
  $type = 0,
  $dltype = 'normal',
  $range_id = '',
  $list_id = '' 
)

Erzeugt einen Downloadlink abhaengig von der Konfiguration des Systems ($GLOBALS['SENDFILE_LINK_MODE'] = 'normal'|'old'|'rewrite')

Parameters
string$file_id
string$file_name
integer$typesendfile type 1,2,3,4,5 or 6
string$dltype'normal', 'zip' or 'force' (or 'force_download')
Returns
string downloadlink

Here is the call graph for this function:

Here is the caller graph for this function:

getFileExtension (   $str)

Here is the caller graph for this function:

GetFileIcon (   $ext,
  $with_img_tag = false 
)

Here is the call graph for this function:

Here is the caller graph for this function:

getFolderChildren (   $folder_id)

Returns the read- and executable subfolders to a given folder_id : id of the target folder

Returns
: array($subfolders, $numberofsubfolders)

Here is the call graph for this function:

Here is the caller graph for this function:

getFolderId (   $parent_id,
  $in_recursion = false 
)

Here is the call graph for this function:

Here is the caller graph for this function:

getLinkPath (   $file_id)

Here is the call graph for this function:

Here is the caller graph for this function:

getUploadMetadata (   $range_id,
  $refresh = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

insert_link_db (   $range_id,
  $the_file_size,
  $refresh = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

JS_for_upload ( )

Here is the call graph for this function:

link_form (   $range_id,
  $updating = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

link_item (   $range_id,
  $create = FALSE,
  $echo = FALSE,
  $refresh = FALSE,
  $link_update = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

move_item (   $item_id,
  $new_parent,
  $change_sem_to = false 
)

Here is the call graph for this function:

Here is the caller graph for this function:

parse_header (   $header)

Here is the caller graph for this function:

parse_link (   $link,
  $level = 0 
)

Here is the call graph for this function:

Here is the caller graph for this function:

pclzip_convert_filename_cb (   $p_event,
$p_header 
)
prepareFilename (   $filename,
  $shorten = FALSE,
  $checkfolder = false 
)

kills forbidden characters in filenames, shortens filename to 31 Characters if desired, checks for unique filename in given folder and modifies filename if needed

Parameters
string$filenameoriginal filename
bool$shortenif true, filename is shortened to 31 chars
bool$checkfolderif true, uniqueness of filename in this folder is guaranteed
Returns
string the modified filename

Here is the call graph for this function:

Here is the caller graph for this function:

if ($GLOBALS['ZIP_USE_INTERNAL']) readfile_chunked (   $filename)
recursiv_folder_delete (   $parent_id)

Here is the call graph for this function:

Here is the caller graph for this function:

rmdirr (   $dirname)

Delete a file, or a folder and its contents

Author
Aidan Lister aidan.nosp@m.@php.nosp@m..net
Version
1.0
Parameters
string$dirnameThe directory to delete
Returns
bool Returns true on success, false on failure

Here is the caller graph for this function:

unzip_file (   $file_name,
  $dir_name = '',
  $testonly = false 
)

Here is the caller graph for this function:

upload (   $the_file,
  $refresh,
  $range_id 
)

Here is the call graph for this function:

Here is the caller graph for this function:

upload_item (   $range_id,
  $create = FALSE,
  $echo = FALSE,
  $refresh = FALSE 
)

Here is the call graph for this function:

Here is the caller graph for this function:

upload_recursively (   $range_id,
  $dir 
)

Laedt eine bestehende Verzeichnisstruktur in das System. Die ganze Struktur wird samt Dateien und Unterverzeichnissen rekursiv eingefuegt: 1. Den aktuellen Ordner erstellen. – 2. Die Dateien in alphabetischer Reihenfolge einfuegen. – 3. Die Verzeichnisstruktur jedes Unterordners einfuegen (Rekursion). Nach Einfuegen einer Datei / eines Verzeichnisses wird die Datei oder das Verzeichnis geloescht.

Parameters
range_idDie ID des Ordners unter dem die Verzeichnisstruktur
dir
Returns
(no return value)

Here is the call graph for this function:

Here is the caller graph for this function:

upload_zip_file (   $dir_id,
  $file 
)

Eine einzelne Datei in das Verzeichnis mit der dir_id einfuegen.

Here is the call graph for this function:

Here is the caller graph for this function:

upload_zip_item ( )

Here is the call graph for this function:

validate_upload (   $the_file,
  $real_file_name = '' 
)

Checks whether a given file upload is valid and allowed.

Parameters
$the_filefile to upload to Stud.IP
$real_file_namean optional real file name for handling files inside a ZIP (otherwise, the filename of the ZIP itself would always be used)
Returns
Can the given file be uploaded to Stud.IP?

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

$countfiles = 0
$countfolder = 0
$droppable_folder = 0