X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FImages.php;h=9b5f666cecd6083e48f1a5a79cb0f916ccaa6a9d;hb=44e8cf08fa923109c411e3f483c5f3710b7c1d81;hp=b42f7a1ef83dc431549444e7d16251ac88971dfa;hpb=ab7b957e4f3a1be6edcab3afffa2d9b0ab17d9a2;p=Pman.Core diff --git a/DataObjects/Images.php b/DataObjects/Images.php index b42f7a1e..9b5f666c 100644 --- a/DataObjects/Images.php +++ b/DataObjects/Images.php @@ -29,6 +29,20 @@ class Pman_Core_DataObjects_Images extends DB_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + function applyFilters($q, $au, $roo) + { + $tn = $this->tableName(); + + if(!empty($q['search']['filename'])){ + $this->whereAdd(" + $tn.name LIKE '%{$this->escape($q['search']['filename'])}%' + OR + $tn.subject LIKE '%{$this->escape($q['search']['filename'])}%' + "); + } + + + } function checkPerm($lvl, $au) { @@ -118,9 +132,10 @@ class Pman_Core_DataObjects_Images extends DB_DataObject $this->mimetype = $y->fromFilename($filename); } - $this->mimetype= strtolower($this->mimetype); + $this->mimetype = strtolower($this->mimetype); - if (array_shift(explode('/', $this->mimetype)) == 'image') { + $mta = explode('/', $this->mimetype); + if (array_shift($mta) == 'image') { $imgs = @getimagesize($file); @@ -196,21 +211,42 @@ class Pman_Core_DataObjects_Images extends DB_DataObject * * */ - function beforeDelete() + function beforeDelete($dependants_array, $roo) { + + $opts = HTML_FlexyFramework::get()->Pman; + $deldir = $opts['storedir']. '/_deleted_images_'; + if (!file_exists( $deldir )) { + mkdir($deldir, 0755); + } + $fn = $this->getStoreName(); + $b = basename($fn); if (file_exists($fn)) { - unlink($fn); + + if (file_exists($deldir . '/'. $b)) { + unlink($fn); + } else { + rename($fn, $deldir .'/'. $b); + } + + } // delete thumbs.. - $b = basename($fn); + $d = dirname($fn); if (file_exists($d)) { $dh = opendir($d); while (false !== ($fn = readdir($dh))) { if (substr($fn, 0, strlen($b)) == $b) { - unlink($d. '/'. $fn); + + if (file_exists($deldir . '/'. $fn)) { + unlink($d. '/'. $fn); + continue; + } + rename($d. '/'. $fn, $deldir .'/'. $fn); + } } }