Page 1 of 1

Renamin Monitors

Posted: Fri Jul 08, 2005 8:48 pm
by tommy
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

Posted: Fri Jul 08, 2005 10:54 pm
by cordel
You would be absolutly correct (Well mostly at least, I'm no expert). PHP is really relaxed on declairing things and will create the function. I think the veriable was the key but I'll test and find out. Thank you for the report and the posible fix. I'll get this in the next rpm due out this weekend if all goes well and remove my temp hack for export events.
Regards,
Cordel

Posted: Sat Jul 09, 2005 5:39 pm
by zoneminder
Thanks for this Tommy, I'll check it over and add it in for the next release.

Phil