Stud.IP  6.0
FileRef Class Reference
Inheritance diagram for FileRef:
SimpleORMap PrivacyObject FeedbackRange

Public Member Functions

 cbLogDeleteFileRef ()
 
 cbRemoveFileIfOrphaned ()
 
 cbRemoveFeedbackElements ()
 
 cbMakeUniqueFilename ()
 
 setDownloadURL ($field, $url)
 
 getDownloadURL ($dltype='normal')
 
 getAuthorName ()
 
 getAccessibility ()
 
 incrementDownloadCounter ()
 
 getLicenseObject ()
 
 isLink ()
 
 setFolderType ($field, FolderType $folder_type)
 
 getFolderType ()
 
 isImage ()
 
 isAudio ()
 
 isVideo ()
 
 getFileType ()
 
 getRangeName ()
 
 getRangeIcon ($role)
 
 getRangeUrl ()
 
 getRangeCourseId ()
 
 isRangeAccessible (string $user_id=null)
 
- Public Member Functions inherited from SimpleORMap
 __construct ($id=null)
 
 __clone ()
 
 getRelationOptions ($relation)
 
 getTableMetadata ()
 
 hasAutoIncrementColumn ()
 
 setId ($id)
 
 getId ()
 
 getNewId ()
 
 toArray ($only_these_fields=null)
 
 toRawArray ($only_these_fields=null)
 
 toArrayRecursive ($only_these_fields=null)
 
 getValue ($field)
 
 getRelationValue ($relation, $field)
 
 getDefaultValue ($field)
 
 setValue ($field, $value)
 
 __get ($field)
 
 __set ($field, $value)
 
 __isset ($field)
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 getIterator ()
 
 count ()
 
 isField ($field)
 
 isRelation ($field)
 
 isAdditionalField ($field)
 
 isAliasField ($field)
 
 isI18nField ($field)
 
 setData ($data, $reset=false)
 
 isNew ()
 
 isDeleted ()
 
 setNew ($is_new)
 
 getWhereQuery ()
 
 restore ()
 
 store ()
 
 triggerChdate ()
 
 delete ()
 
 isDirty ()
 
 isFieldDirty ($field)
 
 revertValue ($field)
 
 getPristineValue ($field)
 
 initRelation ($relation)
 
 resetRelation ($relation)
 
 cleanup ()
 
- Public Member Functions inherited from FeedbackRange
 getId ()
 

Static Public Member Functions

static exportUserData (StoredUserData $storage)
 
static findAll ($user_id, $begin=null, $end=null, $course_id=null, $file_limit=0, $file_offset=0)
 
static countAll ($user_id, $begin=null, $end=null, $course_id=null)
 
static findPublicFiles ($user_id, $begin=null, $end=null, $file_limit=0, $file_offset=0)
 
static countPublicFiles ($user_id, $begin=null, $end=null)
 
static findUploadedFiles ($user_id, $begin=null, $end=null, $course_id='', $unknown_license_only=false, $file_limit=0, $file_offset=0)
 
static countUploadedFiles ($user_id, $begin=null, $end=null, $course_id='', $unknown_license_only=false)
 
- Static Public Member Functions inherited from SimpleORMap
static tableScheme ($db_table)
 
static expireTableScheme ()
 
static exists ($id)
 
static countBySql ($sql='1', $params=[])
 
static create ($data)
 
static build ($data, $is_new=true)
 
static buildExisting ($data)
 
static import ($data)
 
static findBySQL ($sql, $params=[])
 
static findOneBySQL ($where, $params=[])
 
static findThru ($foreign_key_value, $options)
 
static findEachBySQL ($callable, $sql, $params=[])
 
static findMany ($pks=[], $order='', $order_params=[])
 
static findEachMany ($callable, $pks=[], $order='', $order_params=[])
 
static findAndMapBySQL ($callable, $where, $params=[])
 
static findAndMapMany ($callable, $pks=[], $order='', $order_params=[])
 
static deleteBySQL ($where, $params=[])
 
static toObject ($id_or_object)
 
static __callStatic (string $name, array $arguments)
 

Data Fields

 $path_to_blob
 
- Data Fields inherited from SimpleORMap
const ID_SEPARATOR = '_'
 

Static Protected Member Functions

static configure ($config=[])
 
static getAllSql ($user_id, $begin=null, $end=null, $course_id='', $file_limit=0, $file_offset=0)
 
static getPublicFilesSql ($user_id, $begin=null, $end=null, $file_limit=0, $file_offset=0)
 
static getUploadedFilesSql ($user_id, $begin=null, $end=null, $course_id='', $unknown_license_only=false, $file_limit=0, $file_offset=0)
 
- Static Protected Member Functions inherited from SimpleORMap
static db_table ()
 
static db_fields ()
 
static pk ()
 
static default_values ()
 
static serialized_fields ()
 
static alias_fields ()
 
static i18n_fields ()
 
static additional_fields ()
 
static has_many ()
 
static has_one ()
 
static belongs_to ()
 
static has_and_belongs_to_many ()
 
static registered_callbacks ()
 
static known_slots ()
 
static notification_map ()
 
static getter_setter_map ()
 
static configure ($config=[])
 
static config ($key)
 
static registerCallback ($types, $cb)
 
static unregisterCallback ($types, $cb)
 

Protected Attributes

 $folder_type
 
 $download_url
 
- Protected Attributes inherited from SimpleORMap
 $content = []
 
 $content_db = []
 
 $is_new = true
 
 $is_deleted = false
 
 $relations = []
 
 $additional_data = []
 

Additional Inherited Members

- Static Public Attributes inherited from SimpleORMap
static $schemes = null
 
- Protected Member Functions inherited from SimpleORMap
 _getId ($field)
 
 _setId ($field, $value)
 
 _getAdditionalValueFromRelation ($field)
 
 _setAdditionalValueFromRelation ($field, $value)
 
 _getAdditionalValue ($field)
 
 _setAdditionalValue ($field, $value)
 
 parseRelationOptions ($type, $name, $options)
 
 storeRelations ($only_these=null)
 
 deleteRelations ()
 
 initializeContent ()
 
 applyCallbacks ($type)
 
 cbNotificationMapper ($cb_type)
 
 cbAfterInitialize ($cb_type)
 
 setSerializedValue ($field, $value)
 
 setI18nValue ($field, $value)
 
- Static Protected Attributes inherited from SimpleORMap
static $config = []
 
static $reserved_slots = ['value','newid','iterator','tablemetadata', 'relationvalue','wherequery','relationoptions','data','new','id']
 
static $performs_batch_operation = false
 

Member Function Documentation

◆ cbLogDeleteFileRef()

cbLogDeleteFileRef ( )

◆ cbMakeUniqueFilename()

cbMakeUniqueFilename ( )

This callback is called before storing a FileRef object. In case the name field is changed this callback assures that the name of the FileRef is unique inside the folder where the FileRef is placed.

◆ cbRemoveFeedbackElements()

cbRemoveFeedbackElements ( )

This callback is called after deleting a FileRef. It removes feedback elements that are associated with the FileRef.

◆ cbRemoveFileIfOrphaned()

cbRemoveFileIfOrphaned ( )

This callback is called after deleting a FileRef. It removes the File object that is associated with the FileRef, if the File is not referenced by any other FileRef object.

◆ configure()

static configure (   $config = [])
staticprotected

◆ countAll()

static countAll (   $user_id,
  $begin = null,
  $end = null,
  $course_id = null 
)
static

This method counts all the FileRef objects a user has access to.

See also
FileRef::getAllSql for the parameter description.
Returns
int The amount of found FileRef rows.

◆ countPublicFiles()

static countPublicFiles (   $user_id,
  $begin = null,
  $end = null 
)
static

This method counts the FileRef objects in public folders which can be accessed by a user.

See also
FileRef::getPublicFilesSql for the parameter description.
Returns
int The amount of found FileRef rows.

◆ countUploadedFiles()

static countUploadedFiles (   $user_id,
  $begin = null,
  $end = null,
  $course_id = '',
  $unknown_license_only = false 
)
static

Counts all uploaded files a user has uploaded.

See also
FileRef::getUploadedFilesSql for the parameter description.
Returns
int The amount of files the user uploaded.

◆ exportUserData()

static exportUserData ( StoredUserData  $storage)
static

Export available data of a given user into a storage object (an instance of the StoredUserData class) for that user.

Parameters
StoredUserData$storageobject to store data into

Implements PrivacyObject.

◆ findAll()

static findAll (   $user_id,
  $begin = null,
  $end = null,
  $course_id = null,
  $file_limit = 0,
  $file_offset = 0 
)
static

This method retrieves the FileRef objects a user has access to.

See also
FileRef::getAllSql for the parameter description.
Returns
FileRef[] A list of FileRef objects.

◆ findPublicFiles()

static findPublicFiles (   $user_id,
  $begin = null,
  $end = null,
  $file_limit = 0,
  $file_offset = 0 
)
static

This method retrieves the FileRef objects in public folders which can be accessed by a user.

See also
FileRef::getPublicFilesSql for the parameter description.
Returns
FileRef[] A list of FileRef objects.

◆ findUploadedFiles()

static findUploadedFiles (   $user_id,
  $begin = null,
  $end = null,
  $course_id = '',
  $unknown_license_only = false,
  $file_limit = 0,
  $file_offset = 0 
)
static

Retrieves all uploaded files a user has uploaded.

See also
FileRef::getUploadedFilesSql for the parameter description.
Returns
FileRef[] A list of FileRef objects for files the user uploaded.

◆ getAccessibility()

getAccessibility ( )

Returns true if the file is accessible

◆ getAllSql()

static getAllSql (   $user_id,
  $begin = null,
  $end = null,
  $course_id = '',
  $file_limit = 0,
  $file_offset = 0 
)
staticprotected

This is a helper method to generate the SQL query for the findAll and countAll methods. Relevant FileRef objects for these methods can be limited by a time range and a specific course. The amount and the offset of the FileRef objects to be retrieved can also be set.

Parameters
string$user_idThe ID of the user that is used to count or retrieve FileRef objects.
DateTime | null$beginThe begin of the time range.
DateTime | null$endThe end of the time range.
string$course_idThe ID of the course from which FileRef objects shall be retrieved.
int$file_limitThe maximum amount of FileRef objects to be retrieved.
int$file_offsetThe offset in the FileRef data from which to start retrieving objects.
Returns
mixed[] An array with two indexes:
  • sql: The SQL query string.
  • params: An array with SQL query parameters.

◆ getAuthorName()

getAuthorName ( )

Returns the name of the FileRef's author.

Returns
string The name of the FileRef's author.

◆ getDownloadURL()

getDownloadURL (   $dltype = 'normal')

Returns the download-URL for the FileRef.

Parameters
string$dltypeThe download type: 'normal', 'zip', 'force' or 'force_download'.
Returns
string The URL for the FileRef.

◆ getFileType()

getFileType ( )
Returns
FileType

◆ getFolderType()

getFolderType ( )

◆ getLicenseObject()

getLicenseObject ( )

Returns the license object for this file.

Returns
Object (to be specified!)

◆ getPublicFilesSql()

static getPublicFilesSql (   $user_id,
  $begin = null,
  $end = null,
  $file_limit = 0,
  $file_offset = 0 
)
staticprotected

This is a helper method to generate the SQL query for the findPublicFiles and countPublicFiles methods. Relevant FileRef objects for these methods can be limited by a time range. The amount and the offset of the FileRef objects to be retrieved can also be set.

Parameters
string$user_idThe ID of the user that is used to count or retrieve FileRef objects in public folders.
DateTime | null$beginThe begin of the time range.
DateTime | null$endThe end of the time range.
int$file_limitThe maximum amount of FileRef objects to be retrieved from public folders.
int$file_offsetThe offset in the FileRef data from which to start retrieving objects from public folders.
Returns
mixed[] An array with two indexes:
  • sql: The SQL query string.
  • params: An array with SQL query parameters.

◆ getRangeCourseId()

getRangeCourseId ( )

Returns the course id of FeedbackRange object instance

Returns
string course_id

Implements FeedbackRange.

◆ getRangeIcon()

getRangeIcon (   $role)

Returns the icon object that shall be used with the FeedbackRange object instance.

Parameters
string$rolerole of icon
Returns
Icon icon for the FeedbackRange object instance.

Implements FeedbackRange.

◆ getRangeName()

getRangeName ( )

Returns a human-friendly representation of the FeedbackRange object instance's name.

Returns
string A human-friendly name for the FeedbackRange object instance.

Implements FeedbackRange.

◆ getRangeUrl()

getRangeUrl ( )

Returns the URL of FeedbackRange view, where the object instance is visible together with the related feedback element(s).

Returns
string Path that is usable with the url_for and link_for methods.

Implements FeedbackRange.

◆ getUploadedFilesSql()

static getUploadedFilesSql (   $user_id,
  $begin = null,
  $end = null,
  $course_id = '',
  $unknown_license_only = false,
  $file_limit = 0,
  $file_offset = 0 
)
staticprotected

This is a helper method to generate the SQL query for the findUploadedFiles and countUploadedFiles methods. Relevant FileRef objects for these methods can be limited by a time range and a specified course. Furthermore, it is possible to limit the search to FileRef objects without a license set or with the "unknown" license set. The amount and the offset of the FileRef objects to be retrieved can also be set.

Parameters
string$user_idThe ID of the user whose uploaded files shall be retrieved or counted.
DateTime | null$beginThe begin of the time range.
DateTime | null$endThe end of the time range.
string$course_idThe ID of the course from which FileRef objects shall be retrieved.
bool$unknown_license_onlyWhether to only query for FileRef objects without a license or with the "unknown" license set (true) or to query all uploaded FileRef objects (false). Defaults to false.
int$file_limitThe maximum amount of FileRef objects to be retrieved from public folders.
int$file_offsetThe offset in the FileRef data from which to start retrieving objects from public folders.
Returns
mixed[] An array with two indexes:
  • sql: The SQL query string.
  • params: An array with SQL query parameters.

◆ incrementDownloadCounter()

incrementDownloadCounter ( )

This method increments the download counter of the FileRef.

Returns
int The number of rows of the file_refs table that have been altered.

◆ isAudio()

isAudio ( )

Determines if the FileRef references an audio file.

Returns
bool True, if the referenced file is an audio file, false otherwise.

◆ isImage()

isImage ( )

Determines if the FileRef references an image file.

Returns
bool True, if the referenced file is an image file, false otherwise.

◆ isLink()

isLink ( )

Determines whether this FileRef is a link or not.

Returns
bool True, if the FileRef references a link, false otherwise.

◆ isRangeAccessible()

isRangeAccessible ( string  $user_id = null)

Returns the accessebility of FeedbackRange object instance for current active user

Parameters
string$user_idoptional; use this ID instead of $GLOBALS['user']->id
Returns
bool range object accessebility

Implements FeedbackRange.

◆ isVideo()

isVideo ( )

Determines if the FileRef references a video file.

Returns
bool True, if the referenced file is a video file, false otherwise.

◆ setDownloadURL()

setDownloadURL (   $field,
  $url 
)

Overrides the usual download url that this file_ref would get by the system (sendfile.php...) Use this method by cloud plugins. If you set download URL to null, the normal sendfile.php will be set as default download URL.

Parameters
$url: string as URL or null to set URL to sendfile.php-URL

◆ setFolderType()

setFolderType (   $field,
FolderType  $folder_type 
)

Field Documentation

◆ $download_url

$download_url
protected

◆ $folder_type

$folder_type
protected

◆ $path_to_blob

$path_to_blob

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