Renamin Monitors
Posted: Fri Jul 08, 2005 8:48 pm
I was having problems renaming monitors. If I renamed monitor named XYZ to ABC, all seemed to work. However, the link in the Events directory pointing to the Monitor ID directory, was still named XYZ. It seems the following 'if' clause in zm_actions.php was never executing.
if ( $changes['Name'] )
{
exec( escapeshellcmd( "mv ".EVENTS_PATH."/".$monitor['Name']." ".EVENTS_PATH."/".$new_monitor['Name'] ) );
}
I think the getFormChanges function is not returning an array with named keys. Consequently the item $changes['Name'] does not actually exist. $changes[n] is returned instead.
I went to getFormChanges in zm_funcs.php and changed this:
default :
{
if ( $values[$key] != $value )
{
$changes[] = "$key = '$value'";
}
break;
to this:
default :
{
if ( $values[$key] != $value )
{
$changes[$key] = "$key = '$value'";
}
break;
The code to rename the directory now attempted to execute but failed trying to find the directory to rename.
I changed
exec( escapeshellcmd( "mv ".EVENTS_PATH."/".$monitor['Name']." ".EVENTS_PATH."/".$new_monitor['Name'] ) );
to
exec( escapeshellcmd( "mv ".ZM_DIR_EVENTS."/".$monitor['Name']." ".ZM_DIR_EVENTS."/"$new_monitor['Name'] ) );
It now works. Renaming the monitor now also creates a renamed link in the events directory. I don't know if this has consequences elsewhere in the program.
Hope I'm right and hope it helps
tommy
if ( $changes['Name'] )
{
exec( escapeshellcmd( "mv ".EVENTS_PATH."/".$monitor['Name']." ".EVENTS_PATH."/".$new_monitor['Name'] ) );
}
I think the getFormChanges function is not returning an array with named keys. Consequently the item $changes['Name'] does not actually exist. $changes[n] is returned instead.
I went to getFormChanges in zm_funcs.php and changed this:
default :
{
if ( $values[$key] != $value )
{
$changes[] = "$key = '$value'";
}
break;
to this:
default :
{
if ( $values[$key] != $value )
{
$changes[$key] = "$key = '$value'";
}
break;
The code to rename the directory now attempted to execute but failed trying to find the directory to rename.
I changed
exec( escapeshellcmd( "mv ".EVENTS_PATH."/".$monitor['Name']." ".EVENTS_PATH."/".$new_monitor['Name'] ) );
to
exec( escapeshellcmd( "mv ".ZM_DIR_EVENTS."/".$monitor['Name']." ".ZM_DIR_EVENTS."/"$new_monitor['Name'] ) );
It now works. Renaming the monitor now also creates a renamed link in the events directory. I don't know if this has consequences elsewhere in the program.
Hope I'm right and hope it helps
tommy