// allow create / edit / if the user has
if (!$au) {
-
-
-
return false;
}
return false;
}
+ if (!empty($this->imgtype) && $this->imgtype[0] == '-' && !empty($this->onid)) {
+ // then its an upload
+ $img = DB_DataObject::factory('Images');
+ $img->onid = $this->onid;
+ $img->ontable = $this->ontable;
+ $img->imgtype = $this->imgtype;
+
+ $img->find();
+ while ($img->fetch()) {
+ $img->beforeDelete();
+ $img->delete();
+ }
+
+ }
+
require_once 'File/MimeType.php';
$y = new File_MimeType();
$ext = $y->toExt(trim((string) $this->mimetype ));
- $this->filename = empty($this->filename) ?
- ('image-upload-' . date('Y-m-d H:i:s') . '.' . $ext) : ($this->filename);
+ if(array_pop(explode('.', $this->filename)) != $ext){
+ $this->filename = $this->filename .'.'. $ext;
+ }
if (!$this->createFromData($data)) {
return false;