/blog/www/system/module/system/library/System/Upload.php
PHP | 33 lines | 29 code | 4 blank | 0 comment | 0 complexity | 02d6090d439c5f7680a52a2841c0aeef MD5 | raw file
Possible License(s): BSD-3-Clause
- <?php
- class System_Upload extends DoctrineX_Record
- {
- public function setTableDefinition()
- {
- $this->hasColumn('id', 'integer', null, array('autoincrement' => true, 'primary' => true));
- $this->hasColumn('name', 'string', 64);
- $this->hasColumn('hash', 'string', 32);
- $this->hasColumn('size', 'integer');
- $this->hasColumn('mimeType', 'string', 32);
- $this->actAs(new DoctrineX_Template_Owner());
- }
- public function preDelete()
- {
- $filename = $this->getUser()->getUploadsPath($this->user_id) . '/' . $this->name;
- IO_File::delete($filename);
- }
- public function fromFile(Zend_Form_Element_File $file)
- {
- $this->name = $file->getFileName(null, false);
- $this->hash = $file->getHash('md5');
- $this->size = $file->getFileSize();
- $this->mimeType = $file->getMimeType();
- }
- public function fetchUserUploadsAsPairs($id, $key = 'id', $value = 'name', $options = array(), Doctrine_Query $query = null)
- {
- return $this->fetchAllAsPairs($key, $value, $options, $this->getBaseQuery($query)->where('user_id = ?', $id));
- }
- }