Added Move, started to add delete
This commit is contained in:
@@ -54,7 +54,7 @@ class Task_Photo_Import extends Minion_Task {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($po->duplicate_get()->count())
|
||||
if ($po->list_duplicate()->find_all()->count())
|
||||
$po->duplicate = '1';
|
||||
|
||||
if (! $po->changed())
|
||||
@@ -68,6 +68,7 @@ class Task_Photo_Import extends Minion_Task {
|
||||
return sprintf("Image [%s] processed in DB: %s\n",$params['file'],$po->id);
|
||||
}
|
||||
|
||||
// Force the return of a string or NULL
|
||||
private function dbcol($val,$noval=NULL) {
|
||||
return $val ? (string)$val : $noval;
|
||||
}
|
||||
|
54
application/classes/Task/Photo/Move.php
Normal file
54
application/classes/Task/Photo/Move.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Mark all accounts that have no outstanding invoices and active services as disabled.
|
||||
*
|
||||
* @package Photo
|
||||
* @category Tasks
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Task_Photo_Move extends Minion_Task {
|
||||
protected $_options = array(
|
||||
'file'=>NULL, // Photo File to Move
|
||||
'batch'=>NULL, // Number of photos to move in a batch
|
||||
);
|
||||
|
||||
protected function _execute(array $params) {
|
||||
if ($params['file']) {
|
||||
$po = ORM::factory('Photo',array('filename'=>$params['file']));
|
||||
|
||||
} else {
|
||||
$p = ORM::factory('Photo')
|
||||
->where('date_taken','is not',NULL)
|
||||
->where_open()
|
||||
->where('remove','!=',TRUE)
|
||||
->or_where('remove','is',NULL)
|
||||
->where_close()
|
||||
->where_open()
|
||||
->where('duplicate','!=',TRUE)
|
||||
->or_where('duplicate','is',NULL)
|
||||
->where_close();
|
||||
}
|
||||
|
||||
$c = 0;
|
||||
foreach ($p->find_all() as $po) {
|
||||
if ($po->file_path() == $po->file_path(FALSE,TRUE))
|
||||
continue;
|
||||
|
||||
if ($po->move())
|
||||
printf("Photo [%s] moved to %s.\n",$po->id,$po->file_path());
|
||||
else
|
||||
printf("Photo [%s] NOT moved to %s.\n",$po->id,$po->file_path(FALSE,TRUE));
|
||||
|
||||
$c++;
|
||||
|
||||
if (! is_null($params['batch']) AND $c >= $params['batch'])
|
||||
break;
|
||||
}
|
||||
|
||||
return sprintf("Images processed [%s]\n",$c);
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user