Renamin Monitors

Support and queries relating to all previous versions of ZoneMinder
Locked
tommy
Posts: 45
Joined: Sun Aug 17, 2003 2:58 am

Renamin Monitors

Post 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
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post 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
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Thanks for this Tommy, I'll check it over and add it in for the next release.

Phil
Locked