General improvements

This commit is contained in:
Deon George
2015-06-04 14:25:58 +10:00
parent 9359564ea8
commit c88d289e82
4 changed files with 40 additions and 13 deletions

View File

@@ -19,21 +19,22 @@ class Controller_Photo extends Controller_TemplateDefault {
// Update the current posted photos.
if ($this->request->post())
foreach ($this->request->post('process') as $pid) {
if (! Arr::get($this->request->post('remove'),$pid,FALSE))
continue;
$po = ORM::factory('Photo',$pid);
$po->remove = Arr::get($this->request->post('remove'),$pid);
$po->save();
// If the photo is not marked as remove, or flagged, dont do it.
if (! $po->loaded() OR $po->flag OR ! $po->remove)
continue;
if (! is_writable(dirname($po->file_path())))
$output .= sprintf('Dont have write permissions on %s',dirname($po->file_path()));
$output .= sprintf('Removing %s (%s)',$po->id,$po->file_path());
// Delete it
if (unlink($po->file_path()))
$po->delete();
}
$p = ORM::factory('Photo');
@@ -68,7 +69,7 @@ class Controller_Photo extends Controller_TemplateDefault {
'File Modified'=>array('key'=>'date_file("m",TRUE)'),
'File Created'=>array('key'=>'date_file("c",TRUE)'),
'Filename'=>array('key'=>'file_path(TRUE,FALSE)'),
'Proposed Name'=>array('key'=>'path()'),
'Filesize'=>array('key'=>'file_size()'),
'Width'=>array('key'=>'width'),
'Height'=>array('key'=>'height'),
'Orientation'=>array('key'=>'orientation'),
@@ -125,7 +126,11 @@ class Controller_Photo extends Controller_TemplateDefault {
$po->remove = Arr::get($this->request->post('remove'),$pid);
$po->flag = Arr::get($this->request->post('flag'),$pid);
if ($po->changed())
$output .= HTML::anchor(URL::link('','photo/duplicate/'.$po->id),$po->id).' updated.<br/>';
$po->save();
}
$p = ORM::factory('Photo');
@@ -167,7 +172,7 @@ class Controller_Photo extends Controller_TemplateDefault {
'File Modified'=>array('key'=>'date_file("m",TRUE)'),
'File Created'=>array('key'=>'date_file("c",TRUE)'),
'Filename'=>array('key'=>'file_path(TRUE,FALSE)'),
'Proposed Name'=>array('key'=>'file_path(TRUE,TRUE)'),
'Filesize'=>array('key'=>'file_size()'),
'Width'=>array('key'=>'width'),
'Height'=>array('key'=>'height'),
'Orientation'=>array('key'=>'orientation'),