55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
|
<?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);
|
||
|
}
|
||
|
}
|
||
|
?>
|