Created
February 6, 2013 04:06
-
-
Save RyanCopley/4720187 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileManager | |
private $user | |
FileManager(int userid [,mixed options]) instantiates with a user name, should call the function setUser(id userid) below | |
FileManager(str user [,mixed options]) instantiates with a user name, should call the function below | |
setUser(str user [, mixed options]) - Calls the function below after fetching the ID of the user | |
setUser(int userid [, mixed options]) - Should set the user variable, and check to see if the current user is the one provided. This should clear all data for this object upon setting | |
getUser() - Return the user model that is loaded for this FM. | |
getUserFolder() - Return the folder model for the users root. This should be the only way to fetch thee folder from the external world, everything else must be boxed off from this. | |
FILE AND FOLDERS SHOULD ENSURE THAT THEY WERE SPAWNED VIA A FILE MANAGER | |
IF NOT, THEEY CAN GO BLANK THEMSELVES. | |
File model shit | |
getFileHitCount() - Returns the download count | |
getFileSize() - returns the file size. Spectrenectre said to make sure we store it in the db... | |
getFileDate() - returns the file date. Spectrenectre said to make sure we store it in the db... | |
getFolder() - Returns the folder this file belongs to | |
isFileLocked() - Returns if the file is locked. Things like the users avatar and various other things may be locked, disabling the user from directly modifying them. | |
isSystemFile() | |
isDeletable() | |
//for filemanager::getFileList so we can iterate over them and not worry about object type | |
isFolder() - false | |
isFile() - true | |
fileUpload() - I'm not sure how to handle this. Passing all the data via value is a bad idea. Make sure you don't go crazy on the memory... | |
fileDownload() - Increments the download counter and redirects the user to the file. It is important to note that if you use header("Location" ...) that nothing may be printed out before this. It might be useeful to look at this and try to come up with some solution: http://www.webdeveloper.com/forum/showthread.php?185111-using-header()-after-output-was-sent | |
getFileDownloadURL(file) - Returns the download link of a file. This should go somewhere that ends up calling fileDownload()... probably an ajax call or something of the sorts? | |
systemOverrideWriteRestrictions() - Disables any security for getIsUploadable and folderIsWritable. This is for internal usage only for things like mail attachments, games, so the site can handle moving files to that folder. We do not want the users touching this folder. | |
folder model shit | |
isLocked() - Returns if the folder is locked. Things like the users avatar and various other things may be locked, disabling the user from directly modifying them. System folders will all be locked. | |
isSystemFolder() | |
//for filemanager::getFileList so we can iterate over them and not worry about object type | |
isFolder() - true | |
isFile() - false | |
getFileList() | |
fileExists(str filename) - Returns if this user has the file available | |
fileFind(str filename [, int recursive]) - regex compatible file search via filename. Should return an array of results | |
systemOverrideWriteRestrictions() - Disables any security for getIsUploadable and folderIsWritable. This is for internal usage only for things like mail attachments, games, so the site can handle moving files to that folder. We do not want the users touching this folder. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment