Enhanced the getFormChanges function to handle a number of additional 'types'.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1365 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
049828951a
commit
7b71d70d96
|
@ -257,7 +257,7 @@ function buildSelect( $name, $contents, $onchange="" )
|
|||
return( $html );
|
||||
}
|
||||
|
||||
function getFormChanges( $values, $new_values, $types=false )
|
||||
function getFormChanges( $values, $new_values, $types=false, $columns=false )
|
||||
{
|
||||
$changes = array();
|
||||
if ( !$types )
|
||||
|
@ -265,6 +265,9 @@ function getFormChanges( $values, $new_values, $types=false )
|
|||
|
||||
foreach( $new_values as $key=>$value )
|
||||
{
|
||||
if ( $columns && !$columns[$key] )
|
||||
continue;
|
||||
|
||||
switch( $types[$key] )
|
||||
{
|
||||
case 'set' :
|
||||
|
@ -282,6 +285,62 @@ function getFormChanges( $values, $new_values, $types=false )
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'image' :
|
||||
{
|
||||
if ( is_array( $new_values[$key] ) )
|
||||
{
|
||||
$image_data = getimagesize( $new_values[$key]['tmp_name'] );
|
||||
$changes[$key.'Width'] = $key."Width = ".$image_data[0];
|
||||
$changes[$key.'Height'] = $key."Height = ".$image_data[1];
|
||||
$changes[$key.'Type'] = $key."Type = '".$new_values[$key]['type']."'";
|
||||
$changes[$key.'Size'] = $key."Size = ".$new_values[$key]['size'];
|
||||
ob_start();
|
||||
readfile( $new_values[$key]['tmp_name'] );
|
||||
$changes[$key] = $key." = '".addslashes( ob_get_contents() )."'";
|
||||
ob_end_clean();
|
||||
}
|
||||
else
|
||||
{
|
||||
$changes[] = "$key = '$value'";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'document' :
|
||||
{
|
||||
if ( is_array( $new_values[$key] ) )
|
||||
{
|
||||
$image_data = getimagesize( $new_values[$key]['tmp_name'] );
|
||||
$changes[$key.'Type'] = $key."Type = '".$new_values[$key]['type']."'";
|
||||
$changes[$key.'Size'] = $key."Size = ".$new_values[$key]['size'];
|
||||
ob_start();
|
||||
readfile( $new_values[$key]['tmp_name'] );
|
||||
$changes[$key] = $key." = '".addslashes( ob_get_contents() )."'";
|
||||
ob_end_clean();
|
||||
}
|
||||
else
|
||||
{
|
||||
$changes[] = "$key = '$value'";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'file' :
|
||||
{
|
||||
$changes[$key.'Type'] = $key."Type = '".$new_values[$key]['type']."'";
|
||||
$changes[$key.'Size'] = $key."Size = ".$new_values[$key]['size'];
|
||||
ob_start();
|
||||
readfile( $new_values[$key]['tmp_name'] );
|
||||
$changes[$key] = $key." = '".addslashes( ob_get_contents() )."'";
|
||||
ob_end_clean();
|
||||
break;
|
||||
}
|
||||
case 'raw' :
|
||||
{
|
||||
if ( $values[$key] != $value )
|
||||
{
|
||||
$changes[] = "$key = $value";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
if ( $values[$key] != $value )
|
||||
|
@ -292,6 +351,16 @@ function getFormChanges( $values, $new_values, $types=false )
|
|||
}
|
||||
}
|
||||
}
|
||||
foreach( $values as $key=>$value )
|
||||
{
|
||||
if ( $columns[$key] && $types[$key] == 'toggle' )
|
||||
{
|
||||
if ( !isset($new_values[$key]) && !empty($value) )
|
||||
{
|
||||
$changes[] = "$key = 0";
|
||||
}
|
||||
}
|
||||
}
|
||||
return( $changes );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue