- Silence some warnings

- Send notification to scheduling user about any errors during import/export - does not include full list of errors
This commit is contained in:
Nathan Gray 2011-12-09 18:44:29 +00:00
parent d93f9f4869
commit 20bb80effb

View File

@ -317,14 +317,14 @@
return is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
// check tmp file for read/write capabilities // check tmp file for read/write capabilities
$rm = file_exists($path); $rm = file_exists($path);
$f = fopen($path, 'a'); $f = @fopen($path, 'a');
if ($f===false) if ($f===false)
return false; return false;
fclose($f); fclose($f);
if (!$rm) if (!$rm)
unlink($path); @unlink($path);
return true; return true;
} }
@ -401,7 +401,7 @@
foreach($targets as $target) foreach($targets as $target)
{ {
if($resource = fopen( $target, $data['type'] == 'import' ? 'r' : 'w' )) { if($resource = @fopen( $target, $data['type'] == 'import' ? 'r' : 'w' )) {
$result = $po->$type( $resource, $definition ); $result = $po->$type( $resource, $definition );
fclose($resource); fclose($resource);
@ -454,9 +454,13 @@
self::update_job($data); self::update_job($data);
$contents = ob_get_contents(); $contents = ob_get_contents();
if($contents) {
// Log to cron log
if($contents)
{
fwrite(STDOUT,'importexport_schedule: ' . date('c') . ": \n".$contents); fwrite(STDOUT,'importexport_schedule: ' . date('c') . ": \n".$contents);
} }
ob_end_clean(); ob_end_clean();
} }
@ -473,6 +477,23 @@
$data $data
); );
} }
// Send notification to user
if($data['errors'])
{
$notify = new notifications();
$notify->set_sender($data['account_id']);
$notify->add_receiver($data['account_id']);
$notify->set_subject(lang('Schedule import | export'));
$contents = lang($data['type']) . ' ' . lang('Errors') . ' ' . egw_time::to() . ':';
foreach($data['errors'] as $target => $errors)
{
$contents .= "\n". (is_numeric($target) ? '' : $target."\n");
}
$notify->set_message($contents);
$notify->send();
}
return $result; return $result;
} }
} }