photo/application/classes/Task/Photo/Move.php

59 lines
1.6 KiB
PHP
Raw Normal View History

2015-05-15 04:12:10 +00:00
<?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
'useid'=>TRUE, // If date not in photo use ID
'verbose'=>FALSE, // Show some debuggig
2015-05-15 04:12:10 +00:00
);
protected function _execute(array $params) {
if ($params['file']) {
$po = ORM::factory('Photo',array('filename'=>$params['file']));
} else {
$p = ORM::factory('Photo')
->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,($params['useid'] OR $po->date_taken) ? TRUE : FALSE))
2015-05-15 04:12:10 +00:00
continue;
if ($params['verbose'])
printf("Processing [%s], file [%s] - newpath [%s]\n",$po->id,$po->file_path(),$po->file_path(FALSE,($params['useid'] OR $po->date_taken) ? TRUE : FALSE));
2015-05-15 04:12:10 +00:00
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);
}
}
?>