Detailed Description
StudipDocument.class.php
- Author
- André Noack <noack-quest>, Suchi & Berg GmbH info@.nosp@m.data.nosp@m.-ques.nosp@m.t.de public Small class derived from SimpleORMap to give access to the table dokumente
-
André Noack
Constructor & Destructor Documentation
| __construct |
( |
|
$id = null | ) |
|
constructor
- Parameters
-
| string | id: primary key of table dokumente |
- Returns
- null
Reimplemented from SimpleORMap.
Member Function Documentation
checks access to the document for user with given user_id the number of deleted rows.
- Parameters
-
| string | user_id: id of the user |
- Returns
- boolean: true if user has access to the document
| static createWithFile |
( |
|
$file, |
|
|
|
$data |
|
) |
| |
|
static |
Create a new document using the given file and metadata. This method makes sure that there are no inconsistencies between a real file and its database entry. Only if the file were copied/moved to the documents folder, the database entry is written. If this fails too, the file will be unlinked again. The first parameter can either be an uploaded file or the path to an already existing one. This file will either be moved using move_uploaded_file or it will be copied. The destination is determined this way: If the second parameter $data already contains a "dokument_id", this will be used as the file's destination. This is usually the case when refreshing a file. If there is no such parameter, a new "dokument_id" is generated as usual and is used as the file's destination.
Before a document (and its file) is created, the notification "DocumentWillCreate" will be posted. If the document was created successfuly, the notification "DocumentDidCreate" will be posted. It the document was updated rather than created (see above), the notifications will be "DocumentWillUpdate" and "DocumentDidUpdate". The subject of the notification will always be that document.
- Parameters
-
| $file | string full path to a file (either uploaded or already existing) |
| $data | array an array containing the metadata of the document; just use the same way as StudipDocument::setData |
- Returns
- StudipDocument|null if successful the created document, null otherwise
Delete entry from database. The object is cleared and turned to new state. Posts the Notifications "Document(Will|Did)Delete" if successful. The subject of the notification is the former document.
- Returns
- boolean always true
Reimplemented from SimpleORMap.
| static deleteBySql |
( |
|
$where | ) |
|
|
static |
deletes table rows which matches the given sql-where clause and returns the number of deleted rows.
- Parameters
-
| string | sql clause to use on the right side of WHERE to delete all rows matching this clause |
- Returns
- int: number of rows deleted by the given sql-where-clause.
returns new instance of StudipDocument for given id or null if id does not exist
- Parameters
-
| id | string primary key of table 'dokumente' in db |
- Returns
- object of type StudipDocument that matches id or null if nothing matches id
| static findByCourseId |
( |
|
$cid | ) |
|
|
static |
returns array of StudipDocument-objects of given course id
- Parameters
-
| string | cid: course_id in the db (Seminar_id) with which all StudipDocuments should be filtered |
- Returns
- array of all StudipDocument from the course with the given course_id
| static findByFolderId |
( |
|
$folder_id | ) |
|
|
static |
returns array of document-objects of given folder with id folder_id
- Parameters
-
| string | folder_id: id of a folder whose documents we want to catch |
- Returns
- array of StudipDocument objects of the given folder_id's folder or empty if that folder contains no documents.
| static findBySql |
( |
|
$where | ) |
|
|
static |
returns array of instances of StudipDocument filtered by given sql-where-clause
- Parameters
-
| string,: | sql-where clause to use on the right side of WHERE to filter all StudipDocuments in an array |
- Returns
- array of StudipDocument filtered by where (sql-qhere-clause) or empty array if no matches were found
The documentation for this class was generated from the following file: